Search in sources :

Example 1 with Level

use of mondrian.olap.MondrianDef.Level in project collect by openforis.

the class Mondrian4SchemaGenerator method createDimension.

private Dimension createDimension(DataTable dataTable, AttributeDefinition attrDefn) {
    List<Attribute> attrs = createDimensionAttributes(dataTable, attrDefn);
    if (attrs.isEmpty()) {
        return null;
    } else {
        Dimension dimension = new Dimension();
        dimension.name = attrDefn.getName();
        dimension.caption = getDimensionCaption(attrDefn);
        if (attrDefn.hasMainField()) {
            dimension.key = attrDefn.getMainFieldName();
        } else {
            dimension.key = attrDefn.getName();
        }
        dimension.table = dataTable.getName();
        Attributes attributes = new Attributes();
        attributes.list().addAll(attrs);
        dimension.children.add(attributes);
        List<Level> hierarchyLevels = createHierarchyLevels(attrDefn);
        if (!hierarchyLevels.isEmpty()) {
            Hierarchies hierarchies = new Hierarchies();
            Hierarchy hierarchy = new Hierarchy();
            hierarchy.name = attrDefn.getName() + "_full_hierarchy";
            hierarchy.children.addAll(hierarchyLevels);
            hierarchies.list().add(hierarchy);
            dimension.children.add(hierarchies);
        }
        return dimension;
    }
}
Also used : Hierarchy(mondrian.olap.MondrianDef.Hierarchy) Hierarchies(mondrian.olap.MondrianDef.Hierarchies) Attribute(mondrian.olap.MondrianDef.Attribute) Attributes(mondrian.olap.MondrianDef.Attributes) Level(mondrian.olap.MondrianDef.Level) Dimension(mondrian.olap.MondrianDef.Dimension)

Aggregations

Attribute (mondrian.olap.MondrianDef.Attribute)1 Attributes (mondrian.olap.MondrianDef.Attributes)1 Dimension (mondrian.olap.MondrianDef.Dimension)1 Hierarchies (mondrian.olap.MondrianDef.Hierarchies)1 Hierarchy (mondrian.olap.MondrianDef.Hierarchy)1 Level (mondrian.olap.MondrianDef.Level)1