Annotation of FM2SQL/Convert.java, revision 1.65

1.51      rogo        1: /*
                      2:  * Convert.java -- Converter class -  Filemaker to SQL Converter 
1.52      rogo        3:  * Copyright (C) 2003 Robert Gordesch (rogo@mpiwg-berlin.mpg.de1.51      rogo        4:  * This program is free software; you can redistribute it and/or modify it
                      5:  * under the terms of the GNU General Public License as published by the Free
                      6:  * Software Foundation; either version 2 of the License, or (at your option)
                      7:  * any later version.  Please read license.txt for the full details. A copy of
                      8:  * the GPL may be found at http://www.gnu.org/copyleft/lgpl.html  You should
                      9:  * have received a copy of the GNU General Public License along with this
                     10:  * program; if not, write to the Free Software Foundation, Inc., 59 Temple
                     11:  * Place, Suite 330, Boston, MA 02111-1307 USA  Created on 15.09.2003 by
                     12:  * rogo  
                     13:  */
                     14: 
1.1       rogo       15: import java.awt.Cursor;
                     16: import java.io.BufferedReader;
                     17: import java.io.BufferedWriter;
                     18: import java.io.File;
                     19: import java.io.FileInputStream;
                     20: import java.io.FileNotFoundException;
                     21: import java.io.FileOutputStream;
1.60      rogo       22: import java.io.InputStream;
1.1       rogo       23: import java.io.InputStreamReader;
                     24: import java.io.OutputStreamWriter;
                     25: import java.io.PrintStream;
                     26: import java.io.UnsupportedEncodingException;
1.60      rogo       27: import java.net.URL;
1.57      rogo       28: import java.sql.PreparedStatement;
                     29: import java.sql.SQLException;
                     30: import java.sql.Statement;
                     31: import java.sql.Types;
                     32: import java.util.ArrayList;
                     33: import java.util.Iterator;
                     34: import java.util.List;
1.65    ! rogo       35: import java.util.Properties;
1.57      rogo       36: import java.util.StringTokenizer;
                     37: import java.util.TreeSet;
                     38: import java.util.Vector;
1.1       rogo       39: 
                     40: import com.exploringxml.xml.Node;
                     41: import com.exploringxml.xml.Xparse;
                     42: 
1.34      rogo       43: class Convert
1.1       rogo       44: {
1.34      rogo       45:   static DBBean bean = new DBBean();
                     46:   static DBBean beanDest = new DBBean();
1.1       rogo       47: 
1.34      rogo       48:   static String user = "", passwd = "e1nste1n";
                     49:   static String userDest = "postgres", passwdDest = "rogo";
                     50:   static boolean batchRun = false;
1.1       rogo       51:   static Vector databases = new Vector();
1.30      rogo       52:   final static int numHits = 5000;
                     53:   final static int numIntervalls = 2;
1.1       rogo       54:   public static void main(String args[])
                     55:   {
1.34      rogo       56:     /*    try
                     57:         {
                     58:           //byte[] b = "ö".getBytes("UTF-8");
                     59:         //  System.out.println("QueryString " +b[0]+" "+b[1]+(new String(b).getBytes()[0])+" "+new String(b).getBytes()[1]);
                     60:         //System.out.println(new String(b,"UTF-8"));
                     61:         } catch (UnsupportedEncodingException e)
                     62:         {
                     63:           e.printStackTrace();
                     64:         }*/
1.1       rogo       65:     FileOutputStream file = null;
1.34      rogo       66:     if (args.length != 1)
1.1       rogo       67:     {
1.34      rogo       68:       System.out.println("Usage: java Convert <xml config file>");
                     69:       System.exit(-1);
1.1       rogo       70:     }
                     71:     try
                     72:     {
                     73:       file = new FileOutputStream("./log.txt");
                     74:     } catch (FileNotFoundException e1)
                     75:     {
                     76:       e1.printStackTrace();
1.34      rogo       77:     }
                     78:     PrintStream stream = new PrintStream(file);
1.65    ! rogo       79:     // System.setOut(stream);
1.60      rogo       80:     //System.setErr(stream);
                     81: 
1.34      rogo       82:     readXMLFile(args[0]);
1.60      rogo       83:     if (!(new File(args[0]).exists()))
                     84:       System.exit(0);
                     85: 
1.34      rogo       86:     System.out.println("Finished!");
1.1       rogo       87:     //convert("jdbc:fmpro:http://141.14.237.74:8050","jdbc:postgresql://erebos/test",null,null);
                     88:   }
1.55      rogo       89:   public static void convertBatch(DBBean source, DBBean destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode, String delimiter) throws Exception
1.1       rogo       90:   {
1.34      rogo       91:     bean = source;
                     92:     beanDest = destination;
1.55      rogo       93:     convert(null, null, names, layouts, selects, creates, ids, mode, delimiter);
                     94:     if (true)
                     95:       return;
1.34      rogo       96:     StringBuffer command = null;
1.1       rogo       97:     try
                     98:     {
                     99:       bean.setConnection(source.url);
1.34      rogo      100:       if (names == null)
                    101:         names = bean.getTableNames();
1.1       rogo      102:       //Collections.sort(names);
1.34      rogo      103:       int tbIndex = 1;
                    104: 
                    105:       for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
1.1       rogo      106:       {
                    107:         Vector[] result = null;
1.34      rogo      108:         try
1.1       rogo      109:         {
1.34      rogo      110:           String query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
                    111:           String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
                    112:           query = (selects != null) ? selects.get(tbIndex).toString() : query;
                    113:           //if  vectors[1].get(i) != null)
                    114:           if (!layout.equals(""))
                    115:           {
                    116:             System.out.println("before " + query + " table" + names.get(tbIndex));
                    117:             layout = " layout " + bean.getQC() + layout + bean.getQC();
                    118:             String name = names.get(tbIndex).toString();
                    119:             StringBuffer queryLayout = new StringBuffer(query);
                    120:             queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
                    121:             query = queryLayout.toString();
                    122:             System.out.println("added layout " + query);
                    123: 
                    124:           }
                    125:           System.out.println(" performing query " + query);
1.1       rogo      126:           //result = bean.getQueryData(query, null, 0);
1.34      rogo      127:           bean.getConnection();
                    128:           bean.makeQuery(query, 0);
                    129:         } catch (Exception e)
1.1       rogo      130:         {
                    131:           System.out.println(e.getMessage());
                    132:           e.printStackTrace();
                    133:           continue;
                    134:         }
                    135:         //beanDest.setConnection("jdbc:postgresql://erebos/test3");
                    136:         beanDest.setConnection(destination.url);
                    137: 
                    138:         Statement stm = beanDest.getConnection().createStatement();
                    139: 
                    140:         Vector tables = beanDest.getTableNames();
1.34      rogo      141:         //   Collections.sort(tables);
                    142:         System.out.println("converting table " + names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames()); 
1.1       rogo      143:         tables = beanDest.getTableNames();
                    144:         // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
                    145:         stm = beanDest.getConnection().createStatement();
                    146:         // System.exit(0);
1.34      rogo      147:         if (mode == Convert.DataBase.CONVERT_MODE)
1.1       rogo      148:         {
1.34      rogo      149:           if (tables.indexOf(names.get(tbIndex)) >= 0)
                    150:           {
                    151:             stm.executeUpdate("drop table " + beanDest.getQC() + names.get(tbIndex) + beanDest.getQC());
                    152:             tables.remove((String) names.get(tbIndex));
                    153:             System.out.println("dropped table " + names.get(tbIndex));
                    154:           } else if (tables.indexOf(convertText(names.get(tbIndex).toString())) >= 0)
1.1       rogo      155:           {
1.34      rogo      156:             stm.executeUpdate("drop table " + beanDest.getQC() + convertText((String) names.get(tbIndex)) + beanDest.getQC());
                    157:             tables.remove(convertText((String) names.get(tbIndex)));
                    158:             System.out.println("dropped table " + names.get(tbIndex));
                    159:           }
                    160: 
                    161:           if (tables.indexOf(names.get(tbIndex)) < 0 && tables.indexOf(convertText(names.get(tbIndex).toString())) < 0)
1.1       rogo      162:           {
1.34      rogo      163:             if (creates.get(tbIndex).equals("") || creates.get(tbIndex).toString().toLowerCase().indexOf("create") < 0)
                    164:             {
                    165:               System.out.println("Warning empty or invalid create statement - creating one for you\n");
                    166: 
                    167:               command = new StringBuffer(50);
                    168:               command.append("CREATE TABLE ");
                    169:               command.append(beanDest.getQC());
                    170:               command.append(convertText((String) names.get(tbIndex)));
                    171:               command.append(beanDest.getQC());
                    172:               command.append("(");
                    173:               String type = null;
                    174:               Vector columnNames = bean.getColumnNames();
                    175:               for (int i = 0; i < columnNames.size() - 1; ++i)
                    176:               {
                    177:                 type = bean.metaData.getColumnTypeName(i + 1);
                    178:                 //   System.out.println(i+" "+result[1].get(i)+" "+type);
                    179:                 type = (type.equals("NUMBER")) ? "INT4" : type;
                    180:                 type = (type.equals("CONTAINER")) ? "TEXT" : type;
                    181: 
                    182:                 command.append(beanDest.getQC() + convertText((String) columnNames.get(i)) + beanDest.getQC() + " " + type + ", ");
                    183:               }
                    184:               type = bean.metaData.getColumnTypeName(columnNames.size());
                    185:               type = (type.equals("NUMBER")) ? "INT4" : type;
                    186:               type = (type.equals("CONTAINER")) ? "TEXT" : type;
                    187:               command.append(beanDest.getQC() + convertText((String) columnNames.get(columnNames.size() - 1)) + beanDest.getQC() + " " + type);
                    188:               command.append(" )");
                    189:             } else
                    190:               command = new StringBuffer().append(creates.get(tbIndex).toString());
                    191: 
                    192:             System.out.println(command);
                    193:             //  System.exit(0);
                    194:             //command.append(DBBean.getQC());   
                    195:             stm.executeUpdate(command.toString());
1.1       rogo      196: 
1.34      rogo      197:           }
1.1       rogo      198:         }
1.34      rogo      199:         Vector row = null;
                    200:         command = new StringBuffer();
1.1       rogo      201: 
                    202:         command.append("INSERT  INTO ");
                    203:         command.append(beanDest.getQC());
                    204:         command.append(convertText((String) names.get(tbIndex)));
                    205:         command.append(beanDest.getQC());
                    206:         command.append(" values ( ");
1.3       rogo      207: 
1.34      rogo      208:         for (int i = 0; i < bean.getColumnNames().size() - 1; ++i)
                    209:           command.append("?,");
                    210:         command.append("?)");
                    211:         PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
                    212:         System.out.println(command);
                    213:         while ((row = bean.getNextRow()) != null)
                    214:         {
                    215:           //print rows
                    216:           Object obj = null;
                    217:           for (int k = 0; k < row.size(); ++k)
                    218:           {
                    219:             obj = row.get(k);
                    220:             if (obj instanceof ArrayList)
1.55      rogo      221:               obj = formatFileMakerArray((List) obj, "\n");
1.34      rogo      222:             String str = (obj == null) ? "NULL" : obj.toString();
                    223:             if (!str.equals("NULL"))
                    224:               pstm.setString(k + 1, str);
                    225:             else
                    226:               pstm.setNull(k + 1, Types.NULL);
                    227:           }
                    228:           pstm.execute();
                    229: 
                    230:         } // to for loop    
                    231: 
                    232:       }
                    233:     } catch (Exception e)
                    234:     {
                    235:       System.out.println("Error while connecting to database " + e);
                    236:       //dialog.setVisible(false);
                    237:       //dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    238:       //FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    239:       java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
                    240:       java.io.PrintStream stream = new java.io.PrintStream(b);
                    241:       stream.print(command + "\n\n");
                    242:       e.printStackTrace(stream);
                    243:       System.err.println(b);
                    244:       //FM2SQL.showErrorDialog(b.toString(), "Error occured !");
                    245: 
1.1       rogo      246:     }
1.34      rogo      247:     //  dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    248:     //FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1.1       rogo      249: 
1.34      rogo      250:     //  dialog.setVisible(false); 
1.1       rogo      251:   }
1.55      rogo      252:   public static String formatFileMakerArray(List list, String delimiter)
                    253:   {
                    254:     StringBuffer formattedString = new StringBuffer();
                    255:     for (int i = 0; i < list.size(); ++i)
                    256:     {
                    257:       formattedString.append(list.get(i).toString());
                    258:       if (i < list.size() - 1)
                    259:         formattedString.append(delimiter);
                    260:     }
                    261:     return formattedString.toString();
                    262:   }
1.38      rogo      263:   /**
                    264:    * Method for SQL UPDATE
                    265:    * @param source
                    266:    * @param destination
                    267:    * @param names
                    268:    * @param layouts
                    269:    * @param selects
                    270:    * @param creates
                    271:    * @param ids
                    272:    * @param mode
                    273:    * @throws Exception
                    274:    */
1.34      rogo      275:   public static void update(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception
1.12      rogo      276:   {
                    277:     FM2SQL.ProgressDialog dialog = null;
                    278:     if (FM2SQL.fmInstance != null)
                    279:     {
1.55      rogo      280:       dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
1.12      rogo      281:       dialog.setTitle("Conversion running ...");
                    282:       dialog.title.setText("Getting table data ...");
                    283:       dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2);
                    284:       dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    285:       FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    286:       dialog.thread = Thread.currentThread();
                    287:     }
                    288:     // setting user and passwd 
                    289:     bean.setUserAndPasswd(user, passwd);
                    290:     // setting user and passwd 
                    291:     beanDest.setUserAndPasswd(userDest, passwdDest);
                    292:     if (dialog != null)
                    293:       dialog.setSize(400, 250);
                    294:     StringBuffer command = null;
                    295:     String query = null;
                    296:     try
                    297:     {
                    298:       //bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050");    
                    299:       //bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo");
                    300:       bean.setConnection(source);
                    301:       if (names == null)
                    302:         names = bean.getTableNames();
                    303:       // Collections.sort(names);
                    304:       int tbIndex = 1;
1.55      rogo      305: 
1.12      rogo      306:       // System.out.println("Start at "+names.indexOf("archimedes_facsimiles"));
                    307:       for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
                    308:       {
                    309:         Vector[] result = null;
1.45      rogo      310:         String destTableName = "";
1.12      rogo      311:         try
                    312:         {
                    313:           query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
                    314:           String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
                    315:           query = (selects != null) ? selects.get(tbIndex).toString() : query;
                    316:           //if  vectors[1].get(i) != null)
                    317:           if (layout != "")
                    318:           {
                    319:             layout = " layout " + bean.getQC() + layout + bean.getQC();
                    320:             String name = names.get(tbIndex).toString();
                    321:             StringBuffer queryLayout = new StringBuffer(query);
                    322:             queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
                    323:             query = queryLayout.toString();
                    324:             System.out.println("added layout  " + query);
                    325: 
                    326:           }
                    327:           dialog.title.setText("Getting table data ...");
                    328:           dialog.table.setText(names.get(tbIndex).toString());
                    329:           dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
                    330:           dialog.show();
                    331:           bean.getConnection();
                    332:           bean.makeQuery(query, 0);
                    333:         } catch (Exception e)
                    334:         {
                    335:           continue;
                    336:         }
1.45      rogo      337:         // determine destTableName from createStatement or from source table name
1.55      rogo      338:         if (!creates.get(tbIndex).equals(""))
                    339:         {
                    340:           String create = creates.get(tbIndex).toString().toLowerCase();
                    341:           int fromIndex = create.indexOf("table") + 5;
                    342:           int toIndex = create.indexOf("(");
                    343:           destTableName = create.substring(fromIndex, toIndex).replaceAll(beanDest.getQC(), "").trim();
                    344:           System.out.println("destTable " + destTableName);
                    345: 
                    346:         } else
                    347:           destTableName = convertText(names.get(tbIndex).toString());
1.45      rogo      348: 
1.12      rogo      349:         //beanDest.setConnection("jdbc:postgresql://erebos/test3");
                    350:         beanDest.setConnection(destination);
                    351: 
                    352:         Statement stm = beanDest.getConnection().createStatement();
                    353: 
                    354:         Vector tables = beanDest.getTableNames();
                    355:         // Collections.sort(tables);
                    356:         System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames()); 
                    357:         tables = beanDest.getTableNames();
                    358:         // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
                    359:         stm = beanDest.getConnection().createStatement();
                    360:         // System.exit(0);
1.34      rogo      361: 
1.12      rogo      362:         if (dialog != null)
1.36      rogo      363:           dialog.title.setText("Updating table data ...");
1.12      rogo      364: 
                    365:         int j = -1;
1.34      rogo      366: 
1.12      rogo      367:         Vector row = null;
                    368:         command = new StringBuffer();
                    369: 
                    370:         command.append("UPDATE ");
                    371:         command.append(beanDest.getQC());
1.45      rogo      372:         command.append(destTableName);
                    373:         //command.append(convertText((String) names.get(tbIndex)));
1.12      rogo      374:         command.append(beanDest.getQC());
                    375:         command.append(" SET  ");
                    376: 
                    377:         int size = bean.getColumnNames().size();
                    378:         for (int i = 0; i < size - 1; ++i)
1.34      rogo      379:           command.append(beanDest.getQC() + convertText((String) bean.getColumnNames().get(i)) + beanDest.getQC() + " = ? ,");
                    380:         command.append(convertText((String) bean.getColumnNames().get(size - 1)) + " = ? ");
                    381:         command.append("WHERE " + convertText(ids.get(tbIndex).toString()) + " =  ?");
1.12      rogo      382:         PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
1.34      rogo      383:         System.out.println(command + " " + tbIndex);
                    384:         int rowCount = bean.getRowCount(query);
                    385:         int idIndex = bean.getColumnNames().indexOf(ids.get(tbIndex));
1.12      rogo      386:         while ((row = bean.getNextRow()) != null)
                    387:         {
                    388:           j++;
                    389:           //print rows
                    390:           Object obj = null;
                    391:           /* for(int k=0;k<row.size()-1;++k)
                    392:            {
                    393:                obj = row.get(k);
                    394:                //System.out.println("row "+obj+" "+k);
                    395:             if(obj!=null&&!(obj instanceof ArrayList))
                    396:             command.append("'"+convertUml(obj.toString())+"',"); 
                    397:             else if(obj!=null&&   obj instanceof ArrayList)
                    398:             command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"',"); 
                    399:             else command.append("NULL,");
                    400:            }
                    401:            obj = row.get(row.size() - 1);
                    402:            if (obj != null && !(obj instanceof ArrayList))
                    403:            command.append("'"+convertUml(obj.toString())+"')"); 
                    404:            else
                    405:            if(obj!=null&&   obj instanceof ArrayList)
                    406:             command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"')");         //command.append(obj.toString()+")");
                    407:             else command.append("NULL)");
                    408:            */
                    409:           //command.append("'"+row.get(row.size()-1)+"')"); 
                    410:           //command.append(" )");
                    411:           //  for(int k=0;k<row.size();++k)
                    412: 
                    413:           // System.out.println();
                    414:           //   System.out.println(command+" "+j+" "+row.size()+" "+  ((Vector)result2[0].get(j)).size());
                    415:           // System.out.println(command);
                    416:           for (int k = 0; k < row.size(); ++k)
                    417:           {
                    418:             obj = row.get(k);
                    419:             if (obj instanceof ArrayList)
                    420:               obj = ((List) obj).get(0);
                    421:             String str = (obj == null) ? "NULL" : obj.toString();
                    422:             if (!str.equals("NULL"))
                    423:               pstm.setString(k + 1, str);
                    424:             else
                    425:               pstm.setNull(k + 1, Types.NULL);
                    426:           }
1.34      rogo      427:           pstm.setString(row.size() + 1, row.get(idIndex).toString());
                    428:           //System.out.println(pstm.toString());
                    429:           // System.exit(0);
1.12      rogo      430:           pstm.execute();
                    431:           //stm.executeUpdate(command.toString());
1.34      rogo      432:           if (dialog != null)
                    433:             dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
1.12      rogo      434:           // System.out.println( (int)(((double)(j+1)/(double)result[0].size())*100.0)+" "+result[0].size()+" "+j);
                    435:           command = null;
                    436:         } // to for loop    
                    437: 
                    438:       }
                    439:     } catch (Exception e)
                    440:     {
                    441:       System.out.println("Error while connecting to database " + e);
1.18      rogo      442:       if (dialog != null)
                    443:       {
                    444:         dialog.setVisible(false);
                    445:         dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    446:         FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    447:       }
1.12      rogo      448:       java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
                    449:       java.io.PrintStream stream = new java.io.PrintStream(b);
                    450:       stream.print(command + "\n\n");
                    451:       e.printStackTrace(stream);
                    452:       FM2SQL.showErrorDialog(b.toString(), "Error occured !");
                    453: 
                    454:     }
1.18      rogo      455:     if (dialog != null)
                    456:     {
                    457:       dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    458:       FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    459: 
                    460:       dialog.setVisible(false);
                    461:     }
1.12      rogo      462: 
                    463:   }
