Revision: 3952
Author: [email protected]
Date: Wed Sep 15 08:25:34 2010
Log: Reverting upgrade path changes and moves SnapshotCollection.java back to where it was. The core library jar now includes DomainCategory.
http://code.google.com/p/power-architect/source/detail?r=3952

Added:
 /trunk/src/main/java/ca/sqlpower/architect/SnapshotCollection.java
Deleted:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/SnapshotCollection.java
Modified:
 /trunk/build.xml
 /trunk/regress/ca/sqlpower/architect/ArchitectCoreDependencyTest.java
 /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectPersisterSuperConverter.java /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java /trunk/src/main/java/ca/sqlpower/architect/enterprise/SPObjectSnapshotHierarchyListener.java /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java

=======================================
--- /dev/null
+++ /trunk/src/main/java/ca/sqlpower/architect/SnapshotCollection.java Wed Sep 15 08:25:34 2010
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2010, SQL Power Group Inc.
+ *
+ * This file is part of SQL Power Architect.
+ *
+ * SQL Power Architect is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * SQL Power Architect is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package ca.sqlpower.architect;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import ca.sqlpower.architect.enterprise.DomainCategory;
+import ca.sqlpower.object.AbstractSPObject;
+import ca.sqlpower.object.SPObject;
+import ca.sqlpower.object.SPObjectSnapshot;
+import ca.sqlpower.object.annotation.Accessor;
+import ca.sqlpower.object.annotation.NonBound;
+import ca.sqlpower.object.annotation.NonProperty;
+import ca.sqlpower.object.annotation.Transient;
+import ca.sqlpower.sqlobject.UserDefinedSQLType;
+
+/**
+ * This object contains all of the {...@link SPObjectSnapshot}s and the copies of
+ * the objects they represent. This is mainly for convenience to keep them
+ * grouped together.
+ */
+public class SnapshotCollection extends AbstractSPObject {
+
+    /**
+     * Defines an absolute ordering of the child types of this class.
+     *
+ * IMPORTANT!: When changing this, ensure you maintain the order specified by {...@link #getChildren()}
+     */
+    @SuppressWarnings("unchecked")
+ public static final List<Class<? extends SPObject>> allowedChildTypes = Collections + .unmodifiableList(new ArrayList<Class<? extends SPObject>>(Arrays.asList(UserDefinedSQLType.class,
+                    DomainCategory.class, SPObjectSnapshot.class)));
+
+    /**
+ * The list of all snapshots in our current system. This includes types,
+     * domains, and domain category snapshots.
+     */
+ private final List<SPObjectSnapshot<?>> spobjectSnapshots = new ArrayList<SPObjectSnapshot<?>>();
+
+    /**
+ * List of all copies of {...@link UserDefinedSQLType}s that existed at some
+     * point in the system workspace and are in use in the project.
+     */
+ private final List<UserDefinedSQLType> udtSnapshots = new ArrayList<UserDefinedSQLType>();
+
+    /**
+ * List of all copies of {...@link DomainCategory} that existed at some point
+     * in the system workspace and are in use in the project.
+     */
+ private final List<DomainCategory> categorySnapshots = new ArrayList<DomainCategory>();
+
+    public SnapshotCollection() {
+        setName("Default snapshot collection");
+    }
+
+    @Override
+    protected void addChildImpl(SPObject child, int index) {
+        if (child instanceof SPObjectSnapshot<?>) {
+            addSPObjectSnapshot((SPObjectSnapshot<?>) child, index);
+        } else if (child instanceof UserDefinedSQLType) {
+            addUDTSnapshot((UserDefinedSQLType) child, index);
+        } else if (child instanceof DomainCategory) {
+            addCategorySnapshot((DomainCategory) child, index);
+        }
+    }
+
+ public void addCategorySnapshot(DomainCategory domainCategory, int index) {
+        categorySnapshots.add(index, domainCategory);
+        domainCategory.setParent(this);
+        fireChildAdded(DomainCategory.class, domainCategory, index);
+    }
+
+    public void addUDTSnapshot(UserDefinedSQLType sqlType, int index) {
+        udtSnapshots.add(index, sqlType);
+        sqlType.setParent(this);
+        fireChildAdded(UserDefinedSQLType.class, sqlType, index);
+    }
+
+    public boolean removeUDTSnapshot(UserDefinedSQLType child) {
+        int index = udtSnapshots.indexOf(child);
+        boolean removed = udtSnapshots.remove(child);
+        if (removed) {
+            fireChildRemoved(UserDefinedSQLType.class, child, index);
+            child.setParent(null);
+        }
+        return removed;
+    }
+
+    public boolean removeCategorySnapshot(DomainCategory child) {
+        int index = categorySnapshots.indexOf(child);
+        boolean removed = categorySnapshots.remove(child);
+        if (removed) {
+            fireChildRemoved(DomainCategory.class, child, index);
+            child.setParent(null);
+        }
+        return removed;
+    }
+
+    @Override
+    protected boolean removeChildImpl(SPObject child) {
+        if (child instanceof SPObjectSnapshot<?>) {
+            return removeSPObjectSnapshot((SPObjectSnapshot<?>) child);
+        } else if (child instanceof UserDefinedSQLType) {
+            return removeUDTSnapshot((UserDefinedSQLType) child);
+        } else if (child instanceof DomainCategory) {
+            return removeCategorySnapshot((DomainCategory) child);
+        }
+        return false;
+    }
+
+    @Transient @Accessor
+    @Override
+    public List<Class<? extends SPObject>> getAllowedChildTypes() {
+        return allowedChildTypes;
+    }
+
+    @NonProperty
+    @Override
+    public List<? extends SPObject> getChildren() {
+        List<SPObject> children = new ArrayList<SPObject>();
+        children.addAll(udtSnapshots);
+        children.addAll(categorySnapshots);
+        children.addAll(spobjectSnapshots);
+        return Collections.unmodifiableList(children);
+    }
+
+    @NonBound
+    @Override
+    public List<? extends SPObject> getDependencies() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public void removeDependency(SPObject dependency) {
+        for (UserDefinedSQLType snapshot : udtSnapshots) {
+            snapshot.removeDependency(dependency);
+        }
+        for (DomainCategory category : categorySnapshots) {
+            category.removeDependency(dependency);
+        }
+        for (SPObjectSnapshot<?> snapshot : spobjectSnapshots) {
+            snapshot.removeDependency(dependency);
+        }
+    }
+
+    public boolean removeSPObjectSnapshot(SPObjectSnapshot<?> child) {
+        int index = spobjectSnapshots.indexOf(child);
+        boolean removed = spobjectSnapshots.remove(child);
+        if (removed) {
+            fireChildRemoved(SPObjectSnapshot.class, child, index);
+            child.setParent(null);
+        }
+        return removed;
+    }
+
+    public void addSPObjectSnapshot(SPObjectSnapshot<?> child, int index) {
+        spobjectSnapshots.add(index, child);
+        child.setParent(this);
+        fireChildAdded(SPObjectSnapshot.class, child, index);
+    }
+
+    @NonProperty
+    public List<SPObjectSnapshot<?>> getSPObjectSnapshots() {
+        return Collections.unmodifiableList(spobjectSnapshots);
+    }
+}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/SnapshotCollection.java Thu Sep 9 07:53:46 2010
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2010, SQL Power Group Inc.
- *
- * This file is part of SQL Power Architect.
- *
- * SQL Power Architect is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * SQL Power Architect is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-package ca.sqlpower.architect.enterprise;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import ca.sqlpower.object.AbstractSPObject;
-import ca.sqlpower.object.SPObject;
-import ca.sqlpower.object.SPObjectSnapshot;
-import ca.sqlpower.object.annotation.Accessor;
-import ca.sqlpower.object.annotation.NonBound;
-import ca.sqlpower.object.annotation.NonProperty;
-import ca.sqlpower.object.annotation.Transient;
-import ca.sqlpower.sqlobject.UserDefinedSQLType;
-
-/**
- * This object contains all of the {...@link SPObjectSnapshot}s and the copies of
- * the objects they represent. This is mainly for convenience to keep them
- * grouped together.
- */
-public class SnapshotCollection extends AbstractSPObject {
-
-    /**
-     * Defines an absolute ordering of the child types of this class.
-     *
- * IMPORTANT!: When changing this, ensure you maintain the order specified by {...@link #getChildren()}
-     */
-    @SuppressWarnings("unchecked")
- public static final List<Class<? extends SPObject>> allowedChildTypes = Collections - .unmodifiableList(new ArrayList<Class<? extends SPObject>>(Arrays.asList(UserDefinedSQLType.class,
-                    DomainCategory.class, SPObjectSnapshot.class)));
-
-    /**
- * The list of all snapshots in our current system. This includes types,
-     * domains, and domain category snapshots.
-     */
- private final List<SPObjectSnapshot<?>> spobjectSnapshots = new ArrayList<SPObjectSnapshot<?>>();
-
-    /**
- * List of all copies of {...@link UserDefinedSQLType}s that existed at some
-     * point in the system workspace and are in use in the project.
-     */
- private final List<UserDefinedSQLType> udtSnapshots = new ArrayList<UserDefinedSQLType>();
-
-    /**
- * List of all copies of {...@link DomainCategory} that existed at some point
-     * in the system workspace and are in use in the project.
-     */
- private final List<DomainCategory> categorySnapshots = new ArrayList<DomainCategory>();
-
-    public SnapshotCollection() {
-        setName("Default snapshot collection");
-    }
-
-    @Override
-    protected void addChildImpl(SPObject child, int index) {
-        if (child instanceof SPObjectSnapshot<?>) {
-            addSPObjectSnapshot((SPObjectSnapshot<?>) child, index);
-        } else if (child instanceof UserDefinedSQLType) {
-            addUDTSnapshot((UserDefinedSQLType) child, index);
-        } else if (child instanceof DomainCategory) {
-            addCategorySnapshot((DomainCategory) child, index);
-        }
-    }
-
- public void addCategorySnapshot(DomainCategory domainCategory, int index) {
-        categorySnapshots.add(index, domainCategory);
-        domainCategory.setParent(this);
-        fireChildAdded(DomainCategory.class, domainCategory, index);
-    }
-
-    public void addUDTSnapshot(UserDefinedSQLType sqlType, int index) {
-        udtSnapshots.add(index, sqlType);
-        sqlType.setParent(this);
-        fireChildAdded(UserDefinedSQLType.class, sqlType, index);
-    }
-
-    public boolean removeUDTSnapshot(UserDefinedSQLType child) {
-        int index = udtSnapshots.indexOf(child);
-        boolean removed = udtSnapshots.remove(child);
-        if (removed) {
-            fireChildRemoved(UserDefinedSQLType.class, child, index);
-            child.setParent(null);
-        }
-        return removed;
-    }
-
-    public boolean removeCategorySnapshot(DomainCategory child) {
-        int index = categorySnapshots.indexOf(child);
-        boolean removed = categorySnapshots.remove(child);
-        if (removed) {
-            fireChildRemoved(DomainCategory.class, child, index);
-            child.setParent(null);
-        }
-        return removed;
-    }
-
-    @Override
-    protected boolean removeChildImpl(SPObject child) {
-        if (child instanceof SPObjectSnapshot<?>) {
-            return removeSPObjectSnapshot((SPObjectSnapshot<?>) child);
-        } else if (child instanceof UserDefinedSQLType) {
-            return removeUDTSnapshot((UserDefinedSQLType) child);
-        } else if (child instanceof DomainCategory) {
-            return removeCategorySnapshot((DomainCategory) child);
-        }
-        return false;
-    }
-
-    @Transient @Accessor
-    @Override
-    public List<Class<? extends SPObject>> getAllowedChildTypes() {
-        return allowedChildTypes;
-    }
-
-    @NonProperty
-    @Override
-    public List<? extends SPObject> getChildren() {
-        List<SPObject> children = new ArrayList<SPObject>();
-        children.addAll(udtSnapshots);
-        children.addAll(categorySnapshots);
-        children.addAll(spobjectSnapshots);
-        return Collections.unmodifiableList(children);
-    }
-
-    @NonBound
-    @Override
-    public List<? extends SPObject> getDependencies() {
-        return Collections.emptyList();
-    }
-
-    @Override
-    public void removeDependency(SPObject dependency) {
-        for (UserDefinedSQLType snapshot : udtSnapshots) {
-            snapshot.removeDependency(dependency);
-        }
-        for (DomainCategory category : categorySnapshots) {
-            category.removeDependency(dependency);
-        }
-        for (SPObjectSnapshot<?> snapshot : spobjectSnapshots) {
-            snapshot.removeDependency(dependency);
-        }
-    }
-
-    public boolean removeSPObjectSnapshot(SPObjectSnapshot<?> child) {
-        int index = spobjectSnapshots.indexOf(child);
-        boolean removed = spobjectSnapshots.remove(child);
-        if (removed) {
-            fireChildRemoved(SPObjectSnapshot.class, child, index);
-            child.setParent(null);
-        }
-        return removed;
-    }
-
-    public void addSPObjectSnapshot(SPObjectSnapshot<?> child, int index) {
-        spobjectSnapshots.add(index, child);
-        child.setParent(this);
-        fireChildAdded(SPObjectSnapshot.class, child, index);
-    }
-
-    @NonProperty
-    public List<SPObjectSnapshot<?>> getSPObjectSnapshots() {
-        return Collections.unmodifiableList(spobjectSnapshots);
-    }
-}
=======================================
--- /trunk/build.xml    Tue Aug 17 08:12:16 2010
+++ /trunk/build.xml    Wed Sep 15 08:25:34 2010
@@ -515,10 +515,12 @@
     </target>

        <!-- This target is used to make an architect library jar to embed
