Search in sources :

Example 1 with SchemaReader

use of mondrian.olap.SchemaReader in project mondrian by pentaho.

the class SqlConstraintUtils method getRolesConstraints.

public static Map<RolapLevel, List<RolapMember>> getRolesConstraints(Evaluator evaluator) {
    Member[] mm = evaluator.getMembers();
    SchemaReader schemaReader = evaluator.getSchemaReader();
    Map<RolapLevel, List<RolapMember>> roleConstraints = new LinkedHashMap<RolapLevel, List<RolapMember>>(mm.length);
    for (Member member : mm) {
        boolean isRolesMember = (member instanceof LimitedRollupMember) || (member instanceof MultiCardinalityDefaultMember);
        if (isRolesMember) {
            List<Level> hierarchyLevels = schemaReader.getHierarchyLevels(member.getHierarchy());
            for (Level affectedLevel : hierarchyLevels) {
                List<Member> availableMembers = schemaReader.getLevelMembers(affectedLevel, false);
                List<RolapMember> slicerMembers = new ArrayList<RolapMember>(availableMembers.size());
                for (Member available : availableMembers) {
                    if (!available.isAll()) {
                        slicerMembers.add((RolapMember) available);
                    }
                }
                if (!slicerMembers.isEmpty()) {
                    roleConstraints.put((RolapLevel) affectedLevel, slicerMembers);
                }
            }
        }
    }
    return roleConstraints.isEmpty() ? Collections.<RolapLevel, List<RolapMember>>emptyMap() : roleConstraints;
}
Also used : SchemaReader(mondrian.olap.SchemaReader) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) LimitedRollupMember(mondrian.rolap.RolapHierarchy.LimitedRollupMember) MultiCardinalityDefaultMember(mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember) List(java.util.List) FilteredIterableList(mondrian.util.FilteredIterableList) ArrayList(java.util.ArrayList) TupleList(mondrian.calc.TupleList) Level(mondrian.olap.Level) Member(mondrian.olap.Member) LimitedRollupMember(mondrian.rolap.RolapHierarchy.LimitedRollupMember) MultiCardinalityDefaultMember(mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 TupleList (mondrian.calc.TupleList)1 Level (mondrian.olap.Level)1 Member (mondrian.olap.Member)1 SchemaReader (mondrian.olap.SchemaReader)1 MultiCardinalityDefaultMember (mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)1 LimitedRollupMember (mondrian.rolap.RolapHierarchy.LimitedRollupMember)1 FilteredIterableList (mondrian.util.FilteredIterableList)1