Revision: 3830
Author: [email protected]
Date: Tue Aug  3 12:49:13 2010
Log: Updated the snapshots to also handle domain categories ontop of the domains and types. Previously the update to match the system category was not working.
http://code.google.com/p/power-architect/source/detail?r=3830

Modified:
/trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java
 /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategory.java
/trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategorySnapshot.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Tue Aug 3 09:38:48 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Tue Aug 3 12:49:13 2010
@@ -229,6 +229,16 @@
                             snapshot.setObsolete(true);
                         }
                     }
+ } else if (e.getChild() instanceof DomainCategorySnapshot) { + DomainCategorySnapshot snapshot = (DomainCategorySnapshot) e.getChild();
+                    if (!snapshot.isObsolete()) {
+ for (DomainCategory category : getSystemWorkspace().getDomainCategories()) { + if (category.getUUID().equals(snapshot.getOriginalUUID()) && + !DomainCategory.areEqual(snapshot.getSPObject(), category)) {
+                                snapshot.setObsolete(true);
+                            }
+                        }
+                    }
                 }
             }
         });
@@ -1237,6 +1247,16 @@

             @Override
             public void run() {
+                if (snapshot.getSPObject() instanceof DomainCategory) {
+ for (DomainCategory category : getSystemWorkspace().getDomainCategories()) { + if (category.getUUID().equals(snapshot.getOriginalUUID())) { + ((DomainCategory) snapshot.getSPObject()).updateToMatch(category);
+                            snapshot.setObsolete(false);
+                            return;
+                        }
+                    }
+                }
+
if (!(snapshot.getSPObject() instanceof UserDefinedSQLType)) return; UserDefinedSQLType snapshotType = (UserDefinedSQLType) snapshot.getSPObject(); UserDefinedSQLType systemType = findSystemTypeFromSnapshot(snapshot);
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategory.java Fri Jul 30 13:13:38 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategory.java Tue Aug 3 12:49:13 2010
@@ -23,8 +23,9 @@
 import java.util.Collections;
 import java.util.List;

+import javax.annotation.Nonnull;
+
 import ca.sqlpower.object.AbstractSPObject;
-import ca.sqlpower.object.SPListener;
 import ca.sqlpower.object.SPObject;
 import ca.sqlpower.object.annotation.Constructor;
 import ca.sqlpower.object.annotation.ConstructorParameter;
@@ -44,6 +45,18 @@
      */
     public static final List<Class<? extends SPObject>> allowedChildTypes =
Collections.<Class<? extends SPObject>>singletonList(UserDefinedSQLType.class);
+
+    /**
+ * Compares two domain categories on their properties except their UUID and + * returns true if they all match. Does not look at children of the domain
+     * category.
+     */
+ public static boolean areEqual(@Nonnull DomainCategory cat1, @Nonnull DomainCategory cat2) {
+        if (cat1.getName() == null && cat2.getName() == null) return true;
+ if (cat1.getName() != null && cat1.getName().equals(cat2.getName())) return true;
+
+        return false;
+    }

     /**
* A {...@link List} of {...@link UserDefinedSQLType}s available under this category
@@ -95,15 +108,11 @@
         return childRemoved;
     }

-    @Override
-    public void addSPListener(SPListener l) {
-        // TODO Auto-generated method stub
-        super.addSPListener(l);
-    }
-
-    @Override
-    public void removeSPListener(SPListener l) {
-        // TODO Auto-generated method stub
-        super.removeSPListener(l);
+    /**
+     * Calling this method will update all of the settable properties of
+     * this object with the same properties as those in matchMe.
+     */
+    public void updateToMatch(DomainCategory matchMe) {
+        setName(matchMe.getName());
     }
 }
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategorySnapshot.java Fri Jul 30 12:56:08 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategorySnapshot.java Tue Aug 3 12:49:13 2010
@@ -68,6 +68,6 @@

     @Override
     public String toString() {
-        return getName();
+        return getSPObject().getName();
     }
 }

Reply via email to