1.34      rogo      464:   /**
1.38      rogo      465:    *   transfers the specified array of tables  to the destination database
                    466:       and creates the table if it does not exist if it exists and mode is not append the table is dropped
1.55      rogo      467:   
1.38      rogo      468:    * @param source
                    469:    * @param destination
                    470:    * @param names
                    471:    * @param layouts
                    472:    * @param selects
                    473:    * @param creates
                    474:    * @param ids
                    475:    * @param mode
                    476:    * @throws Exception
1.55      rogo      477:    */
                    478: 
                    479:   public static void convert(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode, String delimiter) throws Exception
1.1       rogo      480:   {
1.34      rogo      481: 
                    482:     FM2SQL.ProgressDialog dialog = null;
                    483: 
                    484:     if (FM2SQL.fmInstance != null)
                    485:     {
1.55      rogo      486:       dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
1.34      rogo      487:       dialog.setTitle("Conversion running ...");
                    488:       dialog.title.setText("Getting table data ...");
                    489:       dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2);
                    490:       dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    491:       FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    492:       dialog.thread = Thread.currentThread();
                    493:       dialog.setSize(400, 250);
                    494:     }
                    495:     java.util.TreeSet myIds = new TreeSet();
                    496:     int deltaID = 1;
                    497:     String idField = "";
1.38      rogo      498:     String destTableName = "";
1.55      rogo      499:     String[] fieldNames = null;
1.34      rogo      500:     if (source != null && destination != null)
                    501:     {
                    502:       // setting user and passwd 
                    503:       bean.setUserAndPasswd(user, passwd);
                    504:       // setting user and passwd 
                    505:       beanDest.setUserAndPasswd(userDest, passwdDest);
                    506:     }
                    507:     StringBuffer command = null;
                    508:     String query = null;
1.1       rogo      509:     try
                    510:     {
1.55      rogo      511:       if (source != null)
                    512:         bean.setConnection(source);
1.34      rogo      513:       else
1.55      rogo      514:         bean.setConnection(bean.url);
                    515: 
1.34      rogo      516:       if (names == null)
                    517:         names = bean.getTableNames();
                    518:       // Collections.sort(names);
                    519:       int tbIndex = 1;
                    520: 
                    521:       // System.out.println("Start at "+names.indexOf("archimedes_facsimiles"));
                    522:       for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
1.1       rogo      523:       {
                    524:         Vector[] result = null;
1.34      rogo      525:         try
1.1       rogo      526:         {
1.34      rogo      527:           query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
                    528:           String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
                    529:           query = (selects != null) ? selects.get(tbIndex).toString() : query;
                    530:           //if  vectors[1].get(i) != null)
                    531:           if (layout != "")
                    532:           {
                    533:             layout = " layout " + bean.getQC() + layout + bean.getQC();
                    534:             String name = names.get(tbIndex).toString();
                    535:             StringBuffer queryLayout = new StringBuffer(query);
                    536:             queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
                    537:             query = queryLayout.toString();
                    538:             System.out.println("added layout  " + query);
1.21      rogo      539: 
1.34      rogo      540:           }
                    541:           //  if ( layout!= "")
                    542:           //    query += " layout " + bean.getQC() + layout + bean.getQC();
                    543:           if (dialog != null)
                    544:           {
                    545:             dialog.title.setText("Reading table data ...");
                    546:             dialog.table.setText(names.get(tbIndex).toString());
                    547:             dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
                    548:             dialog.show();
                    549:           }
                    550:           //result = bean.getQueryData(query, dialog, 0);
                    551:           bean.getConnection();
                    552:           bean.makeQuery(query, 50);
                    553:           idField = ids.get(tbIndex).toString();
                    554: 
                    555:         } catch (Exception e)
                    556:         {
                    557:           System.out.println(e);
                    558:           continue;
1.1       rogo      559:         }
1.55      rogo      560:         if (destination != null)
                    561:           beanDest.setConnection(destination);
1.34      rogo      562:         else
1.55      rogo      563:           beanDest.setConnection(beanDest.url);
1.1       rogo      564:         Statement stm = beanDest.getConnection().createStatement();
                    565: 
                    566:         Vector tables = beanDest.getTableNames();
1.34      rogo      567:         // Collections.sort(tables);
1.1       rogo      568:         System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames()); 
                    569:         tables = beanDest.getTableNames();
                    570:         // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
                    571:         stm = beanDest.getConnection().createStatement();
                    572:         // System.exit(0);
1.55      rogo      573: 
                    574:         // determine destTableName from createStatement or from source table name
1.65    ! rogo      575:         ConversionProperties prop = getFieldNamesAndDestTableName(creates.get(tbIndex).toString(), query, names.get(tbIndex).toString());
        !           576:         destTableName = prop.destTableName;
        !           577:         fieldNames = prop.fieldNames;
        !           578:         if (mode == Convert.DataBase.CONVERT_MODE)
1.1       rogo      579:         {
1.38      rogo      580: 
                    581:           if (tables.indexOf(destTableName) >= 0)
                    582:           {
                    583:             stm.executeUpdate("drop table " + beanDest.getQC() + destTableName + beanDest.getQC());
                    584:             tables.remove(destTableName);
                    585:             System.out.println("dropped table" + destTableName);
                    586: 
                    587:           }
                    588:           /*
                    589:           if(destTableName.equals(""))
1.34      rogo      590:           if (tables.indexOf(names.get(tbIndex)) >= 0)
                    591:           {
                    592:             stm.executeUpdate("drop table " + beanDest.getQC() + names.get(tbIndex) + beanDest.getQC());
                    593:             tables.remove((String) names.get(tbIndex));
                    594:             System.out.println("dropped table" + names.get(tbIndex));
                    595:           } else if (tables.indexOf(convertText(names.get(tbIndex).toString())) >= 0)
1.1       rogo      596:           {
1.34      rogo      597:             stm.executeUpdate("drop table " + beanDest.getQC() + convertText((String) names.get(tbIndex)) + beanDest.getQC());
                    598:             tables.remove(convertText((String) names.get(tbIndex)));
                    599:             System.out.println("dropped table" + names.get(tbIndex));
                    600:           }
1.55      rogo      601:           */
1.38      rogo      602:           if ((tables.indexOf(destTableName) < 0)) //&& tables.indexOf(names.get(tbIndex)) < 0 && tables.indexOf(convertText(names.get(tbIndex).toString())) < 0   )
1.1       rogo      603:           {
1.55      rogo      604: 
1.34      rogo      605:             if (creates.get(tbIndex).equals("") || creates.get(tbIndex).toString().toLowerCase().indexOf("create") < 0)
                    606:             {
                    607:               System.out.println("Warning empty or invalid create statement - creating one for you\n");
                    608: 
                    609:               command = new StringBuffer(50);
                    610:               command.append("CREATE TABLE ");
                    611:               command.append(beanDest.getQC());
                    612:               command.append(convertText((String) names.get(tbIndex)));
                    613:               command.append(beanDest.getQC());
                    614:               command.append("(");
                    615:               String type = null;
                    616:               Vector columnNames = bean.getColumnNames();
                    617:               for (int i = 0; i < columnNames.size() - 1; ++i)
                    618:               {
                    619:                 type = bean.metaData.getColumnTypeName(i + 1);
                    620:                 //   System.out.println(i+" "+result[1].get(i)+" "+type);
                    621:                 type = (type.equals("NUMBER")) ? "INT4" : type;
                    622:                 type = (type.equals("CONTAINER")) ? "TEXT" : type;
                    623: 
                    624:                 command.append(beanDest.getQC() + convertText((String) columnNames.get(i)) + beanDest.getQC() + " " + type + ", ");
                    625:               }
                    626:               type = bean.metaData.getColumnTypeName(columnNames.size());
                    627:               type = (type.equals("NUMBER")) ? "INT4" : type;
                    628:               type = (type.equals("CONTAINER")) ? "TEXT" : type;
                    629:               command.append(beanDest.getQC() + convertText((String) columnNames.get(columnNames.size() - 1)) + beanDest.getQC() + " " + type);
                    630:               command.append(" )");
                    631: 
                    632:               // System.out.println(command);
                    633:               //  System.exit(0);
                    634:               //command.append(DBBean.getQC());   
                    635:             } else
1.38      rogo      636:               command = new StringBuffer().append(creates.get(tbIndex).toString().toLowerCase());
1.34      rogo      637:             stm.executeUpdate(command.toString());
1.1       rogo      638: 
1.34      rogo      639:           }
1.1       rogo      640:         }
1.55      rogo      641:         if (dialog != null)
                    642:           dialog.title.setText("Writing table data ...");
1.34      rogo      643: 
                    644:         // prepare the insert statement
                    645:         int j = -1;
                    646:         Vector row = null;
                    647:         command = new StringBuffer();
                    648: 
                    649:         command.append("INSERT  INTO ");
                    650:         command.append(beanDest.getQC());
1.38      rogo      651:         command.append(destTableName); //convertText((String) names.get(tbIndex)));
1.34      rogo      652:         command.append(beanDest.getQC());
1.55      rogo      653:         command.append(" (");
                    654:         for (int i = 0; i < fieldNames.length; i++)
                    655:         {
                    656:           command.append(fieldNames[i]);
                    657:           if (i < fieldNames.length - 1)
                    658:             command.append(",");
                    659:         }
                    660:         command.append(") ");
                    661: 
1.34      rogo      662:         command.append(" values ( ");
                    663: 
1.38      rogo      664:         // add a question marks for every field 
1.34      rogo      665:         for (int i = 0; i < bean.getColumnNames().size() - 1; ++i)
                    666:           command.append("?,");
                    667:         command.append("?)");
                    668:         PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
                    669:         System.out.println(command);
                    670:         int rowCount = (idField != "") ? myIds.size() : bean.getRowCount(query);
                    671:         Vector vec = new Vector(myIds);
                    672:         int endIndex = -1;
                    673:         String tempQuery = query;
                    674:         String tempID = bean.getQC() + idField + bean.getQC();
1.38      rogo      675:         // if id_field not do incremental conversion else do it all at once
1.34      rogo      676:         if (!idField.equals(""))
                    677:         {
                    678:           long startTime = System.currentTimeMillis();
                    679:           int counter = -1;
                    680:           while (true)
                    681:           {
                    682:             ++counter;
1.55      rogo      683:             if (counter == 0 && dialog != null)
1.34      rogo      684:               dialog.title.setText("Check if data  is available");
1.55      rogo      685:             else if (dialog != null)
1.34      rogo      686:               dialog.title.setText("Check if more  data  is available");
                    687:             myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, numHits);
                    688:             if (myIds.isEmpty())
                    689:               break;
                    690:             vec = new Vector(myIds);
                    691:             rowCount = vec.size();
                    692:             System.out.println("ID LIST SIZE " + Math.round((double) myIds.size() / (double) numIntervalls) + " " + myIds.size());
                    693:             deltaID = (int) Math.round((double) myIds.size() / (double) numIntervalls);
                    694:             if (vec.size() <= numIntervalls)
                    695:             {
                    696:               endIndex = 0;
                    697:               deltaID = vec.size();
                    698:             }
                    699:             for (int k = 0; k < vec.size() - deltaID; k = k + deltaID)
                    700:             {
                    701:               System.out.println(vec.get(k) + " " + vec.get(k + deltaID) + " " + vec.lastElement());
                    702:               if (query.indexOf("where") > 0)
1.55      rogo      703:                 tempQuery = query + " and " + tempID + ">='" + vec.get(k) + "' and " + tempID + "<='" + vec.get(k + deltaID) + "'";
1.34      rogo      704:               else
1.55      rogo      705:                 tempQuery = query + " where " + tempID + ">='" + vec.get(k) + "' and " + tempID + "<='" + vec.get(k + deltaID) + "'";
1.34      rogo      706:               System.out.println(tempQuery);
1.55      rogo      707:               if (dialog != null)
                    708:                 dialog.title.setText("Reading table data ...");
1.34      rogo      709: 
                    710:               bean.makeQuery(tempQuery, deltaID);
1.55      rogo      711:               if (dialog != null)
                    712:                 dialog.title.setText("Writing table data ...");
1.34      rogo      713: 
1.55      rogo      714:               command = writeDatainDestTable(dialog, command, k, pstm, rowCount, delimiter);
1.34      rogo      715:               endIndex = k + deltaID;
                    716:             }
                    717:             System.out.println(endIndex);
1.38      rogo      718:             //all data written ? if not write last chunk of data
1.34      rogo      719:             if (endIndex == vec.size() - 1)
                    720:               System.out.println("fits");
                    721:             else
                    722:             {
                    723:               System.out.println(" last intervall from " + vec.get(endIndex) + " " + vec.lastElement());
1.1       rogo      724: 
1.34      rogo      725:               if (query.indexOf("where") > 0)
1.55      rogo      726:                 tempQuery = query + " and " + tempID + ">='" + vec.get(endIndex) + "' and " + tempID + "<='" + vec.lastElement() + "'";
1.34      rogo      727:               else
1.55      rogo      728:                 tempQuery = query + " where " + tempID + ">='" + vec.get(endIndex) + "' and " + tempID + "<='" + vec.lastElement() + "'";
1.34      rogo      729:               System.out.println(tempQuery);
1.55      rogo      730:               if (dialog != null)
                    731:                 dialog.title.setText("Reading table data ...");
1.34      rogo      732:               bean.makeQuery(tempQuery, 0);
1.55      rogo      733:               if (dialog != null)
                    734:                 dialog.title.setText("Writing table data ...");
                    735:               command = writeDatainDestTable(dialog, command, endIndex, pstm, rowCount, delimiter);
1.34      rogo      736:             }
1.38      rogo      737:             // prepare new query for next chunk
1.34      rogo      738:             if (query.indexOf("where") > 0)
1.55      rogo      739:               tempQuery = query + " and " + tempID + ">'" + vec.lastElement() + "'";
1.34      rogo      740:             else
1.55      rogo      741:               tempQuery = query + " where " + tempID + ">'" + vec.lastElement() + "'";
1.34      rogo      742: 
                    743:           }
                    744:           long endTime = System.currentTimeMillis();
                    745:           System.out.println("Time for incremental convert elapsed " + (endTime - startTime));
                    746:         } else
1.29      rogo      747:         {
1.38      rogo      748:           // read and write all in one big chunk
1.34      rogo      749:           long startTime = System.currentTimeMillis();
1.55      rogo      750: 
1.34      rogo      751:           bean.makeQuery(query, 0);
1.55      rogo      752:           command = writeDatainDestTable(dialog, command, j, pstm, rowCount, delimiter);
1.34      rogo      753:           long endTime = System.currentTimeMillis();
                    754:           System.out.println("Time for old convert elapsed " + (endTime - startTime));
1.29      rogo      755: 
                    756:         }
1.34      rogo      757:       }
                    758:     } catch (Exception e)
                    759:     {
                    760:       System.out.println("Error while connecting to database " + e);
                    761:       if (dialog != null)
                    762:       {
                    763:         dialog.setVisible(false);
                    764:         dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    765:         FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    766:         java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
                    767:         java.io.PrintStream stream = new java.io.PrintStream(b);
                    768:         stream.print(command + "\n\n");
                    769:         e.printStackTrace(stream);
                    770:         FM2SQL.showErrorDialog(b.toString(), "Error occured !");
                    771:       } else
                    772:       {
                    773:         e.printStackTrace();
1.33      rogo      774: 
1.3       rogo      775:       }
1.1       rogo      776:     }
1.34      rogo      777:     if (dialog != null)
                    778:     {
                    779:       dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    780:       FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    781:       dialog.setVisible(false);
                    782:     }
1.27      rogo      783:   }
1.38      rogo      784:   /**
                    785:    * Writes data to the destination table 
                    786:    * @param dialog  progress dialog
                    787:    * @param command 
                    788:    * @param j       data index for progress bar
                    789:    * @param pstm    prepared statement
                    790:    * @param rowCount number of datasets
                    791:    * @return   command
                    792:    * @throws Exception
                    793:    * @throws SQLException
                    794:    */
1.55      rogo      795:   private static StringBuffer writeDatainDestTable(FM2SQL.ProgressDialog dialog, StringBuffer command, int j, PreparedStatement pstm, int rowCount, String delimiter) throws Exception, SQLException
1.27      rogo      796:   {
                    797:     Vector row;
1.34      rogo      798:     while ((row = bean.getNextRow()) != null)
                    799:     {
                    800:       j++;
                    801:       // row = (Vector) result[0].get(j);
                    802:       /*   command = new StringBuffer();
                    803:       
                    804:            command.append("INSERT  INTO ");
                    805:            command.append(beanDest.getQC());
                    806:            command.append(convertText((String) names.get(tbIndex)));
                    807:            command.append(beanDest.getQC());
                    808:            command.append(" values ( ");
                    809:         */
                    810:       //print rows
                    811:       Object obj = null;
                    812:       /* for(int k=0;k<row.size()-1;++k)
                    813:        {
                    814:           obj = row.get(k);
                    815:           //System.out.println("row "+obj+" "+k);
                    816:          if(obj!=null&&!(obj instanceof ArrayList))
                    817:          command.append("'"+convertUml(obj.toString())+"',"); 
                    818:          else if(obj!=null&&   obj instanceof ArrayList)
                    819:          command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"',"); 
                    820:          else command.append("NULL,");
                    821:        }
                    822:        obj = row.get(row.size() - 1);
                    823:        if (obj != null && !(obj instanceof ArrayList))
                    824:        command.append("'"+convertUml(obj.toString())+"')"); 
                    825:         else
                    826:         if(obj!=null&&   obj instanceof ArrayList)
                    827:          command.append("'"+convertUml(((ArrayList)obj).get(0).toString())+"')");         //command.append(obj.toString()+")");
                    828:          else command.append("NULL)");
                    829:         */
                    830:       //command.append("'"+row.get(row.size()-1)+"')"); 
                    831:       //command.append(" )");
                    832:       //  for(int k=0;k<row.size();++k)
                    833: 
                    834:       // System.out.println();
                    835:       //   System.out.println(command+" "+j+" "+row.size()+" "+  ((Vector)result2[0].get(j)).size());
                    836:       // System.out.println(command);
                    837:       for (int k = 0; k < row.size(); ++k)
                    838:       {
                    839:         obj = row.get(k);
1.55      rogo      840: 
                    841:         if (obj instanceof ArrayList)
                    842:           obj = formatFileMakerArray((List) obj, delimiter);
                    843: 
1.34      rogo      844:         String str = (obj == null) ? "NULL" : obj.toString();
1.55      rogo      845:         if (obj instanceof Double)
                    846:         {
                    847:           pstm.setDouble(k + 1, ((Double) obj).doubleValue());
                    848:         } else if (!str.equals("NULL"))
1.34      rogo      849:           pstm.setString(k + 1, str);
                    850:         else
                    851:           pstm.setNull(k + 1, Types.NULL);
                    852:       }
                    853:       pstm.execute();
                    854:       //stm.executeUpdate(command.toString());
                    855:       if (dialog != null)
                    856:         dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
                    857:       // System.out.println( (int)(((double)(j+1)/(double)result[0].size())*100.0)+" "+result[0].size()+" "+j);
                    858:       command = null;
                    859:     } // to while loop    
1.27      rogo      860:     return command;
1.1       rogo      861:   }
                    862: 
1.38      rogo      863:   /**
                    864:    *  removes special characters from the input string as well as .fp5 
                    865:    * @param newName String to change
                    866:    * @return
                    867:    */
