version 1.6, 2005/03/24 12:50:19
|
version 1.7, 2005/04/11 13:27:12
|
Line 119 class Convert
|
Line 119 class Convert
|
|
|
final static int numIntervalls = 4; |
final static int numIntervalls = 4; |
|
|
static boolean debug = true; |
static boolean debug =! false; |
|
|
static boolean isGUI = true; |
static boolean isGUI = true; |
|
|
Line 133 class Convert
|
Line 133 class Convert
|
|
|
static Vector postSQLCommands = new Vector(); |
static Vector postSQLCommands = new Vector(); |
|
|
|
static final String versionID = new String("FM2SQL Version 0.9.0b\n"); |
|
|
public static void main(String args[]) throws IOException |
public static void main(String args[]) throws IOException |
{ |
{ |
/* |
/* |
Line 146 class Convert
|
Line 148 class Convert
|
FileOutputStream file = null; |
FileOutputStream file = null; |
if (args.length != 1) |
if (args.length != 1) |
{ |
{ |
|
System.out.println(versionID); |
System.out.println("Usage: java Convert <xml config file>"); |
System.out.println("Usage: java Convert <xml config file>"); |
System.exit(-1); |
System.exit(-1); |
} |
} |
Line 163 class Convert
|
Line 166 class Convert
|
System.setOut(stream); |
System.setOut(stream); |
System.setErr(stream); |
System.setErr(stream); |
} |
} |
|
System.out.println(versionID); |
StringBuffer sb = readXMLFile(args[0]); |
StringBuffer sb = readXMLFile(args[0]); |
parseXMLConfig(sb); |
parseXMLConfig(sb); |
if (!(new File(args[0]).exists())) |
if (!(new File(args[0]).exists())) |
System.exit(0); |
{ |
|
|
|
System.exit(0); |
|
} |
System.out.println("Finished!"); |
System.out.println("Finished!"); |
// convert("jdbc:fmpro:http://141.14.237.74:8050","jdbc:postgresql://erebos/test",null,null); |
// convert("jdbc:fmpro:http://141.14.237.74:8050","jdbc:postgresql://erebos/test",null,null); |
} |
} |
Line 421 class Convert
|
Line 427 class Convert
|
public static void convert(String source, String destination, Vector names, Vector layouts, |
public static void convert(String source, String destination, Vector names, Vector layouts, |
Vector selects, Vector creates, Vector ids, int mode, String delimiter) throws Exception |
Vector selects, Vector creates, Vector ids, int mode, String delimiter) throws Exception |
{ |
{ |
|
// TODO implement convert_temp mode!!! |
FM2SQL.ProgressDialog dialog = null; |
FM2SQL.ProgressDialog dialog = null; |
|
|
if (isGUI) |
if (isGUI) |
Line 506 class Convert
|
Line 512 class Convert
|
ConversionProperties prop = getFieldNamesAndDestTableName(creates.get(tbIndex).toString(), |
ConversionProperties prop = getFieldNamesAndDestTableName(creates.get(tbIndex).toString(), |
query, names.get(tbIndex).toString()); |
query, names.get(tbIndex).toString()); |
destTableName = prop.destTableName; |
destTableName = prop.destTableName; |
|
if (mode == Convert.DataBase.CONVERT_TEMP_MODE) |
|
{ |
|
destTableName += "_temp"; |
|
} |
fieldNames = prop.fieldNames; |
fieldNames = prop.fieldNames; |
if (mode == Convert.DataBase.CONVERT_MODE) |
if (mode == Convert.DataBase.CONVERT_MODE || mode == Convert.DataBase.CONVERT_TEMP_MODE) |
{ |
{ |
|
|
if (tables.indexOf(destTableName) >= 0) |
if (tables.indexOf(destTableName) >= 0) |
Line 515 class Convert
|
Line 525 class Convert
|
stm.executeUpdate("drop table " + beanDest.getQC() + destTableName + beanDest.getQC()); |
stm.executeUpdate("drop table " + beanDest.getQC() + destTableName + beanDest.getQC()); |
tables.remove(destTableName); |
tables.remove(destTableName); |
System.out.println("dropped table" + destTableName); |
System.out.println("dropped table" + destTableName); |
|
|
} |
} |
if ((tables.indexOf(destTableName) < 0)) |
if ((tables.indexOf(destTableName) < 0)) |
{ |
{ |
Line 529 class Convert
|
Line 538 class Convert
|
command = new StringBuffer(50); |
command = new StringBuffer(50); |
command.append("CREATE TABLE "); |
command.append("CREATE TABLE "); |
command.append(beanDest.getQC()); |
command.append(beanDest.getQC()); |
command.append(convertText((String) names.get(tbIndex))); |
command.append(destTableName);//convertText((String) names.get(tbIndex))); |
command.append(beanDest.getQC()); |
command.append(beanDest.getQC()); |
command.append("("); |
command.append("("); |
String type = null; |
String type = null; |
Line 1008 class Convert
|
Line 1017 class Convert
|
sqlCommand.executeCommand(); |
sqlCommand.executeCommand(); |
} |
} |
int mode = db.mode; |
int mode = db.mode; |
if (mode == DataBase.CONVERT_MODE || mode == DataBase.APPEND_MODE) |
if (mode == DataBase.CONVERT_MODE || mode == DataBase.APPEND_MODE |
|
|| mode == DataBase.CONVERT_TEMP_MODE) |
convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids, |
convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids, |
mode, db.delimiter); |
mode, db.delimiter); |
else if (mode == DataBase.UPDATE_MODE) |
else if (mode == DataBase.UPDATE_MODE) |
Line 1162 class Convert
|
Line 1172 class Convert
|
|
|
else if (modeString.equals("synchronize")) |
else if (modeString.equals("synchronize")) |
mode = DataBase.SYNCHRONIZE_MODE; |
mode = DataBase.SYNCHRONIZE_MODE; |
|
else if (modeString.equals("convert_temp")) |
|
mode = DataBase.CONVERT_TEMP_MODE; |
|
|
// if(node3!=null) |
// if(node3!=null) |
// System.out.println(node3.name); |
// System.out.println(node3.name); |
|
|
Line 1449 class Convert
|
Line 1462 class Convert
|
|
|
final static int SYNCHRONIZE_MODE = 5; |
final static int SYNCHRONIZE_MODE = 5; |
|
|
|
final static int CONVERT_TEMP_MODE = 6; |
|
|
int mode = -1; |
int mode = -1; |
|
|
public DataBase(DBBean bean, Vector tables, Vector layouts, Vector selects, Vector creates, |
public DataBase(DBBean bean, Vector tables, Vector layouts, Vector selects, Vector creates, |
Line 1515 class Convert
|
Line 1530 class Convert
|
while (count < preCommands.size()) |
while (count < preCommands.size()) |
{ |
{ |
SQLCommand sqlcommand=(SQLCommand)preCommands.get(count); |
SQLCommand sqlcommand=(SQLCommand)preCommands.get(count); |
buffr.write(" <sqlcommand execute=\"before\">" + sqlcommand.command + "</sqlcommand>\n"); |
buffr.write(" <sqlcommand execute=\"before\">" + sqlcommand.command |
|
+ "</sqlcommand>\n"); |
count++; |
count++; |
} |
} |
} |
} |
Line 1526 class Convert
|
Line 1542 class Convert
|
{ |
{ |
SQLCommand sqlcommand=(SQLCommand)postCommands.get(count); |
SQLCommand sqlcommand=(SQLCommand)postCommands.get(count); |
|
|
buffr.write(" <sqlcommand execute=\"after\">" + sqlcommand.command + "</sqlcommand>\n"); |
buffr.write(" <sqlcommand execute=\"after\">" + sqlcommand.command |
|
+ "</sqlcommand>\n"); |
count++; |
count++; |
} |
} |
} |
} |
Line 3657 class Convert
|
Line 3674 class Convert
|
// retrieve field_names from select statement |
// retrieve field_names from select statement |
// TODO problem with different fieldNames in create statement will |
// TODO problem with different fieldNames in create statement will |
// overwrite them |
// overwrite them |
if (query.indexOf("*") < 0) |
if (query.indexOf("*") < 0 && create.equals(""))// quick hack for hartmut |
{ |
{ |
int selectEndIndex = query.indexOf("from"); |
int selectEndIndex = query.indexOf("from"); |
StringTokenizer tokenizer = new StringTokenizer(query.substring(6, selectEndIndex), ","); |
StringTokenizer tokenizer = new StringTokenizer(query.substring(6, selectEndIndex), ","); |