-       in other applications -->
+ in other applications. The DomainCategory.class is there to satisfy a dependency
+       in SnapshotCollection.class -->
        <target name="library.jar" depends="compile">
                <jar jarfile="dist/architect-core-${app.version}.jar" 
basedir="${build}"
                        includes="ca/sqlpower/architect/*.class,
+                                   
ca/sqlpower/architect/enterprise/DomainCategory.class,
                                                
ca/sqlpower/architect/ddl/*.class,
                                                
ca/sqlpower/architect/diff/*.class,
                                                
ca/sqlpower/architect/profile/**/*.class,
=======================================
--- /trunk/regress/ca/sqlpower/architect/ArchitectCoreDependencyTest.java Thu Sep 9 07:55:00 2010 +++ /trunk/regress/ca/sqlpower/architect/ArchitectCoreDependencyTest.java Wed Sep 15 08:25:34 2010
@@ -91,6 +91,8 @@
line.equals("import ca.sqlpower.architect.swingui.ArchitectSwingUserSettings;")) continue; if (javaFile.getName().equals("CoreUserSettings.java") && line.equals("import ca.sqlpower.architect.swingui.QFAUserSettings;")) continue; + if (javaFile.getName().equals("SnapshotCollection.java") && + line.equals("import ca.sqlpower.architect.enterprise.DomainCategory;")) continue;

                     TestBeans t = invalidImports(javaFile, line);
                     if(t != null) tests.add(t);
