Search in sources :

Example 1 with IdentifierSegment

use of org.olap4j.mdx.IdentifierSegment in project mondrian by pentaho.

the class NameResolver method resolveInexact.

private OlapElement resolveInexact(OlapElement parent, List<IdentifierSegment> segments, MatchType matchType, List<Namespace> namespaces) {
    OlapElement element = parent;
    for (final IdentifierSegment segment : segments) {
        assert element != null;
        OlapElement child = null;
        for (Namespace namespace : namespaces) {
            child = namespace.lookupChild(element, segment, matchType);
            if (child != null) {
                switch(matchType) {
                    case EXACT:
                    case EXACT_SCHEMA:
                        break;
                    case BEFORE:
                        if (!Util.matches(segment, child.getName())) {
                            matchType = MatchType.LAST;
                        }
                        break;
                    case AFTER:
                        if (!Util.matches(segment, child.getName())) {
                            matchType = MatchType.FIRST;
                        }
                        break;
                }
                break;
            }
        }
        if (child == null) {
            return null;
        }
        element = child;
    }
    return element;
}
Also used : IdentifierSegment(org.olap4j.mdx.IdentifierSegment)

Example 2 with IdentifierSegment

use of org.olap4j.mdx.IdentifierSegment in project mondrian by pentaho.

the class NameResolver method resolveExact.

// same logic as resolveInexact, pared down for common case
// matchType == EXACT
private OlapElement resolveExact(OlapElement parent, List<IdentifierSegment> segments, List<Namespace> namespaces) {
    OlapElement element = parent;
    for (final IdentifierSegment segment : segments) {
        assert element != null;
        OlapElement child = null;
        for (Namespace namespace : namespaces) {
            child = namespace.lookupChild(element, segment);
            if (child != null) {
                break;
            }
        }
        if (child == null) {
            return null;
        }
        element = child;
    }
    return element;
}
Also used : IdentifierSegment(org.olap4j.mdx.IdentifierSegment)

Example 3 with IdentifierSegment

use of org.olap4j.mdx.IdentifierSegment in project mondrian by pentaho.

the class MondrianOlap4jCube method lookupMember.

private MondrianOlap4jMember lookupMember(SchemaReader schemaReader, List<IdentifierSegment> nameParts) {
    final List<mondrian.olap.Id.Segment> segmentList = new ArrayList<mondrian.olap.Id.Segment>();
    for (IdentifierSegment namePart : nameParts) {
        segmentList.add(Util.convert(namePart));
    }
    final mondrian.olap.Member member = schemaReader.getMemberByUniqueName(segmentList, false);
    if (member == null) {
        return null;
    }
    return olap4jSchema.olap4jCatalog.olap4jDatabaseMetaData.olap4jConnection.toOlap4j(member);
}
Also used : mondrian.olap(mondrian.olap) IdentifierSegment(org.olap4j.mdx.IdentifierSegment) IdentifierSegment(org.olap4j.mdx.IdentifierSegment)

Aggregations

IdentifierSegment (org.olap4j.mdx.IdentifierSegment)3 mondrian.olap (mondrian.olap)1