Revision: 3291
Author: ferguson.sebastian
Date: Fri Feb 12 08:33:40 2010
Log: Moved DDLGenorator from ArchitectProject to ArchitectSessionImpl
http://code.google.com/p/power-architect/source/detail?r=3291

Modified:
 /trunk/src/ca/sqlpower/architect/ArchitectProject.java
 /trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java

=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectProject.java Fri Feb 12 07:43:48 2010 +++ /trunk/src/ca/sqlpower/architect/ArchitectProject.java Fri Feb 12 08:33:40 2010
@@ -19,14 +19,12 @@

 package ca.sqlpower.architect;

-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;

 import ca.sqlpower.architect.ddl.DDLGenerator;
-import ca.sqlpower.architect.ddl.GenericDDLGenerator;
 import ca.sqlpower.architect.profile.ProfileManager;
 import ca.sqlpower.object.AbstractSPObject;
 import ca.sqlpower.object.ObjectDependentException;
@@ -60,7 +58,7 @@
     @SuppressWarnings("unchecked")
     public static List<Class<? extends SPObject>> allowedChildTypes =
Collections.unmodifiableList(new ArrayList<Class<? extends SPObject>>( - Arrays.asList(SQLObjectRoot.class, ProfileManager.class, DDLGenerator.class, SQLDatabase.class))); + Arrays.asList(SQLObjectRoot.class, ProfileManager.class, SQLDatabase.class)));

     /**
      * There is a 1:1 ratio between the session and the project.
@@ -70,25 +68,15 @@
     private ProfileManager profileManager;
     private SQLDatabase db;

-    private DDLGenerator ddlGenerator;
-
     /**
* Constructs an architect project. The init method must be called immediately
      * after creating a project.
      * @throws SQLObjectException
      */
     @Constructor
-    public ArchitectProject()
-            throws SQLObjectException {
+    public ArchitectProject() throws SQLObjectException {
         this.rootObject = new SQLObjectRoot();
         this.db = new SQLDatabase();
-
-        try {
-            ddlGenerator = new GenericDDLGenerator();
-        } catch (SQLException e) {
-            throw new SQLObjectException("SQL Error in ddlGenerator",e);
-        }
-
     }

     /**
@@ -98,9 +86,7 @@
         this.session = session;
rootObject.addSQLObjectPreEventListener(new SourceObjectIntegrityWatcher(session));
         rootObject.setParent(this);
-        db.setParent(this);
-        ddlGenerator.setParent(this);
-
+        db.setParent(this);
     }

     /**
@@ -140,11 +126,6 @@
     public SQLDatabase getTargetDatabase() {
         return db;
     }
-
-    @NonProperty
-    public DDLGenerator getDDLGenerator() {
-        return ddlGenerator;
-    }

     @NonProperty
public void setSourceDatabaseList(List<SQLDatabase> databases) throws SQLObjectException {
@@ -166,16 +147,6 @@
             throw new RuntimeException(e);
         }
     }
-
-    @NonProperty
-    public void setDDLGenerator(DDLGenerator generator) {
-        DDLGenerator oldDDLG = ddlGenerator;
-        ddlGenerator = generator;
-        if (oldDDLG != null) {
-            fireChildRemoved(DDLGenerator.class, oldDDLG, 0);
-        }
-        fireChildAdded(DDLGenerator.class, generator, 0);
-    }

     @NonProperty
     public void setProfileManager(ProfileManager manager) {
@@ -227,7 +198,6 @@
         List<SPObject> allChildren = new ArrayList<SPObject>();
         allChildren.add(rootObject);
         allChildren.add(profileManager);
-        allChildren.add(ddlGenerator);
         allChildren.add(db);
         return allChildren;
     }
@@ -241,13 +211,13 @@
         db.removeDependency(dependency);
         rootObject.removeDependency(dependency);
         profileManager.removeDependency(dependency);
-        ddlGenerator.removeDependency(dependency);
     }

     protected void addChildImpl(SPObject child, int index) {
         if (child instanceof SQLObjectRoot) {
-            rootObject = (SQLObjectRoot) child;
+            rootObject = (SQLObjectRoot) child;
         } else {
+
             super.addChildImpl(child, index);
         }
     }
=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java Fri Feb 12 07:43:48 2010 +++ /trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java Fri Feb 12 08:33:40 2010
@@ -21,10 +21,12 @@

 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;

 import ca.sqlpower.architect.ddl.DDLGenerator;
+import ca.sqlpower.architect.ddl.GenericDDLGenerator;
 import ca.sqlpower.architect.profile.ProfileManager;
 import ca.sqlpower.architect.profile.ProfileManagerImpl;
 import ca.sqlpower.sql.DataSourceCollection;
@@ -76,6 +78,8 @@
      */
     private ProjectLoader projectLoader;

+    private DDLGenerator ddlGenerator;
+
     protected boolean isEnterpriseSession;

        public ArchitectSessionImpl(final ArchitectSessionContext context,
@@ -90,7 +94,13 @@
            this.name = name;
         this.projectLoader = new ProjectLoader(this);
         this.isEnterpriseSession = false;
-
+
+        try {
+            ddlGenerator = new GenericDDLGenerator();
+        } catch (SQLException e) {
+            throw new SQLObjectException("SQL Error in ddlGenerator",e);
+        }
+
        }

        // --------------- accessors and mutators ------------------
@@ -167,11 +177,11 @@
     }

     public DDLGenerator getDDLGenerator() {
-        return project.getDDLGenerator();
+        return ddlGenerator;
     }

     public void setDDLGenerator(DDLGenerator generator) {
-        project.setDDLGenerator(generator);
+        ddlGenerator = generator;
     }

public void setSourceDatabaseList(List<SQLDatabase> databases) throws SQLObjectException {

Reply via email to