public class RolapHierarchy extends HierarchyBase
RolapHierarchy
implements Hierarchy
for a ROLAP database.
The ordinal of a hierarchy within a particular cube is found by
calling getOrdinalInCube()
. Ordinals are contiguous and zero-based.
Zero is always the [Measures]
dimension.
NOTE: It is only valid to call that method on the measures hierarchy, and
on members of the RolapCubeHierarchy
subclass. When the measures
hierarchy is of that class, we will move the method down.)
Modifier and Type | Class and Description |
---|---|
static class |
RolapHierarchy.LimitedRollupMember
Substitute for a member in a hierarchy whose rollup policy is 'partial'
or 'hidden'.
|
protected static class |
RolapHierarchy.RolapCalculatedMeasure
Calculated member which is also a measure (that is, a member of the
[Measures] dimension).
|
(package private) static class |
RolapHierarchy.RolapNullMember
A
RolapNullMember is the null member of its hierarchy. |
OlapElement.LocalizedProperty
Modifier and Type | Field and Description |
---|---|
(package private) RolapHierarchy |
closureFor |
protected RolapLevel |
nullLevel
The level that the null member belongs too.
|
protected MondrianDef.RelationOrJoin |
relation |
protected MondrianDef.Hierarchy |
xmlHierarchy |
allLevelName, allMemberName, description, dimension, hasAll, levels, name, subName, uniqueName
caption, visible
Constructor and Description |
---|
RolapHierarchy(RolapDimension dimension,
MondrianDef.Hierarchy xmlHierarchy,
MondrianDef.CubeDimension xmlCubeDimension)
Creates a
RolapHierarchy . |
RolapHierarchy(RolapDimension dimension,
String subName,
String caption,
boolean visible,
String description,
boolean hasAll,
RolapHierarchy closureFor,
Map<String,Annotation> annotationMap)
Creates a hierarchy.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addToFrom(SqlQuery query,
MondrianDef.Expression expression)
Adds to the FROM clause of the query the tables necessary to access the
members of this hierarchy.
|
(package private) void |
addToFrom(SqlQuery query,
RolapStar.Table table)
Adds a table to the FROM clause of the query.
|
(package private) void |
addToFromInverse(SqlQuery query,
MondrianDef.Expression expression)
Adds to the FROM clause of the query the tables necessary to access the
members of this hierarchy in an inverse join order, used with agg tables.
|
protected int |
computeHashCode()
Computes this object's hash code.
|
static Map<String,Annotation> |
createAnnotationMap(MondrianDef.Annotations annotations) |
(package private) RolapDimension |
createClosedPeerDimension(RolapLevel src,
MondrianDef.Closure clos,
MondrianDef.CubeDimension xmlDimension)
Builds a dimension which maps onto a table holding the transitive
closure of the relationship for this parent-child level.
|
Member |
createMember(Member parent,
Level level,
String name,
Formula formula)
Creates a member of this hierarchy.
|
(package private) MemberReader |
createMemberReader(Role role)
Creates a member reader which enforces the access-control profile of
role . |
boolean |
equals(Object o) |
(package private) Exp |
getAggregateChildrenExpression()
Returns an expression which will compute a member's value by aggregating
its children.
|
(package private) String |
getAlias() |
RolapMember |
getAllMember()
Returns the 'all' member.
|
Map<String,Annotation> |
getAnnotationMap()
Returns a list of annotations.
|
Member |
getDefaultMember()
Returns the default member of this hierarchy.
|
protected org.apache.log4j.Logger |
getLogger() |
(package private) List<Member> |
getLowestMembersForAccess(Evaluator evaluator,
Role.HierarchyAccess hAccess,
Map<Member,Access> membersWithAccess)
Goes recursively down a hierarchy and builds a list of the
members that should be constrained on because of access controls.
|
(package private) MemberReader |
getMemberReader() |
Member |
getNullMember()
Returns a special member representing the "null" value.
|
int |
getOrdinalInCube()
Returns the ordinal of this hierarchy in its cube.
|
MondrianDef.RelationOrJoin |
getRelation() |
RolapSchema |
getRolapSchema() |
String |
getSharedHierarchyName()
Returns the name of the source hierarchy, if this hierarchy is shared,
otherwise null.
|
(package private) MondrianDef.Relation |
getTable(String tableName) |
String |
getUniqueKeyLevelName()
Gets "unique key level name" attribute of this Hierarchy, if set.
|
(package private) MondrianDef.Relation |
getUniqueTable()
If this hierarchy has precisely one table, returns that table;
if this hierarchy has no table, return the cube's fact-table;
otherwise, returns null.
|
MondrianDef.Hierarchy |
getXmlHierarchy() |
(package private) void |
init(MondrianDef.CubeDimension xmlDimension)
Initializes a hierarchy within the context of a cube.
|
boolean |
isRagged()
A hierarchy is ragged if it contains one or more levels with hidden
members.
|
(package private) RolapLevel |
newMeasuresLevel() |
void |
setDefaultMember(Member defaultMember)
Sets default member of this Hierarchy.
|
(package private) void |
setMemberReader(MemberReader memberReader) |
(package private) boolean |
tableExists(String tableName) |
equals, getAllLevelName, getAllMemberName, getDescription, getDimension, getHierarchy, getLevels, getName, getQualifiedName, getSubName, getUniqueName, getUniqueNameSsas, hasAll, lookupChild
clone, getCaption, getLocalized, hashCode, isVisible, setCaption, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
getCaption, getLocalized, isVisible
protected MondrianDef.Hierarchy xmlHierarchy
protected MondrianDef.RelationOrJoin relation
protected final RolapLevel nullLevel
final RolapHierarchy closureFor
RolapHierarchy(RolapDimension dimension, String subName, String caption, boolean visible, String description, boolean hasAll, RolapHierarchy closureFor, Map<String,Annotation> annotationMap)
dimension
- DimensionsubName
- Name of this hierarchyhasAll
- Whether hierarchy has an 'all' memberclosureFor
- Hierarchy for which the new hierarchy is a closure;
null for regular hierarchiesRolapHierarchy(RolapDimension dimension, MondrianDef.Hierarchy xmlHierarchy, MondrianDef.CubeDimension xmlCubeDimension)
RolapHierarchy
.dimension
- the dimension this hierarchy belongs toxmlHierarchy
- the xml object defining this hierarchyxmlCubeDimension
- the xml object defining the cube
dimension for this objectpublic static Map<String,Annotation> createAnnotationMap(MondrianDef.Annotations annotations)
protected org.apache.log4j.Logger getLogger()
getLogger
in class OlapElementBase
public boolean equals(Object o)
equals
in class OlapElementBase
protected int computeHashCode()
OlapElementBase
computeHashCode
in class OlapElementBase
void init(MondrianDef.CubeDimension xmlDimension)
void setMemberReader(MemberReader memberReader)
MemberReader getMemberReader()
public Map<String,Annotation> getAnnotationMap()
Annotated
The map may be empty, never null.
RolapLevel newMeasuresLevel()
MondrianDef.Relation getUniqueTable()
boolean tableExists(String tableName)
MondrianDef.Relation getTable(String tableName)
public RolapSchema getRolapSchema()
public MondrianDef.RelationOrJoin getRelation()
public MondrianDef.Hierarchy getXmlHierarchy()
public Member getDefaultMember()
Hierarchy
If a hierarchy is subject to access-control, the default member may
not be visible, so use SchemaReader.getHierarchyDefaultMember(mondrian.olap.Hierarchy)
.
public Member getNullMember()
Hierarchy
Lead
,
NextMember
and ParentMember
walk off the end
of the hierarchy.public RolapMember getAllMember()
public Member createMember(Member parent, Level level, String name, Formula formula)
Hierarchy
formula
must not be null.public String getSharedHierarchyName()
If this hierarchy is a public -- that is, it belongs to a dimension
which is a usage of a shared dimension -- then
sharedHierarchyName
holds the unique name of the shared
hierarchy; otherwise it is null.
Suppose this hierarchy is "Weekly" in the dimension "Order Date" of
cube "Sales", and that "Order Date" is a usage of the "Time"
dimension. Then sharedHierarchyName
will be
"[Time].[Weekly]".
void addToFromInverse(SqlQuery query, MondrianDef.Expression expression)
expression
is not null, adds the tables necessary to
compute that expression.
This method is idempotent: if you call it more than once, it only adds the table(s) to the FROM clause once.
query
- Query to add the hierarchy toexpression
- Level to qualify up to; if null, qualifies up to the
topmost ('all') expression, which may require more columns and more
joinsvoid addToFrom(SqlQuery query, MondrianDef.Expression expression)
expression
is not null, adds
the tables necessary to compute that expression.
This method is idempotent: if you call it more than once, it only adds the table(s) to the FROM clause once.
query
- Query to add the hierarchy toexpression
- Level to qualify up to; if null, qualifies up to the
topmost ('all') expression, which may require more columns and more
joinsvoid addToFrom(SqlQuery query, RolapStar.Table table)
table
is not null, adds the table. Otherwise, add the
relation on which this hierarchy is based on.
This method is idempotent: if you call it more than once, it only adds the table(s) to the FROM clause once.
query
- Query to add the hierarchy totable
- table to add to the queryMemberReader createMemberReader(Role role)
role
.
This method may not be efficient, so the caller should take care not to call it too often. A cache is a good idea.
role
- RoleList<Member> getLowestMembersForAccess(Evaluator evaluator, Role.HierarchyAccess hAccess, Map<Member,Access> membersWithAccess)
Example. If we only give access to Seattle but the query is on the country level, we have to constrain at the city level, not state, or else all the values of all cities in the state will be returned.
public boolean isRagged()
isRagged
in class HierarchyBase
Exp getAggregateChildrenExpression()
It is efficient to share one expression between all calculated members in a parent-child hierarchy, so we only need need to validate the expression once.
RolapDimension createClosedPeerDimension(RolapLevel src, MondrianDef.Closure clos, MondrianDef.CubeDimension xmlDimension)
This method is triggered by the
MondrianDef.Closure
element
in a schema, and is only meaningful for a parent-child hierarchy.
When a Schema contains a parent-child Hierarchy that has an associated closure table, Mondrian creates a parallel internal Hierarchy, called a "closed peer", that refers to the closure table. This is indicated in the schema at the level of a Level, by including a Closure element. The closure table represents the transitive closure of the parent-child relationship.
The peer dimension, with its single hierarchy, and 3 levels (all, closure, item) really 'belong to' the parent-child level. If a single hierarchy had two parent-child levels (however unlikely this might be) then each level would have its own auxiliary dimension.
For example, in the demo schema the [HR].[Employee] dimension contains a parent-child hierarchy:
<Dimension name="Employees" foreignKey="employee_id"> <Hierarchy hasAll="true" allMemberName="All Employees" primaryKey="employee_id"> <Table name="employee"/> <Level name="Employee Id" type="Numeric" uniqueMembers="true" column="employee_id" parentColumn="supervisor_id" nameColumn="full_name" nullParentValue="0"> <Closure parentColumn="supervisor_id" childColumn="employee_id"> <Table name="employee_closure"/> </Closure> ...The internal closed peer Hierarchy has this structure:
<Dimension name="Employees" foreignKey="employee_id"> ... <Hierarchy name="Employees$Closure" hasAll="true" allMemberName="All Employees" primaryKey="employee_id" primaryKeyTable="employee_closure"> <Join leftKey="supervisor_id" rightKey="employee_id"> <Table name="employee_closure"/> <Table name="employee"/> </Join> <Level name="Closure" type="Numeric" uniqueMembers="false" table="employee_closure" column="supervisor_id"/> <Level name="Employee" type="Numeric" uniqueMembers="true" table="employee_closure" column="employee_id"/> </Hierarchy>
Note that the original Level with the Closure produces two Levels in the closed peer Hierarchy: a simple peer (Employee) and a closed peer (Closure).
src
- a parent-child Level that has a Closure clauseclos
- a Closure clausepublic void setDefaultMember(Member defaultMember)
defaultMember
- Default memberpublic String getUniqueKeyLevelName()
Gets "unique key level name" attribute of this Hierarchy, if set. If set, this property indicates that all level properties are functionally dependent (invariant) on their associated levels, and that the set of levels from the root to the named level (inclusive) effectively defines an alternate key.
This allows the GROUP BY to be eliminated from associated queries.
public int getOrdinalInCube()
Temporarily defined against RolapHierarchy; will be moved to RolapCubeHierarchy as soon as the measures hierarchy is a RolapCubeHierarchy.