use of mondrian.olap.MondrianDef.DimensionLink in project collect by openforis.
the class Mondrian4SchemaGenerator method createCube.
private Cube createCube(DataTable dataTable) {
NodeDefinition nodeDef = dataTable.getNodeDefinition();
Cube cube = new Cube();
cube.name = nodeDef.getName();
MeasureGroups measureGroups = new MondrianDef.MeasureGroups();
MeasureGroup measureGroup = new MeasureGroup();
measureGroup.name = cube.name;
Measures measures = new Measures();
List<Measure> measureList = createMeasures(dataTable);
measures.list().addAll(measureList);
measureGroup.children.add(measures);
measureGroup.table = dataTable.getName();
DimensionLinks dimensionLinks = new DimensionLinks();
measureGroup.children.add(dimensionLinks);
measureGroups.list().add(measureGroup);
cube.children.add(measureGroups);
if (nodeDef instanceof EntityDefinition) {
Dimensions dimensions = new Dimensions();
Queue<NodeDefinition> queue = new LinkedList<NodeDefinition>();
queue.addAll(((EntityDefinition) nodeDef).getChildDefinitions());
while (!queue.isEmpty()) {
NodeDefinition def = queue.poll();
if (def instanceof AttributeDefinition) {
AttributeDefinition attrDef = (AttributeDefinition) def;
Dimension dimension = createDimension(dataTable, attrDef);
if (dimension != null) {
dimensions.list().add(dimension);
// add dimension link
DimensionLink dimensionLink = createDimensionLink(dimension, attrDef);
dimensionLinks.list().add(dimensionLink);
}
} else if (!def.isMultiple()) {
queue.addAll(((EntityDefinition) def).getChildDefinitions());
}
}
cube.children.add(dimensions);
}
return cube;
}
use of mondrian.olap.MondrianDef.DimensionLink in project collect by openforis.
the class Mondrian4SchemaGenerator method createDimensionLink.
private DimensionLink createDimensionLink(Dimension dimension, AttributeDefinition attrDef) {
DimensionLink dimensionLink;
if (attrDef instanceof CodeAttributeDefinition) {
CodeAttributeDefinition codeAttrDef = (CodeAttributeDefinition) attrDef;
if (codeAttrDef.isMultiple()) {
dimensionLink = new NoLink();
} else if (codeAttrDef.getList().isExternal()) {
dimensionLink = new FactLink();
} else {
dimensionLink = new ForeignKeyLink();
DataTable dataTable = rdbSchema.getDataTable(attrDef.getParentEntityDefinition());
CodeValueFKColumn fkColumn = dataTable.getForeignKeyCodeColumn((CodeAttributeDefinition) attrDef);
((ForeignKeyLink) dimensionLink).foreignKeyColumn = fkColumn.getName();
}
} else {
dimensionLink = new FactLink();
}
dimensionLink.dimension = dimension.name;
return dimensionLink;
}
Aggregations