Author: kevin1219
Date: Wed Aug 27 12:35:13 2008
New Revision: 2631

Modified:
   trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java
trunk/src/ca/sqlpower/architect/swingui/olap/action/CreateMeasureAction.java trunk/src/ca/sqlpower/architect/swingui/olap/action/EditMeasureAction.java

Log:
Mondrian specifies that a measure must identify a column or expression but not both, so implemented the ui for that.

Modified: trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java  (original)
+++ trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java Wed Aug 27 12:35:13 2008
@@ -176,11 +176,11 @@

     /**
      * Retrieves the SQLTable that represents the data source for the given
-     * cube.
+     * hierarchy.
      *
      * @param hierarchy
      *            the hierarchy whose data source to retrieve
- * @return The table whose columns represent the columns of cube's source + * @return The table whose columns represent the columns of hierarchy's source * table (or view, inline table, or join), or null if the hierarchy
      *         has no table selected.
      * @throws ArchitectException
@@ -199,6 +199,38 @@
             relation = owningCube.getFact();
         }

+        return tableForRelationOrJoin(database, relation);
+    }
+
+    /**
+ * Retrieves the SQLTable that represents the data source for the given cube.
+     *
+     * @param cube The cube whose data source to retrieve.
+ * @return The table whose columns represent the columns of cube's source
+     *         table (or view, inline table, or join), or null if the cube
+     *         has no table set.
+     * @throws ArchitectException
+     *             if populating the necessary SQLObjects fails.
+     */
+ public static SQLTable tableForCube(Cube cube) throws ArchitectException {
+        OLAPSession session = getSession(cube);
+        SQLDatabase database = session.getDatabase();
+
+        RelationOrJoin relation = cube.getFact();
+        return tableForRelationOrJoin(database, relation);
+    }
+
+    /**
+     * Helper method to find the SQLTable that a RelationOrJoin represents.
+     *
+     * @param database The database to search for the table in.
+     * @param relation The RelationOrJoin identifying the table.
+ * @return The SQLTable that the given relation represents, or null if non
+     *         found.
+     * @throws ArchitectException
+     *             if populating the necessary SQLObjects fails
+     */
+ private static SQLTable tableForRelationOrJoin(SQLDatabase database, RelationOrJoin relation) throws ArchitectException {
         if (relation == null) {
             return null;
         } else if (relation instanceof Table) {

Modified: trunk/src/ca/sqlpower/architect/swingui/olap/action/CreateMeasureAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/olap/action/CreateMeasureAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/olap/action/CreateMeasureAction.java Wed Aug 27 12:35:13 2008
@@ -19,6 +19,8 @@

 package ca.sqlpower.architect.swingui.olap.action;

+import ca.sqlpower.architect.ArchitectException;
+import ca.sqlpower.architect.ArchitectRuntimeException;
 import ca.sqlpower.architect.olap.OLAPUtil;
 import ca.sqlpower.architect.olap.MondrianModel.Measure;
 import ca.sqlpower.architect.swingui.ArchitectSwingSession;
@@ -49,7 +51,11 @@

     @Override
     protected DataEntryPanel createDataEntryPanel(Measure model) {
-        return new MeasureEditPanel(model);
+        try {
+            return new MeasureEditPanel(model);
+        } catch (ArchitectException e) {
+            throw new ArchitectRuntimeException(e);
+        }
     }

 }

Modified: trunk/src/ca/sqlpower/architect/swingui/olap/action/EditMeasureAction.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/olap/action/EditMeasureAction.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/olap/action/EditMeasureAction.java Wed Aug 27 12:35:13 2008
@@ -25,6 +25,8 @@
 import javax.swing.JDialog;
 import javax.swing.SwingUtilities;

+import ca.sqlpower.architect.ArchitectException;
+import ca.sqlpower.architect.ArchitectRuntimeException;
 import ca.sqlpower.architect.olap.MondrianModel.Measure;
 import ca.sqlpower.architect.swingui.ArchitectSwingSession;
 import ca.sqlpower.architect.swingui.PlayPen;
@@ -51,9 +53,13 @@
     }

     public void actionPerformed(ActionEvent e) {
-        DataEntryPanel panel = new MeasureEditPanel(measure);
- JDialog dialog = DataEntryPanelBuilder.createDataEntryPanelDialog(panel, dialogOwner, "Measure Properties", "OK");
-        dialog.setLocationRelativeTo(session.getArchitectFrame());
-        dialog.setVisible(true);
+        try {
+            DataEntryPanel panel = new MeasureEditPanel(measure);
+ JDialog dialog = DataEntryPanelBuilder.createDataEntryPanelDialog(panel, dialogOwner, "Measure Properties", "OK");
+            dialog.setLocationRelativeTo(session.getArchitectFrame());
+            dialog.setVisible(true);
+        } catch (ArchitectException ex) {
+            throw new ArchitectRuntimeException(ex);
+        }
     }
 }

Reply via email to