1.34      rogo      868:   public static String convertText(String newName)
1.1       rogo      869:   {
                    870:     StringBuffer alterMe = new StringBuffer(newName.trim().toLowerCase());
                    871:     int length = alterMe.length();
                    872:     int j = 0;
1.34      rogo      873:     int index = alterMe.indexOf(".fp5");
                    874:     if (index >= 0)
                    875:     {
                    876:       alterMe.delete(index, index + 4);
                    877:       length = length - 4;
                    878:     }
                    879: 
1.1       rogo      880:     while (j < length)
1.34      rogo      881:     {
1.1       rogo      882:       if (alterMe.charAt(j) == ' ')
                    883:       {
                    884:         alterMe.setCharAt(j, '_');
1.34      rogo      885:         //    if(j<length-1) j=j+1;
                    886:       } else if (alterMe.charAt(j) == '_')
                    887:       {
                    888: 
                    889:         if (alterMe.charAt(j + 1) == '_')
                    890:           alterMe.deleteCharAt(j);
                    891:         length = length - 1;
                    892:         //  if(j<length-1) j=j+1;
                    893:       } else if (alterMe.charAt(j) == 'ä')
                    894:       {
                    895:         alterMe.setCharAt(j, 'a');
                    896:         alterMe.insert(j + 1, "e");
                    897:         length = length + 1;
                    898:         if (j < length - 1)
                    899:           j = j + 1;
                    900:       } else if (alterMe.charAt(j) == 'ö')
                    901:       {
                    902:         alterMe.setCharAt(j, 'o');
                    903:         alterMe.insert(j + 1, "e");
                    904:         length = length + 1;
                    905:         if (j < length - 1)
                    906:           j = j + 1;
                    907:       } else if (alterMe.charAt(j) == 'ü')
                    908:       {
                    909:         alterMe.setCharAt(j, 'u');
                    910:         alterMe.insert(j + 1, "e");
                    911:         length = length + 1;
                    912:         if (j < length - 1)
                    913:           j = j + 1;
                    914:       } else if (alterMe.charAt(j) == 'ß')
                    915:       {
                    916:         alterMe.setCharAt(j, 's');
                    917:         alterMe.insert(j + 1, "s");
                    918:         length = length + 1;
                    919:         if (j < length - 1)
                    920:           j = j + 1;
                    921:       } else if (alterMe.charAt(j) == ':')
1.1       rogo      922:       {
1.34      rogo      923:         if (j < length - 1)
                    924:         {
                    925:           if (alterMe.charAt(j + 1) == ':')
                    926:           {
                    927:             alterMe.setCharAt(j, '_');
                    928:             alterMe.delete(j + 1, j + 2);
                    929:             length = length - 1;
                    930: 
                    931:           }
1.1       rogo      932: 
1.34      rogo      933:           if (j < length - 1)
                    934:             j = j + 1;
                    935:         }
                    936:       } else if (alterMe.charAt(j) == '-')
                    937:       {
                    938:         alterMe.setCharAt(j, '_');
1.16      rogo      939: 
1.34      rogo      940:       } else if (alterMe.charAt(j) == '?')
1.3       rogo      941:       {
1.34      rogo      942:         // changed ? to _ because of update statement
                    943:         alterMe.setCharAt(j, '_');
                    944:         // length = length + 1;
                    945:         // j=j+1;
                    946:         System.out.println(alterMe);
                    947:       } else if (alterMe.charAt(j) == '.')
                    948:       {
                    949:         if (j == length - 1)
                    950:         {
                    951:           alterMe.delete(j, j);
                    952:           length--;
                    953:         } else
                    954:           alterMe.setCharAt(j, '_');
1.3       rogo      955:       }
1.34      rogo      956: 
                    957:       ++j;
1.1       rogo      958:     }
                    959:     return alterMe.toString();
                    960:   }
1.38      rogo      961:   /**
                    962:    * Converts > and < in an entity (&gt; or &lt;)
                    963:    * @param newName
                    964:    * @return
                    965:    */
1.4       rogo      966:   public static String convertToEntities(String newName)
                    967:   {
                    968:     StringBuffer alterMe = new StringBuffer(newName.trim());
                    969:     int length = alterMe.length();
                    970:     int j = 0;
                    971: 
                    972:     while (j < length)
                    973:     {
                    974: 
                    975:       if (alterMe.charAt(j) == '>')
                    976:       {
                    977:         alterMe.setCharAt(j, '&');
                    978:         alterMe.insert(j + 1, "gt;");
                    979:         length = length + 2;
                    980:         if (j < length - 1)
                    981:           j = j + 1;
                    982: 
                    983:       } else if (alterMe.charAt(j) == '<')
                    984:       {
                    985:         alterMe.setCharAt(j, '&');
                    986:         alterMe.insert(j + 1, "lt;");
                    987:         length = length + 2;
                    988:         if (j < length - 1)
                    989:           j = j + 1;
                    990: 
                    991:       }
                    992:       ++j;
                    993:     }
                    994:     return alterMe.toString();
                    995:   }
1.38      rogo      996:   /**
                    997:    * Masks the single quote character '-->\'
                    998:    * @param newName
                    999:    * @return
                   1000:    */
1.1       rogo     1001:   public static String convertUml(String newName)
1.34      rogo     1002:   {
                   1003:     StringBuffer alterMe = new StringBuffer(newName.trim());
                   1004:     int length = alterMe.length();
                   1005:     int j = 0;
                   1006: 
                   1007:     while (j < length)
                   1008:     {
                   1009: 
                   1010:       if (alterMe.charAt(j) == '\'')
                   1011:       {
                   1012:         alterMe.setCharAt(j, '\\');
                   1013:         alterMe.insert(j + 1, "'");
                   1014:         length = length + 1;
                   1015:         if (j < length - 1)
                   1016:           j = j + 1;
                   1017:       }
                   1018:       /*   else
                   1019:          if (alterMe.charAt(j) == '"')
                   1020:          {
                   1021:         alterMe.setCharAt(j, '\\');
                   1022:         alterMe.insert(j + 1, "\"");
                   1023:         length = length + 1;
                   1024:         if(j<length-1) j=j+1;
                   1025:          }
                   1026:         else
                   1027:         if (alterMe.charAt(j) == '>')
                   1028:          {
                   1029:         alterMe.setCharAt(j, '\\');
                   1030:         alterMe.insert(j + 1, ">");
                   1031:         length = length + 1;
                   1032:         if(j<length-1) j=j+1;
                   1033:          }
                   1034:         else
                   1035:         if (alterMe.charAt(j) == '<')
                   1036:          {
                   1037:         alterMe.setCharAt(j, '\\');
                   1038:         alterMe.insert(j + 1, "<");
                   1039:         length = length + 1;
                   1040:         if(j<length-1) j=j+1;
                   1041:          }
                   1042:        else
                   1043:        if (alterMe.charAt(j) == '?')
                   1044:          {
                   1045:         alterMe.setCharAt(j, '\\');
                   1046:         alterMe.insert(j + 1, "?");
                   1047:         length = length + 1;
                   1048:         if(j<length-1) j=j+1;
                   1049:          }
                   1050:        else
                   1051:        if (alterMe.charAt(j) == '&')
                   1052:          {
                   1053:         alterMe.setCharAt(j, '\\');
                   1054:         alterMe.insert(j + 1, "&");
                   1055:         length = length + 1;
                   1056:         if(j<length-1) j=j+1;
                   1057:          }
                   1058:        else
                   1059:        if (alterMe.charAt(j) == '=')
                   1060:          {
                   1061:         alterMe.setCharAt(j, '\\');
                   1062:         alterMe.insert(j + 1, "=");
                   1063:         length = length + 1;
                   1064:         if(j<length-1) j=j+1;
                   1065:          }
                   1066:        else
                   1067:        if (alterMe.charAt(j) == ',')
                   1068:          {
                   1069:         alterMe.setCharAt(j, '\\');
                   1070:         alterMe.insert(j + 1, ",");
                   1071:         length = length + 1;
                   1072:         if(j<length-1) j=j+1;
                   1073:          }
                   1074:        else
                   1075:        if (alterMe.charAt(j) == '.')
                   1076:          {
                   1077:         alterMe.setCharAt(j, '\\');
                   1078:         alterMe.insert(j + 1, ".");
                   1079:         length = length + 1;
                   1080:         if(j<length-1) j=j+1;
                   1081:          }
                   1082:        else
                   1083:        if (alterMe.charAt(j) == '[')
                   1084:          {
                   1085:         alterMe.setCharAt(j, '\\');
                   1086:         alterMe.insert(j + 1, ".");
                   1087:         length = length + 1;
                   1088:         if(j<length-1) j=j+1;
                   1089:          }
                   1090:       else
                   1091:        if (alterMe.charAt(j) == ']')
                   1092:          {
                   1093:         alterMe.setCharAt(j, '\\');
                   1094:         alterMe.insert(j + 1, ".");
                   1095:         length = length + 1;
                   1096:         if(j<length-1) j=j+1;
                   1097:          }
                   1098:       else
                   1099:        if (alterMe.charAt(j) == '%')
                   1100:          {
                   1101:         alterMe.setCharAt(j, '\\');
                   1102:         alterMe.insert(j + 1, "%");
                   1103:         length = length + 1;
                   1104:         if(j<length-1) j=j+1;
                   1105:          }*/
                   1106:       ++j;
                   1107:     }
                   1108:     return alterMe.toString();
                   1109:   }
1.55      rogo     1110:   /**
                   1111:    * parses the input xml file for batch conversion
                   1112:    * called from readXMLFile
                   1113:    * * @param sb
                   1114:    */
1.34      rogo     1115:   public static void parseXMLConfig(StringBuffer sb)
                   1116:   {
                   1117:     boolean finished = false;
                   1118:     // parse string and build document tree
                   1119:     Xparse parser = new Xparse();
                   1120:     parser.changeEntities = true;
                   1121:     Node root = parser.parse(sb.toString());
                   1122:     // printContents(root);
                   1123:     Vector databases = new Vector();
                   1124:     Vector tables = new Vector();
                   1125:     Vector layouts = new Vector();
                   1126:     Vector selects = new Vector();
                   1127:     Vector creates = new Vector();
                   1128:     Vector ids = new Vector();
1.42      rogo     1129:     String delimiter = "|";
1.34      rogo     1130:     int mode = -1;
                   1131: 
                   1132:     try
1.1       rogo     1133:     {
1.34      rogo     1134:       Node tempNode = root.find("convert/source", new int[] { 1, 1 });
                   1135:       if (tempNode == null)
                   1136:         throw new Error("parse error source tag missing");
                   1137:       System.out.println(tempNode.name);
                   1138:       int length = countNodes(tempNode);
                   1139:       for (int i = 1; i <= length; i++)
1.1       rogo     1140:       {
1.34      rogo     1141: 
1.1       rogo     1142:         DBBean database = new DBBean();
1.34      rogo     1143:         tables = new Vector();
                   1144:         layouts = new Vector();
                   1145:         selects = new Vector();
                   1146:         creates = new Vector();
                   1147:         ids = new Vector();
1.1       rogo     1148:         // parse dataBase
1.34      rogo     1149:         Node node = root.find("convert/source/database/url", new int[] { 1, 1, i, 1 });
                   1150:         Node node1 = root.find("convert/source/database/user", new int[] { 1, 1, i, 1, 1 });
                   1151:         Node node2 = root.find("convert/source/database/password", new int[] { 1, 1, i, 1, 1 });
                   1152:         Node node3 = root.find("convert/source/database", new int[] { 1, 1, i });
                   1153:         Node nodeMode = root.find("convert/source/database/mode", new int[] { 1, 1, i, 1, 1 });
1.55      rogo     1154:         Node delimiterNode = root.find("convert/source/database/delimiter", new int[] { 1, 1, i, 1, 1 });
1.59      rogo     1155:         Node useNormanToUnicodeMapper = root.find("convert/source/database/usenormantounicodemapper", new int[] { 1, 1, i, 1, 1 });
1.65    ! rogo     1156: 
1.34      rogo     1157:         if (node3 == null)
                   1158:           throw new Error("parse error database tag missing");
                   1159:         if (node == null)
                   1160:           throw new Error("parse error url tag missing");
                   1161:         if (node1 == null)
                   1162:           throw new Error("parse error user tag missing");
                   1163:         if (node2 == null)
                   1164:           throw new Error("parse error password tag missing");
1.55      rogo     1165:         if (delimiterNode != null)
                   1166:           delimiter = delimiterNode.getCharacters();
1.65    ! rogo     1167:         if (useNormanToUnicodeMapper != null)
1.59      rogo     1168:         {
                   1169:           database.setUseNormanToUnicodeMapper(Boolean.valueOf(useNormanToUnicodeMapper.getCharacters()).booleanValue());
1.65    ! rogo     1170:           System.out.println("useMapper " + Boolean.valueOf(useNormanToUnicodeMapper.getCharacters().trim()).booleanValue());
        !          1171:         }
        !          1172: 
1.1       rogo     1173:         String url = node.getCharacters();
                   1174:         String user = node1.getCharacters();
                   1175:         String password = node2.getCharacters();
                   1176:         database.setURL(url.trim());
                   1177:         database.setUserAndPasswd(user.trim(), password.trim());
1.34      rogo     1178:         System.out.println(node.name + " " + node.getCharacters());
                   1179:         System.out.println(node1.name + " " + node1.getCharacters());
                   1180:         System.out.println(node2.name + " " + node2.getCharacters());
                   1181:         String modeString = "";
                   1182:         if (nodeMode == null)
                   1183:           modeString = "convert";
                   1184:         else
                   1185:           modeString = nodeMode.getCharacters();
                   1186:         if (modeString.equals("convert"))
                   1187:           mode = DataBase.CONVERT_MODE;
                   1188:         else if (modeString.equals("append"))
                   1189:           mode = DataBase.APPEND_MODE;
                   1190:         else if (modeString.equals("update"))
                   1191:           mode = DataBase.UPDATE_MODE;
1.48      rogo     1192:         else if (modeString.equals("delete"))
                   1193:           mode = DataBase.DELETE_MODE;
1.62      rogo     1194:         else if (modeString.equals("synchronize"))
1.65    ! rogo     1195:           mode = DataBase.SYNCHRONIZE_MODE;
1.48      rogo     1196: 
1.34      rogo     1197:         //   if(node3!=null)
                   1198:         // System.out.println(node3.name);
                   1199: 
                   1200:         int length2 = countNodes(node3);
                   1201: 
                   1202:         System.out.println("number of tables " + length2);
                   1203: 
                   1204:         for (int j = 1; j <= length2; ++j)
                   1205:         {
                   1206:           Node node4 = root.find("convert/source/database/table", new int[] { 1, 1, i, j });
                   1207:           Node node5 = root.find("convert/source/database/table/select", new int[] { 1, 1, i, j, 1 });
                   1208:           Node node6 = root.find("convert/source/database/table/create", new int[] { 1, 1, i, j, 1 });
                   1209:           if (node4 != null)
                   1210:             System.out.println(node4.name + " " + node4.attributes.get("layout").equals(""));
                   1211:           if (node5 != null)
                   1212:             System.out.println(node5.name + " " + node5.getCharacters());
                   1213:           if (node6 != null)
                   1214:             System.out.println(node6.name + " " + node6.getCharacters());
                   1215:           if (node4 == null)
                   1216:             throw new Error("parse error table tag missing");
                   1217:           // if(node5==null) throw new Error("parse error select tag missing");
                   1218:           // if(node6==null) throw new Error("parse error create tag missing");
                   1219:           String name = (String) node4.attributes.get("name");
                   1220:           String layout = (String) node4.attributes.get("layout");
                   1221:           String id = (String) node4.attributes.get("id");
                   1222:           System.out.println("id was " + id);
                   1223:           if (name == null)
                   1224:             throw new Error("parse error required table tag attribute name missing");
                   1225:           if (layout == null)
                   1226:             layout = "";
                   1227:           if (id == null)
                   1228:             id = "";
                   1229:           if (name.equals(""))
                   1230:             throw new Error("parse error table tag attribute must not be empty");
                   1231:           tables.add(name);
                   1232:           layouts.add(layout);
                   1233:           ids.add(id);
                   1234:           String query = (node5 == null) ? "" : node5.getCharacters();
                   1235:           if (query.equals(""))
                   1236:             System.err.println("Warning empty select tag or  select tag missing !!");
                   1237:           query = (query.equals("")) ? "select * from " + database.getQC() + name + database.getQC() : query;
                   1238:           selects.add(query);
                   1239:           if (node6 != null)
                   1240:             creates.add(node6.getCharacters().trim());
                   1241:           else
                   1242:             creates.add("");
                   1243: 
                   1244:         }
1.42      rogo     1245:         DataBase dataBase = new DataBase(database, tables, layouts, selects, creates, ids, mode);
                   1246:         dataBase.delimiter = delimiter;
                   1247:         databases.add(dataBase);
1.34      rogo     1248:       }
                   1249:       DBBean database = new DBBean();
                   1250:       // parse dataBase
                   1251:       Node node = root.find("convert/destination/database/url", new int[] { 1, 1, 1, 1 });
                   1252:       Node node1 = root.find("convert/destination/database/user", new int[] { 1, 1, 1, 1, 1 });
                   1253:       Node node2 = root.find("convert/destination/database/password", new int[] { 1, 1, 1, 1, 1 });
                   1254:       String url = node.getCharacters();
                   1255:       String user = node1.getCharacters();
                   1256:       String password = node2.getCharacters();
                   1257:       System.out.println(url);
                   1258:       database.setURL(url.trim());
                   1259:       database.setUserAndPasswd(user.trim(), password.trim());
                   1260:       //databases.add(database);
                   1261:       for (Iterator iter = databases.iterator(); iter.hasNext();)
1.1       rogo     1262:       {
                   1263:         DataBase db = (DataBase) iter.next();
1.62      rogo     1264:         if (mode == DataBase.CONVERT_MODE || mode == DataBase.APPEND_MODE)
1.55      rogo     1265:           convertBatch(db.bean, database, db.tables, db.layouts, db.selects, db.creates, db.ids, mode, db.delimiter);
1.65    ! rogo     1266:         else if (mode == DataBase.UPDATE_MODE)
        !          1267:           update(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode);
        !          1268:         else if (mode == DataBase.SYNCHRONIZE_MODE)
        !          1269:         {
        !          1270:           user = bean.user;
        !          1271:           passwd = bean.passwd;
        !          1272:           userDest = database.user;
        !          1273:           passwdDest = database.passwd;
        !          1274: 
1.62      rogo     1275:           synchronize(db.bean.url, database.url, db.tables, db.layouts, db.selects, db.creates, db.ids, mode);
1.65    ! rogo     1276:         }
1.1       rogo     1277:       }
1.34      rogo     1278:       // printContents(node3);
                   1279:       //   FM2SQL.fmInstance=new FM2SQL();
                   1280:     } catch (Exception e)
                   1281:     {
1.55      rogo     1282: 
1.34      rogo     1283:       e.printStackTrace();
1.65    ! rogo     1284: 
        !          1285:     } finally
        !          1286:     {
        !          1287:       bean.closeAllConnections();
        !          1288:       beanDest.closeAllConnections();
1.34      rogo     1289:     }
                   1290:   }
                   1291:   public static Vector getXMLConfig(String xmlFile)
                   1292:   {
                   1293:     StringBuffer sb = null;
                   1294:     try
                   1295:     {
                   1296:       // read XML Metadata from a file
                   1297:       FileInputStream fi = new FileInputStream(xmlFile);
                   1298:       InputStreamReader isr = new InputStreamReader(fi, "UTF-8");
                   1299:       BufferedReader buffr = new BufferedReader(isr);
                   1300:       sb = new StringBuffer();
                   1301:       int c = 0;
                   1302:       while ((c = buffr.read()) != -1)
                   1303:       {
                   1304:         char ch = (char) c;
                   1305:         sb.append(ch);
                   1306:         // System.out.print((char)c);
1.1       rogo     1307:       }
                   1308: 
1.34      rogo     1309:     } catch (Exception e)
                   1310:     {
                   1311:       e.printStackTrace();
                   1312:     }
                   1313: 
                   1314:     boolean finished = false;
                   1315:     // parse string and build document tree
                   1316:     Xparse parser = new Xparse();
                   1317:     parser.changeEntities = true;
                   1318:     Node root = parser.parse(sb.toString());
                   1319:     // printContents(root);
                   1320:     Vector databases = new Vector();
                   1321:     Vector tables = new Vector();
                   1322:     Vector layouts = new Vector();
                   1323:     Vector selects = new Vector();
                   1324:     Vector creates = new Vector();
                   1325:     Vector ids = new Vector();
1.55      rogo     1326:     String delimiter = "|";
1.34      rogo     1327:     int mode = -1;
                   1328:     try
1.1       rogo     1329:     {
1.34      rogo     1330:       Node tempNode = root.find("convert/source", new int[] { 1, 1 });
                   1331:       if (tempNode == null)
                   1332:         throw new Error("parse error source tag missing");
                   1333:       System.out.println(tempNode.name);
                   1334:       int length = countNodes(tempNode);
                   1335:       for (int i = 1; i <= length; i++)
1.1       rogo     1336:       {
1.34      rogo     1337: 
                   1338:         DBBean database = new DBBean();
                   1339:         tables = new Vector();
                   1340:         layouts = new Vector();
                   1341:         selects = new Vector();
                   1342:         creates = new Vector();
                   1343:         ids = new Vector();
                   1344:         // parse dataBase
                   1345:         Node node = root.find("convert/source/database/url", new int[] { 1, 1, i, 1 });
                   1346:         Node node1 = root.find("convert/source/database/user", new int[] { 1, 1, i, 1, 1 });
                   1347:         Node node2 = root.find("convert/source/database/password", new int[] { 1, 1, i, 1, 1 });
                   1348:         Node node3 = root.find("convert/source/database", new int[] { 1, 1, i });
                   1349:         Node nodeMode = root.find("convert/source/database/mode", new int[] { 1, 1, i, 1, 1 });
1.55      rogo     1350:         Node delimiterNode = root.find("convert/source/database/delimiter", new int[] { 1, 1, i, 1, 1 });
1.59      rogo     1351:         Node useNormanToUnicodeMapper = root.find("convert/source/database/usenormantounicodemapper", new int[] { 1, 1, i, 1, 1 });
1.55      rogo     1352: 
1.44      rogo     1353:         if (delimiterNode != null)
                   1354:           delimiter = delimiterNode.getCharacters();
1.65    ! rogo     1355:         if (useNormanToUnicodeMapper != null)
1.59      rogo     1356:         {
                   1357:           database.setUseNormanToUnicodeMapper(Boolean.valueOf(useNormanToUnicodeMapper.getCharacters()).booleanValue());
1.65    ! rogo     1358:           System.out.println("useMapper " + Boolean.valueOf(useNormanToUnicodeMapper.getCharacters().trim()).booleanValue());
        !          1359:         }
1.59      rogo     1360: 
1.34      rogo     1361:         if (node3 == null)
                   1362:           throw new Error("parse error database tag missing");
                   1363:         if (node == null)
                   1364:           throw new Error("parse error url tag missing");
                   1365:         if (node1 == null)
                   1366:           throw new Error("parse error user tag missing");
                   1367:         if (node2 == null)
                   1368:           throw new Error("parse error password tag missing");
                   1369:         String url = node.getCharacters();
                   1370:         String user = node1.getCharacters();
                   1371:         String password = node2.getCharacters();
                   1372:         database.setURL(url.trim());
                   1373:         database.setUserAndPasswd(user.trim(), password.trim());
                   1374:         System.out.println(node.name + " " + node.getCharacters());
                   1375:         System.out.println(node1.name + " " + node1.getCharacters());
                   1376:         System.out.println(node2.name + " " + node2.getCharacters());
                   1377:         String modeString = "";
                   1378:         if (nodeMode == null)
                   1379:           modeString = "convert";
                   1380:         else
                   1381:           modeString = nodeMode.getCharacters();
                   1382:         if (modeString.equals("convert"))
                   1383:           mode = DataBase.CONVERT_MODE;
                   1384:         else if (modeString.equals("append"))
                   1385:           mode = DataBase.APPEND_MODE;
                   1386:         else if (modeString.equals("update"))
                   1387:           mode = DataBase.UPDATE_MODE;
1.48      rogo     1388:         else if (modeString.equals("delete"))
                   1389:           mode = DataBase.DELETE_MODE;
                   1390: 
1.34      rogo     1391:         //   if(node3!=null)
                   1392:         // System.out.println(node3.name);
                   1393: 
                   1394:         int length2 = countNodes(node3);
                   1395: 
                   1396:         System.out.println("number of tables " + length2);
                   1397: 
                   1398:         for (int j = 1; j <= length2; ++j)
                   1399:         {
                   1400:           Node node4 = root.find("convert/source/database/table", new int[] { 1, 1, i, j });
                   1401:           Node node5 = root.find("convert/source/database/table/select", new int[] { 1, 1, i, j, 1 });
                   1402:           Node node6 = root.find("convert/source/database/table/create", new int[] { 1, 1, i, j, 1 });
                   1403:           if (node4 != null)
                   1404:             System.out.println(node4.name + " " + node4.attributes.get("layout").equals(""));
                   1405:           if (node5 != null)
                   1406:             System.out.println(node5.name + " " + node5.getCharacters());
                   1407:           if (node6 != null)
                   1408:             System.out.println(node6.name + " " + node6.getCharacters());
                   1409:           if (node4 == null)
                   1410:             throw new Error("parse error table tag missing");
                   1411:           // if(node5==null) throw new Error("parse error select tag missing");
                   1412:           // if(node6==null) throw new Error("parse error create tag missing");
                   1413:           String name = (String) node4.attributes.get("name");
                   1414:           String layout = (String) node4.attributes.get("layout");
                   1415:           String id = (String) node4.attributes.get("id");
                   1416:           System.out.println("id was " + id);
                   1417: 
                   1418:           if (name == null)
                   1419:             throw new Error("parse error required table tag attribute name missing");
                   1420:           if (layout == null)
                   1421:             layout = "";
                   1422:           if (id == null)
                   1423:             id = "";
                   1424:           if (name.equals(""))
                   1425:             throw new Error("parse error table tag attribute must not be empty");
                   1426:           tables.add(name);
                   1427:           layouts.add(layout);
                   1428:           ids.add(id);
                   1429:           String query = (node5 == null) ? "" : node5.getCharacters();
                   1430:           if (query.equals(""))
                   1431:             System.err.println("Warning empty select tag or  select tag missing !!");
                   1432:           query = (query.equals("")) ? "select * from " + database.getQC() + name + database.getQC() : query;
                   1433:           selects.add(query);
                   1434:           if (node6 != null)
                   1435:             creates.add(node6.getCharacters().trim());
                   1436:           else
                   1437:             creates.add("");
                   1438: 
                   1439:         }
1.55      rogo     1440:         DataBase dataBase = new DataBase(database, tables, layouts, selects, creates, ids, mode);
                   1441:         dataBase.delimiter = delimiter;
1.43      rogo     1442:         databases.add(dataBase);
1.1       rogo     1443:       }
1.34      rogo     1444:       DBBean database = new DBBean();
                   1445:       // parse dataBase
                   1446:       Node node = root.find("convert/destination/database/url", new int[] { 1, 1, 1, 1 });
                   1447:       Node node1 = root.find("convert/destination/database/user", new int[] { 1, 1, 1, 1, 1 });
                   1448:       Node node2 = root.find("convert/destination/database/password", new int[] { 1, 1, 1, 1, 1 });
                   1449:       String url = node.getCharacters();
                   1450:       String user = node1.getCharacters();
                   1451:       String password = node2.getCharacters();
                   1452:       System.out.println(url);
                   1453:       database.setURL(url.trim());
                   1454:       database.setUserAndPasswd(user.trim(), password.trim());
                   1455:       databases.add(new DataBase(database, null, null, null, null, null, 0));
                   1456:       //databases.add(database);
                   1457:       /*    for (Iterator iter = databases.iterator(); iter.hasNext();)
                   1458:          {
                   1459:            DataBase db = (DataBase) iter.next();
                   1460:            convertBatch(db.bean,database,db.tables,db.layouts,db.selects,db.creates);
                   1461:           
                   1462:          }*/
                   1463:       // printContents(node3);
                   1464:       //   FM2SQL.fmInstance=new FM2SQL();
                   1465:     } catch (Exception e)
                   1466:     {
                   1467:       // TODO Auto-generated catch block
                   1468:       e.printStackTrace();
1.1       rogo     1469:     }
1.34      rogo     1470:     return databases;
                   1471:   }
                   1472: 
                   1473:   private static int countNodes(Node tempNode)
                   1474:   {
                   1475:     int length = 0;
                   1476:     for (int i = 0; i < tempNode.contents.v.size(); ++i)
1.1       rogo     1477:     {
1.34      rogo     1478:       Node node = (Node) tempNode.contents.v.elementAt(i);
                   1479:       if (node.type.equals("element"))
1.1       rogo     1480:       {
1.34      rogo     1481:         if (node.name.equals("database"))
                   1482:           length++;
                   1483:         if (node.name.equals("table"))
                   1484:           length++;
1.1       rogo     1485:       }
1.34      rogo     1486: 
                   1487:       // System.out.println(((Node)tempNode.contents.v.elementAt(i)).attributes+" "+i);
1.1       rogo     1488:     }
1.34      rogo     1489:     return length;
                   1490:   }
                   1491:   private static void printContents(Node root)
                   1492:   {
                   1493: 
                   1494:     Vector contents = (root.index == null) ? root.contents.v : root.index.v;
                   1495:     for (int i = 0; i < contents.size(); ++i)
1.1       rogo     1496:     {
1.34      rogo     1497:       Node n = (Node) contents.elementAt(i);
                   1498:       if (n.type.equals("element"))
                   1499:       {
                   1500:         System.out.println("tag " + n.name);
                   1501:         System.out.println(n.getCharacters());
                   1502:         //contents=n.contents.v i=0;
                   1503:       }
                   1504:       // System.out.println(n.type);
1.1       rogo     1505:     }
1.34      rogo     1506:   }
1.38      rogo     1507:   /**
                   1508:    * reads the specified xml file
                   1509:    * @param xmlFile
                   1510:    */