=======================================
--- /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java Thu Sep 9 07:53:46 2010 +++ /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java Wed Sep 15 08:25:34 2010
@@ -22,7 +22,7 @@
 import ca.sqlpower.architect.ArchitectProject;
 import ca.sqlpower.architect.ArchitectSessionContextImpl;
 import ca.sqlpower.architect.ProjectSettings;
-import ca.sqlpower.architect.enterprise.SnapshotCollection;
+import ca.sqlpower.architect.SnapshotCollection;
 import ca.sqlpower.architect.ProjectSettings.ColumnVisibility;
 import ca.sqlpower.architect.ddl.critic.CriticAndSettings;
 import ca.sqlpower.architect.ddl.critic.CriticAndSettings.Severity;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Thu Sep 9 07:53:46 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Wed Sep 15 08:25:34 2010
@@ -60,6 +60,7 @@
 import ca.sqlpower.architect.ArchitectSession;
 import ca.sqlpower.architect.ArchitectSessionContext;
 import ca.sqlpower.architect.ArchitectSessionImpl;
+import ca.sqlpower.architect.SnapshotCollection;
 import ca.sqlpower.architect.ddl.DDLGenerator;
 import ca.sqlpower.architect.swingui.ArchitectSwingProject;
 import ca.sqlpower.architect.swingui.ArchitectSwingSessionContext;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectPersisterSuperConverter.java Wed May 5 12:48:15 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectPersisterSuperConverter.java Wed Sep 15 08:25:34 2010
