Author: [EMAIL PROTECTED]
Date: Mon Sep  8 15:38:05 2008
New Revision: 2709

Modified:
trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
   trunk/src/ca/sqlpower/architect/ArchitectSession.java
   trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java
   trunk/src/ca/sqlpower/architect/CoreProject.java
   trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSession.java
   trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
   trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java

Log:
Moved the OLAP root object from the core session to the swing session. This is a fix for bug 1629.

Modified: trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java
==============================================================================
--- trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java (original) +++ trunk/regress/ca/sqlpower/architect/swingui/TestingArchitectSwingSession.java Mon Sep 8 15:38:05 2008
@@ -67,6 +67,7 @@
     private KettleJob kettleJob;
     private RecentMenu recent;
     private ArchitectSession delegateSession;
+    private OLAPRootObject olapRootObject;

     private boolean showPkTag = true;
     private boolean showFkTag = true;
@@ -95,6 +96,7 @@
         sourceDatabases = new DBTree(this);
playpen = RelationalPlayPenFactory.createPlayPen(this, sourceDatabases);
         undoManager = new UndoManager(playpen);
+        olapRootObject = new OLAPRootObject(delegateSession);

         compareDMSettings = new CompareDMSettings();

@@ -338,7 +340,7 @@
     }

     public OLAPRootObject getOLAPRootObject() {
-        return delegateSession.getOLAPRootObject();
+        return olapRootObject;
     }

     public void showOLAPSchemaManager(Window owner) {

Modified: trunk/src/ca/sqlpower/architect/ArchitectSession.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ArchitectSession.java       (original)
+++ trunk/src/ca/sqlpower/architect/ArchitectSession.java Mon Sep 8 15:38:05 2008
@@ -21,7 +21,6 @@
 import java.util.List;

 import ca.sqlpower.architect.ddl.DDLGenerator;
-import ca.sqlpower.architect.olap.OLAPRootObject;
 import ca.sqlpower.architect.profile.ProfileManager;

 public interface ArchitectSession extends UserPrompterFactory {
@@ -98,15 +97,5 @@

     /* docs inherit from interface */
public UserPrompter createUserPrompter(String question, String okText, String notOkText, String cancelText);
-
-    /**
- * Returns the OLAP root object, which contains all the OLAP sessions that are part of this
-     * Architect session.
-     * <p>
- * Note: We would prefer not to let ArchitectSession reference anything in the OLAP editor, - * since we do not want the core Architect API to include OLAP support. We are currently
-     * trying to come up with a way to put this somewhere else.
-     */
-    public OLAPRootObject getOLAPRootObject();

 }

Modified: trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java   (original)
+++ trunk/src/ca/sqlpower/architect/ArchitectSessionImpl.java Mon Sep 8 15:38:05 2008
@@ -24,7 +24,6 @@

 import ca.sqlpower.architect.ddl.DDLGenerator;
 import ca.sqlpower.architect.ddl.GenericDDLGenerator;
-import ca.sqlpower.architect.olap.OLAPRootObject;
 import ca.sqlpower.architect.profile.ProfileManagerImpl;

 /**
@@ -43,7 +42,6 @@
     private SQLDatabase db;
     private String name;
     private SQLObjectRoot rootObject;
-    private OLAPRootObject olapRootObject;

     /**
* The factory that creates user prompters for this session. Defaults to a
@@ -67,7 +65,6 @@
            this.context = context;
            this.name = name;
            this.rootObject = new SQLObjectRoot();
- this.olapRootObject = new OLAPRootObject(this); // XXX wrong reference direction--core shouldn't depend on OLAP
         this.profileManager = new ProfileManagerImpl(this);
         this.project = new CoreProject(this);
         this.db = new SQLDatabase();
@@ -161,9 +158,6 @@
         }
         userPrompterFactory = upFactory;
     }
-
-    public OLAPRootObject getOLAPRootObject() {
-        return olapRootObject;
-    }
+
 }


Modified: trunk/src/ca/sqlpower/architect/CoreProject.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/CoreProject.java    (original)
+++ trunk/src/ca/sqlpower/architect/CoreProject.java Mon Sep 8 15:38:05 2008
@@ -47,9 +47,7 @@
 import ca.sqlpower.architect.SQLRelationship.UpdateDeleteRule;
 import ca.sqlpower.architect.SQLTable.Folder;
 import ca.sqlpower.architect.ddl.GenericDDLGenerator;
-import ca.sqlpower.architect.olap.MondrianXMLReader;
 import ca.sqlpower.architect.olap.OLAPObject;
-import ca.sqlpower.architect.olap.OLAPSession;
 import ca.sqlpower.architect.profile.ColumnProfileResult;
 import ca.sqlpower.architect.profile.ColumnValueCount;
 import ca.sqlpower.architect.profile.TableProfileResult;
@@ -165,32 +163,6 @@
         try {
             dbcsLoadIdMap = new HashMap<String, SPDataSource>();
             sqlObjectLoadIdMap = new HashMap<String, SQLObject>();
-            olapObjectLoadIdMap = new HashMap<String, OLAPObject>();
-
- // sqlObjectLoadIdMap is not ready yet when parsing the olap objects - // so this keeps track of the id of the SQLDatabase that OLAPSessions reference. - Map<OLAPSession, String> sessionDbMap = new HashMap<OLAPSession, String>();
-
-            if (uin.markSupported()) {
-                uin.mark(Integer.MAX_VALUE);
-            } else {
- throw new IllegalStateException("Failed to load with an input stream that does not support mark!");
-            }
-
- // parse the Mondrian business model parts first because the olap id
-            // map is needed in the digester for parsing the olap gui
-            try {
- MondrianXMLReader.parse(uin, session.getOLAPRootObject(), sessionDbMap, olapObjectLoadIdMap);
-            } catch (SAXException e) {
- logger.error("Error parsing project file's olap schemas!", e); - throw new ArchitectException("SAX Exception in project file olap schemas parse!", e);
-            } catch (Exception ex) {
- logger.error("General Exception in project file olap schemas parse!", ex);
-                throw new ArchitectException("Unexpected Exception", ex);
-            }
-
-            // returning to the beginning of the inputStream
-            uin.reset();

             Digester digester = null;

@@ -293,14 +265,6 @@
                     }
                 }

-            }
-
-            // now that the sqlObjectLoadIdMap is populated, we can set the
-            // OLAPSessions' database.
- for (Map.Entry<OLAPSession, String> entry : sessionDbMap.entrySet()) {
-                OLAPSession oSession = entry.getKey();
- SQLDatabase db = (SQLDatabase) sqlObjectLoadIdMap.get(entry.getValue());
-                oSession.setDatabase(db);
             }

             setModified(false);

Modified: trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSession.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSession.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSession.java Mon Sep 8 15:38:05 2008
@@ -27,6 +27,7 @@
 import ca.sqlpower.architect.ArchitectSession;
 import ca.sqlpower.architect.CoreUserSettings;
 import ca.sqlpower.architect.etl.kettle.KettleJob;
+import ca.sqlpower.architect.olap.OLAPRootObject;
 import ca.sqlpower.architect.olap.OLAPSession;
 import ca.sqlpower.architect.swingui.olap.OLAPEditSession;
 import ca.sqlpower.architect.undo.UndoManager;
@@ -291,6 +292,16 @@
* @return the associated OLAPEditSession, creates a new one if none found.
      */
     public OLAPEditSession getOLAPEditSession(OLAPSession olapSession);
+
+    /**
+ * Returns the OLAP root object, which contains all the OLAP sessions that are part of this
+     * Architect session.
+     * <p>
+ * Note: We would prefer not to let ArchitectSession reference anything in the OLAP editor, + * since we do not want the core Architect API to include OLAP support. We are currently
+     * trying to come up with a way to put this somewhere else.
+     */
+    public OLAPRootObject getOLAPRootObject();

     /**
* Adds the given listener to the list of interested parties who want to be

Modified: trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/ArchitectSwingSessionImpl.java Mon Sep 8 15:38:05 2008
@@ -1,4 +1,4 @@
-/*
+ /*
  * Copyright (c) 2008, SQL Power Group Inc.
  *
  * This file is part of Power*Architect.
@@ -80,6 +80,11 @@
      * This is the core session that some tasks are delegated to.
      */
     private final ArchitectSession delegateSession;
+
+    /**
+     * This OLAP object contains the OLAP session.
+     */
+    private OLAPRootObject olapRootObject;

     /**
      * The Frame where the main part of the GUI for this session appears.
@@ -158,6 +163,7 @@
         this.isNew = true;
         this.context = context;
         this.delegateSession = new ArchitectSessionImpl(context, name);
+        this.olapRootObject = new OLAPRootObject(delegateSession);
((ArchitectSessionImpl)delegateSession).setProfileManager(new ProfileManagerImpl(this)); ((ArchitectSessionImpl)delegateSession).setUserPrompterFactory(this);
         this.recent = new RecentMenu(this.getClass()) {
@@ -789,7 +795,7 @@
     }

     public OLAPRootObject getOLAPRootObject() {
-        return delegateSession.getOLAPRootObject();
+        return olapRootObject;
     }

     /**

Modified: trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java (original)
+++ trunk/src/ca/sqlpower/architect/swingui/SwingUIProject.java Mon Sep 8 15:38:05 2008
@@ -57,7 +57,9 @@
 import ca.sqlpower.architect.SQLRelationship;
 import ca.sqlpower.architect.SQLSchema;
 import ca.sqlpower.architect.SQLTable;
+import ca.sqlpower.architect.UnclosableInputStream;
 import ca.sqlpower.architect.ddl.DDLGenerator;
+import ca.sqlpower.architect.olap.MondrianXMLReader;
 import ca.sqlpower.architect.olap.MondrianXMLWriter;
 import ca.sqlpower.architect.olap.OLAPObject;
 import ca.sqlpower.architect.olap.OLAPSession;
@@ -157,7 +159,47 @@
public void load(InputStream in, DataSourceCollection dataSources) throws IOException, ArchitectException {
         olapPaneLoadIdMap = new HashMap<String, OLAPPane<?, ?>>();

-        super.load(in, dataSources);
+        UnclosableInputStream uin = new UnclosableInputStream(in);
+        olapObjectLoadIdMap = new HashMap<String, OLAPObject>();
+
+ // sqlObjectLoadIdMap is not ready yet when parsing the olap objects + // so this keeps track of the id of the SQLDatabase that OLAPSessions reference. + Map<OLAPSession, String> sessionDbMap = new HashMap<OLAPSession, String>();
+
+        try {
+            if (uin.markSupported()) {
+                uin.mark(Integer.MAX_VALUE);
+            } else {
+ throw new IllegalStateException("Failed to load with an input stream that does not support mark!");
+            }
+
+ // parse the Mondrian business model parts first because the olap id
+            // map is needed in the digester for parsing the olap gui
+            try {
+ MondrianXMLReader.parse(uin, getSession().getOLAPRootObject(), sessionDbMap, olapObjectLoadIdMap);
+            } catch (SAXException e) {
+ logger.error("Error parsing project file's olap schemas!", e); + throw new ArchitectException("SAX Exception in project file olap schemas parse!", e);
+            } catch (Exception ex) {
+ logger.error("General Exception in project file olap schemas parse!", ex);
+                throw new ArchitectException("Unexpected Exception", ex);
+            }
+
+            in.reset();
+
+            super.load(in, dataSources);
+        }
+        finally {
+            uin.forceClose();
+        }
+
+        // now that the sqlObjectLoadIdMap is populated, we can set the
+        // OLAPSessions' database.
+ for (Map.Entry<OLAPSession, String> entry : sessionDbMap.entrySet()) {
+            OLAPSession oSession = entry.getKey();
+ SQLDatabase db = (SQLDatabase) sqlObjectLoadIdMap.get(entry.getValue());
+            oSession.setDatabase(db);
+        }

// set the view positions again in the case that the viewport was invalid earlier.
         getSession().getPlayPen().setInitialViewPosition();

Reply via email to