1 package org.jbpm.ant; 2 3 import java.util.StringTokenizer ; 4 5 import org.apache.tools.ant.BuildException; 6 import org.apache.tools.ant.Task; 7 import org.hibernate.cfg.Configuration; 8 import org.hibernate.tool.hbm2ddl.SchemaExport; 9 import org.jbpm.db.JbpmSchema; 10 11 public class JbpmSchemaTask extends Task { 12 13 private String cfg = null; 14 private String properties = null; 15 16 private boolean quiet = false; 17 private boolean text = false; 18 private String output = null; 19 private String delimiter = null; 20 21 private String actions = null; 22 23 public void execute() throws BuildException { 24 if (actions==null) throw new RuntimeException ("actions is null in jbpmschema task"); 25 26 Configuration configuration = AntTaskJbpmSessionFactory.getConfiguration(cfg, properties); 27 JbpmSchema jbpmSchema = new JbpmSchema(configuration); 28 29 SchemaExport schemaExport = new SchemaExport(configuration); 30 if (output!=null) schemaExport.setOutputFile(output); 31 if (delimiter!=null) schemaExport.setDelimiter(delimiter); 32 33 StringTokenizer tokenizer = new StringTokenizer (actions, ","); 34 while (tokenizer.hasMoreTokens()) { 35 String action = tokenizer.nextToken(); 36 37 if ("drop".equalsIgnoreCase(action)) { 38 schemaExport.drop(!quiet, !text); 39 40 } else if ("create".equalsIgnoreCase(action)) { 41 schemaExport.create(!quiet, !text); 42 43 } else if ("clean".equalsIgnoreCase(action)) { 44 jbpmSchema.cleanSchema(); 45 } 46 } 47 } 48 49 public void setActions(String actions) { 50 this.actions = actions; 51 } 52 public void setCfg(String cfg) { 53 this.cfg = cfg; 54 } 55 public void setDelimiter(String delimiter) { 56 this.delimiter = delimiter; 57 } 58 public void setOutput(String output) { 59 this.output = output; 60 } 61 public void setProperties(String properties) { 62 this.properties = properties; 63 } 64 public void setQuiet(boolean quiet) { 65 this.quiet = quiet; 66 } 67 public void setText(boolean text) { 68 this.text = text; 69 } 70 } 71 | Popular Tags |