Revision: 3287
Author: [email protected]
Date: Thu Feb 11 14:16:30 2010
Log: The session parameter for the ArchitectProject is now defined in the init method. This lets us create a project first then attach the children to the project.
http://code.google.com/p/power-architect/source/detail?r=3287

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

=======================================
--- /trunk/regress/ca/sqlpower/architect/ArchitectProjectTest.java Thu Feb 11 11:47:13 2010 +++ /trunk/regress/ca/sqlpower/architect/ArchitectProjectTest.java Thu Feb 11 14:16:30 2010
@@ -36,7 +36,9 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        objectUnderTest = new ArchitectProject(new StubArchitectSession());
+        ArchitectSession session = new StubArchitectSession();
+        objectUnderTest = new ArchitectProject();
+        objectUnderTest.init(session);
         getRootObject().addChild(objectUnderTest, 0);
     }

=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectProject.java Thu Feb 11 11:47:13 2010 +++ /trunk/src/ca/sqlpower/architect/ArchitectProject.java Thu Feb 11 14:16:30 2010
@@ -33,7 +33,6 @@
 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.NonBound;
 import ca.sqlpower.object.annotation.NonProperty;
 import ca.sqlpower.object.annotation.Transient;
@@ -63,28 +62,41 @@
Collections.unmodifiableList(new ArrayList<Class<? extends SPObject>>( Arrays.asList(SQLObjectRoot.class, ProfileManager.class, DDLGenerator.class, SQLDatabase.class)));

-    private final ArchitectSession session;
+    /**
+     * There is a 1:1 ratio between the session and the project.
+     */
+    private ArchitectSession session;
     private SQLObjectRoot rootObject;
     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(@ConstructorParameter(propertyName="session") ArchitectSession session)
+    public ArchitectProject()
             throws SQLObjectException {
-        this.session = session;
         this.rootObject = new SQLObjectRoot();
         this.db = new SQLDatabase();

- rootObject.addSQLObjectPreEventListener(new SourceObjectIntegrityWatcher(session));
-
         try {
             ddlGenerator = new GenericDDLGenerator();
         } catch (SQLException e) {
             throw new SQLObjectException("SQL Error in ddlGenerator",e);
         }

+    }
+
+    /**
+     * Call this to initialize the session and the children of the project.
+     */
+    public void init(ArchitectSession session) {
+        this.session = session;
+ rootObject.addSQLObjectPreEventListener(new SourceObjectIntegrityWatcher(session));
         rootObject.setParent(this);
         db.setParent(this);
         ddlGenerator.setParent(this);
=======================================
--- /trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java Thu Feb 11 11:47:13 2010 +++ /trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java Thu Feb 11 14:16:30 2010
@@ -80,7 +80,8 @@
                String name) throws SQLObjectException {

            this.context = context;
-           this.project = new ArchitectProject(this);
+           this.project = new ArchitectProject();
+           project.init(this);
            this.project.setProfileManager(new ProfileManagerImpl(this));
            this.name = name;
         this.projectLoader = new ProjectLoader(this);

Reply via email to