| 1 |
|
package org.apache.torque.task; |
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
import java.io.BufferedWriter; |
| 23 |
|
import java.io.FileWriter; |
| 24 |
|
|
| 25 |
|
import org.apache.tools.ant.BuildException; |
| 26 |
|
import org.apache.tools.ant.Project; |
| 27 |
|
import org.apache.tools.ant.Task; |
| 28 |
|
|
| 29 |
|
import org.apache.torque.engine.database.model.Database; |
| 30 |
|
import org.apache.torque.engine.database.transform.SQLToAppData; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
@author |
| 36 |
|
@author |
| 37 |
|
@version |
| 38 |
|
|
|
|
|
| 0% |
Uncovered Elements: 21 (21) |
Complexity: 6 |
Complexity Density: 0.38 |
|
| 39 |
|
public class TorqueSQLTransformTask extends Task |
| 40 |
|
{ |
| 41 |
|
|
| 42 |
|
private String inputFile; |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
private String outputFile; |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
@return |
| 51 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
0
|
public String getInputFile()... |
| 53 |
|
{ |
| 54 |
0
|
return inputFile; |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
@param |
| 61 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 62 |
0
|
public void setInputFile(String v)... |
| 63 |
|
{ |
| 64 |
0
|
inputFile = v; |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
@return |
| 71 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 72 |
0
|
public String getOutputFile()... |
| 73 |
|
{ |
| 74 |
0
|
return outputFile; |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
@param |
| 83 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 84 |
0
|
public void setOutputFile (String v)... |
| 85 |
|
{ |
| 86 |
0
|
outputFile = v; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
@throws |
| 93 |
|
|
| 94 |
|
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
|
| 95 |
0
|
public void execute() throws BuildException... |
| 96 |
|
{ |
| 97 |
0
|
try |
| 98 |
|
{ |
| 99 |
0
|
log("Parsing SQL Schema", Project.MSG_INFO); |
| 100 |
|
|
| 101 |
0
|
SQLToAppData sqlParser = new SQLToAppData(inputFile); |
| 102 |
0
|
Database app = sqlParser.execute(); |
| 103 |
|
|
| 104 |
0
|
log("Preparing to write xml schema", Project.MSG_INFO); |
| 105 |
0
|
FileWriter fr = new FileWriter(outputFile); |
| 106 |
0
|
BufferedWriter br = new BufferedWriter (fr); |
| 107 |
|
|
| 108 |
0
|
br.write(app.toString()); |
| 109 |
|
|
| 110 |
0
|
log("Writing xml schema", Project.MSG_INFO); |
| 111 |
|
|
| 112 |
0
|
br.flush(); |
| 113 |
0
|
br.close(); |
| 114 |
|
} |
| 115 |
|
catch (Exception e) |
| 116 |
|
{ |
| 117 |
0
|
throw new BuildException(e); |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
} |