Diff for /FM2SQL/Attic/Convert.java between versions 1.79 and 1.87

version 1.79, 2004/10/12 18:46:52 version 1.87, 2004/11/23 13:00:51
Line 18  import java.io.File; Line 18  import java.io.File;
 import java.io.FileInputStream;  import java.io.FileInputStream;
 import java.io.FileNotFoundException;  import java.io.FileNotFoundException;
 import java.io.FileOutputStream;  import java.io.FileOutputStream;
   import java.io.IOException;
 import java.io.InputStream;  import java.io.InputStream;
 import java.io.InputStreamReader;  import java.io.InputStreamReader;
 import java.io.OutputStreamWriter;  import java.io.OutputStreamWriter;
Line 92  class Convert Line 93  class Convert
   
     final static int numIntervalls = 4;      final static int numIntervalls = 4;
   
     static boolean debug = true;      static boolean debug = false;
   
     public static void main(String args[])      static boolean isGUI = true;
       public static void main(String args[]) throws IOException
     {      {
         /*          /*
          * try { //byte[] b = "ö".getBytes("UTF-8"); //           * try { //byte[] b = "ö".getBytes("UTF-8"); //
Line 103  class Convert Line 105  class Convert
          * //System.out.println(new String(b,"UTF-8")); } catch           * //System.out.println(new String(b,"UTF-8")); } catch
          * (UnsupportedEncodingException e) { e.printStackTrace(); }           * (UnsupportedEncodingException e) { e.printStackTrace(); }
          */           */
           isGUI = false;
         FileOutputStream file = null;          FileOutputStream file = null;
         if (args.length != 1)          if (args.length != 1)
         {          {
Line 111  class Convert Line 114  class Convert
         }          }
         try          try
         {          {
             file = new FileOutputStream("./log.txt");              File temp = File.createTempFile("fm2sql", ".txt");
               file = new FileOutputStream(temp);
         }          }
         catch (FileNotFoundException e1)          catch (FileNotFoundException e1)
         {          {
             e1.printStackTrace();              e1.printStackTrace();
         }          }
         PrintStream stream = new PrintStream(file, false);          PrintStream stream = new PrintStream(file, true);
         if (!debug)          if (!debug)
         {          {
             System.setOut(stream);              System.setOut(stream);
Line 136  class Convert Line 140  class Convert
         bean = source;          bean = source;
         beanDest = destination;          beanDest = destination;
         convert(null, null, names, layouts, selects, creates, ids, mode, delimiter);          convert(null, null, names, layouts, selects, creates, ids, mode, delimiter);
         if (true)  
             return;  
         StringBuffer command = null;  
         try  
         {  
             bean.setConnection(source.url);  
             if (names == null)  
                 names = bean.getTableNames();  
             //Collections.sort(names);  
             int tbIndex = 1;  
   
             for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)  
             {  
                 Vector[] result = null;  
                 try  
                 {  
                     String query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();  
                     String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();  
                     query = (selects != null) ? selects.get(tbIndex).toString() : query;  
                     //if vectors[1].get(i) != null)  
                     if (!layout.equals(""))  
                     {  
                         System.out.println("before " + query + " table" + names.get(tbIndex));  
                         layout = " layout " + bean.getQC() + layout + bean.getQC();  
                         String name = names.get(tbIndex).toString();  
                         StringBuffer queryLayout = new StringBuffer(query);  
                         queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);  
                         query = queryLayout.toString();  
                         System.out.println("added layout " + query);  
   
                     }  
                     System.out.println(" performing query " + query);  
                     //result = bean.getQueryData(query, null, 0);  
                     bean.getConnection();  
                     bean.makeQuery(query, 0);  
                 }  
                 catch (Exception e)  
                 {  
                     System.out.println(e.getMessage());  
                     e.printStackTrace();  
                     continue;  
                 }  
                 //beanDest.setConnection("jdbc:postgresql://erebos/test3");  
                 beanDest.setConnection(destination.url);  
   
                 Statement stm = beanDest.getConnection().createStatement();  
   
                 Vector tables = beanDest.getTableNames();  
                 //   Collections.sort(tables);  
                 System.out.println("converting table " + names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames());  
                 tables = beanDest.getTableNames();  
                 // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));  
                 stm = beanDest.getConnection().createStatement();  
                 // System.exit(0);  
                 if (mode == Convert.DataBase.CONVERT_MODE)  
                 {  
                     if (tables.indexOf(names.get(tbIndex)) >= 0)  
                     {  
                         stm.executeUpdate("drop table " + beanDest.getQC() + names.get(tbIndex) + beanDest.getQC());  
                         tables.remove((String) names.get(tbIndex));  
                         System.out.println("dropped table " + names.get(tbIndex));  
                     }  
                     else if (tables.indexOf(convertText(names.get(tbIndex).toString())) >= 0)  
                     {  
                         stm.executeUpdate("drop table " + beanDest.getQC() + convertText((String) names.get(tbIndex)) + beanDest.getQC());  
                         tables.remove(convertText((String) names.get(tbIndex)));  
                         System.out.println("dropped table " + names.get(tbIndex));  
                     }  
   
                     if (tables.indexOf(names.get(tbIndex)) < 0 && tables.indexOf(convertText(names.get(tbIndex).toString())) < 0)  
                     {  
                         if (creates.get(tbIndex).equals("") || creates.get(tbIndex).toString().toLowerCase().indexOf("create") < 0)  
                         {  
                             System.out.println("Warning empty or invalid create statement - creating one for you\n");  
   
                             command = new StringBuffer(50);  
                             command.append("CREATE TABLE ");  
                             command.append(beanDest.getQC());  
                             command.append(convertText((String) names.get(tbIndex)));  
                             command.append(beanDest.getQC());  
                             command.append("(");  
                             String type = null;  
                             Vector columnNames = bean.getColumnNames();  
                             for (int i = 0; i < columnNames.size() - 1; ++i)  
                             {  
                                 type = bean.metaData.getColumnTypeName(i + 1);  
                                 //   System.out.println(i+" "+result[1].get(i)+"  
                                 // "+type);  
                                 type = (type.equals("NUMBER")) ? "INT4" : type;  
                                 type = (type.equals("CONTAINER")) ? "TEXT" : type;  
   
                                 command.append(beanDest.getQC() + convertText((String) columnNames.get(i)) + beanDest.getQC() + " " + type + ", ");  
                             }  
                             type = bean.metaData.getColumnTypeName(columnNames.size());  
                             type = (type.equals("NUMBER")) ? "INT4" : type;  
                             type = (type.equals("CONTAINER")) ? "TEXT" : type;  
                             command.append(beanDest.getQC() + convertText((String) columnNames.get(columnNames.size() - 1)) + beanDest.getQC() + " " + type);  
                             command.append(" )");  
                         }  
                         else  
                             command = new StringBuffer().append(creates.get(tbIndex).toString());  
   
                         System.out.println(command);  
                         //  System.exit(0);  
                         //command.append(DBBean.getQC());  
                         stm.executeUpdate(command.toString());  
   
                     }  
                 }  
                 Vector row = null;  
                 command = new StringBuffer();  
   
                 command.append("INSERT  INTO ");  
                 command.append(beanDest.getQC());  
                 command.append(convertText((String) names.get(tbIndex)));  
                 command.append(beanDest.getQC());  
                 command.append(" values ( ");  
   
                 for (int i = 0; i < bean.getColumnNames().size() - 1; ++i)  
                     command.append("?,");  
                 command.append("?)");  
                 PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());  
                 System.out.println(command);  
                 while ((row = bean.getNextRow()) != null)  
                 {  
                     //print rows  
                     Object obj = null;  
                     for (int k = 0; k < row.size(); ++k)  
                     {  
                         obj = row.get(k);  
                         if (obj instanceof ArrayList)  
                             obj = formatFileMakerArray((List) obj, "\n");  
                         String str = (obj == null) ? "NULL" : obj.toString();  
                         if (!str.equals("NULL"))  
                             pstm.setString(k + 1, str);  
                         else  
                             pstm.setNull(k + 1, Types.NULL);  
                     }  
                     pstm.execute();  
   
                 } // to for loop  
   
             }  
         }  
         catch (Exception e)  
         {  
             System.out.println("Error while connecting to database " + e);  
             //dialog.setVisible(false);  
             //dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
             //FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
             java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();  
             java.io.PrintStream stream = new java.io.PrintStream(b);  
             stream.print(command + "\n\n");  
             e.printStackTrace(stream);  
             System.err.println(b);  
             //FM2SQL.showErrorDialog(b.toString(), "Error occured !");  
   
         }  
         //  dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
         //FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
   
         //  dialog.setVisible(false);  
     }      }
   
     public static String formatFileMakerArray(List list, String delimiter)      public static String formatFileMakerArray(List list, String delimiter)
