1 5 package org.enhydra.ant.taskdefs; 6 7 import java.io.File ; 8 import org.apache.tools.ant.BuildException; 9 import org.apache.tools.ant.Task; 10 import org.enhydra.dods.generator.DODSGenerator; 11 12 68 public class Dods extends Task { 69 protected String domlfile = null; 70 protected String outputDir = null; 71 protected String action = "dods:build_all"; protected String templateDir = null; 73 protected String confDir = null; 74 protected String templateSet = "standard"; 75 protected String force = "false"; 76 protected String database = DODSGenerator.DATABASE_NOT_SET; 77 protected boolean html = false; 78 protected boolean pdf = false; 79 protected boolean xmi = false; 80 protected boolean ptl = false; 81 public Dods() {} 82 83 88 public void execute() throws org.apache.tools.ant.BuildException { 89 if (domlfile == null) { 90 throw new BuildException("doml attribute must be set!"); 91 } 92 if (outputDir == null) { 93 throw new BuildException("output directory attribute must be set!"); 94 } 95 if (!(new File (outputDir)).isDirectory()) { 96 throw new BuildException("output directory must be a valid directory!"); 97 } 98 if (confDir != null) { 99 if (!(new File (confDir)).isDirectory()) { 100 throw new BuildException("configuration directory must be a valid directory!"); 101 } 102 } 103 try { 104 if (System.getProperty("DODS_HOME") == null) { 105 if (System.getProperty("ENHYDRA_DIR") != null) { 106 System.setProperty("DODS_HOME", 107 System.getProperty("ENHYDRA_DIR") + File.separator 108 + "dods"); 109 } else { 110 throw new BuildException("DODS_HOME not set"); 111 } 112 } 113 System.setProperty("JAVA_HOME", System.getProperty("JAVA_HOME")); 114 System.setProperty("TEMPLATESET", templateSet); 115 int exit = DODSGenerator.generateAll(outputDir, domlfile, action, 116 confDir, templateDir, templateSet, force, database, html, 117 pdf, xmi, ptl); 118 } catch (Exception e) { 119 throw new BuildException(e); 120 } 121 } 122 123 128 public void setDomlfile(String domlfile) { 129 this.domlfile = domlfile; 130 } 131 132 137 public void setTemplateDir(String tempDir) { 138 this.templateDir = tempDir; 139 if (tempDir != null) { 140 try { 141 File tempFile = new File (tempDir); 142 143 if (!tempFile.isDirectory()) { 144 this.templateDir = null; 145 } 146 } catch (NullPointerException e) { 147 this.templateDir = null; 148 } 149 } 150 151 } 152 153 158 public void setOutputDir(String outdir) { 159 outputDir = outdir; 160 } 161 162 167 public void setAction(String action) { 168 this.action = action; 169 } 170 171 176 public void setTemplateSet(String template) { 177 this.templateSet = template; 178 } 179 180 185 public void setDatabase(String database) { 186 this.database = database; 187 } 188 189 194 public void setForce(String force) { 195 this.force = "false"; 196 if (force.equals("true")) { 197 this.force = "true"; 198 } 199 } 200 201 205 public void setHtml(String html) { 206 this.html = false; 207 if (html.equals("true")) { 208 this.html = true; 209 } 210 } 211 212 216 public void setPdf(String pdf) { 217 this.pdf = false; 218 if (pdf.equals("true")) { 219 this.pdf = true; 220 } 221 } 222 223 227 public void setXmi(String xmi) { 228 this.xmi = false; 229 if (xmi.equals("true")) { 230 this.xmi = true; 231 } 232 } 233 234 238 public void setPtl(String ptl) { 239 this.ptl = false; 240 if (ptl.equals("true")) { 241 this.ptl = true; 242 } 243 } 244 245 249 public void setConfDir(String string) { 250 confDir = string; 251 } 252 } 253
| Popular Tags
|