1.34      rogo     1511:   public static void readXMLFile(String xmlFile)
1.1       rogo     1512:   {
1.34      rogo     1513:     try
                   1514:     {
1.60      rogo     1515:       InputStream stream = null;
1.65    ! rogo     1516: 
        !          1517:       if (xmlFile.indexOf("file://") >= 0 || xmlFile.indexOf("http://") >= 0)
1.60      rogo     1518:       {
1.65    ! rogo     1519:         URL url = new URL(xmlFile);
1.60      rogo     1520:         stream = url.openStream();
1.65    ! rogo     1521:       } else
        !          1522:         // read XML Metadata from a file
        !          1523:         stream = new FileInputStream(xmlFile);
1.60      rogo     1524:       InputStreamReader isr = new InputStreamReader(stream, "UTF-8");
1.34      rogo     1525:       BufferedReader buffr = new BufferedReader(isr);
                   1526:       StringBuffer sb = new StringBuffer();
                   1527:       int c = 0;
                   1528:       while ((c = buffr.read()) != -1)
                   1529:       {
                   1530:         char ch = (char) c;
                   1531:         sb.append(ch);
                   1532:         // System.out.print((char)c);
                   1533:       }
                   1534:       parseXMLConfig(sb);
                   1535:     } catch (Exception e)
                   1536:     {
                   1537:       e.printStackTrace();
                   1538:     }
1.1       rogo     1539:   }
1.64      rogo     1540:   /**
                   1541:      * Helper class for Conversion etc
                   1542:      * Holds the some data
                   1543:      * @author rogo
                   1544:      *
                   1545:      */
1.65    ! rogo     1546: 
        !          1547:   public static class ConversionProperties
1.64      rogo     1548:   {
                   1549:     String destTableName;
1.65    ! rogo     1550:     String[] fieldNames;
        !          1551:     public ConversionProperties()
1.64      rogo     1552:     {
                   1553:     }
1.65    ! rogo     1554:     public ConversionProperties(String destTableName, String[] fieldNames)
1.64      rogo     1555:     {
                   1556:       this.destTableName = destTableName;
1.65    ! rogo     1557:       this.fieldNames = fieldNames;
        !          1558: 
1.64      rogo     1559:     }
1.65    ! rogo     1560: 
1.64      rogo     1561:   }
1.38      rogo     1562:   /**
                   1563:    * Helper class for XML-File parsing
                   1564:    * Holds the parsed data
                   1565:    * @author rogo
                   1566:    *
                   1567:    */
1.34      rogo     1568:   public static class DataBase
                   1569:   {
                   1570:     DBBean bean;
                   1571:     Vector creates;
                   1572:     Vector selects;
                   1573:     Vector layouts;
                   1574:     Vector tables;
                   1575:     Vector ids;
1.43      rogo     1576:     String delimiter = "//";
1.59      rogo     1577:     boolean useNormanToUnicodeMapper = false;
1.65    ! rogo     1578: 
1.34      rogo     1579:     final static int CONVERT_MODE = 1;
                   1580:     final static int APPEND_MODE = 2;
                   1581:     final static int UPDATE_MODE = 3;
1.40      rogo     1582:     final static int DELETE_MODE = 4;
1.62      rogo     1583:     final static int SYNCHRONIZE_MODE = 5;
1.65    ! rogo     1584: 
1.34      rogo     1585:     int mode = -1;
                   1586: 
                   1587:     public DataBase(DBBean bean, Vector tables, Vector layouts, Vector selects, Vector creates, Vector ids, int mode)
                   1588:     {
                   1589:       this.bean = bean;
                   1590:       this.tables = tables;
                   1591:       this.layouts = layouts;
                   1592:       this.selects = selects;
                   1593:       this.creates = creates;
                   1594:       this.ids = ids;
                   1595:       this.mode = mode;
                   1596:       this.bean.setIDVector(ids);
                   1597:     }
1.38      rogo     1598:     /**
1.42      rogo     1599:      * writes the data contained in this object to the buffered writer
1.38      rogo     1600:      * * @param buffr
                   1601:      * @throws Exception
                   1602:      */
1.34      rogo     1603:     public void exportToXML(BufferedWriter buffr) throws Exception
                   1604:     {
                   1605:       // ids=bean.getIDVector();
                   1606:       buffr.write("    <database>\n");
                   1607:       buffr.write("      <url>" + bean.url + "</url>\n");
                   1608:       buffr.write("      <user>" + bean.user + "</user>\n");
                   1609:       buffr.write("      <password>" + bean.passwd + "</password>\n");
1.55      rogo     1610:       buffr.write("      <delimiter>" + delimiter + "</delimiter>\n");
1.34      rogo     1611:       String modeString = "";
                   1612:       if (mode == CONVERT_MODE)
                   1613:         modeString = "convert";
                   1614:       else if (mode == APPEND_MODE)
1.5       rogo     1615:         modeString = "append";
1.34      rogo     1616:       else if (mode == UPDATE_MODE)
                   1617:         modeString = "update";
1.48      rogo     1618:       else if (mode == DELETE_MODE)
1.55      rogo     1619:         modeString = "delete";
1.34      rogo     1620: 
                   1621:       buffr.write("      <mode>" + modeString + "</mode>\n");
1.59      rogo     1622:       buffr.write("      <usenormantounicodemapper>" + useNormanToUnicodeMapper + "</usenormantounicodemapper>\n");
1.65    ! rogo     1623: 
1.34      rogo     1624:       int index = 0;
                   1625:       while (index < tables.size())
                   1626:       {
                   1627:         String table = (String) tables.get(index);
                   1628:         String layout = (String) layouts.get(index);
                   1629:         String select = (String) selects.get(index);
                   1630:         String create = (String) creates.get(index);
                   1631:         String id = (String) ids.get(index);
                   1632: 
                   1633:         buffr.write("      <table name = \"" + table + "\" layout = \"" + layout + "\" id = \"" + id + "\" >\n");
                   1634:         buffr.write("         <select>" + convertToEntities(select) + "</select>\n");
                   1635:         if (!create.equals(""))
                   1636:           buffr.write("         <create>" + create + "         </create>\n");
                   1637:         buffr.write("      </table>\n");
                   1638:         index++;
                   1639:       }
                   1640:       buffr.write("    </database>\n");
                   1641:     }
                   1642:     public String toString()
                   1643:     {
                   1644:       return bean.url + " " + tables;
                   1645:     }
1.1       rogo     1646: 
1.34      rogo     1647:   }
                   1648:   public static String convertToUTF8(Object command)
1.1       rogo     1649:   {
1.34      rogo     1650:     String str = null;
                   1651:     try
                   1652:     {
                   1653:       str = new String(command.toString().getBytes("UTF-8"));
                   1654:     } catch (UnsupportedEncodingException e)
                   1655:     {
                   1656:       // TODO Auto-generated catch block
                   1657:       e.printStackTrace();
                   1658:     }
                   1659:     return str;
1.1       rogo     1660:   }
                   1661:   public static void writeConfig(String file, DataBase source, DataBase destination) throws Exception
                   1662:   {
1.34      rogo     1663:     if (!file.toLowerCase().endsWith(".xml"))
                   1664:       file += ".xml";
1.1       rogo     1665:     File f = new File(file);
1.34      rogo     1666: 
                   1667:     FileOutputStream fout = new FileOutputStream(f);
                   1668:     OutputStreamWriter outsw = new OutputStreamWriter(fout, "UTF-8");
1.1       rogo     1669:     BufferedWriter buffw = new BufferedWriter(outsw);
                   1670:     buffw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                   1671:     buffw.newLine();
                   1672:     buffw.write("<convert>\n");
                   1673:     buffw.write("  <source>\n");
                   1674:     source.exportToXML(buffw);
                   1675:     buffw.write("  </source>\n");
                   1676:     buffw.write("\n  <destination>\n");
                   1677:     destination.exportToXML(buffw);
                   1678:     buffw.write("  </destination>\n");
                   1679:     buffw.write("</convert>\n");
                   1680:     buffw.close();
1.34      rogo     1681:   }
1.46      rogo     1682:   public static void delete(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception
                   1683:   {
                   1684:     FM2SQL.ProgressDialog dialog = null;
                   1685:     if (FM2SQL.fmInstance != null)
                   1686:     {
1.55      rogo     1687:       dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
1.46      rogo     1688:       dialog.setTitle("Conversion running ...");
                   1689:       dialog.title.setText("Getting table data ...");
                   1690:       dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2);
                   1691:       dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                   1692:       FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                   1693:       dialog.thread = Thread.currentThread();
                   1694:     }
                   1695:     // setting user and passwd 
                   1696:     bean.setUserAndPasswd(user, passwd);
                   1697:     // setting user and passwd 
                   1698:     beanDest.setUserAndPasswd(userDest, passwdDest);
                   1699:     if (dialog != null)
                   1700:       dialog.setSize(400, 250);
                   1701:     StringBuffer command = null;
                   1702:     String query = null;
                   1703:     try
                   1704:     {
                   1705:       //bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050");    
                   1706:       //bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo");
                   1707:       bean.setConnection(source);
                   1708:       if (names == null)
                   1709:         names = bean.getTableNames();
                   1710:       // Collections.sort(names);
                   1711:       int tbIndex = 1;
                   1712: 
                   1713:       // System.out.println("Start at "+names.indexOf("archimedes_facsimiles"));
                   1714:       for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
                   1715:       {
                   1716:         Vector[] result = null;
                   1717:         java.util.TreeSet myIds = new TreeSet();
                   1718:         java.util.TreeSet myIdsDest = new TreeSet();
                   1719:         int deltaID = 1;
                   1720:         String idField = "";
                   1721:         String destTableName = "";
                   1722: 
                   1723:         try
                   1724:         {
                   1725:           query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
                   1726:           String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
                   1727:           query = (selects != null) ? selects.get(tbIndex).toString() : query;
                   1728:           //if  vectors[1].get(i) != null)
                   1729:           if (layout != "")
                   1730:           {
                   1731:             layout = " layout " + bean.getQC() + layout + bean.getQC();
                   1732:             String name = names.get(tbIndex).toString();
                   1733:             StringBuffer queryLayout = new StringBuffer(query);
                   1734:             queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
                   1735:             query = queryLayout.toString();
                   1736:             System.out.println("added layout  " + query);
                   1737: 
                   1738:           }
                   1739:           dialog.title.setText("Getting table data ...");
                   1740:           dialog.table.setText(names.get(tbIndex).toString());
                   1741:           dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
                   1742:           dialog.show();
                   1743:           bean.getConnection();
                   1744:           bean.makeQuery(query, 50);
                   1745:           idField = ids.get(tbIndex).toString();
                   1746: 
                   1747:         } catch (Exception e)
                   1748:         {
                   1749:           continue;
                   1750:         }
                   1751:         // determine destTableName from createStatement or from source table name
                   1752:         if (!creates.get(tbIndex).equals(""))
                   1753:         {
                   1754:           String create = creates.get(tbIndex).toString().toLowerCase();
                   1755:           int fromIndex = create.indexOf("table") + 5;
                   1756:           int toIndex = create.indexOf("(");
                   1757:           destTableName = create.substring(fromIndex, toIndex).replaceAll(beanDest.getQC(), "").trim();
                   1758:           System.out.println("destTable " + destTableName);
                   1759: 
                   1760:         } else
                   1761:           destTableName = convertText(names.get(tbIndex).toString());
                   1762: 
                   1763:         // for id kram
                   1764:         Vector vec = null;
                   1765:         Vector vecDest = null;
1.47      rogo     1766:         //      tempo
                   1767:         beanDest.setConnection(destination);
1.46      rogo     1768:         int rowCount = (idField != "") ? myIds.size() : bean.getRowCount(query);
                   1769:         String tempID = bean.getQC() + idField + bean.getQC();
                   1770:         String tempIDdest = beanDest.getQC() + convertText(idField) + beanDest.getQC();
1.47      rogo     1771: 
1.46      rogo     1772:         int endIndex = -1;
                   1773:         String tempQuery = query;
1.47      rogo     1774:         String destQuery = query.replaceAll(names.get(tbIndex).toString(), destTableName);
1.49      rogo     1775:         String tempQueryDest = destQuery;
                   1776:         // remove extra query parts destQuery.substring(0,destQuery.lastIndexOf(destTableName)+destTableName.length()+1);
1.47      rogo     1777:         System.out.println("new Query " + tempQueryDest);
1.46      rogo     1778:         if (!idField.equals(""))
                   1779:         {
                   1780:           long startTime = System.currentTimeMillis();
                   1781:           int counter = -1;
                   1782:           while (true)
                   1783:           {
                   1784:             ++counter;
                   1785:             if (counter == 0 && dialog != null)
                   1786:               dialog.title.setText("Check if data  is available");
                   1787:             else if (dialog != null)
                   1788:               dialog.title.setText("Check if more  data  is available");
                   1789:             myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, numHits);
                   1790:             myIdsDest = beanDest.getIDVector(convertText(idField), destTableName, tempQueryDest, numHits);
                   1791:             if (myIds.isEmpty())
                   1792:               break;
                   1793:             vec = new Vector(myIds);
                   1794:             vecDest = new Vector(myIdsDest);
                   1795:             rowCount = vec.size();
1.47      rogo     1796:             // Deletion will work this way
                   1797:             Vector deleted = new Vector(vec);
                   1798:             Vector linesToDelete = new Vector(vecDest);
                   1799:             // remove all lines that should not be deleted
                   1800:             linesToDelete.removeAll(deleted);
                   1801:             // System.out.println("ID LIST SIZE " + Math.round((double) myIds.size() / (double) numIntervalls) + " " + myIdsDest.size());
1.46      rogo     1802:             /// @TODO complete delete task remove query show lines to be deleted let user choose if he wants that
1.47      rogo     1803:             System.out.println("number of lines to  be deleted " + linesToDelete.size());
1.46      rogo     1804:             deltaID = (int) Math.round((double) myIds.size() / (double) numIntervalls);
1.47      rogo     1805:             beanDest.setConnection(destination);
1.46      rogo     1806: 
1.47      rogo     1807:             Statement stm = beanDest.getConnection().createStatement();
1.46      rogo     1808: 
1.47      rogo     1809:             Vector tables = beanDest.getTableNames();
                   1810:             // Collections.sort(tables);
                   1811:             System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames()); 
                   1812:             tables = beanDest.getTableNames();
                   1813:             // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
                   1814:             stm = beanDest.getConnection().createStatement();
                   1815: 
                   1816:             if (dialog != null)
                   1817:               dialog.title.setText(" Deleting table data ...");
                   1818: 
                   1819:             int j = -1;
                   1820: 
                   1821:             Vector row = null;
                   1822:             command = new StringBuffer();
                   1823: 
                   1824:             command.append("DELETE FROM");
                   1825:             command.append(beanDest.getQC());
                   1826:             command.append(destTableName);
                   1827:             //command.append(convertText((String) names.get(tbIndex)));
                   1828:             command.append(beanDest.getQC());
                   1829:             int size = bean.getColumnNames().size();
                   1830:             command.append("WHERE " + convertText(ids.get(tbIndex).toString()) + " =  ?");
                   1831:             PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
                   1832:             System.out.println(command + " " + tbIndex);
                   1833:             //int rowCount = bean.getRowCount(query);
                   1834:             //        int idIndex = bean.getColumnNames().indexOf(ids.get(tbIndex));
                   1835:             while (true)
1.46      rogo     1836:             {
                   1837: 
1.48      rogo     1838:               ++j;
1.47      rogo     1839:               if (j == linesToDelete.size())
                   1840:                 break;
                   1841:               //print rows
                   1842:               pstm.setString(1, linesToDelete.get(j).toString());
                   1843:               System.out.println(pstm.toString());
1.55      rogo     1844:               pstm.execute();
1.46      rogo     1845:               if (dialog != null)
1.47      rogo     1846:                 dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
                   1847:               command = null;
1.46      rogo     1848:             }
                   1849:             // prepare new query for next chunk
                   1850:             if (query.indexOf("where") > 0)
                   1851:               tempQuery = query + " and " + tempID + ">'" + vec.lastElement() + "'";
                   1852:             else
                   1853:               tempQuery = query + " where " + tempID + ">'" + vec.lastElement() + "'";
                   1854: 
1.47      rogo     1855:           } //to outer while
                   1856:         } // to idfield if  
                   1857:       } // table loop
                   1858: 
                   1859:     } catch (Exception e)