Line 329  class Convert Line 171  class Convert
     {      {
   
         FM2SQL.ProgressDialog dialog = null;          FM2SQL.ProgressDialog dialog = null;
         if (FM2SQL.fmInstance != null)          if (isGUI)
         {          {
             dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);              dialog = initDialog();
             dialog.setTitle("Conversion running ...");  
             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.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  
             FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  
             dialog.thread = Thread.currentThread();  
         }          }
         // setting user and passwd          // setting user and passwd
         bean.setUserAndPasswd(user, passwd);          bean.setUserAndPasswd(user, passwd);
         // setting user and passwd          // setting user and passwd
         beanDest.setUserAndPasswd(userDest, passwdDest);          beanDest.setUserAndPasswd(userDest, passwdDest);
         if (dialog != null)  
             dialog.setSize(400, 250);  
         StringBuffer command = null;          StringBuffer command = null;
         String query = null;          String query = null;
         try          try
         {          {
             //bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050");  
             //bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo");  
             bean.setConnection(source);              bean.setConnection(source);
   
             if (names == null)              if (names == null)
                 names = bean.getTableNames();                  names = bean.getTableNames();
             // Collections.sort(names);              // Collections.sort(names);
             int tbIndex = 1;              int tbIndex = 1;
   
             // System.out.println("Start at              System.out.println("Start at table " + names.firstElement());
             // "+names.indexOf("archimedes_facsimiles"));  
             for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)              for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
             {              {
                 Vector[] result = null;                  Vector[] result = null;
Line 371  class Convert Line 205  class Convert
                     //if vectors[1].get(i) != null)                      //if vectors[1].get(i) != null)
                     if (layout != "")                      if (layout != "")
                     {                      {
                         layout = " layout " + bean.getQC() + layout + bean.getQC();                          query = addLayoutToQuery(names, query, tbIndex, layout);
                         String name = names.get(tbIndex).toString();  
                         StringBuffer queryLayout = new StringBuffer(query);  
                         queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);  
                         query = queryLayout.toString();  
                         System.out.println("added layout  " + query);  
   
                     }                      }
                     if (dialog != null)                      if (dialog != null)
                     {                      {
                         dialog.title.setText("Getting table data ...");                          prepareDialogforUse(names, dialog, tbIndex);
                         dialog.table.setText(names.get(tbIndex).toString());  
                         dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());  
                         dialog.show();  
                     }                      }
                     bean.getConnection();                      bean.getConnection();
                     bean.makeQuery(query, 0);                      bean.makeQuery(query, 0);
Line 392  class Convert Line 218  class Convert
                 }                  }
                 catch (Exception e)                  catch (Exception e)
                 {                  {
                       System.out.println("Warning exception occured \n " + e);
   
                     continue;                      continue;
                 }                  }
                 // determine destTableName from createStatement or from source                  // determine destTableName from createStatement or from source
