Diff for /FM2SQL/Attic/Convert.java between versions 1.41 and 1.42

version 1.41, 2004/03/01 12:37:10 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 435  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 1079  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 1103  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 1112  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 1179  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 1197  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 1245  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 1269  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 1454  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;
Line 1473  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 1484  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";

Removed from v.1.41  
changed lines
  Added in v.1.42


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