Author: jfuerth
Date: Tue Feb 17 15:52:57 2009
New Revision: 2943

Modified:
   trunk/regress/ca/sqlpower/architect/ArchitectUtilsTest.java
   trunk/src/ca/sqlpower/architect/ArchitectUtils.java
   trunk/src/ca/sqlpower/architect/SourceObjectIntegrityWatcher.java
   trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
   trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java
   trunk/src/ca/sqlpower/architect/profile/AbstractProfileResult.java
   trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java
   trunk/src/ca/sqlpower/architect/swingui/DataMoverPanel.java
   trunk/src/ca/sqlpower/architect/swingui/PlayPen.java
   trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java
   trunk/src/ca/sqlpower/architect/swingui/action/ProfileAction.java
   trunk/src/ca/sqlpower/architect/swingui/table/ProfileTableModel.java

Log:
Moved a number of ArchitectUtils methods that are directly applicable to SQLObjects into the library-based SQLObjectUtils utility class so the library and other apps have access to them.

Modified: trunk/regress/ca/sqlpower/architect/ArchitectUtilsTest.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/ArchitectUtilsTest.java (original)
+++ trunk/regress/ca/sqlpower/architect/ArchitectUtilsTest.java Tue Feb 17 15:52:57 2009
@@ -215,14 +215,14 @@
         parentdb.addChild(sch);
         sch.addChild(t);

- assertEquals(parentdb, ArchitectUtils.getAncestor(t.getColumnsFolder(), SQLDatabase.class)); - assertEquals(sch, ArchitectUtils.getAncestor(t.getColumnsFolder(), SQLSchema.class)); - assertEquals(t, ArchitectUtils.getAncestor(t.getColumnsFolder(), SQLTable.class)); - assertEquals(t.getColumnsFolder(), ArchitectUtils.getAncestor(t.getColumnsFolder(), SQLTable.Folder.class)); - assertNull(ArchitectUtils.getAncestor(t.getColumnsFolder(), SQLCatalog.class)); + assertEquals(parentdb, SQLObjectUtils.getAncestor(t.getColumnsFolder(), SQLDatabase.class)); + assertEquals(sch, SQLObjectUtils.getAncestor(t.getColumnsFolder(), SQLSchema.class)); + assertEquals(t, SQLObjectUtils.getAncestor(t.getColumnsFolder(), SQLTable.class)); + assertEquals(t.getColumnsFolder(), SQLObjectUtils.getAncestor(t.getColumnsFolder(), SQLTable.Folder.class)); + assertNull(SQLObjectUtils.getAncestor(t.getColumnsFolder(), SQLCatalog.class));

         parentdb.removeChild(sch);
