001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: */
019:
020: /*
021: *
022: * @author Tanja Jovanovic, Nenad Vico
023: * @version 1.0.0
024: *
025: */
026: package org.enhydra.kelp.ant.dods;
027:
028: import java.io.File;
029: import org.enhydra.dods.generator.DODSGenerator;
030: import org.enhydra.kelp.ant.node.AntProject;
031:
032: /**
033: * This class is used for generating DODS code and DODS documentation.
034: */
035: public class KelpDODSGenerator extends DODSGenerator {
036:
037: public static AntProject project = null;
038:
039: public KelpDODSGenerator() {
040: super ();
041: System.out.println("KelpDODSGenerator()");
042: setForce("true");
043: setKelp(true);
044: }
045:
046: /**
047: * This method is called before wizard closing. User should
048: * override this method to involve any pre-closing action.
049: */
050: public void preClose() {
051: saveParameters();
052: }
053:
054: public static void main(String[] args) {
055:
056: System.out.println("KelpDODSGenerator=" + args[0]);
057: KelpDODSGenerator kelpGenerator = new KelpDODSGenerator();
058: System.out.println("1-KelpDODSGenerator=" + args[0]);
059:
060: if (args.length > 0) {
061: // check path
062: File root = new File(args[0]);
063: try {
064: if (!root.exists()) {
065: System.err.println("ERROR: directory'" + args[0]
066: + "' don't exist!");
067: }
068:
069: project = new AntProject(args[0]);
070: // String enhydraDir = project.getProperty(AntProject.ENHYDRA_DIR);
071: // File dodsDirFile = new File(enhydraDir,"dods");
072: // System.setProperty("DODS_HOME", dodsDirFile.getAbsolutePath());
073:
074: // System.setProperty("JAVA_HOME", System.getProperty("java.home"));
075:
076: } catch (Exception ex) {
077: project = null;
078: }
079: if (project != null) {
080:
081: String domlFilePath = project
082: .getProperty(AntProject.DODS_DOML);
083: if (domlFilePath.endsWith(".doml")
084: || domlFilePath.endsWith(".DOML")) {
085: kelpGenerator.setDoml(domlFilePath);
086: }
087: if (project.getProperty(AntProject.DODS_INVOKE)
088: .equalsIgnoreCase("true")) {
089: kelpGenerator.setInvoke(true);
090: } else {
091: kelpGenerator.setInvoke(false);
092: }
093: if ((project
094: .getProperty(AntProject.DODS_GENERATED_SRC_DIR) != null)) {
095: kelpGenerator
096: .setOutputDir(project
097: .getProperty(AntProject.DODS_GENERATED_SRC_DIR));
098: }
099: kelpGenerator.setTemplateSet(project
100: .getProperty(AntProject.DODS_TEMPLATE_SET));
101: kelpGenerator.setAction(project
102: .getProperty(AntProject.DODS_ACTION));
103: kelpGenerator.runWizard();
104: } else {
105: System.err
106: .println("ERROR: Could not find project root!");
107: }
108: }
109:
110: }
111:
112: private void saveParameters() {
113: project.setProperty(AntProject.DODS_ACTION, this .getAction());
114: project.setProperty(AntProject.DODS_DOML, this .getDoml());
115: project.setProperty(AntProject.DODS_GENERATED_SRC_DIR, this
116: .getOutputDir());
117: if (this .getInvoke()) {
118: project.setProperty(AntProject.DODS_INVOKE, "true");
119: } else {
120: project.setProperty(AntProject.DODS_INVOKE, "false");
121: }
122: project.setProperty(AntProject.DODS_TEMPLATE_SET, this
123: .getTemplateSet());
124: project.save();
125: }
126: }
|