Line 408  class Convert Line 236  class Convert
                 else                  else
                     destTableName = convertText(names.get(tbIndex).toString());                      destTableName = convertText(names.get(tbIndex).toString());
   
                 //beanDest.setConnection("jdbc:postgresql://erebos/test3");  
                 beanDest.setConnection(destination);                  beanDest.setConnection(destination);
   
                 Statement stm = beanDest.getConnection().createStatement();                  Statement stm = beanDest.getConnection().createStatement();
   
                 Vector tables = beanDest.getTableNames();                  Vector tables = beanDest.getTableNames();
                 // Collections.sort(tables);  
                 System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames());                  System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames());
                 tables = beanDest.getTableNames();                  tables = beanDest.getTableNames();
                 // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));  
                 stm = beanDest.getConnection().createStatement();                  stm = beanDest.getConnection().createStatement();
                 // System.exit(0);  
   
                 if (dialog != null)                  if (dialog != null)
                     dialog.title.setText("Updating table data ...");                      dialog.title.setText("Updating table data ...");
                   else
                       System.out.println("Updating table data ...");
                 int j = -1;                  int j = -1;
   
                 Vector row = null;                  Vector row = null;
Line 450  class Convert Line 276  class Convert
                     j++;                      j++;
                     //print rows                      //print rows
                     Object obj = null;                      Object obj = null;
                     /*  
                      * for(int k=0;k <row.size()-1;++k) { obj = row.get(k);  
                      * //System.out.println("row "+obj+" "+k); if(obj!=null&&!(obj  
                      * instanceof ArrayList))  
                      * command.append("'"+convertUml(obj.toString())+"',"); else  
                      * if(obj!=null&& obj instanceof ArrayList)  
                      * command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"',");  
                      * else command.append("NULL,"); } obj = row.get(row.size() - 1); if  
                      * (obj != null && !(obj instanceof ArrayList))  
                      * command.append("'"+convertUml(obj.toString())+"')"); else  
                      * if(obj!=null&& obj instanceof ArrayList)  
                      * command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"')");  
                      * //command.append(obj.toString()+")"); else command.append("NULL)");  
                      */  
                     //command.append("'"+row.get(row.size()-1)+"')");  
                     //command.append(" )");  
                     //  for(int k=0;k<row.size();++k)  
                     // System.out.println();  
                     //   System.out.println(command+" "+j+" "+row.size()+" "+  
                     // ((Vector)result2[0].get(j)).size());  
                     // System.out.println(command);  
                     for (int k = 0; k < row.size(); ++k)                      for (int k = 0; k < row.size(); ++k)
                     {                      {
                         obj = row.get(k);                          obj = row.get(k);
Line 483  class Convert Line 288  class Convert
                             pstm.setNull(k + 1, Types.NULL);                              pstm.setNull(k + 1, Types.NULL);
                     }                      }
                     pstm.setString(row.size() + 1, row.get(idIndex).toString());                      pstm.setString(row.size() + 1, row.get(idIndex).toString());
                     //System.out.println(pstm.toString());  
                     // System.exit(0);  
                     pstm.execute();                      pstm.execute();
                     //stm.executeUpdate(command.toString());  
                     if (dialog != null)                      if (dialog != null)
                         dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));                          dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
                     // System.out.println(  
                     // (int)(((double)(j+1)/(double)result[0].size())*100.0)+"  
                     // "+result[0].size()+" "+j);  
                     command = null;                      command = null;
                 } // to for loop                  } // to for loop
   
