Search in sources :

Example 6 with MultiCardinalityDefaultMember

use of mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember in project mondrian by pentaho.

the class SqlConstraintUtils method getRoleConstraintMembers.

public static Map<Level, List<RolapMember>> getRoleConstraintMembers(SchemaReader schemaReader, Member[] members) {
    // LinkedHashMap keeps insert-order
    Map<Level, List<RolapMember>> roleMembers = new LinkedHashMap<Level, List<RolapMember>>();
    Role role = schemaReader.getRole();
    for (Member member : members) {
        if (member instanceof LimitedRollupMember || member instanceof MultiCardinalityDefaultMember) {
            // iterate relevant levels to get accessible members
            List<Level> hierarchyLevels = schemaReader.getHierarchyLevels(member.getHierarchy());
            for (Level affectedLevel : hierarchyLevels) {
                List<RolapMember> slicerMembers = new ArrayList<RolapMember>();
                boolean hasCustom = false;
                List<Member> availableMembers = schemaReader.getLevelMembers(affectedLevel, false);
                for (Member availableMember : availableMembers) {
                    if (!availableMember.isAll()) {
                        slicerMembers.add((RolapMember) availableMember);
                    }
                    hasCustom |= role.getAccess(availableMember) == Access.CUSTOM;
                }
                if (!slicerMembers.isEmpty()) {
                    roleMembers.put(affectedLevel, slicerMembers);
                }
                if (!hasCustom) {
                    // we don't have partial access, no need to go deeper
                    break;
                }
            }
        }
    }
    return roleMembers;
}
Also used : ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) LimitedRollupMember(mondrian.rolap.RolapHierarchy.LimitedRollupMember) Role(mondrian.olap.Role) MultiCardinalityDefaultMember(mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember) Level(mondrian.olap.Level) List(java.util.List) FilteredIterableList(mondrian.util.FilteredIterableList) ArrayList(java.util.ArrayList) TupleList(mondrian.calc.TupleList) Member(mondrian.olap.Member) LimitedRollupMember(mondrian.rolap.RolapHierarchy.LimitedRollupMember) MultiCardinalityDefaultMember(mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)

Aggregations

MultiCardinalityDefaultMember (mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)6 Role (mondrian.olap.Role)5 Hierarchy (mondrian.olap.Hierarchy)4 HierarchyAccess (mondrian.olap.Role.HierarchyAccess)4 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 TupleList (mondrian.calc.TupleList)2 Level (mondrian.olap.Level)2 Member (mondrian.olap.Member)2 LimitedRollupMember (mondrian.rolap.RolapHierarchy.LimitedRollupMember)2 FilteredIterableList (mondrian.util.FilteredIterableList)2 SchemaReader (mondrian.olap.SchemaReader)1