1 19 20 26 package org.enhydra.kelp.ant.dods; 27 28 import java.io.File ; 29 import java.io.BufferedReader ; 30 import java.io.InputStreamReader ; 31 import java.io.IOException ; 32 import java.util.ArrayList ; 33 import java.util.HashMap ; 34 import java.util.HashSet ; 35 import java.lang.reflect.Method ; 36 import java.lang.reflect.InvocationTargetException ; 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 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 61 public void preClose() { 62 saveParameters(); 63 } 64 65 public static void main(String [] 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 File root = new File (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 84 86 } 87 catch (Exception ex) { 88 project = null; 89 } 90 if(project != null){ 91 92 String 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 |