Revision: 3719
Author: mo.jeff
Date: Tue Jul 13 09:45:23 2010
Log: Added a snapshot implementation for DomainCategories.
http://code.google.com/p/power-architect/source/detail?r=3719

Added:
/trunk/regress/ca/sqlpower/architect/enterprise/DomainCategorySnapshotTest.java /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategorySnapshot.java
Modified:
 /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java

=======================================
--- /dev/null
+++ /trunk/regress/ca/sqlpower/architect/enterprise/DomainCategorySnapshotTest.java Tue Jul 13 09:45:23 2010
@@ -0,0 +1,76 @@
+/*
+ * 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 ca.sqlpower.architect.util.ArchitectNewValueMaker;
+import ca.sqlpower.object.PersistedSPObjectTest;
+import ca.sqlpower.object.SPObject;
+import ca.sqlpower.sql.DataSourceCollection;
+import ca.sqlpower.sql.SPDataSource;
+import ca.sqlpower.testutil.NewValueMaker;
+
+public class DomainCategorySnapshotTest extends PersistedSPObjectTest {
+    public DomainCategorySnapshotTest(String name) throws Exception {
+        super(name);
+    }
+
+    private DomainCategory category;
+    private DomainCategorySnapshot categorySnapshot;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        category = new DomainCategory("test");
+        categorySnapshot = new DomainCategorySnapshot(category, 0);
+
+        getRootObject().addChild(category, 0);
+        getRootObject().addChild(categorySnapshot, 0);
+    }
+
+    @Override
+    public SPObject getSPObjectUnderTest() {
+        return categorySnapshot;
+    }
+
+    @Override
+    protected Class<? extends SPObject> getChildClassType() {
+        return DomainCategory.class;
+    }
+
+ 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 {
+
+    }
+}
=======================================
--- /dev/null
+++ /trunk/src/main/java/ca/sqlpower/architect/enterprise/DomainCategorySnapshot.java Tue Jul 13 09:45:23 2010
@@ -0,0 +1,74 @@
+/*
+ * 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.Collections;
+import java.util.List;
+
+import ca.sqlpower.object.SystemSPObjectSnapshot;
+import ca.sqlpower.object.ObjectDependentException;
+import ca.sqlpower.object.SPObject;
+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 = "originalUUID") String originalUUID, + @ConstructorParameter (propertyName = "workspaceRevision", defaultValue = "0") int systemRevision) {
+        super(originalUUID, systemRevision);
+        this.spObject = spObject;
+        this.spObject.setParent(this);
+    }
+
+    public DomainCategorySnapshot(DomainCategory original,
+            int systemRevision) throws IllegalArgumentException,
+            ObjectDependentException {
+        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);
+
+    public List<Class<? extends SPObject>> getAllowedChildTypes() {
+        return allowedChildTypes;
+    }
+
+    public List<? extends SPObject> getChildren() {
+        return Collections.singletonList(spObject);
+    }
+
+    @Accessor
+    public DomainCategory getSPObject() {
+        return spObject;
+    }
+}
=======================================
--- /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java Mon Jul 5 15:06:27 2010 +++ /trunk/regress/ca/sqlpower/architect/util/ArchitectNewValueMaker.java Tue Jul 13 09:45:23 2010
@@ -24,17 +24,18 @@
 import ca.sqlpower.architect.ProjectSettings;
 import ca.sqlpower.architect.ProjectSettings.ColumnVisibility;
 import ca.sqlpower.architect.ddl.critic.CriticAndSettings;
+import ca.sqlpower.architect.ddl.critic.CriticAndSettings.Severity;
 import ca.sqlpower.architect.ddl.critic.CriticGrouping;
 import ca.sqlpower.architect.ddl.critic.CriticManager;
-import ca.sqlpower.architect.ddl.critic.CriticAndSettings.Severity;
 import ca.sqlpower.architect.ddl.critic.impl.AlphaNumericNameCritic;
+import ca.sqlpower.architect.enterprise.DomainCategory;
 import ca.sqlpower.architect.etl.kettle.KettleSettings;
-import ca.sqlpower.architect.olap.OLAPObject;
-import ca.sqlpower.architect.olap.OLAPRootObject;
-import ca.sqlpower.architect.olap.OLAPSession;
 import ca.sqlpower.architect.olap.MondrianModel.Cube;
 import ca.sqlpower.architect.olap.MondrianModel.Dimension;
 import ca.sqlpower.architect.olap.MondrianModel.Schema;
+import ca.sqlpower.architect.olap.OLAPObject;
+import ca.sqlpower.architect.olap.OLAPRootObject;
+import ca.sqlpower.architect.olap.OLAPSession;
 import ca.sqlpower.architect.profile.ColumnProfileResult;
 import ca.sqlpower.architect.profile.ColumnValueCount;
 import ca.sqlpower.architect.profile.ProfileManager;
@@ -162,6 +163,9 @@
return ((ArchitectSwingProject) makeNewValue(ArchitectSwingProject.class, null, null)).getOlapRootObject();
         } else if (OLAPObject.class.isAssignableFrom(valueType)) {
return mondrianValueMaker.makeNewValue(valueType, oldVal, propName);
+        } else if (valueType == DomainCategory.class) {
+            DomainCategory category = new DomainCategory("new");
+            return category;
         } else if (valueType == CriticGrouping.class) {
CriticGrouping group = new CriticGrouping(CriticAndSettings.StarterPlatformTypes.GENERIC.getName()); CriticManager manager = (CriticManager) makeNewValue(CriticManager.class, null, "parent of group");

Reply via email to