Revision: 3232
Author: silva.josemanuel1
Date: Mon Jan 18 11:55:38 2010
Log: ASSIGNED - bug 2509: Move the compare DM settings to the project root object.
http://trillian.sqlpower.ca/bugzilla/show_bug.cgi?id=2509
http://code.google.com/p/power-architect/source/detail?r=3232

Modified:
 /trunk/src/ca/sqlpower/architect/ArchitectProject.java
 /trunk/src/ca/sqlpower/architect/ddl/DDLGenerator.java
 /trunk/src/ca/sqlpower/architect/ddl/DDLStatement.java
 /trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java

=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectProject.java Mon Jan 18 09:19:18 2010 +++ /trunk/src/ca/sqlpower/architect/ArchitectProject.java Mon Jan 18 11:55:38 2010
@@ -150,15 +150,25 @@
     }

     public int childPositionOffset(Class<? extends SPObject> childType) {
- //TODO generated, would be better to do when this class has all its children decided
-        return 0;
+
+        if (childType.isAssignableFrom(SQLObjectRoot.class)) {
+            return 0;
+        } else if (childType.isAssignableFrom(ProfileManager.class)) {
+            return 1;
+        } else if (childType.isAssignableFrom(DDLGenerator.class)) {
+            return 2;
+        } else if (childType.isAssignableFrom(SQLDatabase.class)) {
+            return 3;
+        } else {
+            throw new IllegalArgumentException();
+        }
     }

     public List<Class<? extends SPObject>> getAllowedChildTypes() {
List<Class<? extends SPObject>> childTypes = new ArrayList<Class<? extends SPObject>>();
         childTypes.add(SQLObjectRoot.class);
         childTypes.add(ProfileManager.class);
- // childTypes.add(DDLGenerator.class); TODO make DDLGenerator an SPObject
+        childTypes.add(DDLGenerator.class);
         childTypes.add(SQLDatabase.class);
         return childTypes;
     }
@@ -167,7 +177,7 @@
         List<SPObject> allChildren = new ArrayList<SPObject>();
         allChildren.add(rootObject);
         allChildren.add(profileManager);
- // allChildren.add(ddlGenerator); TODO make DDLGenerator an SPObject
+        allChildren.add(ddlGenerator);
         allChildren.add(db);
         return allChildren;
     }
=======================================
--- /trunk/src/ca/sqlpower/architect/ddl/DDLGenerator.java Fri May 22 06:08:44 2009 +++ /trunk/src/ca/sqlpower/architect/ddl/DDLGenerator.java Mon Jan 18 11:55:38 2010
@@ -19,15 +19,16 @@

 package ca.sqlpower.architect.ddl;

-import ca.sqlpower.sqlobject.SQLObject;
 import java.sql.SQLException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;

-import ca.sqlpower.sqlobject.SQLObjectException;
+import ca.sqlpower.object.SPObject;
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.sqlobject.SQLIndex;
+import ca.sqlpower.sqlobject.SQLObject;
+import ca.sqlpower.sqlobject.SQLObjectException;
 import ca.sqlpower.sqlobject.SQLRelationship;
 import ca.sqlpower.sqlobject.SQLTable;

@@ -39,7 +40,7 @@
  * @author fuerth
  * @version $Id$
  */
-public interface DDLGenerator {
+public interface DDLGenerator extends SPObject {

     /**
      * Returns the name of this DDL Generator, which should be a
=======================================
--- /trunk/src/ca/sqlpower/architect/ddl/DDLStatement.java Mon Nov 16 11:23:52 2009 +++ /trunk/src/ca/sqlpower/architect/ddl/DDLStatement.java Mon Jan 18 11:55:38 2010
@@ -18,6 +18,11 @@
  */
 package ca.sqlpower.architect.ddl;

+import java.util.Collections;
+import java.util.List;
+
+import ca.sqlpower.object.AbstractSPObject;
+import ca.sqlpower.object.SPObject;
 import ca.sqlpower.sqlobject.SQLObject;

 /**
@@ -25,7 +30,7 @@
  * certain Data Definition Language statement does, as well as the
  * text of that statement for a particular database.
  */
-public class DDLStatement {
+public class DDLStatement extends AbstractSPObject {

        public static class StatementType {

@@ -165,4 +170,34 @@
     public String toString() {
return getType()+" "+DDLUtils.toQualifiedName(getTargetCatalog(), getTargetSchema(), object.getName());
     }
-}
+
+    @Override
+    protected boolean removeChildImpl(SPObject child) {
+        return false;
+    }
+
+    public boolean allowsChildren() {
+        return false;
+    }
+
+    public int childPositionOffset(Class<? extends SPObject> childType) {
+        return 0;
+    }
+
+    public List<Class<? extends SPObject>> getAllowedChildTypes() {
+        return Collections.emptyList();
+    }
+
+    public List<? extends SPObject> getChildren() {
+        return Collections.emptyList();
+    }
+
+    public List<? extends SPObject> getDependencies() {
+ // Assuming that the SQLObject field object is never modified/removed, as is the case currently...
+        return Collections.emptyList();
+    }
+
+    public void removeDependency(SPObject dependency) {
+
+    }
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java Tue Jan 5 08:48:08 2010 +++ /trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java Mon Jan 18 11:55:38 2010
@@ -26,6 +26,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -36,6 +37,8 @@
 import ca.sqlpower.architect.ArchitectUtils;
 import ca.sqlpower.architect.DepthFirstSearch;
 import ca.sqlpower.architect.profile.ProfileFunctionDescriptor;
+import ca.sqlpower.object.AbstractSPObject;
+import ca.sqlpower.object.SPObject;
 import ca.sqlpower.object.SPObjectUtils;
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.sqlobject.SQLDatabase;
@@ -51,7 +54,7 @@
 import ca.sqlpower.sqlobject.SQLRelationship.Deferrability;
 import ca.sqlpower.sqlobject.SQLRelationship.UpdateDeleteRule;

-public class GenericDDLGenerator implements DDLGenerator {
+public class GenericDDLGenerator extends AbstractSPObject implements DDLGenerator {

        public static final String GENERATOR_VERSION = "$Revision$";

@@ -147,6 +150,7 @@
     /**
      * A mapping from JDBC type code (Integer values) to
      * appliable profile functions (min,max,avg,sum,etc...)
+     * XXX This doesn't seem to be used at all
      */
     protected Map<String, ProfileFunctionDescriptor> profileFunctionMap;

@@ -1380,4 +1384,41 @@
     public boolean supportsRollback() {
         return true;
     }
-}
+
+    @Override
+    protected boolean removeChildImpl(SPObject child) {
+        return false;
+    }
+
+    public boolean allowsChildren() {
+        return true;
+    }
+
+    public int childPositionOffset(Class<? extends SPObject> childType) {
+        if (childType.isAssignableFrom(DDLStatement.class)) {
+            return 0;
+        } else {
+            throw new IllegalArgumentException();
+        }
+    }
+
+    public List<Class<? extends SPObject>> getAllowedChildTypes() {
+ List<Class<? extends SPObject>> types = new ArrayList<Class<? extends SPObject>>();
+        types.add(DDLStatement.class);
+        return null;
+    }
+
+    public List<? extends SPObject> getChildren() {
+        List<SPObject> children = new ArrayList<SPObject>();
+        children.addAll(ddlStatements);
+        return children;
+    }
+
+    public List<? extends SPObject> getDependencies() {
+        return Collections.emptyList();
+    }
+
+    public void removeDependency(SPObject dependency) {
+
+    }
+}

Reply via email to