Search in sources :

Example 11 with MemberChildrenConstraint

use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.

the class RestrictedMemberReader method processMemberChildren.

private Map<RolapMember, Access> processMemberChildren(List<RolapMember> fullChildren, List<RolapMember> children, MemberChildrenConstraint constraint) {
    // todo: optimize if parentMember is beyond last level
    List<RolapMember> grandChildren = null;
    Map<RolapMember, Access> memberToAccessMap = new LinkedHashMap<RolapMember, Access>();
    for (int i = 0; i < fullChildren.size(); i++) {
        RolapMember member = fullChildren.get(i);
        // If a child is hidden (due to raggedness)
        // or doesn't have access include its children.
        // This must be done before applying access-control.
        final Access access;
        if (hierarchyAccess != null) {
            access = hierarchyAccess.getAccess(member);
        } else {
            access = Access.ALL;
        }
        if ((ragged && member.isHidden()) || access.equals(Access.NONE)) {
            // Replace this member with all of its children.
            // They might be hidden too, but we'll get to them in due
            // course. They also might be access-controlled; that's why
            // we deal with raggedness before we apply access-control.
            fullChildren.remove(i);
            if (grandChildren == null) {
                grandChildren = new ArrayList<RolapMember>();
            } else {
                grandChildren.clear();
            }
            memberReader.getMemberChildren(member, grandChildren, constraint);
            fullChildren.addAll(i, grandChildren);
            // Step back to before the first child we just inserted,
            // and go through the loop again.
            --i;
            continue;
        }
        // access-control.
        switch(access) {
            case NONE:
                break;
            default:
                children.add(member);
                memberToAccessMap.put(member, access);
                break;
        }
    }
    return memberToAccessMap;
}
Also used : TupleConstraint(mondrian.rolap.sql.TupleConstraint) MemberChildrenConstraint(mondrian.rolap.sql.MemberChildrenConstraint)

Example 12 with MemberChildrenConstraint

use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.

the class RolapSchemaReader method getMemberChildrenWithDetails.

public Map<? extends Member, Access> getMemberChildrenWithDetails(Member member, Evaluator evaluator) {
    MemberChildrenConstraint constraint = sqlConstraintFactory.getMemberChildrenConstraint(evaluator);
    final Hierarchy hierarchy = member.getHierarchy();
    final MemberReader memberReader = getMemberReader(hierarchy);
    final ArrayList<RolapMember> memberChildren = new ArrayList<RolapMember>();
    return memberReader.getMemberChildren((RolapMember) member, memberChildren, constraint);
}
Also used : MemberChildrenConstraint(mondrian.rolap.sql.MemberChildrenConstraint)

Example 13 with MemberChildrenConstraint

use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.

the class RolapSchemaReader method getMemberChildren.

public List<Member> getMemberChildren(List<Member> members, Evaluator context) {
    if (members.size() == 0) {
        return Collections.emptyList();
    } else {
        MemberChildrenConstraint constraint = sqlConstraintFactory.getMemberChildrenConstraint(context);
        final Hierarchy hierarchy = members.get(0).getHierarchy();
        final MemberReader memberReader = getMemberReader(hierarchy);
        final List<RolapMember> rolapMemberList = Util.cast(members);
        final List<RolapMember> children = new ArrayList<RolapMember>();
        memberReader.getMemberChildren(rolapMemberList, children, constraint);
        return Util.cast(children);
    }
}
Also used : MemberChildrenConstraint(mondrian.rolap.sql.MemberChildrenConstraint)

Example 14 with MemberChildrenConstraint

use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.

the class RolapSchemaReader method lookupMemberChildByName.

public Member lookupMemberChildByName(Member parent, Id.Segment childName, MatchType matchType) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("looking for child \"" + childName + "\" of " + parent);
    }
    assert !(parent instanceof RolapHierarchy.LimitedRollupMember);
    try {
        MemberChildrenConstraint constraint;
        if (childName instanceof Id.NameSegment && matchType.isExact()) {
            constraint = sqlConstraintFactory.getChildByNameConstraint((RolapMember) parent, (Id.NameSegment) childName);
        } else {
            constraint = sqlConstraintFactory.getMemberChildrenConstraint(null);
        }
        List<RolapMember> children = internalGetMemberChildren(parent, constraint);
        if (children.size() > 0) {
            return RolapUtil.findBestMemberMatch(children, (RolapMember) parent, children.get(0).getLevel(), childName, matchType);
        }
    } catch (NumberFormatException e) {
        // this was thrown in SqlQuery#quote(boolean numeric, Object
        // value). This happens when Mondrian searches for unqualified Olap
        // Elements like [Month], because it tries to look up a member with
        // that name in all dimensions. Then it generates for example
        // "select .. from time where year = Month" which will result in a
        // NFE because "Month" can not be parsed as a number. The real bug
        // is probably, that Mondrian looks at members at all.
        // 
        // @see RolapCube#lookupChild()
        LOGGER.debug("NumberFormatException in lookupMemberChildByName " + "for parent = \"" + parent + "\", childName=\"" + childName + "\", exception: " + e.getMessage());
    }
    return null;
}
Also used : MemberChildrenConstraint(mondrian.rolap.sql.MemberChildrenConstraint)

Example 15 with MemberChildrenConstraint

use of mondrian.rolap.sql.MemberChildrenConstraint in project mondrian by pentaho.

the class RolapSchemaReader method lookupMemberChildrenByNames.

public List<Member> lookupMemberChildrenByNames(Member parent, List<Id.NameSegment> childNames, MatchType matchType) {
    MemberChildrenConstraint constraint = sqlConstraintFactory.getChildrenByNamesConstraint((RolapMember) parent, childNames);
    List<RolapMember> children = internalGetMemberChildren(parent, constraint);
    List<Member> childMembers = new ArrayList<Member>();
    childMembers.addAll(children);
    return childMembers;
}
Also used : MemberChildrenConstraint(mondrian.rolap.sql.MemberChildrenConstraint)

Aggregations

MemberChildrenConstraint (mondrian.rolap.sql.MemberChildrenConstraint)17 Evaluator (mondrian.olap.Evaluator)3 Result (mondrian.olap.Result)3 NonEmptyResult (mondrian.rolap.RolapConnection.NonEmptyResult)3 TupleConstraint (mondrian.rolap.sql.TupleConstraint)3 Callable (java.util.concurrent.Callable)2 Level (mondrian.olap.Level)2 Member (mondrian.olap.Member)2 Connection (mondrian.olap.Connection)1 Listener (mondrian.rolap.RolapNative.Listener)1 NativeEvent (mondrian.rolap.RolapNative.NativeEvent)1 TupleEvent (mondrian.rolap.RolapNative.TupleEvent)1