Search in sources :

Example 1 with LimitedRollupMember

use of mondrian.rolap.RolapHierarchy.LimitedRollupMember 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)

Example 2 with LimitedRollupMember

use of mondrian.rolap.RolapHierarchy.LimitedRollupMember in project mondrian by pentaho.

the class RolapUtil method constraintBitkeyForLimitedMembers.

/**
 * Modifies a bitkey so that it includes the proper bits
 * for members in an array which should be considered
 * as a limited rollup member.
 */
public static void constraintBitkeyForLimitedMembers(Evaluator evaluator, Member[] members, RolapCube cube, BitKey levelBitKey) {
    // so that we can pick the correct agg table.
    for (Member curMember : members) {
        if (curMember instanceof LimitedRollupMember) {
            final int savepoint = evaluator.savepoint();
            try {
                // set NonEmpty to false to avoid the possibility of
                // constraining member retrieval by context, which itself
                // requires determination of limited members, resulting
                // in infinite loop.
                evaluator.setNonEmpty(false);
                List<Member> lowestMembers = ((RolapHierarchy) curMember.getHierarchy()).getLowestMembersForAccess(evaluator, ((LimitedRollupMember) curMember).hierarchyAccess, FunUtil.getNonEmptyMemberChildrenWithDetails(evaluator, curMember));
                assert lowestMembers.size() > 0;
                Member lowMember = lowestMembers.get(0);
                while (true) {
                    RolapStar.Column curColumn = ((RolapCubeLevel) lowMember.getLevel()).getBaseStarKeyColumn(cube);
                    if (curColumn != null) {
                        levelBitKey.set(curColumn.getBitPosition());
                    }
                    // or all of them are added.
                    if (!((RolapCubeLevel) lowMember.getLevel()).isUnique()) {
                        lowMember = lowMember.getParentMember();
                        if (lowMember.isAll()) {
                            break;
                        }
                    } else {
                        break;
                    }
                }
            } finally {
                evaluator.restore(savepoint);
            }
        }
    }
}
Also used : Member(mondrian.olap.Member) LimitedRollupMember(mondrian.rolap.RolapHierarchy.LimitedRollupMember) LimitedRollupMember(mondrian.rolap.RolapHierarchy.LimitedRollupMember)

Example 3 with LimitedRollupMember

use of mondrian.rolap.RolapHierarchy.LimitedRollupMember 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

Member (mondrian.olap.Member)3 LimitedRollupMember (mondrian.rolap.RolapHierarchy.LimitedRollupMember)3 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 MultiCardinalityDefaultMember (mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)2 FilteredIterableList (mondrian.util.FilteredIterableList)2 Role (mondrian.olap.Role)1 SchemaReader (mondrian.olap.SchemaReader)1