1.55      rogo     1860:     {
                   1861:       System.out.println("Error while connecting to database " + e);
1.47      rogo     1862:       if (dialog != null)
                   1863:       {
1.55      rogo     1864:         dialog.setVisible(false);
1.47      rogo     1865:         dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                   1866:         FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1.55      rogo     1867:       }
                   1868:       java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
                   1869:       java.io.PrintStream stream = new java.io.PrintStream(b);
                   1870:       stream.print(command + "\n\n");
                   1871:       e.printStackTrace(stream);
                   1872:       FM2SQL.showErrorDialog(b.toString(), "Error occured !");
                   1873: 
                   1874:     }
                   1875:     if (dialog != null)
                   1876:     {
                   1877:       dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                   1878:       FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
1.46      rogo     1879: 
1.55      rogo     1880:       dialog.setVisible(false);
                   1881:     }
                   1882:   } // to method
1.65    ! rogo     1883: 
1.60      rogo     1884:   /**
                   1885:    * synchronize method based on delete method code
                   1886:    * 
                   1887:    * @param source
                   1888:    * @param destination
                   1889:    * @param names
                   1890:    * @param layouts
                   1891:    * @param selects
                   1892:    * @param creates
                   1893:    * @param ids
                   1894:    * @param mode
                   1895:    * @throws Exception
                   1896:    */
                   1897:   // TODO implement append,update and delete in one method
                   1898:   // TODO using id based algorithm
                   1899:   public static void synchronize(String source, String destination, Vector names, Vector layouts, Vector selects, Vector creates, Vector ids, int mode) throws Exception
                   1900:   {
1.62      rogo     1901:     System.out.println(" bin in synchronize!!!");
1.60      rogo     1902:     FM2SQL.ProgressDialog dialog = null;
                   1903:     if (FM2SQL.fmInstance != null)
                   1904:     {
                   1905:       dialog = new FM2SQL.ProgressDialog(FM2SQL.fmInstance, bean);
1.61      rogo     1906:       dialog.setTitle("Synchronize running ...");
1.60      rogo     1907:       dialog.title.setText("Getting table data ...");
                   1908:       dialog.setLocation(FM2SQL.fmInstance.getLocationOnScreen().x + (FM2SQL.fmInstance.getWidth() - 400) / 2, FM2SQL.fmInstance.getLocationOnScreen().y + (FM2SQL.fmInstance.getHeight() - 250) / 2);
                   1909:       dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                   1910:       FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                   1911:       dialog.thread = Thread.currentThread();
                   1912:     }
                   1913:     // setting user and passwd 
                   1914:     bean.setUserAndPasswd(user, passwd);
                   1915:     // setting user and passwd 
                   1916:     beanDest.setUserAndPasswd(userDest, passwdDest);
                   1917:     if (dialog != null)
                   1918:       dialog.setSize(400, 250);
                   1919:     StringBuffer command = null;
                   1920:     String query = null;
                   1921:     try
                   1922:     {
                   1923:       //bean.setConnection("jdbc:fmpro:http://141.14.237.74:8050");    
                   1924:       //bean.setConnection("jdbc:postgresql://erebos/test","postgres","rogo");
                   1925:       bean.setConnection(source);
                   1926:       if (names == null)
                   1927:         names = bean.getTableNames();
                   1928:       // Collections.sort(names);
                   1929:       int tbIndex = 1;
                   1930: 
                   1931:       // System.out.println("Start at "+names.indexOf("archimedes_facsimiles"));
                   1932:       for (tbIndex = 0; tbIndex < names.size(); ++tbIndex)
                   1933:       {
                   1934:         Vector[] result = null;
                   1935:         java.util.TreeSet myIds = new TreeSet();
                   1936:         java.util.TreeSet myIdsDest = new TreeSet();
                   1937:         int deltaID = 1;
                   1938:         String idField = "";
                   1939:         String destTableName = "";
                   1940: 
                   1941:         try
                   1942:         {
                   1943:           query = "select * from " + bean.getQC() + names.get(tbIndex).toString() + bean.getQC();
                   1944:           String layout = (layouts.isEmpty()) ? "" : layouts.get(tbIndex).toString();
                   1945:           query = (selects != null) ? selects.get(tbIndex).toString() : query;
                   1946:           //if  vectors[1].get(i) != null)
1.62      rogo     1947:           if (!layout.equals(""))
1.60      rogo     1948:           {
                   1949:             layout = " layout " + bean.getQC() + layout + bean.getQC();
                   1950:             String name = names.get(tbIndex).toString();
                   1951:             StringBuffer queryLayout = new StringBuffer(query);
                   1952:             queryLayout.insert(queryLayout.indexOf(name) + name.length() + 1, " " + layout);
                   1953:             query = queryLayout.toString();
                   1954:             System.out.println("added layout  " + query);
                   1955: 
                   1956:           }
1.65    ! rogo     1957:           if (dialog != null)
        !          1958:           {
        !          1959:             dialog.title.setText("Getting table data ...");
        !          1960:             dialog.table.setText(names.get(tbIndex).toString());
        !          1961:             dialog.status.setText("Table " + (tbIndex + 1) + " of " + names.size());
        !          1962:             dialog.show();
1.62      rogo     1963:           }
1.60      rogo     1964:           bean.getConnection();
                   1965:           bean.makeQuery(query, 50);
                   1966:           idField = ids.get(tbIndex).toString();
                   1967: 
                   1968:         } catch (Exception e)
                   1969:         {
                   1970:           continue;
                   1971:         }
                   1972:         // determine destTableName from createStatement or from source table name
                   1973:         if (!creates.get(tbIndex).equals(""))
                   1974:         {
                   1975:           String create = creates.get(tbIndex).toString().toLowerCase();
                   1976:           int fromIndex = create.indexOf("table") + 5;
                   1977:           int toIndex = create.indexOf("(");
                   1978:           destTableName = create.substring(fromIndex, toIndex).replaceAll(beanDest.getQC(), "").trim();
                   1979:           System.out.println("destTable " + destTableName);
                   1980: 
                   1981:         } else
                   1982:           destTableName = convertText(names.get(tbIndex).toString());
                   1983: 
                   1984:         // for id kram
                   1985:         Vector vec = null;
                   1986:         Vector vecDest = null;
                   1987:         //      tempo
                   1988:         beanDest.setConnection(destination);
                   1989:         int rowCount = (idField != "") ? myIds.size() : bean.getRowCount(query);
                   1990:         String tempID = bean.getQC() + idField + bean.getQC();
                   1991:         String tempIDdest = beanDest.getQC() + convertText(idField) + beanDest.getQC();
                   1992: 
                   1993:         int endIndex = -1;
                   1994:         String tempQuery = query;
                   1995:         String destQuery = query.replaceAll(names.get(tbIndex).toString(), destTableName);
                   1996:         String tempQueryDest = destQuery;
                   1997:         // remove extra query parts destQuery.substring(0,destQuery.lastIndexOf(destTableName)+destTableName.length()+1);
                   1998:         System.out.println("new Query " + tempQueryDest);
                   1999:         if (!idField.equals(""))
                   2000:         {
                   2001:           long startTime = System.currentTimeMillis();
                   2002:           int counter = -1;
                   2003:           while (true)
                   2004:           {
                   2005:             ++counter;
                   2006:             if (counter == 0 && dialog != null)
                   2007:               dialog.title.setText("Check if data  is available");
                   2008:             else if (dialog != null)
                   2009:               dialog.title.setText("Check if more  data  is available");
                   2010:             myIds = bean.getIDVector(ids.get(tbIndex).toString(), (String) names.get(tbIndex), tempQuery, numHits);
                   2011:             myIdsDest = beanDest.getIDVector(convertText(idField), destTableName, tempQueryDest, numHits);
                   2012:             if (myIds.isEmpty())
                   2013:               break;
                   2014:             vec = new Vector(myIds);
                   2015:             vecDest = new Vector(myIdsDest);
                   2016:             rowCount = vec.size();
                   2017:             // Deletion will work this way
                   2018:             Vector deleted = new Vector(vec);
1.65    ! rogo     2019:             TreeSet linesToDelete = new TreeSet(vecDest);
        !          2020: 
1.64      rogo     2021:             TreeSet linesToAppend = new TreeSet(vec);
1.61      rogo     2022:             // remove all lines that are already in dest database
                   2023:             linesToAppend.removeAll(vecDest);
1.60      rogo     2024:             // remove all lines that should not be deleted
                   2025:             linesToDelete.removeAll(deleted);
1.65    ! rogo     2026:             System.out.println("linesToAppend " + linesToAppend + " " + vecDest + " " + destTableName);
        !          2027:             System.out.println("linesToDelete " + linesToDelete + " " + vecDest + " " + destTableName);
        !          2028:             // prepare new query for next chunk
        !          2029:             if (query.indexOf("where") > 0)
        !          2030:               tempQuery = query + " and " + tempID + ">='" + vec.firstElement() + "' and " + tempID + "<='" + vec.lastElement() + "' order by " + tempID;
        !          2031:             else
        !          2032:               tempQuery = query + " where " + tempID + ">='" + vec.firstElement() + "' and " + tempID + "<='" + vec.lastElement() + "'"; // order by "+tempID;
        !          2033:             System.out.println("tempQuery is now " + tempQuery + " order by " + tempID);
        !          2034:             //  bean.makeQuery(tempQuery,vec.size());
        !          2035: 
        !          2036:             ConversionProperties prop = getFieldNamesAndDestTableName(creates.get(tbIndex).toString(), query, names.get(tbIndex).toString());
        !          2037:             StringBuffer insCommand = createInsertCommand(prop.destTableName, prop.fieldNames);
        !          2038:             StringBuffer updCommand  = createUpdateCommand(prop.destTableName, prop.fieldNames, tempID);
        !          2039:             StringBuffer delCommand  = createDeleteCommand(destTableName,tempID);
        !          2040:             PreparedStatement insPst = beanDest.getConnection().prepareStatement(insCommand.toString());
        !          2041:             PreparedStatement updPst = beanDest.getConnection().prepareStatement(updCommand.toString());
        !          2042:             PreparedStatement delPSt = beanDest.getConnection().prepareStatement(delCommand.toString());
        !          2043:             Vector[] vectors = bean.getQueryData(tempQuery, vec.size());
        !          2044:             int idIndex = vectors[1].indexOf(idField);
        !          2045:             // todo arraylist code has to be added
        !          2046:             for (Iterator iter = vectors[0].iterator(); iter.hasNext();)
        !          2047:             {
        !          2048:               Vector line = (Vector) iter.next();
        !          2049:               Object lineIDIndex = line.get(idIndex);
        !          2050:               System.out.println("line " + linesToDelete.contains(line.get(idIndex))+" "+lineIDIndex);
        !          2051:               if (linesToAppend.contains(lineIDIndex))
        !          2052:               {
        !          2053:                 for (int l = 0; l < line.size(); ++l)
        !          2054:                 {
        !          2055:                   Object obj = line.get(l);
        !          2056:                   if (obj != null)
        !          2057:                     insPst.setString(l + 1, obj.toString());
        !          2058:                   else
        !          2059:                     insPst.setNull(l + 1, Types.NULL);
        !          2060:                 }
        !          2061:                 insPst.execute();
        !          2062:               
        !          2063:               }   
        !          2064:               
        !          2065:               else // update
        !          2066:                 {
        !          2067:                   for (int l = 0; l < line.size(); ++l)
        !          2068:                         {
        !          2069:                           Object obj = line.get(l);
        !          2070:                           if (obj != null)
        !          2071:                             updPst.setString(l + 1, obj.toString());
        !          2072:                           else
        !          2073:                             updPst.setNull(l + 1, Types.NULL);
        !          2074:                         }
        !          2075:                         updPst.setString(line.size()+1,line.get(idIndex).toString());
        !          2076:                         updPst.execute();
        !          2077:       
        !          2078:                 }
        !          2079:             }
        !          2080:            
        !          2081:           //  delPSt.setString(1,"6");
        !          2082:           //  delPSt.setString(1,"7");
        !          2083:           //  delPSt.setString(1,"8");
        !          2084:           
        !          2085:             //delPSt.execute();
        !          2086:             System.out.println();
1.60      rogo     2087:             // System.out.println("ID LIST SIZE " + Math.round((double) myIds.size() / (double) numIntervalls) + " " + myIdsDest.size());
                   2088:             /// @TODO complete delete task remove query show lines to be deleted let user choose if he wants that
                   2089:             System.out.println("number of lines to  be deleted " + linesToDelete.size());
                   2090:             deltaID = (int) Math.round((double) myIds.size() / (double) numIntervalls);
1.65    ! rogo     2091:             System.out.println("deltaID " + deltaID);
        !          2092:             //System.out.println();
        !          2093:           
        !          2094:             if (true)
        !          2095:               return;
        !          2096: 
1.60      rogo     2097:             beanDest.setConnection(destination);
                   2098: 
                   2099:             Statement stm = beanDest.getConnection().createStatement();
                   2100: 
                   2101:             Vector tables = beanDest.getTableNames();
                   2102:             // Collections.sort(tables);
                   2103:             System.out.println(names.get(tbIndex) + " " + tables.indexOf(convertText((String) names.get(tbIndex)))); // "//beanDest.getTypeNames()); 
                   2104:             tables = beanDest.getTableNames();
                   2105:             // System.out.println(beanDest.getTableNames(beanDest.getCatalogs().get(2).toString()));
                   2106:             stm = beanDest.getConnection().createStatement();
                   2107: 
                   2108:             if (dialog != null)
                   2109:               dialog.title.setText(" Deleting table data ...");
                   2110: 
                   2111:             int j = -1;
                   2112: 
                   2113:             Vector row = null;
                   2114:             command = new StringBuffer();
                   2115: 
                   2116:             command.append("DELETE FROM");
                   2117:             command.append(beanDest.getQC());
                   2118:             command.append(destTableName);
                   2119:             //command.append(convertText((String) names.get(tbIndex)));
                   2120:             command.append(beanDest.getQC());
                   2121:             int size = bean.getColumnNames().size();
                   2122:             command.append("WHERE " + convertText(ids.get(tbIndex).toString()) + " =  ?");
                   2123:             PreparedStatement pstm = beanDest.getConnection().prepareStatement(command.toString());
                   2124:             System.out.println(command + " " + tbIndex);
                   2125:             //int rowCount = bean.getRowCount(query);
                   2126:             //        int idIndex = bean.getColumnNames().indexOf(ids.get(tbIndex));
1.65    ! rogo     2127: /*            while (true)
1.60      rogo     2128:             {
                   2129: 
                   2130:               ++j;
                   2131:               if (j == linesToDelete.size())
                   2132:                 break;
                   2133:               //print rows
                   2134:               pstm.setString(1, linesToDelete.get(j).toString());
                   2135:               System.out.println(pstm.toString());
                   2136:               pstm.execute();
                   2137:               if (dialog != null)
                   2138:                 dialog.progress.setValue((int) (((double) (j + 1) / (double) rowCount) * 100.0));
                   2139:               command = null;
                   2140:             }
                   2141:             // prepare new query for next chunk
                   2142:             if (query.indexOf("where") > 0)
                   2143:               tempQuery = query + " and " + tempID + ">'" + vec.lastElement() + "'";
                   2144:             else
                   2145:               tempQuery = query + " where " + tempID + ">'" + vec.lastElement() + "'";
1.65    ! rogo     2146: */
1.60      rogo     2147:           } //to outer while
                   2148:         } // to idfield if  
                   2149:       } // table loop
                   2150: 
                   2151:     } catch (Exception e)
                   2152:     {
                   2153:       System.out.println("Error while connecting to database " + e);
                   2154:       if (dialog != null)
                   2155:       {
                   2156:         dialog.setVisible(false);
                   2157:         dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                   2158:         FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                   2159:       }
                   2160:       java.io.ByteArrayOutputStream b = new java.io.ByteArrayOutputStream();
                   2161:       java.io.PrintStream stream = new java.io.PrintStream(b);
                   2162:       stream.print(command + "\n\n");
                   2163:       e.printStackTrace(stream);
                   2164:       FM2SQL.showErrorDialog(b.toString(), "Error occured !");
                   2165: 
                   2166:     }
                   2167:     if (dialog != null)
                   2168:     {
                   2169:       dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                   2170:       FM2SQL.fmInstance.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                   2171: 
                   2172:       dialog.setVisible(false);
                   2173:     }
                   2174:   } // to method
                   2175: 
1.56      rogo     2176:   /**
                   2177:    * Converts input String in norman encoding to unicode 
                   2178:    * @param inp
                   2179:    * @return converted String
                   2180:    */
