Revision: 3739
Author: mo.jeff
Date: Wed Jul 14 16:06:30 2010
Log: In order to support DomainCategory snapshotting, I changed the way the
snapshots work so that the object that is the copy isn't a child of the
snapshot object. This way, the UDT copy can still have the DomainCategory
copy as its parent, and not be bound to also have the UDTsnapshot as its
parent, which would require multi-parent support.
http://code.google.com/p/power-architect/source/detail?r=3739
Modified:
/trunk/regress/ca/sqlpower/architect/enterprise/DomainCategorySnapshotTest.java
/trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java
/trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategorySnapshot.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java
=======================================
---
/trunk/regress/ca/sqlpower/architect/enterprise/DomainCategorySnapshotTest.java
Tue Jul 13 09:45:23 2010
+++
/trunk/regress/ca/sqlpower/architect/enterprise/DomainCategorySnapshotTest.java
Wed Jul 14 16:06:30 2010
@@ -56,21 +56,5 @@
public NewValueMaker createNewValueMaker(SPObject root,
DataSourceCollection<SPDataSource> dsCollection) {
return new ArchitectNewValueMaker(root, dsCollection);
- }
-
- /**
- * Must be overridden to account for the single, final child
- */
- @Override
- public SPObject testSPPersisterAddsChild() throws Exception {
- return null;
- }
-
- /**
- * Must be overridden to account for the single, final child
- */
- @Override
- public void testAddChildFiresEvents() throws Exception {
-
}
}
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java Tue
Jul 13 09:47:40 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/ArchitectProject.java Wed
Jul 14 16:06:30 2010
@@ -24,6 +24,7 @@
import java.util.Collections;
import java.util.List;
+import ca.sqlpower.architect.enterprise.DomainCategory;
import ca.sqlpower.architect.profile.ProfileManager;
import ca.sqlpower.enterprise.client.Group;
import ca.sqlpower.enterprise.client.User;
@@ -65,9 +66,9 @@
*/
@SuppressWarnings("unchecked")
public static final List<Class<? extends SPObject>> allowedChildTypes
= Collections
- .unmodifiableList(new ArrayList<Class<? extends
SPObject>>(Arrays.asList(SPObjectSnapshot.class,
- SQLObjectRoot.class, ProfileManager.class,
ProjectSettings.class, User.class, Group.class,
- UserDefinedSQLType.class)));
+ .unmodifiableList(new ArrayList<Class<? extends
SPObject>>(Arrays.asList(UserDefinedSQLType.class,
+ DomainCategory.class, SPObjectSnapshot.class,
SQLObjectRoot.class, ProfileManager.class,
+ ProjectSettings.class, User.class, Group.class)));
/**
* There is a 1:1 ratio between the session and the project.
@@ -81,6 +82,7 @@
private List<Group> groups = new ArrayList<Group>();
private final List<UserDefinedSQLType> sqlTypes = new
ArrayList<UserDefinedSQLType>();
private final List<SPObjectSnapshot> sqlTypeSnapshots = new
ArrayList<SPObjectSnapshot>();
+ private final List<DomainCategory> domainCategories = new
ArrayList<DomainCategory>();
/**
* The current integrity watcher on the project.
@@ -249,6 +251,12 @@
fireChildRemoved(UserDefinedSQLType.class, child, index);
child.setParent(null);
return true;
+ } else if (child instanceof DomainCategory) {
+ int index = domainCategories.indexOf((DomainCategory) child);
+ domainCategories.remove((DomainCategory) child);
+ fireChildRemoved(DomainCategory.class, child, index);
+ child.setParent(null);
+ return true;
} else if (child instanceof SPObjectSnapshot) {
int index = sqlTypeSnapshots.indexOf((SPObjectSnapshot) child);
sqlTypeSnapshots.remove((SPObjectSnapshot) child);
@@ -312,6 +320,7 @@
allChildren.addAll(users);
allChildren.addAll(groups);
allChildren.addAll(sqlTypes);
+ allChildren.addAll(domainCategories);
allChildren.addAll(sqlTypeSnapshots);
return allChildren;
}
@@ -338,6 +347,8 @@
addGroup((Group) child, index);
} else if (child instanceof UserDefinedSQLType) {
addSQLType((UserDefinedSQLType) child, index);
+ } else if (child instanceof DomainCategory) {
+ addDomainCategory((DomainCategory) child, index);
} else if (child instanceof SPObjectSnapshot) {
addSPObjectSnapshot((SPObjectSnapshot) child, index);
} else {
@@ -367,6 +378,11 @@
public List<SPObjectSnapshot> getSqlTypeSnapshots() {
return Collections.unmodifiableList(sqlTypeSnapshots);
}
+
+ @NonProperty
+ public List<DomainCategory> getDomainCategories() {
+ return Collections.unmodifiableList(domainCategories);
+ }
public void addUser(User user, int index) {
users.add(index, user);
@@ -404,4 +420,10 @@
return projectSettings;
}
-}
+
+ public void addDomainCategory(DomainCategory domainCategory, int
index) {
+ domainCategories.add(index, domainCategory);
+ domainCategory.setParent(this);
+ fireChildAdded(DomainCategory.class, domainCategory, index);
+ }
+}
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategorySnapshot.java
Tue Jul 13 09:45:23 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategorySnapshot.java
Wed Jul 14 16:06:30 2010
@@ -22,26 +22,23 @@
import java.util.Collections;
import java.util.List;
-import ca.sqlpower.object.SystemSPObjectSnapshot;
import ca.sqlpower.object.ObjectDependentException;
import ca.sqlpower.object.SPObject;
+import ca.sqlpower.object.SystemSPObjectSnapshot;
import ca.sqlpower.object.annotation.Accessor;
import ca.sqlpower.object.annotation.Constructor;
import ca.sqlpower.object.annotation.ConstructorParameter;
-import ca.sqlpower.object.annotation.ConstructorParameter.ParameterType;
public class DomainCategorySnapshot extends
SystemSPObjectSnapshot<DomainCategory> {
private final DomainCategory spObject;
@Constructor
public DomainCategorySnapshot(
- @ConstructorParameter (isProperty = ParameterType.CHILD,
- propertyName = "spObject") DomainCategory spObject,
+ @ConstructorParameter (propertyName = "spObject")
DomainCategory spObject,
@ConstructorParameter (propertyName = "originalUUID") String
originalUUID,
@ConstructorParameter (propertyName = "workspaceRevision",
defaultValue = "0") int systemRevision) {
super(originalUUID, systemRevision);
this.spObject = spObject;
- this.spObject.setParent(this);
}
public DomainCategorySnapshot(DomainCategory original,
@@ -50,21 +47,20 @@
super(original.getUUID(), systemRevision);
setName(original.getName());
spObject = new DomainCategory(original.getName());
- spObject.setParent(this);
}
/**
* An unmodifiable {...@link List} of allowed child types
*/
public static final List<Class<? extends SPObject>> allowedChildTypes =
- Collections.<Class<? extends
SPObject>>singletonList(DomainCategory.class);
+ Collections.emptyList();
public List<Class<? extends SPObject>> getAllowedChildTypes() {
return allowedChildTypes;
}
public List<? extends SPObject> getChildren() {
- return Collections.singletonList(spObject);
+ return Collections.emptyList();
}
@Accessor
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java
Tue Jul 13 09:47:40 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectSwingProject.java
Wed Jul 14 16:06:30 2010
@@ -73,10 +73,10 @@
*/
@SuppressWarnings("unchecked")
public static final List<Class<? extends SPObject>> allowedChildTypes
= Collections
- .unmodifiableList(new ArrayList<Class<? extends
SPObject>>(Arrays.asList(SPObjectSnapshot.class, SQLObjectRoot.class,
+ .unmodifiableList(new ArrayList<Class<? extends
SPObject>>(Arrays.asList(UserDefinedSQLType.class,
+ DomainCategory.class, SPObjectSnapshot.class,
SQLObjectRoot.class,
OLAPRootObject.class, PlayPenContentPane.class,
ProfileManager.class, ProjectSettings.class,
- CriticManager.class, KettleSettings.class, User.class,
Group.class, UserDefinedSQLType.class,
- DomainCategory.class)));
+ CriticManager.class, KettleSettings.class, User.class,
Group.class)));
/**
* A hash map mapping all the descendants of this project.
@@ -145,8 +145,6 @@
private PlayPenContentPane playPenContentPane;
- private final List<DomainCategory> domainCategories = new
ArrayList<DomainCategory>();
-
/**
* This OLAP object contains the OLAP session.
*/
@@ -214,12 +212,6 @@
return super.removeChildImpl(child);
} else if (child instanceof PlayPenContentPane) {
return removeOLAPContentPane((PlayPenContentPane) child);
- } else if (child instanceof DomainCategory) {
- int index = domainCategories.indexOf((DomainCategory) child);
- domainCategories.remove((DomainCategory) child);
- fireChildRemoved(DomainCategory.class, child, index);
- child.setParent(null);
- return true;
}
return false;
}
@@ -275,7 +267,7 @@
allChildren.addAll(getUsers());
allChildren.addAll(getGroups());
allChildren.addAll(getSqlTypes());
- allChildren.addAll(domainCategories);
+ allChildren.addAll(getDomainCategories());
allChildren.addAll(getSqlTypeSnapshots());
return allChildren;
}
@@ -325,11 +317,6 @@
}
}
- public void addDomainCategory(DomainCategory domainCategory, int
index) {
- domainCategories.add(index, domainCategory);
- domainCategory.setParent(this);
- fireChildAdded(DomainCategory.class, domainCategory, index);
- }
@NonProperty
public void setPlayPenContentPane(PlayPenContentPane pane) {