Class RolapSchemaReader

java.lang.Object
mondrian.rolap.RolapSchemaReader
All Implemented Interfaces:
NameResolver.Namespace, SchemaReader, RolapNativeSet.SchemaReaderWithMemberReaderAvailable

A RolapSchemaReader allows you to read schema objects while observing the access-control profile specified by a given role.
Since:
Feb 24, 2003
Author:
jhyde
  • Field Details

    • role

      protected final Role role
    • schema

      protected final RolapSchema schema
  • Method Details

    • getRole

      public Role getRole()
      Description copied from interface: SchemaReader
      Returns the access-control profile that this SchemaReader is implementing.
      Specified by:
      getRole in interface SchemaReader
    • getHierarchyRootMembers

      public List<Member> getHierarchyRootMembers(Hierarchy hierarchy)
      Description copied from interface: SchemaReader
      Returns an array of the root members of hierarchy.
      Specified by:
      getHierarchyRootMembers in interface SchemaReader
      Parameters:
      hierarchy - Hierarchy
      See Also:
    • getMemberReader

      public mondrian.rolap.MemberReader getMemberReader(Hierarchy hierarchy)
      This method uses a double-checked locking idiom to avoid making the method fully synchronized, or potentially creating the same MemberReader more than once. Double-checked locking can cause issues if a second thread accesses the field without either a shared lock in place or the field being specified as volatile. In this case, hierarchyReaders is a ConcurrentHashMap, which internally uses volatile load semantics for read operations. This assures values written by one thread will be visible when read by others. http://en.wikipedia.org/wiki/Double-checked_locking
      Specified by:
      getMemberReader in interface RolapNativeSet.SchemaReaderWithMemberReaderAvailable
    • substitute

      public Member substitute(Member member)
      Description copied from interface: SchemaReader
      Substitutes a member with an equivalent member which enforces the access control policy of this SchemaReader.
      Specified by:
      substitute in interface SchemaReader
    • getMemberRange

      public void getMemberRange(Level level, Member startMember, Member endMember, List<Member> list)
      Description copied from interface: SchemaReader
      Appends to list all members between startMember and endMember (inclusive) which belong to level.
      Specified by:
      getMemberRange in interface SchemaReader
    • compareMembersHierarchically

      public int compareMembersHierarchically(Member m1, Member m2)
      Description copied from interface: SchemaReader
      Compares a pair of Members according to their order in a prefix traversal. (that is, it is an ancestor or a earlier), is a sibling, or comes later in a prefix traversal.
      Specified by:
      compareMembersHierarchically in interface SchemaReader
      Returns:
      A negative integer if m1 is an ancestor, an earlier sibling of an ancestor, or a descendent of an earlier sibling, of m2; zero if m1 is a sibling of m2; a positive integer if m1 comes later in the prefix traversal then m2.
    • getMemberParent

      public Member getMemberParent(Member member)
      Description copied from interface: SchemaReader
      Returns the parent of member.
      Specified by:
      getMemberParent in interface SchemaReader
      Parameters:
      member - Member
      Returns:
      null if member is a root member
    • getMemberDepth

      public int getMemberDepth(Member member)
      Description copied from interface: SchemaReader
      Returns the depth of a member.

      This may not be the same as member.getLevel(). getDepth() for three reasons:

      1. Access control. The most senior visible member has level 0. If the client is not allowed to see the "All" and "Nation" levels of the "Store" hierarchy, then members of the "State" level will have depth 0.
      2. Parent-child hierarchies. Suppose Fred reports to Wilma, and Wilma reports to no one. "All Employees" has depth 0, Wilma has depth 1, and Fred has depth 2. Fred and Wilma are both in the "Employees" level, which has depth 1.
      3. Ragged hierarchies. If Israel has only one, hidden, province then the depth of Tel Aviv, Israel is 2, whereas the depth of another city, San Francisco, CA, USA is 3.
      Specified by:
      getMemberDepth in interface SchemaReader
    • getMemberChildren

      public List<Member> getMemberChildren(Member member)
      Description copied from interface: SchemaReader
      Returns direct children of member.
      Specified by:
      getMemberChildren in interface SchemaReader
    • getMemberChildren

      public List<Member> getMemberChildren(Member member, Evaluator context)
      Description copied from interface: SchemaReader
      Returns direct children of member, optimized for NON EMPTY.

      If context == null then there is no context and all members are returned - then its identical to SchemaReader.getMemberChildren(Member). If context is not null, the resulting members may be restricted to those members that have a non empty row in the fact table for context. Wether or not optimization is possible depends on the SchemaReader implementation.

      Specified by:
      getMemberChildren in interface SchemaReader
    • countMemberChildren

      public int countMemberChildren(Member member, Evaluator context)
    • getParentChildContributingChildren

      public void getParentChildContributingChildren(Member dataMember, Hierarchy hierarchy, List<Member> list)
      Description copied from interface: SchemaReader
      Returns a list of contributing children of a member of a parent-child hierarchy.
      Specified by:
      getParentChildContributingChildren in interface SchemaReader
      Parameters:
      dataMember - Data member for a member of the parent-child hierarcy
      hierarchy - Hierarchy
      list - List of members to populate
    • getChildrenCountFromCache

      public int getChildrenCountFromCache(Member member)
      Description copied from interface: SchemaReader
      Returns number of children parent of a member, if the information can be retrieved from cache, otherwise -1.
      Specified by:
      getChildrenCountFromCache in interface SchemaReader
    • getLevelCardinality

      public int getLevelCardinality(Level level, boolean approximate, boolean materialize)
      Description copied from interface: SchemaReader
      Returns the number of members in a level, returning an approximation if acceptable.
      Specified by:
      getLevelCardinality in interface SchemaReader
      Parameters:
      level - Level
      approximate - Whether an approximation is acceptable
      materialize - Whether to go to disk if no approximation for the count is available and the members are not in cache. If false, returns Integer.MIN_VALUE if value is not in cache.
    • getMemberChildren

      public List<Member> getMemberChildren(List<Member> members)
      Description copied from interface: SchemaReader
      Returns direct children of each element of members.
      Specified by:
      getMemberChildren in interface SchemaReader
      Parameters:
      members - Array of members
      Returns:
      array of child members
    • getMemberChildren

      public List<Member> getMemberChildren(List<Member> members, Evaluator context)
      Description copied from interface: SchemaReader
      Returns direct children of each element of members which is not empty in context.
      Specified by:
      getMemberChildren in interface SchemaReader
      Parameters:
      members - Array of members
      context - Evaluation context
      Returns:
      array of child members
    • getMemberAncestors

      public void getMemberAncestors(Member member, List<Member> ancestorList)
      Description copied from interface: SchemaReader
      Returns a list of ancestors of member, in depth order.

      For example, for [Store].[USA].[CA], returns {[Store].[USA], [Store].[All Stores]}.

      Specified by:
      getMemberAncestors in interface SchemaReader
      Parameters:
      member - Member
      ancestorList - List of ancestors
    • getCube

      public Cube getCube()
      Description copied from interface: SchemaReader
      Returns the default cube in which to look for dimensions etc.
      Specified by:
      getCube in interface SchemaReader
      Returns:
      Default cube
    • withoutAccessControl

      public SchemaReader withoutAccessControl()
      Description copied from interface: SchemaReader
      Returns a similar schema reader that has no access control.
      Specified by:
      withoutAccessControl in interface SchemaReader
      Returns:
      Schema reader that has a similar perspective (e.g. cube) but no access control
    • getElementChild

      public OlapElement getElementChild(OlapElement parent, Id.Segment name)
      Description copied from interface: SchemaReader
      Looks up the child of parent name, returning null if no element is found.

      Always equivalent to getElementChild(parent, name, MatchType.EXACT).

      Specified by:
      getElementChild in interface SchemaReader
      Parameters:
      parent - Parent element to search in
      name - Compound in compound name, such as "[Product]" or "&[1]"
      Returns:
      Element with given name, or null
    • getElementChild

      public OlapElement getElementChild(OlapElement parent, Id.Segment name, MatchType matchType)
      Description copied from interface: SchemaReader
      Looks up the child of parent called name, or an approximation according to matchType, returning null if no element is found.
      Specified by:
      getElementChild in interface SchemaReader
      Parameters:
      parent - Parent element to search in
      name - Compound in compound name, such as "[Product]" or "&[1]"
      matchType - Match type
      Returns:
      Element with given name, or null
    • getMemberByUniqueName

      public final Member getMemberByUniqueName(List<Id.Segment> uniqueNameParts, boolean failIfNotFound)
      Description copied from interface: SchemaReader
      Finds a member based upon its unique name, requiring an exact match.

      This method is equivalent to calling SchemaReader.getMemberByUniqueName(java.util.List, boolean, MatchType) with MatchType.EXACT.

      Specified by:
      getMemberByUniqueName in interface SchemaReader
      Parameters:
      uniqueNameParts - Unique name of member
      failIfNotFound - Whether to throw an error, as opposed to returning null, if there is no such member.
      Returns:
      The member, or null if not found
    • getMemberByUniqueName

      public Member getMemberByUniqueName(List<Id.Segment> uniqueNameParts, boolean failIfNotFound, MatchType matchType)
      Description copied from interface: SchemaReader
      Finds a member based upon its unique name.
      Specified by:
      getMemberByUniqueName in interface SchemaReader
      Parameters:
      uniqueNameParts - Unique name of member
      failIfNotFound - Whether to throw an error, as opposed to returning null, if there is no such member.
      matchType - indicates the match mode; if not specified, EXACT
      Returns:
      The member, or null if not found
    • lookupCompound

      public OlapElement lookupCompound(OlapElement parent, List<Id.Segment> names, boolean failIfNotFound, int category)
      Description copied from interface: SchemaReader
      Looks up an MDX object by name.

      Resolves a name such as '[Products].[Product Department].[Produce]' by resolving the components ('Products', and so forth) one at a time.

      Specified by:
      lookupCompound in interface SchemaReader
      Parameters:
      parent - Parent element to search in
      names - Exploded compound name, such as {"Products", "Product Department", "Produce"}
      failIfNotFound - If the element is not found, determines whether to return null or throw an error
      category - Type of returned element, a Category value; Category.Unknown if it doesn't matter.
    • lookupCompound

      public final OlapElement lookupCompound(OlapElement parent, List<Id.Segment> names, boolean failIfNotFound, int category, MatchType matchType)
      Description copied from interface: SchemaReader
      Looks up an MDX object by name, specifying how to match if no object exactly matches the name.

      Resolves a name such as '[Products].[Product Department].[Produce]' by resolving the components ('Products', and so forth) one at a time.

      Specified by:
      lookupCompound in interface SchemaReader
      Parameters:
      parent - Parent element to search in
      names - Exploded compound name, such as {"Products", "Product Department", "Produce"}
      failIfNotFound - If the element is not found, determines whether to return null or throw an error
      category - Type of returned element, a Category value; Category.Unknown if it doesn't matter.
      matchType - indicates the match mode; if not specified, EXACT
    • lookupCompoundInternal

      public final OlapElement lookupCompoundInternal(OlapElement parent, List<Id.Segment> names, boolean failIfNotFound, int category, MatchType matchType)
    • getNamespaces

      public List<NameResolver.Namespace> getNamespaces()
      Description copied from interface: SchemaReader
      Returns a list of namespaces to search when resolving elements by name.

      For example, a schema reader from the perspective of a cube will return cube and schema namespaces.

      Specified by:
      getNamespaces in interface SchemaReader
      Returns:
      List of namespaces
    • lookupChild

      public OlapElement lookupChild(OlapElement parent, org.olap4j.mdx.IdentifierSegment segment)
      Description copied from interface: NameResolver.Namespace
      Looks up a child element.
      Specified by:
      lookupChild in interface NameResolver.Namespace
      Parameters:
      parent - Parent element
      segment - Name segment
      Returns:
      Olap element, or null
    • lookupChild

      public OlapElement lookupChild(OlapElement parent, org.olap4j.mdx.IdentifierSegment segment, MatchType matchType)
      Description copied from interface: NameResolver.Namespace
      Looks up a child element, using a match type for inexact matching.

      If matchType is MatchType.EXACT, effect is identical to calling NameResolver.Namespace.lookupChild(OlapElement, org.olap4j.mdx.IdentifierSegment).

      Match type is ignored except when searching for members.

      Specified by:
      lookupChild in interface NameResolver.Namespace
      Parameters:
      parent - Parent element
      segment - Name segment
      matchType - Match type
      Returns:
      Olap element, or null
    • lookupMemberChildByName

      public Member lookupMemberChildByName(Member parent, Id.Segment childName, MatchType matchType)
      Description copied from interface: SchemaReader
      Finds a child of a member with a given name.
      Specified by:
      lookupMemberChildByName in interface SchemaReader
    • lookupMemberChildrenByNames

      public List<Member> lookupMemberChildrenByNames(Member parent, List<Id.NameSegment> childNames, MatchType matchType)
      Description copied from interface: SchemaReader
      Finds a list of child members with the given names.
      Specified by:
      lookupMemberChildrenByNames in interface SchemaReader
    • getCalculatedMember

      public Member getCalculatedMember(List<Id.Segment> nameParts)
      Description copied from interface: SchemaReader
      Looks up a calculated member by name. If the name is not found in the current scope, returns null.
      Specified by:
      getCalculatedMember in interface SchemaReader
    • getNamedSet

      public NamedSet getNamedSet(List<Id.Segment> nameParts)
      Description copied from interface: SchemaReader
      Looks up a set by name. If the name is not found in the current scope, returns null.
      Specified by:
      getNamedSet in interface SchemaReader
    • getLeadMember

      public Member getLeadMember(Member member, int n)
      Description copied from interface: SchemaReader
      Returns a member n further along in the same level from member.
      Specified by:
      getLeadMember in interface SchemaReader
    • getLevelMembers

      public List<Member> getLevelMembers(Level level, boolean includeCalculated)
      Description copied from interface: SchemaReader
      Returns the members of a level, optionally including calculated members.
      Specified by:
      getLevelMembers in interface SchemaReader
    • getLevelMembers

      public List<Member> getLevelMembers(Level level, Evaluator context)
      Description copied from interface: SchemaReader
      Returns the members of a level, optionally filtering out members which are empty.
      Specified by:
      getLevelMembers in interface SchemaReader
      Parameters:
      level - Level
      context - Context for filtering
      Returns:
      Members of this level
    • getCubeDimensions

      public List<Dimension> getCubeDimensions(Cube cube)
      Description copied from interface: SchemaReader
      Returns the accessible dimensions of a cube.
      Specified by:
      getCubeDimensions in interface SchemaReader
    • getDimensionHierarchies

      public List<Hierarchy> getDimensionHierarchies(Dimension dimension)
      Description copied from interface: SchemaReader
      Returns the accessible hierarchies of a dimension.
      Specified by:
      getDimensionHierarchies in interface SchemaReader
    • getHierarchyLevels

      public List<Level> getHierarchyLevels(Hierarchy hierarchy)
      Description copied from interface: SchemaReader
      Returns the accessible levels of a hierarchy.
      Specified by:
      getHierarchyLevels in interface SchemaReader
      Parameters:
      hierarchy - Hierarchy
    • getHierarchyDefaultMember

      public Member getHierarchyDefaultMember(Hierarchy hierarchy)
      Description copied from interface: SchemaReader
      Returns the default member of a hierarchy. If the default member is in an inaccessible level, returns the nearest ascendant/descendant member.
      Specified by:
      getHierarchyDefaultMember in interface SchemaReader
      Parameters:
      hierarchy - Hierarchy
      Returns:
      Default member of hierarchy
    • isDrillable

      public boolean isDrillable(Member member)
      Description copied from interface: SchemaReader
      Returns whether a member has visible children.
      Specified by:
      isDrillable in interface SchemaReader
    • isVisible

      public boolean isVisible(Member member)
      Description copied from interface: SchemaReader
      Returns whether a member is visible.
      Specified by:
      isVisible in interface SchemaReader
    • getCubes

      public Cube[] getCubes()
      Description copied from interface: SchemaReader
      Returns the list of accessible cubes.
      Specified by:
      getCubes in interface SchemaReader
    • getCalculatedMembers

      public List<Member> getCalculatedMembers(Hierarchy hierarchy)
      Description copied from interface: SchemaReader
      Returns a list of calculated members in a given hierarchy.
      Specified by:
      getCalculatedMembers in interface SchemaReader
    • getCalculatedMembers

      public List<Member> getCalculatedMembers(Level level)
      Description copied from interface: SchemaReader
      Returns a list of calculated members in a given level.
      Specified by:
      getCalculatedMembers in interface SchemaReader
    • getCalculatedMembers

      public List<Member> getCalculatedMembers()
      Description copied from interface: SchemaReader
      Returns the list of calculated members.
      Specified by:
      getCalculatedMembers in interface SchemaReader
    • getNativeSetEvaluator

      public NativeEvaluator getNativeSetEvaluator(FunDef fun, Exp[] args, Evaluator evaluator, Calc calc)
      Description copied from interface: SchemaReader
      Returns an object which can evaluate an expression in native SQL, or null if this is not possible.
      Specified by:
      getNativeSetEvaluator in interface SchemaReader
      Parameters:
      fun - Function
      args - Arguments to the function
      evaluator - Evaluator, provides context
      calc - the calc to be natively evaluated
    • getParameter

      public Parameter getParameter(String name)
      Description copied from interface: SchemaReader
      Returns the definition of a parameter with a given name, or null if not found.
      Specified by:
      getParameter in interface SchemaReader
    • getDataSource

      public DataSource getDataSource()
      Description copied from interface: SchemaReader
      Returns the data source.
      Specified by:
      getDataSource in interface SchemaReader
      Returns:
      data source
    • getSchema

      public RolapSchema getSchema()
      Description copied from interface: SchemaReader
      Returns the schema.
      Specified by:
      getSchema in interface SchemaReader
      Returns:
      Schema, never null
    • withLocus

      public SchemaReader withLocus()
      Description copied from interface: SchemaReader
      Returns a schema reader that automatically assigns a locus to each operation.

      It is less efficient; use this only if the operation is occurring outside the context of a statement. If you get the internal error "no locus", that's a sign you should use this method.

      Specified by:
      withLocus in interface SchemaReader
      Returns:
      Schema reader that assigns a locus to each operation
    • getMemberChildrenWithDetails

      public Map<? extends Member,Access> getMemberChildrenWithDetails(Member member, Evaluator evaluator)
      Description copied from interface: SchemaReader
      Similar to SchemaReader.getMemberChildren(Member, Evaluator) but returns a map of the grand-children and their access details and costs more to invoke because of the access controls. Called by RolapHierarchy when determining the lowest access level of a Role within a hierarchy.
      Specified by:
      getMemberChildrenWithDetails in interface SchemaReader
    • countMemberChildren

      public int countMemberChildren(Member parentMember)
      Specified by:
      countMemberChildren in interface SchemaReader