1.65    ! rogo     2181:   static public String normanToUnicode(String inp)
        !          2182:   {
1.56      rogo     2183:     StringBuffer buf = new StringBuffer();
1.65    ! rogo     2184:     for (int i = 0; i < inp.length(); i++)
        !          2185:     {
1.56      rogo     2186:       char c = inp.charAt(i);
1.65    ! rogo     2187:       // System.out.println("char "+c+" "+(int)c);
        !          2188:       switch (c)
        !          2189:       {
        !          2190:         case 1 :
        !          2191:           buf.append("\u00d0");
        !          2192:           break; // Eth
        !          2193:         case 2 :
        !          2194:           buf.append("\u00f0");
        !          2195:           break; // eth
        !          2196:         case 3 :
        !          2197:           buf.append("\u0141");
        !          2198:           break; // Lslash
        !          2199:         case 4 :
        !          2200:           buf.append("\u0142");
        !          2201:           break; // lslash
        !          2202:         case 5 :
        !          2203:           buf.append("\u0160");
        !          2204:           break; // S caron
        !          2205:         case 6 :
        !          2206:           buf.append("\u0161");
        !          2207:           break; // s caron
        !          2208:         case 7 :
        !          2209:           buf.append("\u00dd");
        !          2210:           break; // Y acute
        !          2211:         case 8 :
        !          2212:           buf.append("\u00fd");
        !          2213:           break; // y acute
        !          2214:         case 11 :
        !          2215:           buf.append("\u00de");
        !          2216:           break; // Thorn
        !          2217:         case 12 :
        !          2218:           buf.append("\u00fe");
        !          2219:           break; // thorn
        !          2220:         case 14 :
        !          2221:           buf.append("\u017d");
        !          2222:           break; // Z caron
        !          2223:         case 15 :
        !          2224:           buf.append("\u017e");
        !          2225:           break; // z caron
        !          2226:         case 17 :
        !          2227:           buf.append("\u0073");
        !          2228:           break; // asciitilde
        !          2229:         case 18 :
        !          2230:           buf.append("j\u0305");
        !          2231:           break; // j macron [does a single char exist?]
        !          2232:         case 19 :
        !          2233:           buf.append("^");
        !          2234:           break; // circumflex
        !          2235:         case 20 :
        !          2236:           buf.append("\u0303");
        !          2237:           break; // tilde
        !          2238:         case 21 :
        !          2239:           buf.append("\u00bd");
        !          2240:           break; // onehalf
        !          2241:         case 22 :
        !          2242:           buf.append("\u00bc");
        !          2243:           break; // onequarter
        !          2244:         case 23 :
        !          2245:           buf.append("\u00b9");
        !          2246:           break; // onesuperior
        !          2247:         case 24 :
        !          2248:           buf.append("\u00be");
        !          2249:           break; // threequarters
        !          2250:         case 25 :
        !          2251:           buf.append("\u00b3");
        !          2252:           break; // threesuperior
        !          2253:         case 26 :
        !          2254:           buf.append("\u00b2");
        !          2255:           break; // twosuperior
        !          2256:         case 27 :
        !          2257:           buf.append("\u00a6");
        !          2258:           break; // brokenbar
        !          2259:         case 28 :
        !          2260:           buf.append("-");
        !          2261:           break; // minus
        !          2262:         case 29 :
        !          2263:           buf.append("\u00d7");
        !          2264:           break; // multiply
        !          2265:         case 39 :
        !          2266:           buf.append("'");
        !          2267:           break; // quotesingle
        !          2268:         case 94 :
        !          2269:           buf.append("\u0302");
        !          2270:           break; // circumflex
        !          2271:         case 96 :
        !          2272:           buf.append("\u0300");
        !          2273:           break; // grave
        !          2274:         case 196 :
        !          2275:           buf.append("\u00c4");
        !          2276:           break; // A dieresis
        !          2277:         case 197 :
        !          2278:           buf.append("\u00c5");
        !          2279:           break; // A ring
        !          2280:         case 201 :
        !          2281:           buf.append("\u00c9");
        !          2282:           break; // E acute
        !          2283:         case 209 :
        !          2284:           buf.append("\u00d1");
        !          2285:           break; // N tilde
        !          2286:         case 214 :
        !          2287:           buf.append("\u00d6");
        !          2288:           break; // O dieresis
        !          2289:         case 220 :
        !          2290:           buf.append("\u00dc");
        !          2291:           break; // U dieresis
        !          2292:         case 225 :
        !          2293:           buf.append("\u00e1");
        !          2294:           break; // a acute
        !          2295:         case 224 :
        !          2296:           buf.append("\u00e0");
        !          2297:           break; // a grave
        !          2298:         case 226 :
        !          2299:           buf.append("\u00e2");
        !          2300:           break; // a circumflex
        !          2301:         case 228 :
        !          2302:           buf.append("\u00e4");
        !          2303:           break; // a dieresis
        !          2304:         case 227 :
        !          2305:           buf.append("\u00e3");
        !          2306:           break; // a tilde
        !          2307:         case 229 :
        !          2308:           buf.append("\u0101");
        !          2309:           break; // a macron
        !          2310:         case 231 :
        !          2311:           buf.append("\u00e7");
        !          2312:           break; // c cedilla
        !          2313:         case 233 :
        !          2314:           buf.append("\u00e9");
        !          2315:           break; // e acute
        !          2316:         case 232 :
        !          2317:           buf.append("\u00e8");
        !          2318:           break; // e grave
        !          2319:         case 234 :
        !          2320:           buf.append("\u00ea");
        !          2321:           break; // e circumflex
        !          2322:         case 235 :
        !          2323:           buf.append("\u00eb");
        !          2324:           break; // e dieresis
        !          2325:         case 237 :
        !          2326:           buf.append("\u00ed");
        !          2327:           break; // i acute
        !          2328:         case 236 :
        !          2329:           buf.append("\u00ec");
        !          2330:           break; // i grave
        !          2331:         case 238 :
        !          2332:           buf.append("\u00ee");
        !          2333:           break; // i circumflex
        !          2334:         case 239 :
        !          2335:           buf.append("\u00ef");
        !          2336:           break; // i dieresis
        !          2337:         case 241 :
        !          2338:           buf.append("\u00f1");
        !          2339:           break; // n tilde
        !          2340:         case 243 :
        !          2341:           buf.append("\u00f3");
        !          2342:           break; // o acute
        !          2343:         case 242 :
        !          2344:           buf.append("\u00f2");
        !          2345:           break; // o grave
        !          2346:         case 244 :
        !          2347:           buf.append("\u00f4");
        !          2348:           break; // o circumflex
        !          2349:         case 246 :
        !          2350:           buf.append("\u00f6");
        !          2351:           break; // o dieresis
        !          2352:         case 245 :
        !          2353:           buf.append("\u00f5");
        !          2354:           break; // o tilde
        !          2355:         case 250 :
        !          2356:           buf.append("\u00fa");
        !          2357:           break; // u acute
        !          2358:         case 249 :
        !          2359:           buf.append("\u00f9");
        !          2360:           break; // u grave
        !          2361:         case 251 :
        !          2362:           buf.append("\u00fb");
        !          2363:           break; // u circumflex
        !          2364:         case 252 :
        !          2365:           buf.append("\u00fc");
        !          2366:           break; // u dieresis
        !          2367:         case 8224 :
        !          2368:           buf.append("\u1e6d");
        !          2369:           break; // t underdot
        !          2370:         case 176 :
        !          2371:           buf.append("\u00b0");
        !          2372:           break; // degree
        !          2373:         case 162 :
        !          2374:           buf.append("\u1ebd");
        !          2375:           break; // e tilde
        !          2376:         case 163 :
        !          2377:           buf.append("\u00a3");
        !          2378:           break; // sterling
        !          2379:         case 167 :
        !          2380:           buf.append("\u00a7");
        !          2381:           break; // section
        !          2382:         case 182 :
        !          2383:           buf.append("\u00b6");
        !          2384:           break; // paragraph
        !          2385:         case 223 :
        !          2386:           buf.append("\u015b");
        !          2387:           break; // s acute
        !          2388:         case 174 :
        !          2389:           buf.append("\u1e5b");
        !          2390:           break; // r underdot
        !          2391:         case 169 :
        !          2392:           buf.append("\u1e45");
        !          2393:           break; // n overdot
        !          2394:         case 353 :
        !          2395:           buf.append("\u1e45");
        !          2396:           break; // n overdot
        !          2397:         case 180 :
        !          2398:           buf.append("\u0301");
        !          2399:           break; // acute
        !          2400:         case 168 :
        !          2401:           buf.append("\u0308");
        !          2402:           break; // dieresis
        !          2403:         case 8800 :
        !          2404:           buf.append("\u1e6d");
        !          2405:           break; // t underdot
        !          2406:         case 198 :
        !          2407:           buf.append("\u00c6");
        !          2408:           break; // AE
        !          2409:         case 216 :
        !          2410:           buf.append("\u014d");
        !          2411:           break; // o macron
        !          2412:         case 8734 :
        !          2413:           buf.append("\u0129");
        !          2414:           break; // i tilde
        !          2415:         case 177 :
        !          2416:           buf.append("\u00b1");
        !          2417:           break; // plusminus
        !          2418:         case 165 :
        !          2419:           buf.append("\u012b");
        !          2420:           break; // i macron
        !          2421:         case 181 :
        !          2422:           buf.append("\u1e43");
        !          2423:           break; // m underdot
        !          2424:         case 8706 :
        !          2425:           buf.append("\u1e0d");
        !          2426:           break; // d underdot
        !          2427:         case 240 :
        !          2428:           buf.append("\u1e0d");
        !          2429:           break; // d underdot
        !          2430: 
        !          2431:         case 8721 :
        !          2432:           buf.append("\u1e63");
        !          2433:           break; // s underdot
        !          2434:         case 960 :
        !          2435:           buf.append("\u017a");
        !          2436:           break; // z acute
        !          2437:         case 8747 :
        !          2438:           buf.append("\u1e45");
        !          2439:           break; // n overdot
        !          2440:         case 937 :
        !          2441:           buf.append("\u0169");
        !          2442:           break; // u tilde
        !          2443:         case 230 :
        !          2444:           buf.append("\u00e6");
        !          2445:           break; // ae
        !          2446:         case 248 :
        !          2447:           buf.append("\u00f8");
        !          2448:           break; // oslash
        !          2449:         case 191 :
        !          2450:           buf.append("\u0304\u0306");
        !          2451:           break; // macron breve
        !          2452:         case 172 :
        !          2453:           buf.append("\u1e37");
        !          2454:           break; // 
        !          2455:         case 8730 :
        !          2456:           buf.append("j\u0305");
        !          2457:           break; // j macron [does a single char exist?]
        !          2458:         case 402 :
        !          2459:           buf.append("\u0103");
        !          2460:           break; // a breve
        !          2461:         case 8776 :
        !          2462:           buf.append("\u016d");
        !          2463:           break; // u breve
        !          2464:         case 187 :
        !          2465:           buf.append("\u1e42");
        !          2466:           break; // M underdot
        !          2467:         case 8230 :
        !          2468:           buf.append("\u2026");
        !          2469:           break; // ellipsis
        !          2470:         case 192 :
        !          2471:           buf.append("\u00c0");
        !          2472:           break; // A grave
        !          2473:         case 195 :
        !          2474:           buf.append("\u00c3");
        !          2475:           break; // A tilde
        !          2476:         case 213 :
        !          2477:           buf.append("\u00d5");
        !          2478:           break; // O tilde
        !          2479:         case 338 :
        !          2480:           buf.append("m\u0306");
        !          2481:           break; // m breve
        !          2482:         case 339 :
        !          2483:           buf.append("\u0153");
        !          2484:           break; // oe
        !          2485:         case 8211 :
        !          2486:           buf.append("\u2013");
        !          2487:           break; // endash
        !          2488:         case 8212 :
        !          2489:           buf.append("\u2014");
        !          2490:           break; // emdash
        !          2491:         case 8220 :
        !          2492:           buf.append("\u201c");
        !          2493:           break; // quotedblleft
        !          2494:         case 8221 :
        !          2495:           buf.append("\u201d");
        !          2496:           break; // quotedblright
        !          2497:         case 8216 :
        !          2498:           buf.append("\u2018");
        !          2499:           break; // quoteleft
        !          2500:         case 8217 :
        !          2501:           buf.append("\u2019");
        !          2502:           break; // quoteright
        !          2503:         case 247 :
        !          2504:           buf.append("\u1e37");
        !          2505:           break; // l underring [actually underdot]
        !          2506:         case 9674 :
        !          2507:           buf.append("\u1e41");
        !          2508:           break; // m overdot
        !          2509:         case 255 :
        !          2510:           buf.append("n\u0306");
        !          2511:           break; // n breve
        !          2512:         case 376 :
        !          2513:           buf.append("\u00d7");
        !          2514:           break; // multiply
        !          2515:         case 8364 :
        !          2516:           buf.append("\u1e5b");
        !          2517:           break; // r underring [actually underdot]
        !          2518:         case 8249 :
        !          2519:           buf.append("\u1e44");
        !          2520:           break; // N overdot
        !          2521:         case 8250 :
        !          2522:           buf.append("\u1e62");
        !          2523:           break; // S underdot
        !          2524:         case 64257 :
        !          2525:           buf.append("\u1e24");
        !          2526:           break; // H underdot
        !          2527:         case 64258 :
        !          2528:           buf.append("\u1e0c");
        !          2529:           break; // D underdot
        !          2530:         case 8225 :
        !          2531:           buf.append("\u2021");
        !          2532:           break; // daggerdbl
        !          2533:         case 8218 :
        !          2534:           buf.append("\u1e36");
        !          2535:           break; // L underdot
        !          2536:         case 8222 :
        !          2537:           buf.append("\u0113");
        !          2538:           break; // e macron
        !          2539:         case 194 :
        !          2540:           buf.append("\u1e5f");
        !          2541:           break; // r underbar
        !          2542:         case 202 :
        !          2543:           buf.append("r\u0324");
        !          2544:           break; // r underdieresis
        !          2545:         case 193 :
        !          2546:           buf.append("\u012a");
        !          2547:           break; // I macron
        !          2548:         case 8486 :
        !          2549:         case 203 :
        !          2550:           buf.append("\u016b");
        !          2551:           break; // u macron
        !          2552:         case 200 :
        !          2553:           buf.append("\u1e6c");
        !          2554:           break; // T underdot
        !          2555:         case 205 :
        !          2556:           buf.append("\u1e64");
        !          2557:           break; // S acute
        !          2558:         case 206 :
        !          2559:           buf.append("\u2020");
        !          2560:           break; // dagger
        !          2561:         case 207 :
        !          2562:           buf.append("\u0115");
        !          2563:           break; // e breve
        !          2564:         case 204 :
        !          2565:           buf.append("\u014f");
        !          2566:           break; // o breve
        !          2567:         case 211 :
        !          2568:           buf.append("\u0100");
        !          2569:           break; // A macron
        !          2570:         case 212 :
        !          2571:           buf.append("\u1e46");
        !          2572:           break; // N underdot
        !          2573:         case 210 :
        !          2574:           buf.append("\u1e3b");
        !          2575:           break; // l underbar
        !          2576:         case 218 :
        !          2577:           buf.append("\u016a");
        !          2578:           break; // U macron
        !          2579:         case 219 :
        !          2580:           buf.append("\u0179");
        !          2581:           break; // Z acute
        !          2582:         case 217 :
        !          2583:           buf.append("\u1e5a");
        !          2584:           break; // R underdot
        !          2585:         case 305 :
        !          2586:           buf.append("\u0131");
        !          2587:           break; // dotlessi
        !          2588:         case 710 :
        !          2589:           buf.append("\u1e47");
        !          2590:           break; // n underdot
        !          2591:         case 732 :
        !          2592:           buf.append("\u1e49");
        !          2593:           break; // n underbar
        !          2594:         case 175 :
        !          2595:           buf.append("\u0304");
        !          2596:           break; // macron
        !          2597:         case 728 :
        !          2598:           buf.append("\u0306");
        !          2599:           break; // breve
        !          2600:         case 729 :
        !          2601:         case 215 :
        !          2602:           buf.append("\u1e25");
        !          2603:           break; // h underdot
        !          2604:         case 730 :
        !          2605:           buf.append("\u012d");
        !          2606:           break; // i breve
        !          2607:         case 184 :
        !          2608:           buf.append("\u0327");
        !          2609:           break; // cedilla
        !          2610:         case 733 :
        !          2611:           buf.append("\u030b");
        !          2612:           break; // hungarumlaut
        !          2613:         case 731 :
        !          2614:           buf.append("\u0328");
        !          2615:           break; // ogonek
        !          2616:         case 711 :
        !          2617:           buf.append("\u030c");
        !          2618:           break; // caron
        !          2619:         case 199 :
        !          2620:           buf.append("\u012b\u0303");
        !          2621:           break; // imacron tilde
        !          2622:         case 8226 :
        !          2623:           buf.append("\u1e5d");
        !          2624:           break; // runderdot macron
        !          2625:         case 8482 :
        !          2626:           buf.append("\u016b\0306");
        !          2627:           break; // umacron breve
        !          2628:         case 8804 :
        !          2629:           buf.append("\u0101\u0301");
        !          2630:           break; // amacron acute
        !          2631:         case 8805 :
        !          2632:           buf.append("\u016b\u0301");
        !          2633:           break; // umacron acute
        !          2634:         case 8719 :
        !          2635:           buf.append("\u0113\u0301");
        !          2636:           break; // emacron acute
        !          2637:         case 170 :
        !          2638:           buf.append("\u0113\u0300");
        !          2639:           break; // emacron breve
        !          2640:         case 186 :
        !          2641:           buf.append("\u014d\u0300");
        !          2642:           break; // omacron breve
        !          2643:         case 161 :
        !          2644:           buf.append("\u0101\u0306");
        !          2645:           break; // amacron breve
        !          2646:         case 8710 :
        !          2647:           buf.append("\u0101\u0303");
        !          2648:           break; // amacron tilde
        !          2649:         case 171 :
        !          2650:           buf.append("\u012b\u0301");
        !          2651:           break; // imacron acute
        !          2652:         case 8260 :
        !          2653:           buf.append("\u1e00");
        !          2654:           break; // runderdotmacron acute
        !          2655:         case 183 :
        !          2656:           buf.append("\u1e5b\u0301");
        !          2657:           break; // runderdot acute
        !          2658:         case 8240 :
        !          2659:           buf.append("\u012b\u0306");
        !          2660:           break; // imacron breve
        !          2661:         case 63743 :
        !          2662:           buf.append("\u016b\u0303");
        !          2663:           break; // umacron tilde
        !          2664:         default :
        !          2665:           buf.append(c);
        !          2666:           if ((int) c > 127)
        !          2667:             System.out.println("char " + c + " " + (int) c);
        !          2668:           break;
1.57      rogo     2669:       }
                   2670:     }
                   2671:     return buf.toString();
                   2672:   }
                   2673: 