Line 500  class Convert Line 299  class Convert
         catch (Exception e)          catch (Exception e)
         {          {
             System.out.println("Error while connecting to database " + e);              System.out.println("Error while connecting to database " + e);
             if (dialog != null)              if (isGUI)
             {              {
                 dialog.setVisible(false);                  showExceptionDialog(dialog, command, e);
                 dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
                 FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
             }              }
             java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();              else
             java.io.PrintStream stream = new java.io.PrintStream(b);              {
             stream.print(command + "\n\n");                  e.printStackTrace();
             e.printStackTrace(stream);  
             FM2SQL.showErrorDialog(b.toString(), "Error occured !");  
   
         }          }
         if (dialog != null)          } finally
           {
               if (isGUI)
               {
                   resetGUI(dialog);
               }
           }
       }
   
       /**
        * @param dialog
        */
       private static void resetGUI(FM2SQL.ProgressDialog dialog)
         {          {
             dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));              dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
             FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));              FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
           dialog.setVisible(false);
       }
   
       /**
        * @param dialog
        * @param command
        * @param e
        */
       private static void showExceptionDialog(FM2SQL.ProgressDialog dialog, StringBuffer command, Exception e)
       {
             dialog.setVisible(false);              dialog.setVisible(false);
           dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
           FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
           java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
           java.io.PrintStream stream = new java.io.PrintStream(b);
           stream.print(command + "\n\n");
           e.printStackTrace(stream);
           FM2SQL.showErrorDialog(b.toString(), "Error occured !");
         }          }
   
       /**
        * @return
        */
       private static FM2SQL.ProgressDialog initDialog()
       {
           FM2SQL.ProgressDialog dialog;
           dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
           dialog.setTitle("Conversion running ...");
           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.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
           FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
           dialog.thread = Thread.currentThread();
           dialog.setSize(420, 250);
           return dialog;
     }      }
   
     /**      /**
Line 544  class Convert Line 382  class Convert
   
         FM2SQL.ProgressDialog dialog = null;          FM2SQL.ProgressDialog dialog = null;
   
         if (FM2SQL.fmInstance != null)          if (isGUI)
         {          {
             dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);              dialog = initDialog();
             dialog.setTitle("Conversion running ...");  
             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.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  
             FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  
             dialog.thread = Thread.currentThread();  
             dialog.setSize(400, 250);  
         }          }
   
           System.out.println("connection established " + source + " " + bean.url);
   
         java.util.TreeSet myIds = new TreeSet();          java.util.TreeSet myIds = new TreeSet();
         int deltaID = 1;          int deltaID = 1;
         String idField = "";          String idField = "";
         String destTableName = "";          String destTableName = "";
         String[] fieldNames = null;          String[] fieldNames = null;
   
         if (source != null && destination != null)          if (source != null && destination != null)
         {          {
             // setting user and passwd              // setting user and passwd
Line 567  class Convert Line 402  class Convert
             // setting user and passwd              // setting user and passwd
             beanDest.setUserAndPasswd(userDest, passwdDest);              beanDest.setUserAndPasswd(userDest, passwdDest);
         }          }
   
         StringBuffer command = null;          StringBuffer command = null;
         String query = null;          String query = null;
         try          try
         {          {
   
             if (source != null)              if (source != null)
                 bean.setConnection(source);                  bean.setConnection(source);
             else              else
                 bean.setConnection(bean.url);                  bean.setConnection(bean.url);
   
             if (names == null)              if (names == null)
                 names = bean.getTableNames();                  names = bean.getTableNames();
             // Collections.sort(names);  
             int tbIndex = 1;              int tbIndex = 1;
   
             // System.out.println("Start at  
             // "+names.indexOf("archimedes_facsimiles"));  
             for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)              for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
             {              {
                 Vector[] result = null;                  Vector[] result = null;
                 try                  try
                 {                  {
                     query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();  
                     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() : "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
                     //if vectors[1].get(i) != null)  
                     if (layout != "")                      if (layout != "")
                     {                      {
                         layout = " layout " + bean.getQC() + layout + bean.getQC();                          query = addLayoutToQuery(names, query, tbIndex, layout);
                         String name = names.get(tbIndex).toString();  
                         StringBuffer queryLayout = new StringBuffer(query);  
                         queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);  
                         query = queryLayout.toString();  
                         System.out.println("added layout  " + query);  
   
                     }                      }
                     //  if ( layout!= "")  
                     //   query += " layout " + bean.getQC() + layout +  
                     // bean.getQC();  
                     if (dialog != null)                      if (dialog != null)
                     {                      {
                         dialog.title.setText("Reading table data ...");                          prepareDialogforUse(names, dialog, tbIndex);
                         dialog.table.setText(names.get(tbIndex).toString());  
                         dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());  
                         dialog.show();  
                     }                      }
                     //result = bean.getQueryData(query, dialog, 0);  
                     bean.getConnection();                      bean.getConnection();
                     bean.makeQuery(query, 50);                      bean.makeQuery(query, 50);
                     idField = ids.get(tbIndex).toString();                      idField = ids.get(tbIndex).toString();
Line 620  class Convert Line 440  class Convert
                 }                  }
                 catch (Exception e)                  catch (Exception e)
                 {                  {
                     System.out.println(e);                      System.out.println("Warning exception occured \n " + e);
   
                     continue;                      continue;
                 }                  }
                 if (destination != null)                  if (destination != null)
Line 652  class Convert Line 473  class Convert
                         System.out.println("dropped table" + destTableName);                          System.out.println("dropped table" + destTableName);
   
                     }                      }
                     /*                      if ((tables.indexOf(destTableName) < 0))
                      * if(destTableName.equals("")) if (tables.indexOf(names.get(tbIndex)) >=  
                      * 0) { stm.executeUpdate("drop table " + beanDest.getQC() +  
                      * names.get(tbIndex) + beanDest.getQC()); tables.remove((String)  
                      * names.get(tbIndex)); System.out.println("dropped table" +  
                      * names.get(tbIndex)); } else if  
                      * (tables.indexOf(convertText(names.get(tbIndex).toString())) >= 0) {  
                      * stm.executeUpdate("drop table " + beanDest.getQC() +  
                      * convertText((String) names.get(tbIndex)) + beanDest.getQC());  
                      * tables.remove(convertText((String) names.get(tbIndex)));  
                      * System.out.println("dropped table" + names.get(tbIndex)); }  
                      */  
                     if ((tables.indexOf(destTableName) < 0)) //&&  
                     // tables.indexOf(names.get(tbIndex))  
                     // < 0 &&  
                     // tables.indexOf(convertText(names.get(tbIndex).toString()))  
                     // < 0 )  
                     {                      {
   
                         if (creates.get(tbIndex).equals("") || creates.get(tbIndex).toString().toLowerCase().indexOf("create") < 0)                          if (creates.get(tbIndex).equals("") || creates.get(tbIndex).toString().toLowerCase().indexOf("create") < 0)
Line 699  class Convert Line 504  class Convert
                             command.append(beanDest.getQC() + convertText((String) columnNames.get(columnNames.size() - 1)) + beanDest.getQC() + " " + type);                              command.append(beanDest.getQC() + convertText((String) columnNames.get(columnNames.size() - 1)) + beanDest.getQC() + " " + type);
                             command.append(" )");                              command.append(" )");
   
                             // System.out.println(command);  
                             //  System.exit(0);  
                             //command.append(DBBean.getQC());  
                         }                          }
                         else                          else
                             command = new StringBuffer().append(creates.get(tbIndex).toString().toLowerCase());                              command = new StringBuffer().append(creates.get(tbIndex).toString().toLowerCase());
