--- FM2SQL/Attic/Convert.java 2004/08/05 11:17:10 1.68 +++ FM2SQL/Attic/Convert.java 2004/08/06 11:15:41 1.69 @@ -31,9 +31,9 @@ import java.sql.Statement; import java.sql.Types; import java.text.ParseException; import java.util.ArrayList; +import java.util.Hashtable; import java.util.Iterator; import java.util.List; -import java.util.Properties; import java.util.StringTokenizer; import java.util.TreeSet; import java.util.Vector; @@ -41,8 +41,34 @@ import java.util.Vector; import com.exploringxml.xml.Node; import com.exploringxml.xml.Xparse; + class Convert { + /**Helper class for index creation + * @author rogo + * + */ + public static class IndexList extends Vector + { + public String toString() + { + StringBuffer buff = new StringBuffer(1000); + int count = 0; + for (Iterator iter = this.iterator(); iter.hasNext();) + { + String element = (String) iter.next(); + if (count < elementCount-1) + { + buff.append(element).append(", "); + count++; + } else + buff.append(element); + + } + + return buff.toString(); + } + } static DBBean bean = new DBBean(); static DBBean beanDest = new DBBean(); @@ -1127,6 +1153,7 @@ class Convert Vector selects = new Vector(); Vector creates = new Vector(); Vector ids = new Vector(); + Vector indexListVec= new Vector(); String delimiter = "|"; int mode = -1; @@ -1146,6 +1173,7 @@ class Convert selects = new Vector(); creates = new Vector(); ids = new Vector(); + indexListVec= new Vector(); // parse dataBase Node node = root.find("convert/source/database/url", new int[] { 1, 1, i, 1 }); Node node1 = root.find("convert/source/database/user", new int[] { 1, 1, i, 1, 1 }); @@ -1220,6 +1248,8 @@ class Convert String name = (String) node4.attributes.get("name"); String layout = (String) node4.attributes.get("layout"); String id = (String) node4.attributes.get("id"); + String indexList = (String) node4.attributes.get("indexList"); + System.out.println("id was " + id); if (name == null) throw new Error("parse error required table tag attribute name missing"); @@ -1227,11 +1257,15 @@ class Convert layout = ""; if (id == null) id = ""; + if(indexList==null) + indexList=""; if (name.equals("")) throw new Error("parse error table tag attribute must not be empty"); tables.add(name); layouts.add(layout); + ids.add(id); + indexListVec.add(indexList); String query = (node5 == null) ? "" : node5.getCharacters(); if (query.equals("")) System.err.println("Warning empty select tag or select tag missing !!"); @@ -1245,6 +1279,7 @@ class Convert } DataBase dataBase = new DataBase(database, tables, layouts, selects, creates, ids, mode); dataBase.delimiter = delimiter; + dataBase.buildIndexTable(indexListVec); databases.add(dataBase); } DBBean database = new DBBean(); @@ -1575,6 +1610,10 @@ class Convert Vector tables; Vector ids; String delimiter = "//"; + /** + * maps table name to index fields + */ + Hashtable htIndex = new Hashtable(); boolean useNormanToUnicodeMapper = false; final static int CONVERT_MODE = 1; @@ -1597,6 +1636,16 @@ class Convert this.bean.setIDVector(ids); } /** + * @param indexListVec + */ + public void buildIndexTable(Vector indexListVec) + { + for (int i = 0; i < tables.size(); i++) + { + fillIndexList((String)tables.get(i),(String)indexListVec.get(i)); + } + } + /** * writes the data contained in this object to the buffered writer * * @param buffr * @throws Exception @@ -1630,8 +1679,10 @@ class Convert String select = (String) selects.get(index); String create = (String) creates.get(index); String id = (String) ids.get(index); - - buffr.write("