1.65    ! rogo     2674:   static public String normanToUnicodeOld(String inp)
        !          2675:   {
1.57      rogo     2676:     StringBuffer buf = new StringBuffer();
1.65    ! rogo     2677:     for (int i = 0; i < inp.length(); i++)
        !          2678:     {
1.57      rogo     2679:       char c = inp.charAt(i);
1.65    ! rogo     2680:       switch (c)
        !          2681:       {
        !          2682:         case 1 :
        !          2683:           buf.append("\u00d0");
        !          2684:           break; // Eth
        !          2685:         case 2 :
        !          2686:           buf.append("\u00f0");
        !          2687:           break; // eth
        !          2688:         case 3 :
        !          2689:           buf.append("\u0141");
        !          2690:           break; // Lslash
        !          2691:         case 4 :
        !          2692:           buf.append("\u0142");
        !          2693:           break; // lslash
        !          2694:         case 5 :
        !          2695:           buf.append("\u0160");
        !          2696:           break; // S caron
        !          2697:         case 6 :
        !          2698:           buf.append("\u0161");
        !          2699:           break; // s caron
        !          2700:         case 7 :
        !          2701:           buf.append("\u00dd");
        !          2702:           break; // Y acute
        !          2703:         case 8 :
        !          2704:           buf.append("\u00fd");
        !          2705:           break; // y acute
        !          2706:         case 11 :
        !          2707:           buf.append("\u00de");
        !          2708:           break; // Thorn
        !          2709:         case 12 :
        !          2710:           buf.append("\u00fe");
        !          2711:           break; // thorn
        !          2712:         case 14 :
        !          2713:           buf.append("\u017d");
        !          2714:           break; // Z caron
        !          2715:         case 15 :
        !          2716:           buf.append("\u017e");
        !          2717:           break; // z caron
        !          2718:         case 17 :
        !          2719:           buf.append("\u0073");
        !          2720:           break; // asciitilde
        !          2721:         case 18 :
        !          2722:           buf.append("j\u0305");
        !          2723:           break; // j macron [does a single char exist?]
        !          2724:         case 19 :
        !          2725:           buf.append("^");
        !          2726:           break; // circumflex
        !          2727:         case 20 :
        !          2728:           buf.append("\u0303");
        !          2729:           break; // tilde
        !          2730:         case 21 :
        !          2731:           buf.append("\u00bd");
        !          2732:           break; // onehalf
        !          2733:         case 22 :
        !          2734:           buf.append("\u00bc");
        !          2735:           break; // onequarter
        !          2736:         case 23 :
        !          2737:           buf.append("\u00b9");
        !          2738:           break; // onesuperior
        !          2739:         case 24 :
        !          2740:           buf.append("\u00be");
        !          2741:           break; // threequarters
        !          2742:         case 25 :
        !          2743:           buf.append("\u00b3");
        !          2744:           break; // threesuperior
        !          2745:         case 26 :
        !          2746:           buf.append("\u00b2");
        !          2747:           break; // twosuperior
        !          2748:         case 27 :
        !          2749:           buf.append("\u00a6");
        !          2750:           break; // brokenbar
        !          2751:         case 28 :
        !          2752:           buf.append("-");
        !          2753:           break; // minus
        !          2754:         case 29 :
        !          2755:           buf.append("\u00d7");
        !          2756:           break; // multiply
        !          2757:         case 39 :
        !          2758:           buf.append("'");
        !          2759:           break; // quotesingle
        !          2760:         case 94 :
        !          2761:           buf.append("\u0302");
        !          2762:           break; // circumflex
        !          2763:         case 96 :
        !          2764:           buf.append("\u0300");
        !          2765:           break; // grave
        !          2766:         case 128 :
        !          2767:           buf.append("\u00c4");
        !          2768:           break; // A dieresis
        !          2769:         case 129 :
        !          2770:           buf.append("\u00c5");
        !          2771:           break; // A ring
        !          2772:         case 131 :
        !          2773:           buf.append("\u00c9");
        !          2774:           break; // E acute
        !          2775:         case 132 :
        !          2776:           buf.append("\u00d1");
        !          2777:           break; // N tilde
        !          2778:         case 133 :
        !          2779:           buf.append("\u00d6");
        !          2780:           break; // O dieresis
        !          2781:         case 134 :
        !          2782:           buf.append("\u00dc");
        !          2783:           break; // U dieresis
        !          2784:         case 135 :
        !          2785:           buf.append("\u00e1");
        !          2786:           break; // a acute
        !          2787:         case 136 :
        !          2788:           buf.append("\u00e0");
        !          2789:           break; // a grave
        !          2790:         case 137 :
        !          2791:           buf.append("\u00e2");
        !          2792:           break; // a circumflex
        !          2793:         case 138 :
        !          2794:           buf.append("\u00e4");
        !          2795:           break; // a dieresis
        !          2796:         case 139 :
        !          2797:           buf.append("\u00e3");
        !          2798:           break; // a tilde
        !          2799:         case 140 :
        !          2800:           buf.append("\u0101");
        !          2801:           break; // a macron
        !          2802:         case 141 :
        !          2803:           buf.append("\u00e7");
        !          2804:           break; // c cedilla
        !          2805:         case 142 :
        !          2806:           buf.append("\u00e9");
        !          2807:           break; // e acute
        !          2808:         case 143 :
        !          2809:           buf.append("\u00e8");
        !          2810:           break; // e grave
        !          2811:         case 144 :
        !          2812:           buf.append("\u00ea");
        !          2813:           break; // e circumflex
        !          2814:         case 145 :
        !          2815:           buf.append("\u00eb");
        !          2816:           break; // e dieresis
        !          2817:         case 146 :
        !          2818:           buf.append("\u00ed");
        !          2819:           break; // i acute
        !          2820:         case 147 :
        !          2821:           buf.append("\u00ec");
        !          2822:           break; // i grave
        !          2823:         case 148 :
        !          2824:           buf.append("\u00ee");
        !          2825:           break; // i circumflex
        !          2826:         case 149 :
        !          2827:           buf.append("\u00ef");
        !          2828:           break; // i dieresis
        !          2829:         case 150 :
        !          2830:           buf.append("\u00f1");
        !          2831:           break; // n tilde
        !          2832:         case 151 :
        !          2833:           buf.append("\u00f3");
        !          2834:           break; // o acute
        !          2835:         case 152 :
        !          2836:           buf.append("\u00f2");
        !          2837:           break; // o grave
        !          2838:         case 153 :
        !          2839:           buf.append("\u00f4");
        !          2840:           break; // o circumflex
        !          2841:         case 154 :
        !          2842:           buf.append("\u00f6");
        !          2843:           break; // o dieresis
        !          2844:         case 155 :
        !          2845:           buf.append("\u00f5");
        !          2846:           break; // o tilde
        !          2847:         case 156 :
        !          2848:           buf.append("\u00fa");
        !          2849:           break; // u acute
        !          2850:         case 157 :
        !          2851:           buf.append("\u00f9");
        !          2852:           break; // u grave
        !          2853:         case 158 :
        !          2854:           buf.append("\u00fb");
        !          2855:           break; // u circumflex
        !          2856:         case 159 :
        !          2857:           buf.append("\u00fc");
        !          2858:           break; // u dieresis
        !          2859:         case 160 :
        !          2860:           buf.append("\u1e6d");
        !          2861:           break; // t underdot
        !          2862:         case 161 :
        !          2863:           buf.append("\u00b0");
        !          2864:           break; // degree
        !          2865:         case 162 :
        !          2866:           buf.append("\u1ebd");
        !          2867:           break; // e tilde
        !          2868:         case 163 :
        !          2869:           buf.append("\u00a3");
        !          2870:           break; // sterling
        !          2871:         case 164 :
        !          2872:           buf.append("\u00a7");
        !          2873:           break; // section
        !          2874:         case 166 :
        !          2875:           buf.append("\u00b6");
        !          2876:           break; // paragraph
        !          2877:         case 167 :
        !          2878:           buf.append("\u015b");
        !          2879:           break; // s acute
        !          2880:         case 168 :
        !          2881:           buf.append("\u1e5b");
        !          2882:           break; // r underdot
        !          2883:         case 169 :
        !          2884:           buf.append("\u1e67");
        !          2885:           break; // s caron
        !          2886:         case 171 :
        !          2887:           buf.append("\u0301");
        !          2888:           break; // acute
        !          2889:         case 172 :
        !          2890:           buf.append("\u0308");
        !          2891:           break; // dieresis
        !          2892:         case 173 :
        !          2893:           buf.append("\u1e6d");
        !          2894:           break; // t underdot
        !          2895:         case 174 :
        !          2896:           buf.append("\u00c6");
        !          2897:           break; // AE
        !          2898:         case 175 :
        !          2899:           buf.append("\u014d");
        !          2900:           break; // o macron
        !          2901:         case 176 :
        !          2902:           buf.append("\u0129");
        !          2903:           break; // i tilde
        !          2904:         case 177 :
        !          2905:           buf.append("\u00b1");
        !          2906:           break; // plusminus
        !          2907:         case 180 :
        !          2908:           buf.append("\u012b");
        !          2909:           break; // i macron
        !          2910:         case 181 :
        !          2911:           buf.append("\u1e43");
        !          2912:           break; // m underdot
        !          2913:         case 182 :
        !          2914:           buf.append("\u1e0d");
        !          2915:           break; // d underdot
        !          2916:         case 183 :
        !          2917:           buf.append("\u1e63");
        !          2918:           break; // s underdot
        !          2919:         case 185 :
        !          2920:           buf.append("\u017a");
        !          2921:           break; // z acute
        !          2922:         case 186 :
        !          2923:           buf.append("\u1e45");
        !          2924:           break; // n overdot
        !          2925:         case 189 :
        !          2926:           buf.append("\u0169");
        !          2927:           break; // u tilde
        !          2928:         case 190 :
        !          2929:           buf.append("\u00e6");
        !          2930:           break; // ae
        !          2931:         case 191 :
        !          2932:           buf.append("\u00f8");
        !          2933:           break; // oslash
        !          2934:         case 192 :
        !          2935:           buf.append("\u0304\u0306");
        !          2936:           break; // macron breve
        !          2937:         case 194 :
        !          2938:           buf.append("\u1e37");
        !          2939:           break; // 
        !          2940:         case 195 :
        !          2941:           buf.append("j\u0305");
        !          2942:           break; // j macron [does a single char exist?]
        !          2943:         case 196 :
        !          2944:           buf.append("\u0103");
        !          2945:           break; // a breve
        !          2946:         case 197 :
        !          2947:           buf.append("\u016d");
        !          2948:           break; // u breve
        !          2949:         case 200 :
        !          2950:           buf.append("\u1e42");
        !          2951:           break; // M underdot
        !          2952:         case 201 :
        !          2953:           buf.append("\u2026");
        !          2954:           break; // ellipsis
        !          2955:         case 203 :
        !          2956:           buf.append("\u00c0");
        !          2957:           break; // A grave
        !          2958:         case 204 :
        !          2959:           buf.append("\u00c3");
        !          2960:           break; // A tilde
        !          2961:         case 205 :
        !          2962:           buf.append("\u00d5");
        !          2963:           break; // O tilde
        !          2964:         case 206 :
        !          2965:           buf.append("m\u0306");
        !          2966:           break; // m breve
        !          2967:         case 207 :
        !          2968:           buf.append("\u0153");
        !          2969:           break; // oe
        !          2970:         case 208 :
        !          2971:           buf.append("\u2013");
        !          2972:           break; // endash
        !          2973:         case 209 :
        !          2974:           buf.append("\u2014");
        !          2975:           break; // emdash
        !          2976:         case 210 :
        !          2977:           buf.append("\u201c");
        !          2978:           break; // quotedblleft
        !          2979:         case 211 :
        !          2980:           buf.append("\u201d");
        !          2981:           break; // quotedblright
        !          2982:         case 212 :
        !          2983:           buf.append("\u2018");
        !          2984:           break; // quoteleft
        !          2985:         case 213 :
        !          2986:           buf.append("\u2019");
        !          2987:           break; // quoteright
        !          2988:         case 214 :
        !          2989:           buf.append("\u1e37");
        !          2990:           break; // l underring [actually underdot]
        !          2991:         case 215 :
        !          2992:           buf.append("\u1e41");
        !          2993:           break; // m overdot
        !          2994:         case 216 :
        !          2995:           buf.append("n\u0306");
        !          2996:           break; // n breve
        !          2997:         case 217 :
        !          2998:           buf.append("\u00d7");
        !          2999:           break; // multiply
        !          3000:         case 219 :
        !          3001:           buf.append("\u1e5b");
        !          3002:           break; // r underring [actually underdot]
        !          3003:         case 220 :
        !          3004:           buf.append("\u1e44");
        !          3005:           break; // N overdot
        !          3006:         case 221 :
        !          3007:           buf.append("\u1e62");
        !          3008:           break; // S underdot
        !          3009:         case 222 :
        !          3010:           buf.append("\u1e24");
        !          3011:           break; // H underdot
        !          3012:         case 223 :
        !          3013:           buf.append("\u1e0c");
        !          3014:           break; // D underdot
        !          3015:         case 224 :
        !          3016:           buf.append("\u2021");
        !          3017:           break; // daggerdbl
        !          3018:         case 226 :
        !          3019:           buf.append("\u1e36");
        !          3020:           break; // L underdot
        !          3021:         case 227 :
        !          3022:           buf.append("\u0113");
        !          3023:           break; // e macron
        !          3024:         case 229 :
        !          3025:           buf.append("\u1e5f");
        !          3026:           break; // r underbar
        !          3027:         case 230 :
        !          3028:           buf.append("r\u0324");
        !          3029:           break; // r underdieresis
        !          3030:         case 231 :
        !          3031:           buf.append("\u012a");
        !          3032:           break; // I macron
        !          3033:         case 232 :
        !          3034:           buf.append("\u016b");
        !          3035:           break; // u macron
        !          3036:         case 233 :
        !          3037:           buf.append("\u01e6c");
        !          3038:           break; // T underdot
        !          3039:         case 234 :
        !          3040:           buf.append("\u1e64");
        !          3041:           break; // S acute
        !          3042:         case 235 :
        !          3043:           buf.append("\u2020");
        !          3044:           break; // dagger
        !          3045:         case 236 :
        !          3046:           buf.append("\u0115");
        !          3047:           break; // e breve
        !          3048:         case 237 :
        !          3049:           buf.append("\u014f");
        !          3050:           break; // o breve
        !          3051:         case 238 :
        !          3052:           buf.append("\u0100");
        !          3053:           break; // A macron
        !          3054:         case 239 :
        !          3055:           buf.append("\u1e46");
        !          3056:           break; // N underdot
        !          3057:         case 241 :
        !          3058:           buf.append("\u1e3b");
        !          3059:           break; // l underbar
        !          3060:         case 242 :
        !          3061:           buf.append("\u016a");
        !          3062:           break; // U macron
        !          3063:         case 243 :
        !          3064:           buf.append("\u0179");
        !          3065:           break; // Z acute
        !          3066:         case 244 :
        !          3067:           buf.append("\u1e5a");
        !          3068:           break; // R underdot
        !          3069:         case 245 :
        !          3070:           buf.append("\u0131");
        !          3071:           break; // dotlessi
        !          3072:         case 246 :
        !          3073:           buf.append("\u1e47");
        !          3074:           break; // n underdot
        !          3075:         case 247 :
        !          3076:           buf.append("\u1e49");
        !          3077:           break; // n underbar
        !          3078:         case 248 :
        !          3079:           buf.append("\u0304");
        !          3080:           break; // macron
        !          3081:         case 249 :
        !          3082:           buf.append("\u0306");
        !          3083:           break; // breve
        !          3084:         case 250 :
        !          3085:           buf.append("\u1e25");
        !          3086:           break; // h underdot
        !          3087:         case 251 :
        !          3088:           buf.append("\u012d");
        !          3089:           break; // i breve
        !          3090:         case 252 :
        !          3091:           buf.append("\u0327");
        !          3092:           break; // cedilla
        !          3093:         case 253 :
        !          3094:           buf.append("\u030b");
        !          3095:           break; // hungarumlaut
        !          3096:         case 254 :
        !          3097:           buf.append("\u0328");
        !          3098:           break; // ogonek
        !          3099:         case 255 :
        !          3100:           buf.append("\u030c");
        !          3101:           break; // caron
        !          3102:         case 130 :
        !          3103:           buf.append("\u012b\u0303");
        !          3104:           break; // imacron tilde
        !          3105:         case 165 :
        !          3106:           buf.append("\u1e5d");
        !          3107:           break; // runderdot macron
        !          3108:         case 170 :
        !          3109:           buf.append("\u016b\0306");
        !          3110:           break; // umacron breve
        !          3111:         case 178 :
        !          3112:           buf.append("\u0101\u0301");
        !          3113:           break; // amacron acute
        !          3114:         case 179 :
        !          3115:           buf.append("\u016b\u0301");
        !          3116:           break; // umacron acute
        !          3117:         case 184 :
        !          3118:           buf.append("\u0113\u0301");
        !          3119:           break; // emacron acute
        !          3120:         case 187 :
        !          3121:           buf.append("\u0113\u0300");
        !          3122:           break; // emacron breve
        !          3123:         case 188 :
        !          3124:           buf.append("\u014d\u0300");
        !          3125:           break; // omacron breve
        !          3126:         case 193 :
        !          3127:           buf.append("\u0101\u0306");
        !          3128:           break; // amacron breve
        !          3129:         case 198 :
        !          3130:           buf.append("\u0101\u0303");
        !          3131:           break; // amacron tilde
        !          3132:         case 199 :
        !          3133:           buf.append("\u012b\u0301");
        !          3134:           break; // imacron acute
        !          3135:         case 218 :
        !          3136:           buf.append("\u1e00");
        !          3137:           break; // runderdotmacron acute
        !          3138:         case 225 :
        !          3139:           buf.append("\u1e5b\u0301");
        !          3140:           break; // runderdot acute
        !          3141:         case 228 :
        !          3142:           buf.append("\u012b\u0306");
        !          3143:           break; // imacron breve
        !          3144:         case 240 :
        !          3145:           buf.append("\u016b\u0303");
        !          3146:           break; // umacron tilde
        !          3147:         default :
        !          3148:           buf.append(c);
        !          3149:           break;
1.56      rogo     3150:       }
                   3151:     }
                   3152:     return buf.toString();
                   3153:   }