Line 719  class Convert Line 521  class Convert
   
                 command.append("INSERT  INTO ");                  command.append("INSERT  INTO ");
                 command.append(beanDest.getQC());                  command.append(beanDest.getQC());
                 command.append(destTableName); //convertText((String)                  command.append(destTableName);
                 // names.get(tbIndex)));  
                 command.append(beanDest.getQC());                  command.append(beanDest.getQC());
                 command.append(" (");                  command.append(" (");
                 for (int i = 0; i < fieldNames.length; i++)                  for (int i = 0; i < fieldNames.length; i++)
Line 828  class Convert Line 629  class Convert
                     System.out.println("Time for old convert elapsed " + (endTime - startTime));                      System.out.println("Time for old convert elapsed " + (endTime - startTime));
   
                 }                  }
                   if (isGUI)
                       resetGUI(dialog);
             }              }
         }          }
         catch (Exception e)          catch (Exception e)
         {          {
             System.out.println("Error while connecting to database " + e);              System.out.println("Error while connecting to database " + e);
             if (dialog != null)              if (isGUI)
             {              {
                 dialog.setVisible(false);                  showExceptionDialog(dialog, command, e);
                 dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));                  resetGUI(dialog);
                 FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
                 java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();  
                 java.io.PrintStream stream = new java.io.PrintStream(b);  
                 stream.print(command + "\n\n");  
                 e.printStackTrace(stream);  
                 FM2SQL.showErrorDialog(b.toString(), "Error occured !");  
             }              }
             else              else
             {              {
Line 850  class Convert Line 647  class Convert
   
             }              }
         }          }
         if (dialog != null)  
       }
   
       /**
        * @param names
        * @param dialog
        * @param tbIndex
        */
       private static void prepareDialogforUse(Vector names, FM2SQL.ProgressDialog dialog, int tbIndex)
         {          {
             dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));          dialog.title.setText("Reading table data ...");
             FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));          dialog.table.setText(names.get(tbIndex).toString());
             dialog.setVisible(false);          dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
           dialog.show();
         }          }
   
       /**
        * @param names
        * @param query
        * @param tbIndex
        * @param layout
        * @return
        */
       private static String addLayoutToQuery(Vector names, String query, int tbIndex, String layout)
       {
           layout = " layout " + bean.getQC() + layout + bean.getQC();
           String name = names.get(tbIndex).toString();
           StringBuffer queryLayout = new StringBuffer(query);
           queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
           query = queryLayout.toString();
           System.out.println("added layout  " + query);
           return query;
     }      }
   
     /**      /**
Line 880  class Convert Line 703  class Convert
         while ((row = bean.getNextRow()) != null)          while ((row = bean.getNextRow()) != null)
         {          {
             j++;              j++;
             // row = (Vector) result[0].get(j);  
             /*  
              * command = new StringBuffer();  
              *   
              * command.append("INSERT INTO "); command.append(beanDest.getQC());  
              * command.append(convertText((String) names.get(tbIndex)));  
              * command.append(beanDest.getQC()); command.append(" values ( ");  
              */  
             //print rows  
             Object obj = null;              Object obj = null;
             /*  
              * for(int k=0;k <row.size()-1;++k) { obj = row.get(k);  
              * //System.out.println("row "+obj+" "+k); if(obj!=null&&!(obj instanceof  
              * ArrayList)) command.append("'"+convertUml(obj.toString())+"',"); else  
              * if(obj!=null&& obj instanceof ArrayList)  
              * command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"',");  
              * else command.append("NULL,"); } obj = row.get(row.size() - 1); if (obj !=  
              * null && !(obj instanceof ArrayList))  
              * command.append("'"+convertUml(obj.toString())+"')"); else  
              * if(obj!=null&& obj instanceof ArrayList)  
              * command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"')");  
              * //command.append(obj.toString()+")"); else command.append("NULL)");  
              */  
             //command.append("'"+row.get(row.size()-1)+"')");  
             //command.append(" )");  
             //  for(int k=0;k<row.size();++k)  
             // System.out.println();  
             //   System.out.println(command+" "+j+" "+row.size()+" "+  
             // ((Vector)result2[0].get(j)).size());  
             // System.out.println(command);  
             for (int k = 0; k < row.size(); ++k)              for (int k = 0; k < row.size(); ++k)
             {              {
                 obj = row.get(k);                  obj = row.get(k);
Line 928  class Convert Line 722  class Convert
                     pstm.setNull(k + 1, Types.NULL);                      pstm.setNull(k + 1, Types.NULL);
             }              }
             pstm.execute();              pstm.execute();
             //stm.executeUpdate(command.toString());              if (isGUI)
             if (dialog != null)  
                 dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));                  dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
             // System.out.println(  
             // (int)(((double)(j+1)/(double)result[0].size())*100.0)+"  
             // "+result[0].size()+" "+j);  
             command = null;              command = null;
         } // to while loop          } // to while loop
         return command;          return command;
