version 1.39, 2004/02/25 10:42:21
|
version 1.42, 2004/03/02 12:04:27
|
Line 59 class Convert
|
Line 59 class Convert
|
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); |
} |
} |
public static void convertBatch(DBBean source, DBBean destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids,int mode) throws Exception |
public static void convertBatch(DBBean source, DBBean destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids,int mode,String delimiter) throws Exception |
{ |
{ |
bean = source; |
bean = source; |
beanDest = destination; |
beanDest = destination; |
convert(null,null,names,layouts,selects,creates,ids,mode); |
convert(null,null,names,layouts,selects,creates,ids,mode,delimiter); |
if(true) return; |
if(true) return; |
StringBuffer command = null; |
StringBuffer command = null; |
try |
try |
Line 190 class Convert
|
Line 190 class Convert
|
{ |
{ |
obj = row.get(k); |
obj = row.get(k); |
if (obj instanceof ArrayList) |
if (obj instanceof ArrayList) |
obj = ((List) obj).get(0); |
obj = formatFileMakerArray((List) obj,"\n"); |
String str = (obj == null) ? "NULL" : obj.toString(); |
String str = (obj == null) ? "NULL" : obj.toString(); |
if (!str.equals("NULL")) |
if (!str.equals("NULL")) |
pstm.setString(k + 1, str); |
pstm.setString(k + 1, str); |
Line 221 class Convert
|
Line 221 class Convert
|
|
|
// dialog.setVisible(false); |
// dialog.setVisible(false); |
} |
} |
|
public static String formatFileMakerArray(List list, String delimiter) |
|
{ |
|
StringBuffer formattedString = new StringBuffer(); |
|
for(int i=0;i<list.size();++i) |
|
{ |
|
formattedString.append(list.get(i).toString()); |
|
if(i<list.size()-1) |
|
formattedString.append(delimiter); |
|
} |
|
return formattedString.toString(); |
|
} |
/** |
/** |
* Method for SQL UPDATE |
* Method for SQL UPDATE |
* @param source |
* @param source |
Line 425 class Convert
|
Line 435 class Convert
|
*/ |
*/ |
|
|
|
|
public static void convert(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception |
public static void convert(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode,String delimiter) throws Exception |
{ |
{ |
|
|
FM2SQL.ProgressDialog dialog = null; |
FM2SQL.ProgressDialog dialog = null; |
Line 784 class Convert
|
Line 794 class Convert
|
{ |
{ |
obj = row.get(k); |
obj = row.get(k); |
if (obj instanceof ArrayList) |
if (obj instanceof ArrayList) |
obj = ((List) obj).get(0); |
if (obj instanceof ArrayList) |
|
obj = formatFileMakerArray((List) obj," | "); |
|
|
String str = (obj == null) ? "NULL" : obj.toString(); |
String str = (obj == null) ? "NULL" : obj.toString(); |
if (!str.equals("NULL")) |
if (!str.equals("NULL")) |
pstm.setString(k + 1, str); |
pstm.setString(k + 1, str); |
Line 1067 class Convert
|
Line 1079 class Convert
|
Vector selects = new Vector(); |
Vector selects = new Vector(); |
Vector creates = new Vector(); |
Vector creates = new Vector(); |
Vector ids = new Vector(); |
Vector ids = new Vector(); |
|
String delimiter = "|"; |
int mode = -1; |
int mode = -1; |
|
|
try |
try |
Line 1091 class Convert
|
Line 1104 class Convert
|
Node node2 = root.find("convert/source/database/password", new int[] { 1, 1, i, 1, 1 }); |
Node node2 = root.find("convert/source/database/password", new int[] { 1, 1, i, 1, 1 }); |
Node node3 = root.find("convert/source/database", new int[] { 1, 1, i }); |
Node node3 = root.find("convert/source/database", new int[] { 1, 1, i }); |
Node nodeMode = root.find("convert/source/database/mode", new int[] { 1, 1, i, 1, 1 }); |
Node nodeMode = root.find("convert/source/database/mode", new int[] { 1, 1, i, 1, 1 }); |
|
Node delimiterNode =root.find("convert/source/database/delimiter", new int[] { 1, 1, i, 1, 1 }); |
if (node3 == null) |
if (node3 == null) |
throw new Error("parse error database tag missing"); |
throw new Error("parse error database tag missing"); |
if (node == null) |
if (node == null) |
Line 1100 class Convert
|
Line 1113 class Convert
|
throw new Error("parse error user tag missing"); |
throw new Error("parse error user tag missing"); |
if (node2 == null) |
if (node2 == null) |
throw new Error("parse error password tag missing"); |
throw new Error("parse error password tag missing"); |
|
if(delimiterNode!=null) delimiter = delimiterNode.getCharacters(); |
String url = node.getCharacters(); |
String url = node.getCharacters(); |
String user = node1.getCharacters(); |
String user = node1.getCharacters(); |
String password = node2.getCharacters(); |
String password = node2.getCharacters(); |
Line 1167 class Convert
|
Line 1181 class Convert
|
creates.add(""); |
creates.add(""); |
|
|
} |
} |
databases.add(new DataBase(database, tables, layouts, selects, creates, ids, mode)); |
DataBase dataBase = new DataBase(database, tables, layouts, selects, creates, ids, mode); |
|
dataBase.delimiter = delimiter; |
|
databases.add(dataBase); |
} |
} |
DBBean database = new DBBean(); |
DBBean database = new DBBean(); |
// parse dataBase |
// parse dataBase |
Line 1185 class Convert
|
Line 1201 class Convert
|
{ |
{ |
DataBase db = (DataBase) iter.next(); |
DataBase db = (DataBase) iter.next(); |
if (mode != DataBase.UPDATE_MODE) |
if (mode != DataBase.UPDATE_MODE) |
convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids,mode); |
convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids,mode,db.delimiter); |
else |
else |
update(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode); |
update(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode); |
|
|
Line 1233 class Convert
|
Line 1249 class Convert
|
Vector selects = new Vector(); |
Vector selects = new Vector(); |
Vector creates = new Vector(); |
Vector creates = new Vector(); |
Vector ids = new Vector(); |
Vector ids = new Vector(); |
|
String delimiter = "|"; |
int mode = -1; |
int mode = -1; |
try |
try |
{ |
{ |
Line 1257 class Convert
|
Line 1273 class Convert
|
Node node2 = root.find("convert/source/database/password", new int[] { 1, 1, i, 1, 1 }); |
Node node2 = root.find("convert/source/database/password", new int[] { 1, 1, i, 1, 1 }); |
Node node3 = root.find("convert/source/database", new int[] { 1, 1, i }); |
Node node3 = root.find("convert/source/database", new int[] { 1, 1, i }); |
Node nodeMode = root.find("convert/source/database/mode", new int[] { 1, 1, i, 1, 1 }); |
Node nodeMode = root.find("convert/source/database/mode", new int[] { 1, 1, i, 1, 1 }); |
|
Node delimiterNode =root.find("convert/source/database/delimiter", new int[] { 1, 1, i, 1, 1 }); |
|
|
|
if(delimiterNode!=null) delimiter = delimiterNode.getCharacters(); |
|
|
if (node3 == null) |
if (node3 == null) |
throw new Error("parse error database tag missing"); |
throw new Error("parse error database tag missing"); |
Line 1442 class Convert
|
Line 1461 class Convert
|
Vector layouts; |
Vector layouts; |
Vector tables; |
Vector tables; |
Vector ids; |
Vector ids; |
|
String delimiter = "|"; |
final static int CONVERT_MODE = 1; |
final static int CONVERT_MODE = 1; |
final static int APPEND_MODE = 2; |
final static int APPEND_MODE = 2; |
final static int UPDATE_MODE = 3; |
final static int UPDATE_MODE = 3; |
|
final static int DELETE_MODE = 4; |
|
|
int mode = -1; |
int mode = -1; |
|
|
public DataBase(DBBean bean, Vector tables, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) |
public DataBase(DBBean bean, Vector tables, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) |
Line 1459 class Convert
|
Line 1481 class Convert
|
this.bean.setIDVector(ids); |
this.bean.setIDVector(ids); |
} |
} |
/** |
/** |
* writes the data contained in this object th the buffered writer |
* writes the data contained in this object to the buffered writer |
* * @param buffr |
* * @param buffr |
* @throws Exception |
* @throws Exception |
*/ |
*/ |
Line 1470 class Convert
|
Line 1492 class Convert
|
buffr.write(" <url>" + bean.url + "</url>\n"); |
buffr.write(" <url>" + bean.url + "</url>\n"); |
buffr.write(" <user>" + bean.user + "</user>\n"); |
buffr.write(" <user>" + bean.user + "</user>\n"); |
buffr.write(" <password>" + bean.passwd + "</password>\n"); |
buffr.write(" <password>" + bean.passwd + "</password>\n"); |
|
buffr.write(" <delimiter>"+delimiter+"</delimiter>\n"); |
String modeString = ""; |
String modeString = ""; |
if (mode == CONVERT_MODE) |
if (mode == CONVERT_MODE) |
modeString = "convert"; |
modeString = "convert"; |