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;
}
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);
}
}
}
}
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;
}
Aggregations