Line 1313  class Convert Line 1103  class Convert
             String url = node.getCharacters();              String url = node.getCharacters();
             String user = node1.getCharacters();              String user = node1.getCharacters();
             String password = node2.getCharacters();              String password = node2.getCharacters();
             System.out.println(url);              System.out.println(" The url is " + url);
             database.setURL(url.trim());              database.setURL(url.trim());
             database.setUserAndPasswd(user.trim(), password.trim());              database.setUserAndPasswd(user.trim(), password.trim());
             //databases.add(database);              //databases.add(database);
Line 1324  class Convert Line 1114  class Convert
                     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 if (mode == DataBase.UPDATE_MODE)                  else if (mode == DataBase.UPDATE_MODE)
                 {                  {
   
                     Convert.user = db.bean.user;                      Convert.user = db.bean.user;
                     Convert.passwd = db.bean.passwd;                      Convert.passwd = db.bean.passwd;
                     userDest = database.user;                      userDest = database.user;
Line 1341  class Convert Line 1132  class Convert
                     synchronize(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter, new Vector(db.htIndex.values()));                      synchronize(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter, new Vector(db.htIndex.values()));
                 }                  }
             }              }
             // printContents(node3);  
             //   FM2SQL.fmInstance=new FM2SQL();  
         }          }
         catch (Exception e)          catch (Exception e)
         {          {
Line 1465  class Convert Line 1255  class Convert
                 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 1538  class Convert Line 1330  class Convert
             database.setURL(url.trim());              database.setURL(url.trim());
             database.setUserAndPasswd(user.trim(), password.trim());              database.setUserAndPasswd(user.trim(), password.trim());
             databases.add(new DataBase(database, null, null, null, null, null, 0));              databases.add(new DataBase(database, null, null, null, null, null, 0));
             //databases.add(database);  
             /*  
              * for (Iterator iter = databases.iterator(); iter.hasNext();) { DataBase  
              * db = (DataBase) iter.next();  
              * convertBatch(db.bean,database,db.tables,db.layouts,db.selects,db.creates); }  
              */  
             // printContents(node3);  
             //   FM2SQL.fmInstance=new FM2SQL();  
         }          }
         catch (Exception e)          catch (Exception e)
         {          {
Line 1742  class Convert Line 1526  class Convert
                 modeString = "update";                  modeString = "update";
             else if (mode == DELETE_MODE)              else if (mode == DELETE_MODE)
                 modeString = "delete";                  modeString = "delete";
               else if (mode == SYNCHRONIZE_MODE)
                   modeString = "synchronize";
   
             buffr.write("      <mode>" + modeString + "</mode>\n");              buffr.write("      <mode>" + modeString + "</mode>\n");
             buffr.write("      <usenormantounicodemapper>" + useNormanToUnicodeMapper + "</usenormantounicodemapper>\n");              buffr.write("      <usenormantounicodemapper>" + useNormanToUnicodeMapper + "</usenormantounicodemapper>\n");
Line 1827  class Convert Line 1613  class Convert
     public static void delete(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception      public static void delete(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception
     {      {
         FM2SQL.ProgressDialog dialog = null;          FM2SQL.ProgressDialog dialog = null;
         if (FM2SQL.fmInstance != null)          if (isGUI)
         {          {
             dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);              dialog = initDialog();
             dialog.setTitle("Conversion running ...");  
             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.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  
             FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  
             dialog.thread = Thread.currentThread();  
         }          }
         // setting user and passwd          // setting user and passwd
         bean.setUserAndPasswd(user, passwd);          bean.setUserAndPasswd(user, passwd);
         // setting user and passwd          // setting user and passwd
         beanDest.setUserAndPasswd(userDest, passwdDest);          beanDest.setUserAndPasswd(userDest, passwdDest);
         if (dialog != null)  
             dialog.setSize(400, 250);  
         StringBuffer command = null;          StringBuffer command = null;
         String query = null;          String query = null;
         try          try
Line 1977  class Convert Line 1755  class Convert
                         command.append("DELETE FROM");                          command.append("DELETE FROM");
                         command.append(beanDest.getQC());                          command.append(beanDest.getQC());
                         command.append(destTableName);                          command.append(destTableName);
                         //command.append(convertText((String)  
                         // names.get(tbIndex)));  
                         command.append(beanDest.getQC());                          command.append(beanDest.getQC());
                         int size = bean.getColumnNames().size();                          int size = bean.getColumnNames().size();
                         command.append("WHERE " + convertText(ids.get(tbIndex).toString()) + " =  ?");                          command.append("WHERE " + convertText(ids.get(tbIndex).toString()) + " =  ?");
                         PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());                          PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
                         System.out.println(command + " " + tbIndex);                          System.out.println(command + " " + tbIndex);
                         //int rowCount = bean.getRowCount(query);  
                         //        int idIndex =  
                         // bean.getColumnNames().indexOf(ids.get(tbIndex));  
                         while (true)                          while (true)
                         {                          {
   
Line 1997  class Convert Line 1770  class Convert
                             pstm.setString(1, linesToDelete.get(j).toString());                              pstm.setString(1, linesToDelete.get(j).toString());
                             System.out.println(pstm.toString());                              System.out.println(pstm.toString());
                             pstm.execute();                              pstm.execute();
                             if (dialog != null)                              if (isGUI)
                                 dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));                                  dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
                             command = null;                              command = null;
                         }                          }
Line 2015  class Convert Line 1788  class Convert
         catch (Exception e)          catch (Exception e)
         {          {
             System.out.println("Error while connecting to database " + e);              System.out.println("Error while connecting to database " + e);
             if (dialog != null)              if (isGUI)
             {              {
                 dialog.setVisible(false);                  showExceptionDialog(dialog, command, e);
                 dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));                  resetGUI(dialog);
                 FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
             }  
             java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();  
             java.io.PrintStream stream = new java.io.PrintStream(b);  
             stream.print(command + "\n\n");  
             e.printStackTrace(stream);  
             FM2SQL.showErrorDialog(b.toString(), "Error occured !");  
   
         }          }
         if (dialog != null)              else
         {          {
             dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));                  e.printStackTrace();
             FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));              }
   
             dialog.setVisible(false);  
         }          }
     } // to method      } // to method
   
