KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > ant > dods > KelpDODSGenerator


1 /*
2 * Enhydra Java Application Server Project
3 *
4 * The contents of this file are subject to the Enhydra Public License
5 * Version 1.1 (the "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy of the License on
7 * the Enhydra web site ( http://www.enhydra.org/ ).
8 *
9 * Software distributed under the License is distributed on an "AS IS"
10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11 * the License for the specific terms governing rights and limitations
12 * under the License.
13 *
14 * The Initial Developer of the Enhydra Application Server is Lutris
15 * Technologies, Inc. The Enhydra Application Server and portions created
16 * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17 * All Rights Reserved.
18  */

19
20 /*
21 *
22 * @author Tanja Jovanovic, Nenad Vico
23 * @version 1.0.0
24 *
25  */

26 package org.enhydra.kelp.ant.dods;
27
28 import java.io.File JavaDoc;
29 import java.io.BufferedReader JavaDoc;
30 import java.io.InputStreamReader JavaDoc;
31 import java.io.IOException JavaDoc;
32 import java.util.ArrayList JavaDoc;
33 import java.util.HashMap JavaDoc;
34 import java.util.HashSet JavaDoc;
35 import java.lang.reflect.Method JavaDoc;
36 import java.lang.reflect.InvocationTargetException JavaDoc;
37 import org.enhydra.dods.wizard.DefaultDODSWizard;
38 import org.enhydra.dods.generator.DODSGenerator;
39 import org.enhydra.dods.Common;
40 import org.enhydra.dods.generator.DODSGenerateException;
41 import org.enhydra.kelp.ant.node.AntProject;
42
43 /**
44  * This class is used for generating DODS code and DODS documentation.
45  */

46 public class KelpDODSGenerator extends DODSGenerator {
47
48     public static AntProject project = null;
49
50     public KelpDODSGenerator(){
51         super();
52         System.out.println("KelpDODSGenerator()");
53         setForce("true");
54         setKelp(true);
55     }
56
57     /**
58      * This method is called before wizard closing. User should
59      * override this method to involve any pre-closing action.
60      */

61     public void preClose() {
62         saveParameters();
63     }
64
65     public static void main(String JavaDoc[] args) {
66
67         System.out.println("KelpDODSGenerator="+args[0]);
68         KelpDODSGenerator kelpGenerator = new KelpDODSGenerator();
69         System.out.println("1-KelpDODSGenerator="+args[0]);
70
71         if (args.length > 0) {
72             // check path
73
File JavaDoc root = new File JavaDoc(args[0]);
74             try {
75                 if(!root.exists()){
76                     System.err.println("ERROR: directory'"+args[0]+"' don't exist!");
77                 }
78
79                 project = new AntProject(args[0]);
80 // String enhydraDir = project.getProperty(AntProject.ENHYDRA_DIR);
81
// File dodsDirFile = new File(enhydraDir,"dods");
82
// System.setProperty("DODS_HOME", dodsDirFile.getAbsolutePath());
83

84 // System.setProperty("JAVA_HOME", System.getProperty("java.home"));
85

86             }
87             catch (Exception JavaDoc ex) {
88                 project = null;
89             }
90             if(project != null){
91
92                 String JavaDoc domlFilePath = project.getProperty(AntProject.DODS_DOML);
93                 if(domlFilePath.endsWith(".doml") || domlFilePath.endsWith(".DOML")){
94                     kelpGenerator.setDoml(domlFilePath);
95                 }
96                 if(project.getProperty(AntProject.DODS_INVOKE).equalsIgnoreCase("true")){
97                     kelpGenerator.setInvoke(true);
98                 }else{
99                     kelpGenerator.setInvoke(false);
100                 }
101                 if ((project.getProperty(AntProject.DODS_GENERATED_SRC_DIR) != null)) {
102                     kelpGenerator.setOutputDir(project.getProperty(AntProject.DODS_GENERATED_SRC_DIR));
103                 }
104                 kelpGenerator.setTemplateSet(project.getProperty(AntProject.DODS_TEMPLATE_SET));
105                 kelpGenerator.setAction(project.getProperty(AntProject.DODS_ACTION));
106                 kelpGenerator.runWizard();
107             }else{
108                 System.err.println("ERROR: Could not find project root!");
109             }
110         }
111
112     }
113
114     private void saveParameters(){
115         project.setProperty(AntProject.DODS_ACTION, this.getAction());
116         project.setProperty(AntProject.DODS_DOML,this.getDoml());
117         project.setProperty(AntProject.DODS_GENERATED_SRC_DIR,this.getOutputDir());
118         if(this.getInvoke()){
119             project.setProperty(AntProject.DODS_INVOKE,"true");
120         }else{
121             project.setProperty(AntProject.DODS_INVOKE,"false");
122         }
123         project.setProperty(AntProject.DODS_TEMPLATE_SET,this.getTemplateSet());
124         project.save();
125     }
126 }
Popular Tags