Author: kevin1219
Date: Fri Aug 29 13:43:28 2008
New Revision: 2671
Modified:
trunk/src/ca/sqlpower/architect/olap/OLAPSession.java
trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java
trunk/src/ca/sqlpower/architect/olap/SchemaWatcher.java
Log:
Removed dependencies from OLAPUtil on the SchemaWatcher.
Modified: trunk/src/ca/sqlpower/architect/olap/OLAPSession.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/olap/OLAPSession.java (original)
+++ trunk/src/ca/sqlpower/architect/olap/OLAPSession.java Fri Aug 29
13:43:28 2008
@@ -23,11 +23,7 @@
import java.util.List;
import ca.sqlpower.architect.SQLDatabase;
-import ca.sqlpower.architect.olap.MondrianModel.Cube;
-import ca.sqlpower.architect.olap.MondrianModel.CubeDimension;
-import ca.sqlpower.architect.olap.MondrianModel.Dimension;
import ca.sqlpower.architect.olap.MondrianModel.Schema;
-import ca.sqlpower.architect.olap.MondrianModel.VirtualCube;
/**
* The collection of objects that support editing and use of an OLAP
schema.
@@ -136,49 +132,5 @@
public boolean removeChild(OLAPObject child) {
throw new UnsupportedOperationException(
"OLAPSession has exactly one child (the Schema) for its
entire lifetime");
- }
-
- /**
- * Returns a public dimension in the child schema with the given name,
case
- * insensitive.
- *
- * @param name
- * The name to search by.
- * @return A public Dimension with the name, or null if not found.
- */
- public Dimension findPublicDimension(String name) {
- return schemaWatcher.findPublicDimension(name);
- }
-
- /**
- * Returns a CubeDimension in the child schema with the given name and
- * parent Cube, case insensitive.
- *
- * @param cubeName Name of the Cube to search in.
- * @param dimName Name of the CubeDimension to search for.
- * @return A CubeDimension in the Cube with the name, or null if not
found.
- */
- public CubeDimension findCubeDimension(String cubeName, String
dimName) {
- return schemaWatcher.findCubeDimension(cubeName, dimName);
- }
-
- /**
- * Returns a Cube in the child schema with the given name.
- *
- * @param name The name to search by.
- * @return A Cube with the name, or null if not found.
- */
- public Cube findCube(String name) {
- return schemaWatcher.findCube(name);
- }
-
- /**
- * Returns a VirtualCube in the child schema with the given name.
- *
- * @param name The name to search by.
- * @return A VirtualCube with the name, or null if not found.
- */
- public VirtualCube findVirtualCube(String name) {
- return schemaWatcher.findVirtualCube(name);
}
}
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 Fri Aug 29 13:43:28
2008
@@ -314,7 +314,12 @@
if (olapSession == null) {
throw new IllegalArgumentException("Can't find OLAPSession
ancestor: " + cu);
}
- return olapSession.findCube(cu.getCubeName());
+ for (Cube c : olapSession.getSchema().getCubes()) {
+ if (c.getName().equalsIgnoreCase(cu.getCubeName())) {
+ return c;
+ }
+ }
+ return null;
}
/**
@@ -338,29 +343,43 @@
return (Dimension) cubeDim;
} else if (cubeDim instanceof DimensionUsage) {
String dimName = ((DimensionUsage) cubeDim).getSource();
- return olapSession.findPublicDimension(dimName);
+ for (Dimension d : olapSession.getSchema().getDimensions()) {
+ if (d.getName().equalsIgnoreCase(dimName)) {
+ return d;
+ }
+ }
} else if (cubeDim instanceof VirtualCubeDimension) {
VirtualCubeDimension vCubeDim = (VirtualCubeDimension) cubeDim;
if (vCubeDim.getCubeName() == null) {
- return olapSession.findPublicDimension(vCubeDim.getName());
+ String dimName = vCubeDim.getName();
+ for (Dimension d :
olapSession.getSchema().getDimensions()) {
+ if (d.getName().equalsIgnoreCase(dimName)) {
+ return d;
+ }
+ }
} else {
- CubeDimension cd =
olapSession.findCubeDimension(vCubeDim.getCubeName(), vCubeDim.getName());
-
- if (cd == null) {
- return null;
- } else if (cd instanceof Dimension) {
- return (Dimension) cd;
- } else if (cd instanceof DimensionUsage) {
- DimensionUsage du = (DimensionUsage) cd;
- return olapSession.findPublicDimension(du.getSource());
- } else {
- throw new IllegalStateException("Invalid reference by
VirtualCubeDimension: " + vCubeDim);
+ for (Cube c : olapSession.getSchema().getCubes()) {
+ if
(c.getName().equalsIgnoreCase(vCubeDim.getCubeName())) {
+ for (CubeDimension cd : c.getDimensions()) {
+ if
(cd.getName().equalsIgnoreCase(vCubeDim.getName())) {
+ if (cd instanceof Dimension) {
+ return (Dimension) cd;
+ } else if (cd instanceof DimensionUsage) {
+ DimensionUsage du = (DimensionUsage)
cd;
+ return findReferencedDimension(du);
+ } else {
+ throw new
IllegalStateException("Invalid reference by VirtualCubeDimension: " +
vCubeDim);
+ }
+ }
+ }
+ }
}
}
} else {
// How do you enter the 4th dimension?!?!? ;)
throw new UnsupportedOperationException("CubeDimension of
type " + cubeDim.getClass() + " not recognized.");
}
+ return null;
}
/**
@@ -383,13 +402,29 @@
}
if (type == Cube.class) {
- return olapSession.findCube(name) == null;
+ for (Cube c : olapSession.getSchema().getCubes()) {
+ if (c.getName().equalsIgnoreCase(name)) {
+ return false;
+ }
+ }
} else if (type == Dimension.class && parent instanceof Schema) {
- return olapSession.findPublicDimension(name) == null;
+ for (Dimension d : ((Schema) parent).getDimensions()) {
+ if (d.getName().equalsIgnoreCase(name)) {
+ return false;
+ }
+ }
} else if (type == Dimension.class && parent instanceof Cube) {
- return olapSession.findCubeDimension(parent.getName(), name)
== null;
+ for (CubeDimension cd : ((Cube) parent).getDimensions()) {
+ if (cd.getName().equalsIgnoreCase(name)) {
+ return false;
+ }
+ }
} else if (type == VirtualCube.class) {
- return olapSession.findVirtualCube(name) == null;
+ for (VirtualCube vCube :
olapSession.getSchema().getVirtualCubes()) {
+ if (vCube.getName().equalsIgnoreCase(name)) {
+ return false;
+ }
+ }
} else if (type == Measure.class) {
Cube c = (Cube) parent;
for (Measure m : c.getMeasures()) {
@@ -397,7 +432,6 @@
return false;
}
}
- return true;
} else if (type == Level.class) {
Hierarchy h = (Hierarchy) parent;
for (Level l : h.getLevels()) {
@@ -405,7 +439,6 @@
return false;
}
}
- return true;
} else if (type == Hierarchy.class) {
Dimension d = (Dimension) parent;
for (Hierarchy h : d.getHierarchies()) {
@@ -418,7 +451,6 @@
return false;
}
}
- return true;
} else if (type == CubeUsage.class) {
VirtualCube vCube = (VirtualCube) parent;
for (CubeUsage usage : vCube.getCubeUsage().getCubeUsages()) {
@@ -426,7 +458,6 @@
return false;
}
}
- return true;
} else if (type == DimensionUsage.class) {
Cube c = (Cube) parent;
for (CubeDimension cd : c.getDimensions()) {
@@ -434,9 +465,7 @@
return false;
}
}
- return true;
- } else {
- return true;
}
+ return true;
}
}
Modified: trunk/src/ca/sqlpower/architect/olap/SchemaWatcher.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/olap/SchemaWatcher.java (original)
+++ trunk/src/ca/sqlpower/architect/olap/SchemaWatcher.java Fri Aug 29
13:43:28 2008
@@ -471,51 +471,6 @@
}
/**
- * Finds and returns a Dimension with the given name, case insensitive.
- *
- * @param name The name to search by.
- * @return A Dimension with the given name, or null if none found.
- */
- public Dimension findPublicDimension(String name) {
- return publicDimensions.get(name.toLowerCase());
- }
-
- /**
- * Finds and returns a CubeDimension with a [EMAIL PROTECTED] CubeDimensionKey}
that
- * matches the given cube name and dimension name, case insensitive.
- *
- * @param cubeName
- * Part of the [EMAIL PROTECTED] CubeDimensionKey} to search by.
- * @param dimName
- * Part of the [EMAIL PROTECTED] CubeDimensionKey} to search by.
- * @return A CubeDimension identified by a [EMAIL PROTECTED] CubeDimensionKey}
that
- * represents the given names, or null with none found.
- */
- public CubeDimension findCubeDimension(String cubeName, String
dimName) {
- return cubeDimensions.get(new CubeDimensionKey(cubeName, dimName));
- }
-
- /**
- * Finds and returns a Cube with the given name, case insensitive.
- *
- * @param name The name to search by.
- * @return A Cube with the given name, or null if none found.
- */
- public Cube findCube(String name) {
- return cubes.get(name.toLowerCase());
- }
-
- /**
- * Finds and returns a VirtualCube with the given name, case
insensitive.
- *
- * @param name The name to search by.
- * @return A VirtualCube with the given name, or null if none found.
- */
- public VirtualCube findVirtualCube(String name) {
- return vCubes.get(name.toLowerCase());
- }
-
- /**
* A composite key class that holds the cubeName and name properties
in a
* VirtualCubeDimension. The cubeName property identifies the name of
Cube
* that holds the CubeDimension and the name property identifies the
name of