Skip to content

Commit

Permalink
Added schema metadata GET endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
scottcame committed Sep 6, 2018
1 parent 34f39f1 commit b1335bc
Show file tree
Hide file tree
Showing 13 changed files with 834 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -29,7 +29,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.ojbc</groupId>
<artifactId>mondrian-rest</artifactId>
<version>1.3.1</version>
<version>1.3.2</version>
<name>Mondrian REST API Implementation</name>
<packaging>war</packaging>

Expand Down
87 changes: 87 additions & 0 deletions src/main/java/org/ojbc/mondrian/CubeWrapper.java
@@ -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;
}

}
83 changes: 83 additions & 0 deletions src/main/java/org/ojbc/mondrian/DimensionWrapper.java
@@ -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;
}

}
86 changes: 86 additions & 0 deletions src/main/java/org/ojbc/mondrian/HierarchyWrapper.java
@@ -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;
}

}
110 changes: 110 additions & 0 deletions src/main/java/org/ojbc/mondrian/LevelWrapper.java
@@ -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;
}



}

0 comments on commit b1335bc

Please sign in to comment.