Line 2057  class Convert Line 1820  class Convert
     {      {
         System.out.println(" bin in synchronize!!!");          System.out.println(" bin in synchronize!!!");
         FM2SQL.ProgressDialog dialog = null;          FM2SQL.ProgressDialog dialog = null;
         if (FM2SQL.fmInstance != null)          if (isGUI)
         {          {
             dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);              dialog = initDialog();
             dialog.setTitle("Synchronize running ...");              dialog.setTitle("Synchronize running ...");
             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.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  
             FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));  
             dialog.thread = Thread.currentThread();  
         }          }
         // setting user and passwd          // setting user and passwd
         bean.setUserAndPasswd(user, passwd);          bean.setUserAndPasswd(user, passwd);
         // setting user and passwd          // setting user and passwd
         beanDest.setUserAndPasswd(userDest, passwdDest);          beanDest.setUserAndPasswd(userDest, passwdDest);
         if (dialog != null)  
             dialog.setSize(400, 250);  
         StringBuffer command = null;          StringBuffer command = null;
         String query = null;          String query = null;
         try          try
         {          {
             //bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050");  
             //bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo");  
             bean.setConnection(source);              bean.setConnection(source);
             if (names == null)              if (names == null)
                 names = bean.getTableNames();                  names = bean.getTableNames();
             // Collections.sort(names);  
             int tbIndex = 1;              int tbIndex = 1;
   
             // System.out.println("Start at  
             // "+names.indexOf("archimedes_facsimiles"));  
             for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)              for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
             {              {
                 Vector[] result = null;                  Vector[] result = null;
Line 2104  class Convert Line 1856  class Convert
                     //if vectors[1].get(i) != null)                      //if vectors[1].get(i) != null)
                     if (!layout.equals(""))                      if (!layout.equals(""))
                     {                      {
                         layout = " layout " + bean.getQC() + layout + bean.getQC();                          query = addLayoutToQuery(names, query, tbIndex, layout);
                         String name = names.get(tbIndex).toString();  
                         StringBuffer queryLayout = new StringBuffer(query);  
                         queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);  
                         query = queryLayout.toString();  
                         System.out.println("added layout  " + query);  
   
                     }                      }
                     if (dialog != null)                      if (dialog != null)
                     {                      {
                         dialog.title.setText("Getting table data ...");                          prepareDialogforUse(names, dialog, tbIndex);
                         dialog.table.setText(names.get(tbIndex).toString());  
                         dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());  
                         dialog.show();  
                     }                      }
                     bean.getConnection();                      bean.getConnection();
                     bean.makeQuery(query, 50);                      bean.makeQuery(query, 50);
Line 2126  class Convert Line 1870  class Convert
                 }                  }
                 catch (Exception e)                  catch (Exception e)
                 {                  {
                       System.out.println("Warning exception occured \n " + e);
   
                     continue;                      continue;
                 }                  }
                 // determine destTableName from createStatement or from source                  // determine destTableName from createStatement or from source
Line 2231  class Convert Line 1977  class Convert
                             if (dialog != null)                              if (dialog != null)
                                 dialog.title.setText("Writing table data ...");                                  dialog.title.setText("Writing table data ...");
   
                             performSynchronize(idField, vec, tempQuery, linesToDelete, linesToAppend, insPst, updPst, delPSt, deltaID, delimiter);                              performSynchronize(idField, vec, tempQuery, linesToDelete, linesToAppend, insPst, updPst, delPSt, deltaID, delimiter, dialog);
                             // System.out.println("ID LIST SIZE " +                              // System.out.println("ID LIST SIZE " +
                             // Math.round((double) myIds.size() / (double)                              // Math.round((double) myIds.size() / (double)
                             // numIntervalls) + " " + myIdsDest.size());                              // numIntervalls) + " " + myIdsDest.size());