- assertNull(ArchitectUtils.getAncestor(t.getColumnsFolder(), SQLDatabase.class)); + assertNull(SQLObjectUtils.getAncestor(t.getColumnsFolder(), SQLDatabase.class));
     }

     public void testCreateTableWhenExisting() throws Exception {
@@ -235,7 +235,7 @@
         schem.addChild(tab);

         try {
-            ArchitectUtils.addSimulatedTable(db, "cat", "schem", "tab");
+            SQLObjectUtils.addSimulatedTable(db, "cat", "schem", "tab");
             fail("Should not have been allowed because table exists");
         } catch (SQLObjectException ex) {
             // expected

Modified: trunk/src/ca/sqlpower/architect/ArchitectUtils.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ArchitectUtils.java (original)
+++ trunk/src/ca/sqlpower/architect/ArchitectUtils.java Tue Feb 17 15:52:57 2009
@@ -22,10 +22,6 @@
 import java.io.IOException;
 import java.net.URL;
 import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;

 import javax.swing.JFileChooser;
@@ -34,13 +30,9 @@
 import org.apache.log4j.Logger;

 import ca.sqlpower.architect.swingui.ASUtils;
-import ca.sqlpower.sqlobject.SQLObjectException;
-import ca.sqlpower.sqlobject.SQLCatalog;
 import ca.sqlpower.sqlobject.SQLColumn;
-import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLObject;
-import ca.sqlpower.sqlobject.SQLSchema;
-import ca.sqlpower.sqlobject.SQLTable;
+import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.swingui.SPSUtils;
 import ca.sqlpower.util.ExceptionReport;

@@ -94,64 +86,14 @@
                else return o1.equals(o2);
        }

-       /**
- * Searches for all columns in the target database which are marked as having
-        * source columns in the given source database.
-        *
- * @param target The database to search. All columns of all tables in this database are searched. - * @param source The database to look for in the target database's columns. - * @return A list of all columns in the target database whose source database is the same - * as the given source object. Every item in the list will be of type SQLColumn.
-        */
- public static List<SQLColumn> findColumnsSourcedFromDatabase(SQLDatabase target, SQLDatabase source) throws SQLObjectException { - if (logger.isDebugEnabled()) logger.debug("Searching for dependencies on "+source+" in "+target);
-               List matches = new ArrayList();
-               Iterator it = target.getChildren().iterator();
-               while (it.hasNext()) {
-                       SQLObject so = (SQLObject) it.next();
- if (logger.isDebugEnabled()) logger.debug("-->Next target item is "+so.getClass().getName()+": "+so+" ("+so.getChildCount()+" children)");
-                       if (so instanceof SQLTable) {
-                               SQLTable t = (SQLTable) so;
-                               Iterator cit = t.getColumns().iterator();
-                               while (cit.hasNext()) {
-                                       Object next = cit.next();
- if (logger.isDebugEnabled()) logger.debug("---->Next item in columns list is a "+next.getClass().getName());
-                                       SQLColumn col = (SQLColumn) next;
- if (col.getSourceColumn() != null && source.equals(col.getSourceColumn().getParentTable().getParentDatabase())) {
-                                               matches.add(col);
-                                       }
-                               }
-                       }
-               }
-               return matches;
-       }
-
-       /**
- * Recursively count tables in the project, including ones that have not been
-        * expanded in the DBTree.
-        *
-        * @param source the source object (usually the database)
-        */
- public static int countTablesSnapshot(SQLObject so) throws SQLObjectException {
-               if (so instanceof SQLTable) {
-                       return 1;
-               } else {
-                       int count = 0;
-                       Iterator it = so.getChildren().iterator();
-                       while (it.hasNext()) {
-                               count += countTablesSnapshot((SQLObject) 
it.next());
-                       }
-                   return count;
-               }
-       }
-
-       /**
-        * Keep in mind that if you go after anything lower than
-        * SQLTable, you will invoke a potentially expensive
-        * populate() method multiple times.
-        *
-        * @param source the source object (usually the database)
-        */
+    /**
+ * Searches for all SQLObjects under a given starting point which are of the
+     * given type. Keep in mind that if you go after anything lower than
+ * SQLTable, you will invoke many potentially expensive populate() methods.
+     *
+     * @param source
+     *            the source object (usually the database)
+     */
        public static <T extends SQLObject>
List<T> findDescendentsByClass(SQLObject so, java.lang.Class<T> clazz, List<T> addTo)
        throws SQLObjectException {
@@ -181,30 +123,6 @@
        }

        /**
-        * Recursively count tables in the project, but only consider tables 
that
-        * have been expanded.
-        *
- * This might be undercounting a little bit because I think this suppresses
-        * the Target Database (playpen) entries.
-        *
-        * @param source the source object (usually the database)
-        */
-       public static int countTables(SQLObject so) throws SQLObjectException {
-               if (so instanceof SQLTable) {
-                       return 1;
- } else if ( (!so.allowsChildren()) || !(so.isPopulated()) || so.getChildren() == null) {
-                   return 0;
-               } else {
-                       int myCount = 0;
-                       Iterator it = so.getChildren().iterator();
-                       while (it.hasNext()) {
-                               myCount += countTables((SQLObject) it.next());
-                       }
-                       return myCount;
-               }
-       }
-
-       /**
      * Double quotes input string for CSV if needed:
      * string contains ", \n, \r, ','
      */
@@ -240,192 +158,6 @@
     }

     /**
- * Returns the parent database of <tt>so</tt> or <tt>null</tt> if <tt>so</tt>
-     * doesn't have an ancestor whose class is <tt>ancestorType</tt>.
-     *
-     * @param so The object for whose ancestor to look. (Thanks, Winston).
- * @return The nearest ancestor of type ancestorType, or null if no such ancestor exists.
-     */
- public static <T extends SQLObject> T getAncestor(SQLObject so, Class<T> ancestorType) {
-        while (so != null) {
-            if (so.getClass().equals(ancestorType)) return (T) so;
-            so = so.getParent();
-        }
-        return null;
-    }
-
-    /**
-     * Returns the object that contains tables in the given database.
-     * Depending on platform, this could be a SQLDatabase, a SQLCatalog,
-     * or a SQLSchema.  A null catName or schemName argument means that
-     * catalogs or schemas are not present in the given database.
-     * <p>
-     * Note, all comparisons are done case-insensitively.
-     *
-     * @param db The database to retrieve the table container from.
- * @param catName The name of the catalog to retrieve. Must be null iff the
-     * database does not have catalogs.
- * @param schemaName The name of the schema to retrieve. Must be null iff the
-     * database does not have schemas.
- * @return The appropriate SQLObject under db that is a parent of SQLTable objects,
-     * given the catalog and schema name arguments.
-     * @throws SQLObjectException
-     */
- public static SQLObject getTableContainer(SQLDatabase db, String catName, String schemaName) throws SQLObjectException {
-        db.populate();
- logger.debug("Looking for catalog="+catName+", schema="+schemaName+" in db "+db);
-        if (db.getChildType() == SQLTable.class) {
-            if (catName != null || schemaName != null) {
- throw new IllegalArgumentException("Catalog or Schema name was given but neither is necessary.");
-            }
-            return db;
-        } else if (db.getChildType() == SQLSchema.class) {
-           if (catName != null) {
- throw new IllegalArgumentException("Catalog name was given but is not necessary.");
-           }
-           if (schemaName == null) {
- throw new IllegalArgumentException("Schema name was expected but none was given.");
-           }
-
-           return (SQLSchema) db.getChildByNameIgnoreCase(schemaName);
-        } else if (db.getChildType() == SQLCatalog.class) {
-            if (catName == null) {
- throw new IllegalArgumentException("Catalog name was expected but none was given.");
-            }
-            SQLCatalog tempCat = db.getCatalogByName(catName);
-
-            if (tempCat == null) return null;
-
-            tempCat.populate();
-
- logger.debug("Found catalog "+catName+". Child Type="+tempCat.getChildType());
-            if (tempCat.getChildType() == SQLSchema.class) {
-                if (schemaName == null) {
- throw new IllegalArgumentException("Schema name was expected but none was given.");
-                }
-
- return (SQLSchema) tempCat.getChildByNameIgnoreCase(schemaName);
-            }
-
-            if (schemaName != null) {
- throw new IllegalArgumentException("Schema name was given but is not necessary.");
-            }
-
-            return tempCat;
-        } else if (db.getChildType() == null) {
-            // special case: there are no children of db
-            logger.debug("Database "+db+" has no children");
-            return null;
-        } else {
- throw new IllegalStateException("Unknown database child type: " + db.getChildType());
-        }
-    }
-
-    /**
- * Returns true if and only if the given set of arguments would result in a - * successful call to {...@link #addSimulatedTable(SQLDatabase, String, String, String)}.
-     * See that method's documentation for the meaning of the arguments.
-     *
- * @throws SQLObjectException if populating any of the relevant SQLObjects fails.
-     */
- public static boolean isCompatibleWithHierarchy(SQLDatabase db, String catalog, String schema, String name) throws SQLObjectException {
-        SQLObject schemaContainer;
-        if ( catalog != null){
-            if (db.isCatalogContainer()){
-                schemaContainer = db.getCatalogByName(catalog);
-                if (schemaContainer == null) {
-                    return true;
-                }
-            } else {
-                return false;
-            }
-        } else {
-            schemaContainer = db;
-        }
-
-        SQLObject tableContainer;
-        if (schema != null){
-            if (schemaContainer.getChildType() == SQLSchema.class){
-                tableContainer = schemaContainer.getChildByName(schema);
-                if (tableContainer == null) {
-                    return true;
-                }
-            } else if (schemaContainer.getChildType() == null) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            tableContainer = schemaContainer;
-        }
-
-        if (name != null) {
- if (tableContainer.getChildType() == null || tableContainer.getChildType() == SQLTable.class){
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            return false;
-        }
-    }
-
-    /**
- * Creates a SQLTable in the given database, optionally under a catalog and/or schema.
-     *
-     * @param db The database to create the table in.
- * @param catalog The catalog that the table (or the table's schema) should be in.
-     * If null, it is assumed the given database doesn't have catalogs.
- * @param schema The schema that the table should be in. If null, it is assumed the
-     * given database doesn't have schemas.
-     * @param name The name of the table to create.
-     * @return The table that was created
- * @throws SQLObjectException If you specify catalog or schema for a database that doesn't - * support catalogs or schemas; also if the database uses catalogs and schemas but you
-     * fail to provide them.
-     */
- public static SQLTable addSimulatedTable(SQLDatabase db, String catalog, String schema, String name) throws SQLObjectException {
-        if (db.getTableByName(catalog, schema, name) != null) {
- throw new SQLObjectException("The table "+catalog+"."+schema+"."+name+" already exists");
-        }
-        SQLObject schemaContainer;
-        if (catalog != null) {
-            if (!db.isCatalogContainer()) {
- throw new SQLObjectException("You tried to add a table with a catalog ancestor to a database that doesn't support catalogs.");
-            }
-            schemaContainer = db.getCatalogByName(catalog);
-            if (schemaContainer == null) {
-                schemaContainer = new SQLCatalog(db, catalog, true);
-                db.addChild(schemaContainer);
-            }
-        } else {
-            schemaContainer = db;
-        }
-
-        SQLObject tableContainer;
-        if (schema != null) {
- Class<? extends SQLObject> childType = schemaContainer.getChildType();
-            if ( !(childType == null || childType == SQLSchema.class) ) {
-                throw new SQLObjectException(
-                        "The schema container ("+schemaContainer+
- ") can't actually contain children of type SQLSchema.");
-            }
-            tableContainer = schemaContainer.getChildByName(schema);
-            if (tableContainer == null) {
- tableContainer = new SQLSchema(schemaContainer, schema, true);
-                schemaContainer.addChild(tableContainer);
-            }
-        } else {
-            tableContainer = schemaContainer;
-        }
-
- SQLTable newTable = new SQLTable(tableContainer, name, null, "TABLE", true);
-        tableContainer.addChild(newTable);
-
-        return newTable;
-    }
-
-    /**
      * Checks if the definitions of two columns are materially different.
      * Some data types (for example, DECIMAL and NUMERIC) are essentially
      * the same.  Also, the precision and scale values on DATE columns are
@@ -500,58 +232,6 @@
         } else {
             return type;
         }
-    }
-
-    /**
-     * Finds the nearest common ancestor of all SQLObjects passed in. For
- * example, if a bunch of columns from the same table are passed in, this - * method will return that table's columns folder. If a bunch of columns
-     * from different tables in the same schema are passed in, this method
-     * returns the database, catalog, or schema the tables belong to.
-     *
-     * @param items The items to find the common ancestor of
-     * @return
-     */
- public static SQLObject findCommonAncestor(Collection<? extends SQLObject> items) {
-
-        // first build up the full ancestory of one randomly chosen item
- List<SQLObject> commonAncestors = ancestorList(items.iterator().next());
-        logger.debug("Initial ancestor list: " + commonAncestors);
-
- // now prune the ancestor list to the largest common prefix with each item
-        for (SQLObject item : items) {
-            List<SQLObject> itemAncestors = ancestorList(item);
-            logger.debug("       Comparing with: " + itemAncestors);
-
-            Iterator<SQLObject> cit = commonAncestors.iterator();
-            Iterator<SQLObject> iit = itemAncestors.iterator();
-            while (cit.hasNext() && iit.hasNext()) {
-                if (cit.next() != iit.next()) {
-                    cit.remove();
-                    break;
-                }
-            }
-
- // remove all remaining items in the common list because they're not in common with this item
-            while (cit.hasNext()) {
-                cit.next();
-                cit.remove();
-            }
-            logger.debug("     After this prune: " + commonAncestors);
-        }
-
- SQLObject commonAncestor = commonAncestors.get(commonAncestors.size() - 1);
-        logger.debug("Returning: " + commonAncestor);
-        return commonAncestor;
-    }
-
-    private static List<SQLObject> ancestorList(SQLObject so) {
-        List<SQLObject> ancestors = new LinkedList<SQLObject>();
-        while (so != null) {
-            ancestors.add(0, so);
-            so = so.getParent();
-        }
-        return ancestors;
     }

     /**

Modified: trunk/src/ca/sqlpower/architect/SourceObjectIntegrityWatcher.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/SourceObjectIntegrityWatcher.java (original) +++ trunk/src/ca/sqlpower/architect/SourceObjectIntegrityWatcher.java Tue Feb 17 15:52:57 2009
@@ -9,6 +9,7 @@
 import ca.sqlpower.sqlobject.SQLObject;
 import ca.sqlpower.sqlobject.SQLObjectPreEvent;
 import ca.sqlpower.sqlobject.SQLObjectPreEventListener;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.util.UserPrompter;
 import ca.sqlpower.util.UserPrompter.UserPromptResponse;
 import ca.sqlpower.util.UserPrompterFactory.UserPromptType;
@@ -36,7 +37,7 @@
         for (SQLObject so : e.getChildren()) {
             SQLDatabase db = (SQLDatabase) so;
             try {
- List<SQLColumn> refs = ArchitectUtils.findColumnsSourcedFromDatabase(session.getTargetDatabase(), db); + List<SQLColumn> refs = SQLObjectUtils.findColumnsSourcedFromDatabase(session.getTargetDatabase(), db);
                 if (!refs.isEmpty()) {
UserPromptResponse response = up.promptUser(refs.size(), db.getName());
                     if (response == UserPromptResponse.OK) {

Modified: trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java        
(original)
+++ trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java Tue Feb 17 15:52:57 2009
@@ -42,6 +42,7 @@
 import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLIndex;
 import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLRelationship;
 import ca.sqlpower.sqlobject.SQLSequence;
 import ca.sqlpower.sqlobject.SQLTable;
@@ -208,7 +209,7 @@

                try {
                        if (allowConnection && tableList.size() > 0) {
- SQLDatabase parentDb = ArchitectUtils.getAncestor(tableList.get(0), SQLDatabase.class); + SQLDatabase parentDb = SQLObjectUtils.getAncestor(tableList.get(0), SQLDatabase.class);
                                con = parentDb.getConnection();
                        } else {
                                con = null;

Modified: trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java  (original)
+++ trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java Tue Feb 17 15:52:57 2009
@@ -44,6 +44,7 @@
 import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.SQLCatalog;
 import ca.sqlpower.sqlobject.SQLDatabase;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLSchema;
 import ca.sqlpower.sqlobject.SQLTable;

@@ -337,9 +338,9 @@
             String cat = qualifier.substring(0, qualifier.indexOf('.'));
String schema = qualifier.substring(qualifier.indexOf('.') + 1);
             return database.getTableByName(cat, schema, name);
- } else if (ArchitectUtils.isCompatibleWithHierarchy(database, qualifier, null, name)) { + } else if (SQLObjectUtils.isCompatibleWithHierarchy(database, qualifier, null, name)) {
             return database.getTableByName(qualifier, null, name);
- } else if (ArchitectUtils.isCompatibleWithHierarchy(database, null, qualifier, name)) { + } else if (SQLObjectUtils.isCompatibleWithHierarchy(database, null, qualifier, name)) {
             return database.getTableByName(null, qualifier, name);
         } else {
             return null;

Modified: trunk/src/ca/sqlpower/architect/profile/AbstractProfileResult.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/profile/AbstractProfileResult.java (original) +++ trunk/src/ca/sqlpower/architect/profile/AbstractProfileResult.java Tue Feb 17 15:52:57 2009
@@ -23,13 +23,13 @@

 import org.apache.log4j.Logger;

-import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.profile.event.ProfileResultEvent;
 import ca.sqlpower.architect.profile.event.ProfileResultListener;
 import ca.sqlpower.sqlobject.SQLCatalog;
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLSchema;
 import ca.sqlpower.sqlobject.SQLTable;

@@ -157,8 +157,8 @@
         SQLObject so1, so2;

         // database name
-        so1 = ArchitectUtils.getAncestor(po, SQLDatabase.class);
-        so2 = ArchitectUtils.getAncestor(opo, SQLDatabase.class);
+        so1 = SQLObjectUtils.getAncestor(po, SQLDatabase.class);
+        so2 = SQLObjectUtils.getAncestor(opo, SQLDatabase.class);
         if (so1 == null && so2 != null) diff = -1;
         else if (so1 != null && so2 == null) diff = 1;
else if (so1 != null && so2 != null) diff = so1.getName().compareTo(so2.getName());
@@ -166,8 +166,8 @@
         if (diff != 0) return diff;

         // catalog name
-        so1 = ArchitectUtils.getAncestor(po, SQLCatalog.class);
-        so2 = ArchitectUtils.getAncestor(opo, SQLCatalog.class);
+        so1 = SQLObjectUtils.getAncestor(po, SQLCatalog.class);
+        so2 = SQLObjectUtils.getAncestor(opo, SQLCatalog.class);
         if (so1 == null && so2 != null) diff = -1;
         else if (so1 != null && so2 == null) diff = 1;
else if (so1 != null && so2 != null) diff = so1.getName().compareTo(so2.getName());
@@ -175,8 +175,8 @@
         if (diff != 0) return diff;

         // schema name
-        so1 = ArchitectUtils.getAncestor(po, SQLSchema.class);
-        so2 = ArchitectUtils.getAncestor(opo, SQLSchema.class);
+        so1 = SQLObjectUtils.getAncestor(po, SQLSchema.class);
+        so2 = SQLObjectUtils.getAncestor(opo, SQLSchema.class);
         if (so1 == null && so2 != null) diff = -1;
         else if (so1 != null && so2 == null) diff = 1;
else if (so1 != null && so2 != null) diff = so1.getName().compareTo(so2.getName());
@@ -184,8 +184,8 @@
         if (diff != 0) return diff;

         // table name
-        so1 = ArchitectUtils.getAncestor(po, SQLTable.class);
-        so2 = ArchitectUtils.getAncestor(opo, SQLTable.class);
+        so1 = SQLObjectUtils.getAncestor(po, SQLTable.class);
+        so2 = SQLObjectUtils.getAncestor(opo, SQLTable.class);
         if (so1 == null && so2 != null) diff = -1;
         else if (so1 != null && so2 == null) diff = 1;
else if (so1 != null && so2 != null) diff = so1.getName().compareTo(so2.getName());
@@ -193,8 +193,8 @@
         if (diff != 0) return diff;

         // column name
-        so1 = ArchitectUtils.getAncestor(po, SQLColumn.class);
-        so2 = ArchitectUtils.getAncestor(opo, SQLColumn.class);
+        so1 = SQLObjectUtils.getAncestor(po, SQLColumn.class);
+        so2 = SQLObjectUtils.getAncestor(opo, SQLColumn.class);
         if (so1 == null && so2 != null) diff = -1;
         else if (so1 != null && so2 == null) diff = 1;
else if (so1 != null && so2 != null) diff = so1.getName().compareTo(so2.getName());
@@ -232,19 +232,19 @@
         SQLObject po = getProfiledObject();
         SQLObject so;

-        so = ArchitectUtils.getAncestor(po, SQLDatabase.class);
+        so = SQLObjectUtils.getAncestor(po, SQLDatabase.class);
         if (so != null) hash *= so.getName().hashCode();

-        so = ArchitectUtils.getAncestor(po, SQLCatalog.class);
+        so = SQLObjectUtils.getAncestor(po, SQLCatalog.class);
         if (so != null) hash *= so.getName().hashCode();

-        so = ArchitectUtils.getAncestor(po, SQLSchema.class);
+        so = SQLObjectUtils.getAncestor(po, SQLSchema.class);
         if (so != null) hash *= so.getName().hashCode();

-        so = ArchitectUtils.getAncestor(po, SQLTable.class);
+        so = SQLObjectUtils.getAncestor(po, SQLTable.class);
         if (so != null) hash *= so.getName().hashCode();

-        so = ArchitectUtils.getAncestor(po, SQLColumn.class);
+        so = SQLObjectUtils.getAncestor(po, SQLColumn.class);
         if (so != null) hash *= so.getName().hashCode();

         hash *= createEndTime;

Modified: trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java        
(original)
+++ trunk/src/ca/sqlpower/architect/swingui/ColumnEditPanel.java Tue Feb 17 15:52:57 2009
@@ -60,7 +60,6 @@
 import org.apache.log4j.Logger;

 import ca.sqlpower.architect.ArchitectSession;
-import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.ddl.DDLUtils;
 import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.SQLObjectRuntimeException;
@@ -567,7 +566,7 @@
     private List<String> updateModel() {
         logger.debug("Updating model"); //$NON-NLS-1$
         List<String> errors = new ArrayList<String>();
- SQLObject compoundEditRoot = ArchitectUtils.findCommonAncestor(columns); + SQLObject compoundEditRoot = SQLObjectUtils.findCommonAncestor(columns);
         logger.debug("Compound edit root is " + compoundEditRoot);
         try {
compoundEditRoot.startCompoundEdit(Messages.getString("ColumnEditPanel.compoundEditName")); //$NON-NLS-1$

Modified: trunk/src/ca/sqlpower/architect/swingui/DataMoverPanel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/DataMoverPanel.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/DataMoverPanel.java Tue Feb 17 15:52:57 2009
@@ -38,7 +38,6 @@
 import javax.swing.JTree;
 import javax.swing.tree.TreePath;

-import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.DepthFirstSearch;
 import ca.sqlpower.architect.ddl.DDLGenerator;
 import ca.sqlpower.architect.ddl.DDLStatement;
@@ -55,6 +54,7 @@
 import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLObject;
 import ca.sqlpower.sqlobject.SQLObjectRoot;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLSchema;
 import ca.sqlpower.sqlobject.SQLTable;
 import ca.sqlpower.swingui.SPSUtils;
@@ -254,7 +254,7 @@
                 destCatalogName, destSchemaName, destTableName);
         if (destTable == null) {
             needToCreate = true;
-            destTable = ArchitectUtils.addSimulatedTable(
+            destTable = SQLObjectUtils.addSimulatedTable(
                 destDB, destCatalogName, destSchemaName, destTableName);
         }


Modified: trunk/src/ca/sqlpower/architect/swingui/PlayPen.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/PlayPen.java        (original)
+++ trunk/src/ca/sqlpower/architect/swingui/PlayPen.java Tue Feb 17 15:52:57 2009
@@ -1518,7 +1518,7 @@
                                // first pass: figure out how much work we need 
to do...
                                while (soIt.hasNext() && !isCancelled()) {
                                        SQLObject so = soIt.next();
-                    tableCount += ArchitectUtils.countTablesSnapshot(so);
+                    tableCount += SQLObjectUtils.countTablesSnapshot(so);
                                }
                                jobSize = new Integer(tableCount);


Modified: trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java Tue Feb 17 15:52:57 2009
@@ -44,7 +44,6 @@
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;

-import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.ArchitectVersion;
 import ca.sqlpower.architect.CoreProject;
 import ca.sqlpower.architect.UnclosableInputStream;
@@ -77,6 +76,7 @@
 import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLIndex;
 import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLRelationship;
 import ca.sqlpower.sqlobject.SQLSchema;
 import ca.sqlpower.sqlobject.SQLTable;
@@ -630,9 +630,9 @@
             int pmMax = 0;
             pm.setMinimum(0);
             if (getSession().isSavingEntireSource()) {
- pmMax = ArchitectUtils.countTablesSnapshot((SQLObject) getSession().getSourceDatabases().getModel().getRoot()); + pmMax = SQLObjectUtils.countTablesSnapshot((SQLObject) getSession().getSourceDatabases().getModel().getRoot());
             } else {
- pmMax = ArchitectUtils.countTables((SQLObject) getSession().getSourceDatabases().getModel().getRoot()); + pmMax = SQLObjectUtils.countTables((SQLObject) getSession().getSourceDatabases().getModel().getRoot());
             }
logger.debug("Setting progress monitor maximum to "+pmMax); //$NON-NLS-1$
             pm.setMaximum(pmMax);

Modified: trunk/src/ca/sqlpower/architect/swingui/action/ProfileAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/action/ProfileAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/action/ProfileAction.java Tue Feb 17 15:52:57 2009
@@ -38,6 +38,7 @@
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLSchema;
 import ca.sqlpower.sqlobject.SQLTable;
 import ca.sqlpower.sqlobject.SQLTable.Folder;
@@ -96,55 +97,55 @@
else if ( tp.getLastPathComponent() instanceof SQLCatalog ) {
                     SQLCatalog cat = (SQLCatalog)tp.getLastPathComponent();
                     sqlObject.add(cat);
- SQLDatabase db = ArchitectUtils.getAncestor(cat,SQLDatabase.class); + SQLDatabase db = SQLObjectUtils.getAncestor(cat,SQLDatabase.class);
                     if ( db != null && sqlObject.contains(db))
                         sqlObject.remove(db);
} else if ( tp.getLastPathComponent() instanceof SQLSchema ) {
                     SQLSchema sch = (SQLSchema)tp.getLastPathComponent();
                     sqlObject.add(sch);

- SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); + SQLCatalog cat = SQLObjectUtils.getAncestor(sch,SQLCatalog.class);
                     if ( cat != null && sqlObject.contains(cat))
                         sqlObject.remove(cat);
- SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); + SQLDatabase db = SQLObjectUtils.getAncestor(sch,SQLDatabase.class);
                     if ( db != null && sqlObject.contains(db))
                         sqlObject.remove(db);
} else if ( tp.getLastPathComponent() instanceof SQLTable ) {
                     SQLTable tab = (SQLTable)tp.getLastPathComponent();
                     sqlObject.add(tab);

- SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); + SQLSchema sch = SQLObjectUtils.getAncestor(tab,SQLSchema.class);
                     if ( sch != null && sqlObject.contains(sch))
                         sqlObject.remove(sch);
- SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); + SQLCatalog cat = SQLObjectUtils.getAncestor(sch,SQLCatalog.class);
                     if ( cat != null && sqlObject.contains(cat))
                         sqlObject.remove(cat);
- SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); + SQLDatabase db = SQLObjectUtils.getAncestor(sch,SQLDatabase.class);
                     if ( db != null && sqlObject.contains(db))
                         sqlObject.remove(db);
} else if ( tp.getLastPathComponent() instanceof SQLTable.Folder ) { - SQLTable tab = ArchitectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class); + SQLTable tab = SQLObjectUtils.getAncestor((Folder)tp.getLastPathComponent(),SQLTable.class);
                     sqlObject.add(tab);
- SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); + SQLSchema sch = SQLObjectUtils.getAncestor(tab,SQLSchema.class);
                     if ( sch != null && sqlObject.contains(sch))
                         sqlObject.remove(sch);
- SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); + SQLCatalog cat = SQLObjectUtils.getAncestor(sch,SQLCatalog.class);
                     if ( cat != null && sqlObject.contains(cat))
                         sqlObject.remove(cat);
- SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); + SQLDatabase db = SQLObjectUtils.getAncestor(sch,SQLDatabase.class);
                     if ( db != null && sqlObject.contains(db))
                         sqlObject.remove(db);

} else if ( tp.getLastPathComponent() instanceof SQLColumn ) { SQLTable tab = ((SQLColumn)tp.getLastPathComponent()).getParentTable();
                     sqlObject.add((SQLColumn)tp.getLastPathComponent());
- SQLSchema sch = ArchitectUtils.getAncestor(tab,SQLSchema.class); + SQLSchema sch = SQLObjectUtils.getAncestor(tab,SQLSchema.class);
                     if ( sch != null && sqlObject.contains(sch))
                         sqlObject.remove(sch);
- SQLCatalog cat = ArchitectUtils.getAncestor(sch,SQLCatalog.class); + SQLCatalog cat = SQLObjectUtils.getAncestor(sch,SQLCatalog.class);
                     if ( cat != null && sqlObject.contains(cat))
                         sqlObject.remove(cat);
- SQLDatabase db = ArchitectUtils.getAncestor(sch,SQLDatabase.class); + SQLDatabase db = SQLObjectUtils.getAncestor(sch,SQLDatabase.class);
                     if ( db != null && sqlObject.contains(db))
                         sqlObject.remove(db);


Modified: trunk/src/ca/sqlpower/architect/swingui/table/ProfileTableModel.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/table/ProfileTableModel.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/table/ProfileTableModel.java Tue Feb 17 15:52:57 2009
@@ -27,7 +27,6 @@

 import org.apache.log4j.Logger;

-import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.ddl.DDLGenerator;
 import ca.sqlpower.architect.ddl.DDLUtils;
 import ca.sqlpower.architect.profile.ColumnProfileResult;
@@ -43,6 +42,7 @@
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.sqlobject.SQLDatabase;
 import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.sqlobject.SQLObjectUtils;
 import ca.sqlpower.sqlobject.SQLSchema;
 import ca.sqlpower.sqlobject.SQLTable;

@@ -133,13 +133,13 @@

         switch(column) {
         case DATABASE:
-            return ArchitectUtils.getAncestor(col,SQLDatabase.class);
+            return SQLObjectUtils.getAncestor(col,SQLDatabase.class);
         case CATALOG:
-            return ArchitectUtils.getAncestor(col,SQLCatalog.class);
+            return SQLObjectUtils.getAncestor(col,SQLCatalog.class);
         case  SCHEMA:
-            return ArchitectUtils.getAncestor(col,SQLSchema.class);
+            return SQLObjectUtils.getAncestor(col,SQLSchema.class);
         case TABLE:
-            return ArchitectUtils.getAncestor(col,SQLTable.class);
+            return SQLObjectUtils.getAncestor(col,SQLTable.class);
         case COLUMN:
             return col;
         case RUNDATE:

Reply via email to