version 1.60, 2004/07/09 10:26:39
|
version 1.63, 2004/07/27 10:41:36
|
Line 25 import java.io.OutputStreamWriter;
|
Line 25 import java.io.OutputStreamWriter;
|
import java.io.PrintStream; |
import java.io.PrintStream; |
import java.io.UnsupportedEncodingException; |
import java.io.UnsupportedEncodingException; |
import java.net.URL; |
import java.net.URL; |
import java.net.URLConnection; |
|
import java.sql.PreparedStatement; |
import java.sql.PreparedStatement; |
import java.sql.SQLException; |
import java.sql.SQLException; |
import java.sql.Statement; |
import java.sql.Statement; |
Line 1262 class Convert
|
Line 1261 class Convert
|
mode = DataBase.UPDATE_MODE; |
mode = DataBase.UPDATE_MODE; |
else if (modeString.equals("delete")) |
else if (modeString.equals("delete")) |
mode = DataBase.DELETE_MODE; |
mode = DataBase.DELETE_MODE; |
|
else if (modeString.equals("synchronize")) |
|
mode = DataBase.SYNCHRONIZE_MODE; |
|
|
// if(node3!=null) |
// if(node3!=null) |
// System.out.println(node3.name); |
// System.out.println(node3.name); |
Line 1330 class Convert
|
Line 1331 class Convert
|
for (Iterator iter = databases.iterator(); iter.hasNext();) |
for (Iterator iter = databases.iterator(); iter.hasNext();) |
{ |
{ |
DataBase db = (DataBase) iter.next(); |
DataBase db = (DataBase) iter.next(); |
if (mode != DataBase.UPDATE_MODE) |
if (mode == DataBase.CONVERT_MODE || mode == DataBase.APPEND_MODE) |
convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter); |
convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter); |
else |
else |
|
if (mode == DataBase.UPDATE_MODE) |
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); |
|
else if(mode==DataBase.SYNCHRONIZE_MODE) |
|
{ |
|
user =bean.user; |
|
passwd =bean.passwd; |
|
userDest =database.user; |
|
passwdDest =database.passwd; |
|
|
|
synchronize(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode); |
|
} |
} |
} |
// printContents(node3); |
// printContents(node3); |
// FM2SQL.fmInstance=new FM2SQL(); |
// FM2SQL.fmInstance=new FM2SQL(); |
Line 1616 class Convert
|
Line 1626 class Convert
|
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; |
final static int DELETE_MODE = 4; |
|
final static int SYNCHRONIZE_MODE = 5; |
|
|
int mode = -1; |
int mode = -1; |
|
|
Line 1934 class Convert
|
Line 1945 class Convert
|
// TODO using id based algorithm |
// TODO using id based algorithm |
public static void synchronize(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception |
public static void synchronize(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception |
{ |
{ |
|
System.out.println(" bin in synchronize!!!"); |
FM2SQL.ProgressDialog dialog = null; |
FM2SQL.ProgressDialog dialog = null; |
if (FM2SQL.fmInstance != null) |
if (FM2SQL.fmInstance != null) |
{ |
{ |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean); |
dialog.setTitle("Conversion running ..."); |
dialog.setTitle("Synchronize running ..."); |
dialog.title.setText("Getting table data ..."); |
dialog.title.setText("Getting table data ..."); |
dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2); |
dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2); |
dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
Line 1979 class Convert
|
Line 1991 class Convert
|
String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString(); |
String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString(); |
query = (selects != null) ? selects.get(tbIndex).toString() : query; |
query = (selects != null) ? selects.get(tbIndex).toString() : query; |
//if vectors[1].get(i) != null) |
//if vectors[1].get(i) != null) |
if (layout != "") |
if (!layout.equals("")) |
{ |
{ |
layout = " layout " + bean.getQC() + layout + bean.getQC(); |
layout = " layout " + bean.getQC() + layout + bean.getQC(); |
String name = names.get(tbIndex).toString(); |
String name = names.get(tbIndex).toString(); |
Line 1989 class Convert
|
Line 2001 class Convert
|
System.out.println("added layout " + query); |
System.out.println("added layout " + query); |
|
|
} |
} |
|
if(dialog!=null) { |
dialog.title.setText("Getting table data ..."); |
dialog.title.setText("Getting table data ..."); |
dialog.table.setText(names.get(tbIndex).toString()); |
dialog.table.setText(names.get(tbIndex).toString()); |
dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size()); |
dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size()); |
dialog.show(); |
dialog.show(); |
|
} |
bean.getConnection(); |
bean.getConnection(); |
bean.makeQuery(query, 50); |
bean.makeQuery(query, 50); |
idField = ids.get(tbIndex).toString(); |
idField = ids.get(tbIndex).toString(); |
Line 2049 class Convert
|
Line 2063 class Convert
|
// Deletion will work this way |
// Deletion will work this way |
Vector deleted = new Vector(vec); |
Vector deleted = new Vector(vec); |
Vector linesToDelete = new Vector(vecDest); |
Vector linesToDelete = new Vector(vecDest); |
|
|
|
Vector linesToAppend = new Vector(vec); |
|
// remove all lines that are already in dest database |
|
linesToAppend.removeAll(vecDest); |
// remove all lines that should not be deleted |
// remove all lines that should not be deleted |
linesToDelete.removeAll(deleted); |
linesToDelete.removeAll(deleted); |
|
System.out.println("linesToAppend "+linesToAppend+" "+vecDest+" "+destTableName); |
|
System.out.println("linesToDelete "+linesToDelete+" "+vecDest+" "+destTableName); |
|
// prepare new query for next chunk |
|
if (query.indexOf("where") > 0) |
|
tempQuery = query + " and " + tempID + ">='" + vec.firstElement() + "' and "+tempID + "<='" + vec.lastElement() + "' order by "+tempID; |
|
else |
|
tempQuery = query + " where " + tempID + ">='" + vec.firstElement() + "' and "+tempID + "<='" + vec.lastElement() + "'";// order by "+tempID; |
|
System.out.println("tempQuery is now "+tempQuery+" order by "+tempID); |
|
// bean.makeQuery(tempQuery,vec.size()); |
|
Vector[] vectors=bean.getQueryData(tempQuery,vec.size()); |
|
System.out.println(vectors[0]); |
|
System.out.println( bean.getColumnNames().indexOf(idField)); |
|
System.exit(0); |
// System.out.println("ID LIST SIZE " + Math.round((double) myIds.size() / (double) numIntervalls) + " " + myIdsDest.size()); |
// System.out.println("ID LIST SIZE " + Math.round((double) myIds.size() / (double) numIntervalls) + " " + myIdsDest.size()); |
/// @TODO complete delete task remove query show lines to be deleted let user choose if he wants that |
/// @TODO complete delete task remove query show lines to be deleted let user choose if he wants that |
System.out.println("number of lines to be deleted " + linesToDelete.size()); |
System.out.println("number of lines to be deleted " + linesToDelete.size()); |