Line 2255  class Convert Line 2001  class Convert
                             //    bean.makeQuery(tempQuery, 0);                              //    bean.makeQuery(tempQuery, 0);
                             if (dialog != null)                              if (dialog != null)
                                 dialog.title.setText("Writing table data ...");                                  dialog.title.setText("Writing table data ...");
                             performSynchronize(idField, vec, tempQuery, linesToDelete, linesToAppend, insPst, updPst, delPSt, deltaID, delimiter);                              performSynchronize(idField, vec, tempQuery, linesToDelete, linesToAppend, insPst, updPst, delPSt, deltaID, delimiter, dialog);
                             // System.out.println("ID LIST SIZE " +                              // System.out.println("ID LIST SIZE " +
                             // Math.round((double) myIds.size() / (double)                              // Math.round((double) myIds.size() / (double)
                             // numIntervalls) + " " + myIdsDest.size());                              // numIntervalls) + " " + myIdsDest.size());
Line 2268  class Convert Line 2014  class Convert
   
                     }                      }
                     String tableName = names.get(tbIndex).toString();                      String tableName = names.get(tbIndex).toString();
                       if (!indexList.isEmpty())
                       {
                     IndexList idList = (IndexList) indexList.get(0);                      IndexList idList = (IndexList) indexList.get(0);
                     System.out.println("found list " + idList);                      System.out.println("found list " + idList);
                     Statement stm = beanDest.getConnection().createStatement();                      Statement stm = beanDest.getConnection().createStatement();
Line 2319  class Convert Line 2067  class Convert
                         // "+destTableName+"_"+indexField);                          // "+destTableName+"_"+indexField);
   
                     }                      }
                       }
                     //  CREATE UNIQUE INDEX title_idx ON films (title);                      //  CREATE UNIQUE INDEX title_idx ON films (title);
                     for (Iterator iter = linesToDelete.iterator(); iter.hasNext();)                      for (Iterator iter = linesToDelete.iterator(); iter.hasNext();)
                     {                      {
Line 2338  class Convert Line 2087  class Convert
         {          {
             System.out.println("Error while connecting to database " + e);              System.out.println("Error while connecting to database " + e);
             e.printStackTrace();              e.printStackTrace();
             if (dialog != null)              if (isGUI)
             {                  showExceptionDialog(dialog, command, e);
                 dialog.setVisible(false);  
                 dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
                 FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
             }              }
             java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();          if (isGUI)
             java.io.PrintStream stream = new java.io.PrintStream(b);  
             stream.print(command + "\n\n");  
             e.printStackTrace(stream);  
             FM2SQL.showErrorDialog(b.toString(), "Error occured !");  
   
         }  
         if (dialog != null)  
         {          {
             dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));              resetGUI(dialog);
             FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));  
   
             dialog.setVisible(false);  
         }          }
     }      }
   
Line 2374  class Convert Line 2110  class Convert
     }      }
   
     private static void performSynchronize(String idField, Vector vec, String tempQuery, TreeSet linesToDelete, TreeSet linesToAppend, PreparedStatement insPst, PreparedStatement updPst,      private static void performSynchronize(String idField, Vector vec, String tempQuery, TreeSet linesToDelete, TreeSet linesToAppend, PreparedStatement insPst, PreparedStatement updPst,
             PreparedStatement delPSt, int deltaID, String delimiter) throws SQLException, ParseException              PreparedStatement delPSt, int deltaID, String delimiter, FM2SQL.ProgressDialog dialog) throws SQLException, ParseException, Exception
     {      {
           if (dialog != null)
           {
               dialog.progress.setValue(0);
               dialog.title.setText("Retrieving new data");
           }
   
         Vector[] vectors = bean.getQueryData(tempQuery, deltaID);          Vector[] vectors = bean.getQueryData(tempQuery, deltaID);
           int count = 0, size = vectors[0].size();
         int idIndex = vectors[1].indexOf(idField);          int idIndex = vectors[1].indexOf(idField);
         System.out.println(idIndex + " " + vectors[1] + " " + idField);          //System.out.println(idIndex + " " + vectors[1] + " " + idField);
         // todo arraylist code has to be added          // todo arraylist code has to be added
           if (dialog != null)
               dialog.title.setText("Synchronize with new data");
   
         for (Iterator iter = vectors[0].iterator(); iter.hasNext();)          for (Iterator iter = vectors[0].iterator(); iter.hasNext();)
         {          {
             Vector line = (Vector) iter.next();              Vector line = (Vector) iter.next();
Line 2416  class Convert Line 2162  class Convert
                 }                  }
                 updPst.setString(line.size() + 1, line.get(idIndex).toString());                  updPst.setString(line.size() + 1, line.get(idIndex).toString());
                 //updPst.addBatch();                  //updPst.addBatch();
                 updPst.execute();                  //updPst.execute();
               }
               if (dialog != null)
               {
                   int value = (int) Math.round(((double) count / (double) size) * 100.0);
                   dialog.progress.setValue(value);
                   count++;
             }              }
         }          }
         //updPst.executeBatch();          //updPst.executeBatch();
Line 4010  class Convert Line 3762  class Convert
         command.append("UPDATE ");          command.append("UPDATE ");
         command.append(beanDest.getQC());          command.append(beanDest.getQC());
         command.append(destTableName);          command.append(destTableName);
         //command.append(convertText((String) names.get(tbIndex)));  
         command.append(beanDest.getQC());          command.append(beanDest.getQC());
         command.append(" SET  ");          command.append(" SET  ");
   

Removed from v.1.79  
changed lines
  Added in v.1.87


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>