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