1 package org.apache.torque.task; 2 3 18 19 import java.io.BufferedWriter ; 20 import java.io.FileWriter ; 21 22 import org.apache.tools.ant.BuildException; 23 import org.apache.tools.ant.Project; 24 import org.apache.tools.ant.Task; 25 26 import org.apache.torque.engine.database.model.Database; 27 import org.apache.torque.engine.database.transform.SQLToAppData; 28 29 36 public class TorqueSQLTransformTask extends Task 37 { 38 39 private String inputFile; 40 41 42 private String outputFile; 43 44 49 public String getInputFile() 50 { 51 return inputFile; 52 } 53 54 59 public void setInputFile(String v) 60 { 61 inputFile = v; 62 } 63 64 69 public String getOutputFile() 70 { 71 return outputFile; 72 } 73 74 81 public void setOutputFile (String v) 82 { 83 outputFile = v; 84 } 85 86 92 public void execute() throws BuildException 93 { 94 try 95 { 96 log("Parsing SQL Schema", Project.MSG_INFO); 97 98 SQLToAppData sqlParser = new SQLToAppData(inputFile); 99 Database app = sqlParser.execute(); 100 101 log("Preparing to write xml schema", Project.MSG_INFO); 102 FileWriter fr = new FileWriter (outputFile); 103 BufferedWriter br = new BufferedWriter (fr); 104 105 br.write(app.toString()); 106 107 log("Writing xml schema", Project.MSG_INFO); 108 109 br.flush(); 110 br.close(); 111 } 112 catch (Exception e) 113 { 114 throw new BuildException(e); 115 } 116 } 117 } 118 | Popular Tags |