Revision: 3310
Author: [email protected]
Date: Thu Feb 18 09:29:28 2010
Log: The DDL Generator is no longer an SPObject. The DDL properties for the target schema and catalog are now stored in Java prefs and a user will gain several prefs for each server project they open. This lets the DDL properties exist for each
user for each project.
http://code.google.com/p/power-architect/source/detail?r=3310

Modified:
 /trunk/src/ca/sqlpower/architect/ddl/DDLGenerator.java
 /trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java
 /trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java

=======================================
--- /trunk/src/ca/sqlpower/architect/ddl/DDLGenerator.java Mon Jan 18 11:55:38 2010 +++ /trunk/src/ca/sqlpower/architect/ddl/DDLGenerator.java Thu Feb 18 09:29:28 2010
@@ -24,7 +24,6 @@
 import java.util.List;
 import java.util.Map;

-import ca.sqlpower.object.SPObject;
 import ca.sqlpower.sqlobject.SQLColumn;
 import ca.sqlpower.sqlobject.SQLIndex;
 import ca.sqlpower.sqlobject.SQLObject;
@@ -40,7 +39,7 @@
  * @author fuerth
  * @version $Id$
  */
-public interface DDLGenerator extends SPObject {
+public interface DDLGenerator {

     /**
      * Returns the name of this DDL Generator, which should be a
=======================================
--- /trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java Mon Feb 8 10:12:47 2010 +++ /trunk/src/ca/sqlpower/architect/ddl/GenericDDLGenerator.java Thu Feb 18 09:29:28 2010
@@ -26,7 +26,6 @@
 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;
@@ -37,8 +36,6 @@
 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;
@@ -54,7 +51,7 @@
 import ca.sqlpower.sqlobject.SQLRelationship.Deferrability;
 import ca.sqlpower.sqlobject.SQLRelationship.UpdateDeleteRule;

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

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

@@ -1385,40 +1382,4 @@
         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) {
-
-    }
-}
+}
=======================================
--- /trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Thu Feb 18 08:05:59 2010 +++ /trunk/src/ca/sqlpower/architect/enterprise/ArchitectClientSideSession.java Thu Feb 18 09:29:28 2010
@@ -12,6 +12,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.prefs.Preferences;

 import javax.swing.SwingUtilities;

@@ -46,6 +47,7 @@
 import ca.sqlpower.architect.ArchitectSession;
 import ca.sqlpower.architect.ArchitectSessionContext;
 import ca.sqlpower.architect.ArchitectSessionImpl;
+import ca.sqlpower.architect.ddl.DDLGenerator;
 import ca.sqlpower.architect.swingui.ArchitectSwingSessionContext;
 import ca.sqlpower.dao.HttpMessageSender;
 import ca.sqlpower.dao.MessageSender;
@@ -82,9 +84,35 @@

        public static final String MONDRIAN_SCHEMA_REL_PATH = "/mondrian";

+       /**
+ * The prefs node that will store information about the current settings of + * the DDL generator and compare DM panels. Currently this is stored in prefs + * because we want to store it per user for each project they are using. In the + * future we may want to store this in the server, once per user per project.
+        */
+ private final Preferences prefs = Preferences.userNodeForPackage(ArchitectClientSideSession.class);
+
+       /**
+        * Describes the location of the project that this session represents.
+        */
        private final ProjectLocation projectLocation;
+
+    /**
+ * An {...@link HttpClient} used to send updates to the server for changes to
+     * the project and to receive updates from other users from the server.
+     */
        private final HttpClient outboundHttpClient;
+
+       /**
+ * The persister that will update the project in this session with changes from
+        * the server.
+        */
        private final SPSessionPersister sessionPersister;
+
+       /**
+ * Used to convert JSON sent from the server into persist calls to forward the
+        * server changes to the {...@link #sessionPersister}.
+        */
        private final SPJSONPersister jsonPersister;
        private final Updater updater;
private final DataSourceCollectionUpdater dataSourceCollectionUpdater = new DataSourceCollectionUpdater();
@@ -92,7 +120,11 @@
        private DataSourceCollection <JDBCDataSource> dataSourceCollection;

        // -
-
+
+    /**
+     * The revision this project is currently at. This will be updated as
+     * changes come in from the server.
+     */
        int currentRevision = 0;

        public ArchitectClientSideSession(ArchitectSessionContext context,
@@ -101,6 +133,21 @@

                this.projectLocation = projectLocation;
                this.isEnterpriseSession = true;
+
+ String ddlgClass = prefs.get(this.projectLocation.getUUID() + ".ddlg", null);
+               if (ddlgClass != null) {
+                   try {
+ DDLGenerator ddlg = (DDLGenerator) Class.forName(ddlgClass).newInstance();
+                setDDLGenerator(ddlg);
+ ddlg.setTargetCatalog(prefs.get(this.projectLocation.getUUID() + ".targetCatalog", null)); + ddlg.setTargetSchema(prefs.get(this.projectLocation.getUUID() + ".targetSchema", null));
+            } catch (Exception e) {
+ createUserPrompter("Cannot load DDL settings due to missing class " + ddlgClass, + UserPromptType.MESSAGE, UserPromptOptions.OK, UserPromptResponse.OK, null, "OK"); + logger.error("Cannot find DDL Generator for class " + ddlgClass +
+                        ", ddl generator properties are not loaded.");
+            }
+               }

                outboundHttpClient = 
createHttpClient(projectLocation.getServiceInfo());

@@ -124,6 +171,17 @@
        @Override
     public boolean close() {
        logger.debug("Closing Client Session");
+
+       if (getDDLGenerator() != null) {
+           if (getDDLGenerator().getTargetCatalog() != null) {
+ prefs.put(projectLocation.getUUID() + ".targetCatalog", getDDLGenerator().getTargetCatalog());
+           }
+           if (getDDLGenerator().getTargetSchema() != null) {
+ prefs.put(projectLocation.getUUID() + ".targetSchema", getDDLGenerator().getTargetSchema());
+           }
+ prefs.put(projectLocation.getUUID() + ".ddlg", getDDLGenerator().getClass().getName());
+       }
+
        try {
                //TODO: Figure out how to de-register the session &c.
//HttpUriRequest request = new HttpDelete(getServerURI(projectLocation.getServiceInfo(),

Reply via email to