Interface SchemaReader
-
- All Known Subinterfaces:
RolapNativeSet.SchemaReaderWithMemberReaderAvailable
- All Known Implementing Classes:
DelegatingSchemaReader
,RolapSchemaReader
public interface SchemaReader
ASchemaReader
queries schema objects (Schema
,Cube
,Dimension
,Hierarchy
,Level
,Member
).It is generally created using
Connection.getSchemaReader()
, but also viaCube.getSchemaReader(Role)
.SchemaReader is deprecated for code outside of mondrian. For new code, use the metadata provided by olap4j, for example
Schema.getCubes()
.If you use a SchemaReader from outside of a mondrian statement, you may get a
EmptyStackException
indicating that mondrian cannot deduce the current locus (statement context). If you get that error, callwithLocus()
to create a SchemaReader that automatically provides a locus whenever a call is made.- Since:
- Feb 24, 2003
- Author:
- jhyde
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
compareMembersHierarchically(Member m1, Member m2)
Compares a pair ofMember
s according to their order in a prefix traversal.int
countMemberChildren(Member parentMember)
Member
getCalculatedMember(List<Id.Segment> nameParts)
Looks up a calculated member by name.List<Member>
getCalculatedMembers()
Returns the list of calculated members.List<Member>
getCalculatedMembers(Hierarchy hierarchy)
Returns a list of calculated members in a given hierarchy.List<Member>
getCalculatedMembers(Level level)
Returns a list of calculated members in a given level.int
getChildrenCountFromCache(Member member)
Returns number of children parent of a member, if the information can be retrieved from cache, otherwise -1.Cube
getCube()
Returns the default cube in which to look for dimensions etc.List<Dimension>
getCubeDimensions(Cube cube)
Returns the accessible dimensions of a cube.Cube[]
getCubes()
Returns the list of accessible cubes.DataSource
getDataSource()
Returns the data source.List<Hierarchy>
getDimensionHierarchies(Dimension dimension)
Returns the accessible hierarchies of a dimension.OlapElement
getElementChild(OlapElement parent, Id.Segment name)
Looks up the child ofparent
name
, returning null if no element is found.OlapElement
getElementChild(OlapElement parent, Id.Segment name, MatchType matchType)
Looks up the child ofparent
calledname
, or an approximation according tomatchType
, returning null if no element is found.Member
getHierarchyDefaultMember(Hierarchy hierarchy)
Returns the default member of a hierarchy.List<Level>
getHierarchyLevels(Hierarchy hierarchy)
Returns the accessible levels of a hierarchy.List<Member>
getHierarchyRootMembers(Hierarchy hierarchy)
Returns an array of the root members ofhierarchy
.Member
getLeadMember(Member member, int n)
Returns a membern
further along in the same level frommember
.int
getLevelCardinality(Level level, boolean approximate, boolean materialize)
Returns the number of members in a level, returning an approximation if acceptable.List<Member>
getLevelMembers(Level level, boolean includeCalculated)
Returns the members of a level, optionally including calculated members.List<Member>
getLevelMembers(Level level, Evaluator context)
Returns the members of a level, optionally filtering out members which are empty.void
getMemberAncestors(Member member, List<Member> ancestorList)
Returns a list of ancestors ofmember
, in depth order.Member
getMemberByUniqueName(List<Id.Segment> uniqueNameParts, boolean failIfNotFound)
Finds a member based upon its unique name, requiring an exact match.Member
getMemberByUniqueName(List<Id.Segment> uniqueNameParts, boolean failIfNotFound, MatchType matchType)
Finds a member based upon its unique name.List<Member>
getMemberChildren(List<Member> members)
Returns direct children of each element ofmembers
.List<Member>
getMemberChildren(List<Member> members, Evaluator context)
Returns direct children of each element ofmembers
which is not empty incontext
.List<Member>
getMemberChildren(Member member)
Returns direct children ofmember
.List<Member>
getMemberChildren(Member member, Evaluator context)
Returns direct children ofmember
, optimized for NON EMPTY.Map<? extends Member,Access>
getMemberChildrenWithDetails(Member member, Evaluator evaluator)
Similar togetMemberChildren(Member, Evaluator)
but returns a map of the grand-children and their access details and costs more to invoke because of the access controls.int
getMemberDepth(Member member)
Returns the depth of a member.Member
getMemberParent(Member member)
Returns the parent ofmember
.void
getMemberRange(Level level, Member startMember, Member endMember, List<Member> list)
Appends tolist
all members betweenstartMember
andendMember
(inclusive) which belong tolevel
.NamedSet
getNamedSet(List<Id.Segment> nameParts)
Looks up a set by name.List<NameResolver.Namespace>
getNamespaces()
Returns a list of namespaces to search when resolving elements by name.NativeEvaluator
getNativeSetEvaluator(FunDef fun, Exp[] args, Evaluator evaluator, Calc calc)
Returns an object which can evaluate an expression in native SQL, or null if this is not possible.Parameter
getParameter(String name)
Returns the definition of a parameter with a given name, or null if not found.void
getParentChildContributingChildren(Member dataMember, Hierarchy hierarchy, List<Member> list)
Returns a list of contributing children of a member of a parent-child hierarchy.Role
getRole()
Returns the access-control profile that thisSchemaReader
is implementing.RolapSchema
getSchema()
Returns the schema.boolean
isDrillable(Member member)
Returns whether a member has visible children.boolean
isVisible(Member member)
Returns whether a member is visible.OlapElement
lookupCompound(OlapElement parent, List<Id.Segment> names, boolean failIfNotFound, int category)
Looks up an MDX object by name.OlapElement
lookupCompound(OlapElement parent, List<Id.Segment> names, boolean failIfNotFound, int category, MatchType matchType)
Looks up an MDX object by name, specifying how to match if no object exactly matches the name.Member
lookupMemberChildByName(Member parent, Id.Segment childName, MatchType matchType)
Finds a child of a member with a given name.List<Member>
lookupMemberChildrenByNames(Member parent, List<Id.NameSegment> childNames, MatchType matchType)
Finds a list of child members with the given names.Member
substitute(Member member)
Substitutes a member with an equivalent member which enforces the access control policy of this SchemaReader.SchemaReader
withLocus()
Returns a schema reader that automatically assigns a locus to each operation.SchemaReader
withoutAccessControl()
Returns a similar schema reader that has no access control.
-
-
-
Method Detail
-
getSchema
RolapSchema getSchema()
Returns the schema.- Returns:
- Schema, never null
-
getRole
Role getRole()
Returns the access-control profile that thisSchemaReader
is implementing.
-
getCubeDimensions
List<Dimension> getCubeDimensions(Cube cube)
Returns the accessible dimensions of a cube.
-
getDimensionHierarchies
List<Hierarchy> getDimensionHierarchies(Dimension dimension)
Returns the accessible hierarchies of a dimension.
-
getHierarchyRootMembers
List<Member> getHierarchyRootMembers(Hierarchy hierarchy)
Returns an array of the root members ofhierarchy
.- Parameters:
hierarchy
- Hierarchy- See Also:
getCalculatedMembers(Hierarchy)
-
getChildrenCountFromCache
int getChildrenCountFromCache(Member member)
Returns number of children parent of a member, if the information can be retrieved from cache, otherwise -1.
-
getLevelCardinality
int getLevelCardinality(Level level, boolean approximate, boolean materialize)
Returns the number of members in a level, returning an approximation if acceptable.- Parameters:
level
- Levelapproximate
- Whether an approximation is acceptablematerialize
- Whether to go to disk if no approximation for the count is available and the members are not in cache. If false, returnsInteger.MIN_VALUE
if value is not in cache.
-
substitute
Member substitute(Member member)
Substitutes a member with an equivalent member which enforces the access control policy of this SchemaReader.
-
getMemberChildren
List<Member> getMemberChildren(Member member, Evaluator context)
Returns direct children ofmember
, optimized for NON EMPTY.If
context == null
then there is no context and all members are returned - then its identical togetMemberChildren(Member)
. Ifcontext
is not null, the resulting members may be restricted to those members that have a non empty row in the fact table forcontext
. Wether or not optimization is possible depends on the SchemaReader implementation.
-
getMemberChildren
List<Member> getMemberChildren(List<Member> members)
Returns direct children of each element ofmembers
.- Parameters:
members
- Array of members- Returns:
- array of child members
-
getMemberChildren
List<Member> getMemberChildren(List<Member> members, Evaluator context)
Returns direct children of each element ofmembers
which is not empty incontext
.- Parameters:
members
- Array of memberscontext
- Evaluation context- Returns:
- array of child members
-
getParentChildContributingChildren
void getParentChildContributingChildren(Member dataMember, Hierarchy hierarchy, List<Member> list)
Returns a list of contributing children of a member of a parent-child hierarchy.- Parameters:
dataMember
- Data member for a member of the parent-child hierarcyhierarchy
- Hierarchylist
- List of members to populate
-
getMemberParent
Member getMemberParent(Member member)
Returns the parent ofmember
.- Parameters:
member
- Member- Returns:
- null if member is a root member
-
getMemberAncestors
void getMemberAncestors(Member member, List<Member> ancestorList)
Returns a list of ancestors ofmember
, in depth order.For example, for [Store].[USA].[CA], returns {[Store].[USA], [Store].[All Stores]}.
- Parameters:
member
- MemberancestorList
- List of ancestors
-
getMemberDepth
int getMemberDepth(Member member)
Returns the depth of a member.This may not be the same as
member.
for three reasons:getLevel
().getDepth
()- 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.
- 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.
- 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.
-
getMemberByUniqueName
Member getMemberByUniqueName(List<Id.Segment> uniqueNameParts, boolean failIfNotFound, MatchType matchType)
Finds a member based upon its unique name.- Parameters:
uniqueNameParts
- Unique name of memberfailIfNotFound
- Whether to throw an error, as opposed to returningnull
, if there is no such member.matchType
- indicates the match mode; if not specified, EXACT- Returns:
- The member, or null if not found
-
getMemberByUniqueName
Member getMemberByUniqueName(List<Id.Segment> uniqueNameParts, boolean failIfNotFound)
Finds a member based upon its unique name, requiring an exact match.This method is equivalent to calling
getMemberByUniqueName(java.util.List, boolean, MatchType)
withMatchType.EXACT
.- Parameters:
uniqueNameParts
- Unique name of memberfailIfNotFound
- Whether to throw an error, as opposed to returningnull
, if there is no such member.- Returns:
- The member, or null if not found
-
lookupCompound
OlapElement lookupCompound(OlapElement parent, List<Id.Segment> names, boolean failIfNotFound, int category, MatchType matchType)
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.
- Parameters:
parent
- Parent element to search innames
- Exploded compound name, such as {"Products", "Product Department", "Produce"}failIfNotFound
- If the element is not found, determines whether to return null or throw an errorcategory
- Type of returned element, aCategory
value;Category.Unknown
if it doesn't matter.matchType
- indicates the match mode; if not specified, EXACT
-
lookupCompound
OlapElement lookupCompound(OlapElement parent, List<Id.Segment> names, boolean failIfNotFound, int category)
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.
- Parameters:
parent
- Parent element to search innames
- Exploded compound name, such as {"Products", "Product Department", "Produce"}failIfNotFound
- If the element is not found, determines whether to return null or throw an errorcategory
- Type of returned element, aCategory
value;Category.Unknown
if it doesn't matter.
-
getCalculatedMember
Member getCalculatedMember(List<Id.Segment> nameParts)
Looks up a calculated member by name. If the name is not found in the current scope, returns null.
-
getNamedSet
NamedSet getNamedSet(List<Id.Segment> nameParts)
Looks up a set by name. If the name is not found in the current scope, returns null.
-
getMemberRange
void getMemberRange(Level level, Member startMember, Member endMember, List<Member> list)
Appends tolist
all members betweenstartMember
andendMember
(inclusive) which belong tolevel
.
-
getLeadMember
Member getLeadMember(Member member, int n)
Returns a membern
further along in the same level frommember
.
-
compareMembersHierarchically
int compareMembersHierarchically(Member m1, Member m2)
Compares a pair ofMember
s 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.- Returns:
- A negative integer if
m1
is an ancestor, an earlier sibling of an ancestor, or a descendent of an earlier sibling, ofm2
; zero ifm1
is a sibling ofm2
; a positive integer ifm1
comes later in the prefix traversal thenm2
.
-
getElementChild
OlapElement getElementChild(OlapElement parent, Id.Segment name, MatchType matchType)
Looks up the child ofparent
calledname
, or an approximation according tomatchType
, returning null if no element is found.- Parameters:
parent
- Parent element to search inname
- Compound in compound name, such as "[Product]" or "&[1]"matchType
- Match type- Returns:
- Element with given name, or null
-
getElementChild
OlapElement getElementChild(OlapElement parent, Id.Segment name)
Looks up the child ofparent
name
, returning null if no element is found.Always equivalent to
getElementChild(parent, name, MatchType.EXACT)
.- Parameters:
parent
- Parent element to search inname
- Compound in compound name, such as "[Product]" or "&[1]"- Returns:
- Element with given name, or null
-
getLevelMembers
List<Member> getLevelMembers(Level level, boolean includeCalculated)
Returns the members of a level, optionally including calculated members.
-
getLevelMembers
List<Member> getLevelMembers(Level level, Evaluator context)
Returns the members of a level, optionally filtering out members which are empty.- Parameters:
level
- Levelcontext
- Context for filtering- Returns:
- Members of this level
-
getHierarchyLevels
List<Level> getHierarchyLevels(Hierarchy hierarchy)
Returns the accessible levels of a hierarchy.- Parameters:
hierarchy
- Hierarchy
-
getHierarchyDefaultMember
Member getHierarchyDefaultMember(Hierarchy hierarchy)
Returns the default member of a hierarchy. If the default member is in an inaccessible level, returns the nearest ascendant/descendant member.- Parameters:
hierarchy
- Hierarchy- Returns:
- Default member of hierarchy
-
isDrillable
boolean isDrillable(Member member)
Returns whether a member has visible children.
-
isVisible
boolean isVisible(Member member)
Returns whether a member is visible.
-
getCubes
Cube[] getCubes()
Returns the list of accessible cubes.
-
getCalculatedMembers
List<Member> getCalculatedMembers(Hierarchy hierarchy)
Returns a list of calculated members in a given hierarchy.
-
getCalculatedMembers
List<Member> getCalculatedMembers(Level level)
Returns a list of calculated members in a given level.
-
lookupMemberChildByName
Member lookupMemberChildByName(Member parent, Id.Segment childName, MatchType matchType)
Finds a child of a member with a given name.
-
lookupMemberChildrenByNames
List<Member> lookupMemberChildrenByNames(Member parent, List<Id.NameSegment> childNames, MatchType matchType)
Finds a list of child members with the given names.
-
getNativeSetEvaluator
NativeEvaluator getNativeSetEvaluator(FunDef fun, Exp[] args, Evaluator evaluator, Calc calc)
Returns an object which can evaluate an expression in native SQL, or null if this is not possible.- Parameters:
fun
- Functionargs
- Arguments to the functionevaluator
- Evaluator, provides contextcalc
- the calc to be natively evaluated
-
getParameter
Parameter getParameter(String name)
Returns the definition of a parameter with a given name, or null if not found.
-
getDataSource
DataSource getDataSource()
Returns the data source.- Returns:
- data source
-
withoutAccessControl
SchemaReader withoutAccessControl()
Returns a similar schema reader that has no access control.- Returns:
- Schema reader that has a similar perspective (e.g. cube) but no access control
-
getCube
Cube getCube()
Returns the default cube in which to look for dimensions etc.- Returns:
- Default cube
-
withLocus
SchemaReader withLocus()
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.
- Returns:
- Schema reader that assigns a locus to each operation
-
getNamespaces
List<NameResolver.Namespace> getNamespaces()
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.
- Returns:
- List of namespaces
-
getMemberChildrenWithDetails
Map<? extends Member,Access> getMemberChildrenWithDetails(Member member, Evaluator evaluator)
Similar togetMemberChildren(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 byRolapHierarchy
when determining the lowest access level of a Role within a hierarchy.
-
countMemberChildren
int countMemberChildren(Member parentMember)
-
-