Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Enhancements to solution for Issue 110

  • Loading branch information...
commit f18f01395a3aa74cac1bb3e17abdd698770093df 1 parent 3c86d38
@sramazzina sramazzina authored
View
42 saiku-core/saiku-service/saiku-service.iml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <excludeFolder url="file://$MODULE_DIR$/target" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="Maven: org.olap4j:olap4j:1.0.0-SNAPSHOT" level="project" />
+ <orderEntry type="library" name="Maven: javacup:javacup:10k" level="project" />
+ <orderEntry type="library" name="Maven: pentaho:mondrian:3.3-SNAPSHOT" level="project" />
+ <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2" level="project" />
+ <orderEntry type="library" name="Maven: commons-dbcp:commons-dbcp:1.2.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-pool:commons-pool:1.2" level="project" />
+ <orderEntry type="library" name="Maven: xml-apis:xml-apis:2.0.2" level="project" />
+ <orderEntry type="library" name="Maven: xerces:xercesImpl:2.5.0" level="project" />
+ <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.4" level="project" />
+ <orderEntry type="library" name="Maven: commons-io:commons-io:1.4" level="project" />
+ <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-math:commons-math:1.1" level="project" />
+ <orderEntry type="library" name="Maven: commons-discovery:commons-discovery:0.2" level="project" />
+ <orderEntry type="library" name="Maven: commons-vfs:commons-vfs:1.0" level="project" />
+ <orderEntry type="library" name="Maven: net.java.dev.javacc:javacc:5.0" level="project" />
+ <orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
+ <orderEntry type="library" name="Maven: eigenbase:eigenbase-xom:1.3.0.11999" level="project" />
+ <orderEntry type="library" name="Maven: eigenbase:eigenbase-properties:1.1.0.10924" level="project" />
+ <orderEntry type="library" name="Maven: eigenbase:eigenbase-resgen:1.3.0.11873" level="project" />
+ <orderEntry type="library" name="Maven: sun:jlfgr:1.0" level="project" />
+ <orderEntry type="library" name="Maven: javax.servlet:servlet-api:2.4" level="project" />
+ <orderEntry type="library" name="Maven: log4j:log4j:1.2.14" level="project" />
+ <orderEntry type="library" name="Maven: xalan:xalan:2.4.1" level="project" />
+ <orderEntry type="library" name="Maven: org.olap4j:olap4j-xmla:1.0.0-SNAPSHOT" level="project" />
+ <orderEntry type="library" name="Maven: org.jdom:jdom:1.1" level="project" />
+ <orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.6.1" level="project" />
+ <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.6.1" level="project" />
+ <orderEntry type="library" name="Maven: net.sourceforge.jexcelapi:jxl:2.6.10" level="project" />
+ </component>
+</module>
+
View
78 saiku-core/saiku-service/src/main/java/org/saiku/olap/query/OlapQuery.java
@@ -99,30 +99,41 @@ public Cube getCube() {
public QueryAxis getUnusedAxis() {
return this.query.getUnusedAxis();
}
-
- public void moveDimension(QueryDimension dimension, Axis axis) {
- dimension.setHierarchizeMode(HierarchizeMode.PRE);
- if (dimension.getName() != "Measures") {
- dimension.setHierarchyConsistent(true);
- }
- QueryAxis unusedAxis = findInUnusedAxis(dimension);
- QueryAxis newQueryAxis = query.getAxis(axis);
- if (unusedAxis != null && newQueryAxis != null) {
- unusedAxis.removeDimension(dimension);
- newQueryAxis.addDimension(dimension);
+
+ public void moveDimension(QueryDimension dimension, Axis targetAxis) {
+
+ QueryAxis actualAxis = findActualAxis(dimension);
+ QueryAxis targetQueryAxis = (targetAxis == null) ? query.getUnusedAxis() : query.getAxis(targetAxis);
+
+ if (actualAxis != null && targetQueryAxis != null && !targetQueryAxis.getDimensions().contains(dimension)) {
+ // Proceed do the things on the new dimension only if it is really necessary
+ if (targetAxis != null) {
+ // Do these things only for all axes != UNUSED
+ dimension.setHierarchizeMode(HierarchizeMode.PRE);
+ if (dimension.getName() != "Measures") {
+ dimension.setHierarchyConsistent(true);
+ }
+ }
+ actualAxis.removeDimension(dimension);
+ targetQueryAxis.addDimension(dimension);
}
}
- public void moveDimension(QueryDimension dimension, Axis axis, int position) {
- dimension.setHierarchizeMode(HierarchizeMode.PRE);
- if (dimension.getName() != "Measures") {
- dimension.setHierarchyConsistent(true);
- }
- QueryAxis unusedAxis = findInUnusedAxis(dimension);
- QueryAxis newQueryAxis = query.getAxis(axis);
- if (unusedAxis != null && newQueryAxis != null) {
- unusedAxis.removeDimension(dimension);
- newQueryAxis.addDimension(position, dimension);
+ public void moveDimension(QueryDimension dimension, Axis targetAxis, int position) {
+ QueryAxis actualAxis = findActualAxis(dimension);
+ QueryAxis targetQueryAxis = (targetAxis == null) ? query.getUnusedAxis() : query.getAxis(targetAxis);
+
+ if (actualAxis != null && targetQueryAxis != null && !targetQueryAxis.getDimensions().contains(dimension)) {
+ // Proceed do the things on the new dimension only if it is really necessary
+ if (targetAxis != null) {
+ // Do these things only for all axes != UNUSED
+ dimension.setHierarchizeMode(HierarchizeMode.PRE);
+ if (dimension.getName() != "Measures") {
+ dimension.setHierarchyConsistent(true);
+ }
+ }
+ actualAxis.removeDimension(dimension);
+ targetQueryAxis.addDimension(position, dimension);
}
}
@@ -130,27 +141,36 @@ public QueryDimension getDimension(String name) {
return this.query.getDimension(name);
}
- private QueryAxis findInUnusedAxis(QueryDimension dimension) {
+ private QueryAxis findActualAxis(QueryDimension dimension) {
+
+ QueryAxis theAxis = findUnusedAxis(dimension);
- QueryAxis theUnusedAxis = null;
+ if (theAxis == null) theAxis = findInQueryAxis(dimension);
- if (query.getUnusedAxis().getDimensions().contains(dimension))
- theUnusedAxis = query.getUnusedAxis();
+ return theAxis;
+ }
+
+ private QueryAxis findUnusedAxis(QueryDimension dimension) {
+
+ QueryAxis theAxis = null;
- return theUnusedAxis;
+ if (query.getUnusedAxis().getDimensions().contains(dimension))
+ theAxis = query.getUnusedAxis();
+ return theAxis;
}
- private QueryAxis findInQueryAxis(QueryDimension dimension) {
+ private QueryAxis findInQueryAxis(QueryDimension dimension) {
+
QueryAxis theAxis = null;
+
Map<Axis,QueryAxis> axes = query.getAxes();
for (Axis axis : axes.keySet()) {
if (axes.get(axis).getDimensions().contains(dimension)) {
theAxis = axes.get(axis);
}
}
-
return theAxis;
- }
+ }
public String getMdx() {
final Writer writer = new StringWriter();
View
10 saiku-core/saiku-service/src/main/java/org/saiku/service/olap/OlapQueryService.java
@@ -428,9 +428,8 @@ public boolean removeLevel(String queryName, String dimensionName, String unique
}
dimension.getInclusions().removeAll(removals);
if (dimension.getInclusions().size() == 0) {
- moveDimension(queryName, null , dimensionName, -1);
+ removeDimension(queryName, dimensionName);
}
-
}
}
}
@@ -462,6 +461,13 @@ public void moveDimension(String queryName, String axisName, String dimensionNam
}
}
+ public void removeDimension(String queryName, String dimensionName) {
+ IQuery query = getIQuery(queryName);
+ moveDimension(queryName, "UNUSED" , dimensionName, -1);
+ query.getDimension(dimensionName).getExclusions().clear();
+ query.getDimension(dimensionName).getInclusions().clear();
+ }
+
public void removeDimension(String queryName, String axisName, String dimensionName) {
IQuery query = getIQuery(queryName);
moveDimension(queryName, "UNUSED" , dimensionName, -1);
Please sign in to comment.
Something went wrong with that request. Please try again.