1.65    ! rogo     3154:   static public String normanToUnicodeNew(String inp)
        !          3155:   {
1.58      rogo     3156:     StringBuffer buf = new StringBuffer();
1.65    ! rogo     3157:     for (int i = 0; i < inp.length(); i++)
        !          3158:     {
1.58      rogo     3159:       char c = inp.charAt(i);
1.65    ! rogo     3160:       switch (c)
        !          3161:       {
        !          3162:         case 1 :
        !          3163:           buf.append("\u00d0");
        !          3164:           break; // Eth
        !          3165:         case 2 :
        !          3166:           buf.append("\u00f0");
        !          3167:           break; // eth
        !          3168:         case 3 :
        !          3169:           buf.append("\u0141");
        !          3170:           break; // Lslash
        !          3171:         case 4 :
        !          3172:           buf.append("\u0142");
        !          3173:           break; // lslash
        !          3174:         case 5 :
        !          3175:           buf.append("\u0160");
        !          3176:           break; // S caron
        !          3177:         case 6 :
        !          3178:           buf.append("\u0161");
        !          3179:           break; // s caron
        !          3180:         case 7 :
        !          3181:           buf.append("\u00dd");
        !          3182:           break; // Y acute
        !          3183:         case 8 :
        !          3184:           buf.append("\u00fd");
        !          3185:           break; // y acute
        !          3186:         case 11 :
        !          3187:           buf.append("\u00de");
        !          3188:           break; // Thorn
        !          3189:         case 12 :
        !          3190:           buf.append("\u00fe");
        !          3191:           break; // thorn
        !          3192:         case 14 :
        !          3193:           buf.append("\u017d");
        !          3194:           break; // Z caron
        !          3195:         case 15 :
        !          3196:           buf.append("\u017e");
        !          3197:           break; // z caron
        !          3198:         case 17 :
        !          3199:           buf.append("\u0073");
        !          3200:           break; // asciitilde
        !          3201:         case 18 :
        !          3202:           buf.append("j\u0305");
        !          3203:           break; // j macron [does a single char exist?]
        !          3204:         case 19 :
        !          3205:           buf.append("^");
        !          3206:           break; // circumflex
        !          3207:         case 20 :
        !          3208:           buf.append("\u0303");
        !          3209:           break; // tilde
        !          3210:         case 21 :
        !          3211:           buf.append("\u00bd");
        !          3212:           break; // onehalf
        !          3213:         case 22 :
        !          3214:           buf.append("\u00bc");
        !          3215:           break; // onequarter
        !          3216:         case 23 :
        !          3217:           buf.append("\u00b9");
        !          3218:           break; // onesuperior
        !          3219:         case 24 :
        !          3220:           buf.append("\u00be");
        !          3221:           break; // threequarters
        !          3222:         case 25 :
        !          3223:           buf.append("\u00b3");
        !          3224:           break; // threesuperior
        !          3225:         case 26 :
        !          3226:           buf.append("\u00b2");
        !          3227:           break; // twosuperior
        !          3228:         case 27 :
        !          3229:           buf.append("\u00a6");
        !          3230:           break; // brokenbar
        !          3231:         case 28 :
        !          3232:           buf.append("-");
        !          3233:           break; // minus
        !          3234:         case 29 :
        !          3235:           buf.append("\u00d7");
        !          3236:           break; // multiply
        !          3237:         case 39 :
        !          3238:           buf.append("'");
        !          3239:           break; // quotesingle
        !          3240:         case 94 :
        !          3241:           buf.append("\u0302");
        !          3242:           break; // circumflex
        !          3243:         case 96 :
        !          3244:           buf.append("\u0300");
        !          3245:           break; // grave
        !          3246:         case 196 :
        !          3247:           buf.append("\u00c4");
        !          3248:           break; // A dieresis
        !          3249:         case 197 :
        !          3250:           buf.append("\u00c5");
        !          3251:           break; // A ring
        !          3252:         case 201 :
        !          3253:           buf.append("\u00c9");
        !          3254:           break; // E acute
        !          3255:         case 209 :
        !          3256:           buf.append("\u00d1");
        !          3257:           break; // N tilde
        !          3258:         case 214 :
        !          3259:           buf.append("\u00d6");
        !          3260:           break; // O dieresis
        !          3261:         case 220 :
        !          3262:           buf.append("\u00dc");
        !          3263:           break; // U dieresis
        !          3264:         case 225 :
        !          3265:           buf.append("\u00e1");
        !          3266:           break; // a acute
        !          3267:         case 224 :
        !          3268:           buf.append("\u00e0");
        !          3269:           break; // a grave
        !          3270:         case 226 :
        !          3271:           buf.append("\u00e2");
        !          3272:           break; // a circumflex
        !          3273:         case 228 :
        !          3274:           buf.append("\u00e4");
        !          3275:           break; // a dieresis
        !          3276:         case 227 :
        !          3277:           buf.append("\u00e3");
        !          3278:           break; // a tilde
        !          3279:         case 229 :
        !          3280:           buf.append("\u0101");
        !          3281:           break; // a macron
        !          3282:         case 231 :
        !          3283:           buf.append("\u00e7");
        !          3284:           break; // c cedilla
        !          3285:         case 233 :
        !          3286:           buf.append("\u00e9");
        !          3287:           break; // e acute
        !          3288:         case 232 :
        !          3289:           buf.append("\u00e8");
        !          3290:           break; // e grave
        !          3291:         case 234 :
        !          3292:           buf.append("\u00ea");
        !          3293:           break; // e circumflex
        !          3294:         case 235 :
        !          3295:           buf.append("\u00eb");
        !          3296:           break; // e dieresis
        !          3297:         case 237 :
        !          3298:           buf.append("\u00ed");
        !          3299:           break; // i acute
        !          3300:         case 236 :
        !          3301:           buf.append("\u00ec");
        !          3302:           break; // i grave
        !          3303:         case 238 :
        !          3304:           buf.append("\u00ee");
        !          3305:           break; // i circumflex
        !          3306:         case 239 :
        !          3307:           buf.append("\u00ef");
        !          3308:           break; // i dieresis
        !          3309:         case 241 :
        !          3310:           buf.append("\u00f1");
        !          3311:           break; // n tilde
        !          3312:         case 243 :
        !          3313:           buf.append("\u00f3");
        !          3314:           break; // o acute
        !          3315:         case 242 :
        !          3316:           buf.append("\u00f2");
        !          3317:           break; // o grave
        !          3318:         case 244 :
        !          3319:           buf.append("\u00f4");
        !          3320:           break; // o circumflex
        !          3321:         case 246 :
        !          3322:           buf.append("\u00f6");
        !          3323:           break; // o dieresis
        !          3324:         case 245 :
        !          3325:           buf.append("\u00f5");
        !          3326:           break; // o tilde
        !          3327:         case 250 :
        !          3328:           buf.append("\u00fa");
        !          3329:           break; // u acute
        !          3330:         case 249 :
        !          3331:           buf.append("\u00f9");
        !          3332:           break; // u grave
        !          3333:         case 251 :
        !          3334:           buf.append("\u00fb");
        !          3335:           break; // u circumflex
        !          3336:         case 252 :
        !          3337:           buf.append("\u00fc");
        !          3338:           break; // u dieresis
        !          3339:         case 8224 :
        !          3340:           buf.append("\u1e6d");
        !          3341:           break; // t underdot
        !          3342:         case 176 :
        !          3343:           buf.append("\u00b0");
        !          3344:           break; // degree
        !          3345:         case 162 :
        !          3346:           buf.append("\u1ebd");
        !          3347:           break; // e tilde
        !          3348:         case 163 :
        !          3349:           buf.append("\u00a3");
        !          3350:           break; // sterling
        !          3351:         case 167 :
        !          3352:           buf.append("\u00a7");
        !          3353:           break; // section
        !          3354:         case 182 :
        !          3355:           buf.append("\u00b6");
        !          3356:           break; // paragraph
        !          3357:         case 223 :
        !          3358:           buf.append("\u015b");
        !          3359:           break; // s acute
        !          3360:         case 174 :
        !          3361:           buf.append("\u1e5b");
        !          3362:           break; // r underdot
        !          3363:         case 169 :
        !          3364:           buf.append("\u1e45");
        !          3365:           break; // n overdot
        !          3366:         case 180 :
        !          3367:           buf.append("\u0301");
        !          3368:           break; // acute
        !          3369:         case 168 :
        !          3370:           buf.append("\u0308");
        !          3371:           break; // dieresis
        !          3372:         case 8800 :
        !          3373:           buf.append("\u1e6d");
        !          3374:           break; // t underdot
        !          3375:         case 198 :
        !          3376:           buf.append("\u00c6");
        !          3377:           break; // AE
        !          3378:         case 216 :
        !          3379:           buf.append("\u014d");
        !          3380:           break; // o macron
        !          3381:         case 8734 :
        !          3382:           buf.append("\u0129");
        !          3383:           break; // i tilde
        !          3384:         case 177 :
        !          3385:           buf.append("\u00b1");
        !          3386:           break; // plusminus
        !          3387:         case 165 :
        !          3388:           buf.append("\u012b");
        !          3389:           break; // i macron
        !          3390:         case 181 :
        !          3391:           buf.append("\u1e43");
        !          3392:           break; // m underdot
        !          3393:         case 8706 :
        !          3394:           buf.append("\u1e0d");
        !          3395:           break; // d underdot
        !          3396:         case 8721 :
        !          3397:           buf.append("\u1e63");
        !          3398:           break; // s underdot
        !          3399:         case 960 :
        !          3400:           buf.append("\u017a");
        !          3401:           break; // z acute
        !          3402:         case 8747 :
        !          3403:           buf.append("\u1e45");
        !          3404:           break; // n overdot
        !          3405:         case 937 :
        !          3406:           buf.append("\u0169");
        !          3407:           break; // u tilde
        !          3408:         case 230 :
        !          3409:           buf.append("\u00e6");
        !          3410:           break; // ae
        !          3411:         case 248 :
        !          3412:           buf.append("\u00f8");
        !          3413:           break; // oslash
        !          3414:         case 191 :
        !          3415:           buf.append("\u0304\u0306");
        !          3416:           break; // macron breve
        !          3417:         case 172 :
        !          3418:           buf.append("\u1e37");
        !          3419:           break; // 
        !          3420:         case 8730 :
        !          3421:           buf.append("j\u0305");
        !          3422:           break; // j macron [does a single char exist?]
        !          3423:         case 402 :
        !          3424:           buf.append("\u0103");
        !          3425:           break; // a breve
        !          3426:         case 8776 :
        !          3427:           buf.append("\u016d");
        !          3428:           break; // u breve
        !          3429:         case 187 :
        !          3430:           buf.append("\u1e42");
        !          3431:           break; // M underdot
        !          3432:         case 8230 :
        !          3433:           buf.append("\u2026");
        !          3434:           break; // ellipsis
        !          3435:         case 192 :
        !          3436:           buf.append("\u00c0");
        !          3437:           break; // A grave
        !          3438:         case 195 :
        !          3439:           buf.append("\u00c3");
        !          3440:           break; // A tilde
        !          3441:         case 213 :
        !          3442:           buf.append("\u00d5");
        !          3443:           break; // O tilde
        !          3444:         case 338 :
        !          3445:           buf.append("m\u0306");
        !          3446:           break; // m breve
        !          3447:         case 339 :
        !          3448:           buf.append("\u0153");
        !          3449:           break; // oe
        !          3450:         case 8211 :
        !          3451:           buf.append("\u2013");
        !          3452:           break; // endash
        !          3453:         case 8212 :
        !          3454:           buf.append("\u2014");
        !          3455:           break; // emdash
        !          3456:         case 8220 :
        !          3457:           buf.append("\u201c");
        !          3458:           break; // quotedblleft
        !          3459:         case 8221 :
        !          3460:           buf.append("\u201d");
        !          3461:           break; // quotedblright
        !          3462:         case 8216 :
        !          3463:           buf.append("\u2018");
        !          3464:           break; // quoteleft
        !          3465:         case 8217 :
        !          3466:           buf.append("\u2019");
        !          3467:           break; // quoteright
        !          3468:         case 247 :
        !          3469:           buf.append("\u1e37");
        !          3470:           break; // l underring [actually underdot]
        !          3471:         case 9674 :
        !          3472:           buf.append("\u1e41");
        !          3473:           break; // m overdot
        !          3474:         case 255 :
        !          3475:           buf.append("n\u0306");
        !          3476:           break; // n breve
        !          3477:         case 376 :
        !          3478:           buf.append("\u00d7");
        !          3479:           break; // multiply
        !          3480:         case 8364 :
        !          3481:           buf.append("\u1e5b");
        !          3482:           break; // r underring [actually underdot]
        !          3483:         case 8249 :
        !          3484:           buf.append("\u1e44");
        !          3485:           break; // N overdot
        !          3486:         case 8250 :
        !          3487:           buf.append("\u1e62");
        !          3488:           break; // S underdot
        !          3489:         case 64257 :
        !          3490:           buf.append("\u1e24");
        !          3491:           break; // H underdot
        !          3492:         case 64258 :
        !          3493:           buf.append("\u1e0c");
        !          3494:           break; // D underdot
        !          3495:         case 8225 :
        !          3496:           buf.append("\u2021");
        !          3497:           break; // daggerdbl
        !          3498:         case 8218 :
        !          3499:           buf.append("\u1e36");
        !          3500:           break; // L underdot
        !          3501:         case 8222 :
        !          3502:           buf.append("\u0113");
        !          3503:           break; // e macron
        !          3504:         case 194 :
        !          3505:           buf.append("\u1e5f");
        !          3506:           break; // r underbar
        !          3507:         case 202 :
        !          3508:           buf.append("r\u0324");
        !          3509:           break; // r underdieresis
        !          3510:         case 193 :
        !          3511:           buf.append("\u012a");
        !          3512:           break; // I macron
        !          3513:         case 203 :
        !          3514:           buf.append("\u016b");
        !          3515:           break; // u macron
        !          3516:         case 200 :
        !          3517:           buf.append("\u1e6c");
        !          3518:           break; // T underdot
        !          3519:         case 205 :
        !          3520:           buf.append("\u1e64");
        !          3521:           break; // S acute
        !          3522:         case 206 :
        !          3523:           buf.append("\u2020");
        !          3524:           break; // dagger
        !          3525:         case 207 :
        !          3526:           buf.append("\u0115");
        !          3527:           break; // e breve
        !          3528:         case 204 :
        !          3529:           buf.append("\u014f");
        !          3530:           break; // o breve
        !          3531:         case 211 :
        !          3532:           buf.append("\u0100");
        !          3533:           break; // A macron
        !          3534:         case 212 :
        !          3535:           buf.append("\u1e46");
        !          3536:           break; // N underdot
        !          3537:         case 210 :
        !          3538:           buf.append("\u1e3b");
        !          3539:           break; // l underbar
        !          3540:         case 218 :
        !          3541:           buf.append("\u016a");
        !          3542:           break; // U macron
        !          3543:         case 219 :
        !          3544:           buf.append("\u0179");
        !          3545:           break; // Z acute
        !          3546:         case 217 :
        !          3547:           buf.append("\u1e5a");
        !          3548:           break; // R underdot
        !          3549:         case 305 :
        !          3550:           buf.append("\u0131");
        !          3551:           break; // dotlessi
        !          3552:         case 710 :
        !          3553:           buf.append("\u1e47");
        !          3554:           break; // n underdot
        !          3555:         case 732 :
        !          3556:           buf.append("\u1e49");
        !          3557:           break; // n underbar
        !          3558:         case 175 :
        !          3559:           buf.append("\u0304");
        !          3560:           break; // macron
        !          3561:         case 728 :
        !          3562:           buf.append("\u0306");
        !          3563:           break; // breve
        !          3564:         case 729 :
        !          3565:           buf.append("\u1e25");
        !          3566:           break; // h underdot
        !          3567:         case 730 :
        !          3568:           buf.append("\u012d");
        !          3569:           break; // i breve
        !          3570:         case 184 :
        !          3571:           buf.append("\u0327");
        !          3572:           break; // cedilla
        !          3573:         case 733 :
        !          3574:           buf.append("\u030b");
        !          3575:           break; // hungarumlaut
        !          3576:         case 731 :
        !          3577:           buf.append("\u0328");
        !          3578:           break; // ogonek
        !          3579:         case 711 :
        !          3580:           buf.append("\u030c");
        !          3581:           break; // caron
        !          3582:         case 199 :
        !          3583:           buf.append("\u012b\u0303");
        !          3584:           break; // imacron tilde
        !          3585:         case 8226 :
        !          3586:           buf.append("\u1e5d");
        !          3587:           break; // runderdot macron
        !          3588:         case 8482 :
        !          3589:           buf.append("\u016b\0306");
        !          3590:           break; // umacron breve
        !          3591:         case 8804 :
        !          3592:           buf.append("\u0101\u0301");
        !          3593:           break; // amacron acute
        !          3594:         case 8805 :
        !          3595:           buf.append("\u016b\u0301");
        !          3596:           break; // umacron acute
        !          3597:         case 8719 :
        !          3598:           buf.append("\u0113\u0301");
        !          3599:           break; // emacron acute
        !          3600:         case 170 :
        !          3601:           buf.append("\u0113\u0300");
        !          3602:           break; // emacron breve
        !          3603:         case 186 :
        !          3604:           buf.append("\u014d\u0300");
        !          3605:           break; // omacron breve
        !          3606:         case 161 :
        !          3607:           buf.append("\u0101\u0306");
        !          3608:           break; // amacron breve
        !          3609:         case 8710 :
        !          3610:           buf.append("\u0101\u0303");
        !          3611:           break; // amacron tilde
        !          3612:         case 171 :
        !          3613:           buf.append("\u012b\u0301");
        !          3614:           break; // imacron acute
        !          3615:         case 8260 :
        !          3616:           buf.append("\u1e00");
        !          3617:           break; // runderdotmacron acute
        !          3618:         case 183 :
        !          3619:           buf.append("\u1e5b\u0301");
        !          3620:           break; // runderdot acute
        !          3621:         case 8240 :
        !          3622:           buf.append("\u012b\u0306");
        !          3623:           break; // imacron breve
        !          3624:         case 63743 :
        !          3625:           buf.append("\u016b\u0303");
        !          3626:           break; // umacron tilde
        !          3627:         default :
        !          3628:           buf.append(c);
        !          3629:           break;
1.58      rogo     3630:       }
                   3631:     }
                   3632:     return buf.toString();
                   3633:   }
1.65    ! rogo     3634:   public static ConversionProperties getFieldNamesAndDestTableName(String create, String query, String tableName)
1.64      rogo     3635:   {
                   3636:     String[] fieldNames = null;
                   3637:     String destTableName = null;
                   3638:     // determine destTableName from createStatement or from source table name
                   3639:     if (!create.equals(""))
                   3640:     {
                   3641:       int fromIndex = create.toLowerCase().indexOf("table") + 5;
                   3642:       int toIndex = create.indexOf("(");
                   3643:       int endIndex = create.indexOf(")", toIndex);
                   3644: 
                   3645:       destTableName = create.substring(fromIndex, toIndex).replaceAll(beanDest.getQC(), "").trim();
                   3646:       System.out.println("destTable " + destTableName);
                   3647:       // retrieve field_names from select statement
                   3648:       // TODO problem with different fieldNames in create statement will overwrite them
                   3649:       if (query.indexOf("*") < 0)
                   3650:       {
                   3651:         int selectEndIndex = query.indexOf("from");
                   3652:         StringTokenizer tokenizer = new StringTokenizer(query.substring(6, selectEndIndex), ",");
                   3653:         int numFields = tokenizer.countTokens();
                   3654:         fieldNames = new String[numFields];
                   3655:         int fieldIndex = 0;
                   3656:         while (tokenizer.hasMoreTokens())
                   3657:         {
                   3658:           String fieldName = tokenizer.nextToken().trim();
                   3659:           fieldNames[fieldIndex] = convertText(fieldName);
                   3660:           System.out.println(fieldNames[fieldIndex]);
                   3661:           fieldIndex++;
                   3662:         }
1.58      rogo     3663: 
1.64      rogo     3664:       } else
                   3665:       {
                   3666:         // use create statement for field names
                   3667:         StringTokenizer tokenizer = new StringTokenizer(create.substring(toIndex + 1, endIndex), ",");
                   3668:         int numFields = tokenizer.countTokens();
                   3669:         fieldNames = new String[numFields];
                   3670:         int fieldIndex = 0;
                   3671:         while (tokenizer.hasMoreTokens())
                   3672:         {
                   3673:           String fieldName = tokenizer.nextToken().trim();
                   3674:           int index = fieldName.lastIndexOf(" ");
                   3675:           fieldNames[fieldIndex] = fieldName.substring(0, index);
                   3676:           System.out.println(fieldNames[fieldIndex]);
                   3677:           fieldIndex++;
                   3678:         }
                   3679:       }
                   3680:     } else
                   3681:     {
                   3682:       destTableName = convertText(tableName);
1.58      rogo     3683: 
1.64      rogo     3684:       // retrieve field_names from select statement
                   3685:       if (query.indexOf("*") < 0)
                   3686:       {
                   3687:         int selectEndIndex = query.indexOf("from");
                   3688:         StringTokenizer tokenizer = new StringTokenizer(query.substring(6, selectEndIndex), ",");
                   3689:         int numFields = tokenizer.countTokens();
                   3690:         fieldNames = new String[numFields];
                   3691:         int fieldIndex = 0;
                   3692:         while (tokenizer.hasMoreTokens())
                   3693:         {
                   3694:           String fieldName = tokenizer.nextToken().trim();
                   3695:           fieldNames[fieldIndex] = convertText(fieldName);
1.65    ! rogo     3696:           // System.out.println("field "+ fieldNames[fieldIndex]);
1.64      rogo     3697:           fieldIndex++;
                   3698:         }
                   3699: 
                   3700:       } else
                   3701:       {
                   3702:         Vector fieldNamesVec = bean.getColumnNames();
                   3703:         fieldNames = new String[fieldNamesVec.size()];
                   3704:         int fieldIndex = -1;
                   3705:         for (Iterator iter = fieldNamesVec.iterator(); iter.hasNext();)
                   3706:         {
                   3707:           String element = (String) iter.next();
                   3708:           fieldNames[++fieldIndex] = bean.getQC() + convertText(element) + bean.getQC();
1.65    ! rogo     3709:           // System.out.println("field " + fieldNames[fieldIndex]);
1.64      rogo     3710:         }
                   3711:       }
                   3712:     }
1.65    ! rogo     3713:     return new ConversionProperties(destTableName, fieldNames);
        !          3714:   }
        !          3715:   /**
        !          3716:    * creates an insert into statement for the specified table and given
        !          3717:    * field names 
        !          3718:    * @param destTableName
        !          3719:    * @param fieldNames
        !          3720:    * @return
        !          3721:    */
        !          3722:   public static StringBuffer createInsertCommand(String destTableName, String[] fieldNames)
        !          3723:   {
        !          3724:     StringBuffer command = new StringBuffer();
        !          3725:     command.append("INSERT  INTO ");
        !          3726:     command.append(beanDest.getQC());
        !          3727:     command.append(destTableName); //convertText((String) names.get(tbIndex)));
        !          3728:     command.append(beanDest.getQC());
        !          3729:     command.append(" (");
        !          3730:     for (int i = 0; i < fieldNames.length; i++)
        !          3731:     {
        !          3732:       command.append(fieldNames[i]);
        !          3733:       if (i < fieldNames.length - 1)
        !          3734:         command.append(",");
        !          3735:     }
        !          3736:     command.append(") ");
        !          3737: 
        !          3738:     command.append(" values ( ");
        !          3739:     // add a question marks for every field 
        !          3740:     for (int i = 0; i < bean.getColumnNames().size() - 1; ++i)
        !          3741:       command.append("?,");
        !          3742:     command.append("?)");
        !          3743:     return command;
        !          3744:   }
        !          3745:   public static StringBuffer createUpdateCommand(String destTableName, String[] fieldNames, String id)
        !          3746:   {
        !          3747:     StringBuffer command = new StringBuffer();
        !          3748: 
        !          3749:     command.append("UPDATE ");
        !          3750:     command.append(beanDest.getQC());
        !          3751:     command.append(destTableName);
        !          3752:     //command.append(convertText((String) names.get(tbIndex)));
        !          3753:     command.append(beanDest.getQC());
        !          3754:     command.append(" SET  ");
        !          3755: 
        !          3756:     int size = bean.getColumnNames().size();
        !          3757:     for (int i = 0; i < size - 1; ++i)
        !          3758:       command.append(fieldNames[i] + " = ? ,");
        !          3759:     command.append(fieldNames[size - 1] + " = ? ");
        !          3760:     command.append("WHERE " + id + " =  ?");
        !          3761:     return command;
        !          3762:   }
        !          3763:   public static StringBuffer createDeleteCommand(String destTableName, String idField)
        !          3764:   {
        !          3765:     StringBuffer command = new StringBuffer();
        !          3766: 
        !          3767:     command.append("DELETE FROM");
        !          3768:     command.append(beanDest.getQC());
        !          3769:     command.append(destTableName);
        !          3770:     //command.append(convertText((String) names.get(tbIndex)));
        !          3771:     command.append(beanDest.getQC());
        !          3772:     command.append("WHERE " + idField + " =  ?");
        !          3773:     return  command;
1.64      rogo     3774:   }
1.55      rogo     3775: }

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