@@ -19,6 +19,8 @@

 package ca.sqlpower.architect.enterprise;

+import java.util.List;
+
 import ca.sqlpower.dao.session.SPObjectConverter;
 import ca.sqlpower.dao.session.SessionPersisterSuperConverter;
 import ca.sqlpower.object.SPObject;
@@ -52,8 +54,9 @@
         } else if (SPObject.class.isAssignableFrom(type)) {
SPObject foundObject = spObjectConverter.convertToComplexType((String) o);
             if (foundObject == null && dsCollection != null) {
- for (UserDefinedSQLType sqlType : dsCollection.getSQLTypes()) {
-                    if (sqlType.getUUID().equals((String) o)) {
+ List<UserDefinedSQLType> listOfSqlTypes = dsCollection.getSQLTypes();
+                for (UserDefinedSQLType sqlType : listOfSqlTypes) {
+ if (sqlType != null && sqlType.getUUID().equals((String) o)) {
                         return sqlType;
                     }
                 }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java Mon Aug 9 15:23:27 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectSessionPersister.java Wed Sep 15 08:25:34 2010
@@ -22,6 +22,8 @@
 import java.util.ArrayList;
 import java.util.List;

+import org.apache.log4j.Logger;
+
 import ca.sqlpower.architect.swingui.ArchitectSwingProject;
 import ca.sqlpower.dao.PersistedSPOProperty;
 import ca.sqlpower.dao.PersistedSPObject;
@@ -36,6 +38,8 @@
  */
 public class ArchitectSessionPersister extends SPSessionPersister {

+    Logger logger = Logger.getLogger(ArchitectSessionPersister.class);
+
public ArchitectSessionPersister(String name, SPObject root, SessionPersisterSuperConverter converter) {
         super(name, root, converter);
     }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/SPObjectSnapshotHierarchyListener.java Thu Sep 9 07:53:46 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/SPObjectSnapshotHierarchyListener.java Wed Sep 15 08:25:34 2010
@@ -27,6 +27,7 @@

 import org.apache.log4j.Logger;

+import ca.sqlpower.architect.SnapshotCollection;
 import ca.sqlpower.object.AbstractSPListener;
 import ca.sqlpower.object.SPChildEvent;
 import ca.sqlpower.object.SPObject;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java Thu Sep 9 07:53:46 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java Wed Sep 15 08:25:34 2010
@@ -28,11 +28,11 @@

 import ca.sqlpower.architect.ArchitectProject;
 import ca.sqlpower.architect.ProjectSettings;
+import ca.sqlpower.architect.SnapshotCollection;
 import ca.sqlpower.architect.ddl.critic.CriticManager;
 import ca.sqlpower.architect.enterprise.BusinessDefinition;
 import ca.sqlpower.architect.enterprise.DomainCategory;
 import ca.sqlpower.architect.enterprise.FormulaMetricCalculation;
-import ca.sqlpower.architect.enterprise.SnapshotCollection;
 import ca.sqlpower.architect.etl.kettle.KettleSettings;
 import ca.sqlpower.architect.olap.OLAPRootObject;
 import ca.sqlpower.architect.olap.OLAPSession;
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java Fri Jul 30 07:49:27 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/dbtree/DBTreeModel.java Wed Sep 15 08:25:34 2010
@@ -42,9 +42,11 @@

 import org.apache.log4j.Logger;

+import ca.sqlpower.architect.SnapshotCollection;
 import ca.sqlpower.object.SPChildEvent;
 import ca.sqlpower.object.SPListener;
 import ca.sqlpower.object.SPObject;
+import ca.sqlpower.object.AbstractSPObject;
 import ca.sqlpower.object.SPObjectSnapshot;
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.sqlobject.SQLDatabase;
@@ -662,12 +664,22 @@
        }

        public boolean isLeaf(Object parent) {
- if (logger.isDebugEnabled()) logger.debug("DBTreeModel.isLeaf("+parent+"): returning "+!((SQLObject) parent).allowsChildren()); //$NON-NLS-1$ //$NON-NLS-2$
+               if (logger.isDebugEnabled()) {
+                   if (parent instanceof AbstractSPObject) {
+ logger.debug("DBTreeModel.isLeaf("+parent+"): returning "+!((AbstractSPObject) parent).allowsChildren()); //$NON-NLS-1$ //$NON-NLS-2$
+                   }
+                   else {
+ logger.debug("DBTreeModel.isLeaf("+parent+"): returning "+!((SQLObject) parent).allowsChildren()); //$NON-NLS-1$ //$NON-NLS-2$
+                   }
+               }
                if (parent instanceof FolderNode) {
                    return false;
                } else if (parent instanceof SQLColumn) {
                    return true;
                }
+               if (parent instanceof SnapshotCollection) {
+                  return true;
+               }
                return !((SPObject) parent).allowsChildren();
        }

Reply via email to