Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
834 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Unless explicitly acquired and licensed from Licensor under another license, the contents of | ||
* this file are subject to the Reciprocal Public License ("RPL") Version 1.5, or subsequent | ||
* versions as allowed by the RPL, and You may not copy or use this file in either source code | ||
* or executable form, except in compliance with the terms and conditions of the RPL | ||
* | ||
* All software distributed under the RPL is provided strictly on an "AS IS" basis, WITHOUT | ||
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND LICENSOR HEREBY DISCLAIMS ALL SUCH | ||
* WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
* PARTICULAR PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific language | ||
* governing rights and limitations under the RPL. | ||
* | ||
* http://opensource.org/licenses/RPL-1.5 | ||
* | ||
* Copyright 2018 Open Justice Broker Consortium and Cascadia Analytics LLC | ||
*/ | ||
package org.ojbc.mondrian; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.olap4j.OlapException; | ||
import org.olap4j.metadata.Cube; | ||
import org.olap4j.metadata.Dimension; | ||
import org.olap4j.metadata.Measure; | ||
|
||
/** | ||
* A wrapper around olap4j Cube objects, suitable for serialization via json. | ||
* | ||
*/ | ||
public class CubeWrapper { | ||
|
||
private String name; | ||
private String caption; | ||
private List<MeasureWrapper> measures; | ||
private List<DimensionWrapper> dimensions; | ||
|
||
CubeWrapper() { | ||
} | ||
|
||
public CubeWrapper(Cube cube) throws OlapException { | ||
this.name = cube.getName(); | ||
this.caption = cube.getCaption(); | ||
measures = new ArrayList<>(); | ||
for (Measure measure : cube.getMeasures()) { | ||
measures.add(new MeasureWrapper(measure)); | ||
} | ||
dimensions = new ArrayList<>(); | ||
for (Dimension d : cube.getDimensions()) { | ||
dimensions.add(new DimensionWrapper(d)); | ||
} | ||
} | ||
|
||
public List<MeasureWrapper> getMeasures() { | ||
return Collections.unmodifiableList(measures); | ||
} | ||
|
||
public List<DimensionWrapper> getDimensions() { | ||
return Collections.unmodifiableList(dimensions); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getCaption() { | ||
return caption; | ||
} | ||
|
||
void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
void setCaption(String caption) { | ||
this.caption = caption; | ||
} | ||
|
||
void setMeasures(List<MeasureWrapper> measures) { | ||
this.measures = measures; | ||
} | ||
|
||
void setDimensions(List<DimensionWrapper> dimensions) { | ||
this.dimensions = dimensions; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Unless explicitly acquired and licensed from Licensor under another license, the contents of | ||
* this file are subject to the Reciprocal Public License ("RPL") Version 1.5, or subsequent | ||
* versions as allowed by the RPL, and You may not copy or use this file in either source code | ||
* or executable form, except in compliance with the terms and conditions of the RPL | ||
* | ||
* All software distributed under the RPL is provided strictly on an "AS IS" basis, WITHOUT | ||
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND LICENSOR HEREBY DISCLAIMS ALL SUCH | ||
* WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
* PARTICULAR PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific language | ||
* governing rights and limitations under the RPL. | ||
* | ||
* http://opensource.org/licenses/RPL-1.5 | ||
* | ||
* Copyright 2018 Open Justice Broker Consortium and Cascadia Analytics LLC | ||
*/ | ||
package org.ojbc.mondrian; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.olap4j.OlapException; | ||
import org.olap4j.metadata.Dimension; | ||
import org.olap4j.metadata.Hierarchy; | ||
|
||
/** | ||
* A wrapper around olap4j Dimension objects, suitable for serialization via json. | ||
* | ||
*/ | ||
public class DimensionWrapper { | ||
|
||
private String name; | ||
private String caption; | ||
private String type; | ||
private List<HierarchyWrapper> hierarchies; | ||
|
||
DimensionWrapper() { | ||
} | ||
|
||
public DimensionWrapper(Dimension d) throws OlapException { | ||
this.name = d.getName(); | ||
this.caption = d.getCaption(); | ||
this.type = d.getDimensionType().getDescription(); | ||
hierarchies = new ArrayList<>(); | ||
for(Hierarchy h : d.getHierarchies()) { | ||
hierarchies.add(new HierarchyWrapper(h)); | ||
} | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getCaption() { | ||
return caption; | ||
} | ||
|
||
public List<HierarchyWrapper> getHierarchies() { | ||
return Collections.unmodifiableList(hierarchies); | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
void setCaption(String caption) { | ||
this.caption = caption; | ||
} | ||
|
||
void setHierarchies(List<HierarchyWrapper> hierarchies) { | ||
this.hierarchies = hierarchies; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Unless explicitly acquired and licensed from Licensor under another license, the contents of | ||
* this file are subject to the Reciprocal Public License ("RPL") Version 1.5, or subsequent | ||
* versions as allowed by the RPL, and You may not copy or use this file in either source code | ||
* or executable form, except in compliance with the terms and conditions of the RPL | ||
* | ||
* All software distributed under the RPL is provided strictly on an "AS IS" basis, WITHOUT | ||
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND LICENSOR HEREBY DISCLAIMS ALL SUCH | ||
* WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
* PARTICULAR PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific language | ||
* governing rights and limitations under the RPL. | ||
* | ||
* http://opensource.org/licenses/RPL-1.5 | ||
* | ||
* Copyright 2018 Open Justice Broker Consortium and Cascadia Analytics LLC | ||
*/ | ||
package org.ojbc.mondrian; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import org.olap4j.OlapException; | ||
import org.olap4j.metadata.Hierarchy; | ||
import org.olap4j.metadata.Level; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* A wrapper around olap4j Hierarchy objects, suitable for serialization via json. | ||
* | ||
*/ | ||
public class HierarchyWrapper { | ||
|
||
private String name; | ||
private String caption; | ||
private boolean hasAll; | ||
private List<LevelWrapper> levels; | ||
|
||
HierarchyWrapper() { | ||
} | ||
|
||
public HierarchyWrapper(Hierarchy h) throws OlapException { | ||
this.name = h.getName(); | ||
this.caption = h.getCaption(); | ||
this.hasAll = h.hasAll(); | ||
levels = new ArrayList<>(); | ||
for(Level level : h.getLevels()) { | ||
levels.add(new LevelWrapper(level)); | ||
} | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getCaption() { | ||
return caption; | ||
} | ||
|
||
@JsonProperty("hasAll") | ||
public boolean getHasAll() { | ||
return hasAll; | ||
} | ||
|
||
public List<LevelWrapper> getLevels() { | ||
return Collections.unmodifiableList(levels); | ||
} | ||
|
||
void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
void setCaption(String caption) { | ||
this.caption = caption; | ||
} | ||
|
||
void setHasAll(boolean hasAll) { | ||
this.hasAll = hasAll; | ||
} | ||
|
||
void setLevels(List<LevelWrapper> levels) { | ||
this.levels = levels; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* Unless explicitly acquired and licensed from Licensor under another license, the contents of | ||
* this file are subject to the Reciprocal Public License ("RPL") Version 1.5, or subsequent | ||
* versions as allowed by the RPL, and You may not copy or use this file in either source code | ||
* or executable form, except in compliance with the terms and conditions of the RPL | ||
* | ||
* All software distributed under the RPL is provided strictly on an "AS IS" basis, WITHOUT | ||
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND LICENSOR HEREBY DISCLAIMS ALL SUCH | ||
* WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
* PARTICULAR PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific language | ||
* governing rights and limitations under the RPL. | ||
* | ||
* http://opensource.org/licenses/RPL-1.5 | ||
* | ||
* Copyright 2018 Open Justice Broker Consortium and Cascadia Analytics LLC | ||
*/ | ||
package org.ojbc.mondrian; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.olap4j.OlapException; | ||
import org.olap4j.metadata.Level; | ||
import org.olap4j.metadata.Member; | ||
|
||
/** | ||
* A wrapper around olap4j Level objects, suitable for serialization via json. | ||
* | ||
*/ | ||
public class LevelWrapper { | ||
|
||
static final int CARDINALITY_LIMIT = 100; | ||
|
||
private String name; | ||
private String caption; | ||
private int depth; | ||
private int cardinality; | ||
private boolean populated; | ||
private List<MemberWrapper> members; | ||
|
||
LevelWrapper() { | ||
} | ||
|
||
public LevelWrapper(Level level) throws OlapException { | ||
this.name = level.getName(); | ||
this.caption = level.getCaption(); | ||
this.depth = level.getDepth(); | ||
this.cardinality = level.getCardinality(); | ||
members = new ArrayList<>(); | ||
if (cardinality <= CARDINALITY_LIMIT) { | ||
populated = true; | ||
for(Member member : level.getMembers()) { | ||
members.add(new MemberWrapper(member)); | ||
} | ||
} else { | ||
populated = false; | ||
} | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getCaption() { | ||
return caption; | ||
} | ||
|
||
public int getDepth() { | ||
return depth; | ||
} | ||
|
||
public int getCardinality() { | ||
return cardinality; | ||
} | ||
|
||
public boolean isPopulated() { | ||
return populated; | ||
} | ||
|
||
public List<MemberWrapper> getMembers() { | ||
return members; | ||
} | ||
|
||
void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
void setCaption(String caption) { | ||
this.caption = caption; | ||
} | ||
|
||
void setDepth(int depth) { | ||
this.depth = depth; | ||
} | ||
|
||
void setCardinality(int cardinality) { | ||
this.cardinality = cardinality; | ||
} | ||
|
||
void setPopulated(boolean populated) { | ||
this.populated = populated; | ||
} | ||
|
||
void setMembers(List<MemberWrapper> members) { | ||
this.members = members; | ||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.