本文整理汇总了Java中mondrian.olap.Hierarchy类的典型用法代码示例。如果您正苦于以下问题:Java Hierarchy类的具体用法?Java Hierarchy怎么用?Java Hierarchy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Hierarchy类属于mondrian.olap包,在下文中一共展示了Hierarchy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JRMondrianHierarchy
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public JRMondrianHierarchy(Hierarchy hierarchy)
{
this.hierarchy = hierarchy;
if (hierarchy == null)
{
levels = new JRMondrianLevel[0];
}
else
{
Level[] hierarchyLevels = hierarchy.getLevels();
levels = new JRMondrianLevel[hierarchyLevels.length];
for (int i = 0; i < hierarchyLevels.length; i++)
{
levels[i] = new JRMondrianLevel(hierarchyLevels[i]);
}
}
}
示例2: JRMondrianAxis
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public JRMondrianAxis(Axis axis, Hierarchy[] axisHierarchies, JRMondrianFactory factory)
{
List<Position> positions = axis.getPositions();
tuples = new JRMondrianTuple[positions.size()];
int idx = 0;
for (Iterator<Position> it = positions.iterator(); it.hasNext(); ++idx)
{
Position position = it.next();
tuples[idx] = new JRMondrianTuple(position, factory);
}
hierarchies = new JRMondrianHierarchy[axisHierarchies.length];
for (int i = 0; i < axisHierarchies.length; i++)
{
hierarchies[i] = new JRMondrianHierarchy(axisHierarchies[i]);
}
}
示例3: getSharedDimensions
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public NamedList<Dimension> getSharedDimensions() throws OlapException {
final MondrianOlap4jConnection olap4jConnection =
olap4jCatalog.olap4jDatabaseMetaData.olap4jConnection;
final SortedSet<MondrianOlap4jDimension> dimensions =
new TreeSet<MondrianOlap4jDimension>(
new Comparator<MondrianOlap4jDimension>() {
public int compare(
MondrianOlap4jDimension o1,
MondrianOlap4jDimension o2)
{
return o1.getName().compareTo(o2.getName());
}
}
);
final Role role = olap4jConnection.getMondrianConnection().getRole();
for (Hierarchy hierarchy : schema.getSharedHierarchies()) {
if (role.canAccess(hierarchy)) {
dimensions.add(
olap4jConnection.toOlap4j(hierarchy.getDimension()));
}
}
NamedList<MondrianOlap4jDimension> list =
new NamedListImpl<MondrianOlap4jDimension>();
list.addAll(dimensions);
return Olap4jUtil.cast(list);
}
示例4: pushSelf
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public RolapEvaluator pushSelf(RolapEvaluator evaluator) {
final RolapEvaluator evaluator2 = evaluator.push();
// Restore default member for each hierarchy
// in the tuple.
for (Hierarchy hierarchy : hierarchyList) {
final int ordinal =
hierarchy.getDimension().getOrdinal(
evaluator.root.cube);
final RolapMember defaultMember =
evaluator.root.defaultMembers[ordinal];
evaluator2.setContext(defaultMember);
}
evaluator2.removeCalcMember(this);
return evaluator2;
}
示例5: testHierarchyVisibility
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public void testHierarchyVisibility() throws Exception {
for (Boolean testValue : new Boolean[] {true, false}) {
String cubeDef =
"<Cube name=\"Foo\">\n"
+ " <Table name=\"store\"/>\n"
+ " <Dimension name=\"Bar\">\n"
+ " <Hierarchy name=\"Bacon\" hasAll=\"true\" visible=\"@[email protected]\">\n"
+ " <Level name=\"Store Type\" column=\"store_type\" uniqueMembers=\"true\"/>\n"
+ " </Hierarchy>\n"
+ " </Dimension>\n"
+ " <Measure name=\"Store Sqft\" column=\"store_sqft\" aggregator=\"sum\"\n"
+ " formatString=\"#,###\"/>\n"
+ "</Cube>\n";
cubeDef = cubeDef.replace(
"@[email protected]",
String.valueOf(testValue));
final TestContext context =
TestContext.instance().create(
null, cubeDef, null, null, null, null);
final Cube cube =
context.getConnection().getSchema()
.lookupCube("Foo", true);
Dimension dim = null;
for (Dimension dimCheck : cube.getDimensions()) {
if (dimCheck.getName().equals("Bar")) {
dim = dimCheck;
}
}
assertNotNull(dim);
final Hierarchy hier = dim.getHierarchy();
assertNotNull(hier);
assertEquals(
MondrianProperties.instance().SsasCompatibleNaming.get()
? "Bacon"
: "Bar.Bacon",
hier.getName());
assertTrue(testValue.equals(hier.isVisible()));
}
}
示例6: matchLevel
import mondrian.olap.Hierarchy; //导入依赖的package包/类
/**
* Creates a level usage. A level usage is a column that is used in a
* collapsed dimension aggregate table.
*
* <p> First, iterate through the ExplicitRules.TableDef's level
* definitions for one with a name equal to the RolapLevel unique name,
* i.e., [Time].[Quarter]. Now, using the level's column name, search
* through the aggregate table's columns for one with that name and make a
* level usage for the column. Return true if the aggregate table's column
* was found.
*/
protected boolean matchLevel(
final Hierarchy hierarchy,
final HierarchyUsage hierarchyUsage,
final RolapLevel rlevel)
{
msgRecorder.pushContextName("ExplicitRecognizer.matchLevel");
try {
// Try to match a Level's name against the RolapLevel unique name.
String levelUniqueName = rlevel.getUniqueName();
for (ExplicitRules.TableDef.Level level : getTableDef().getLevels())
{
if (level.getName().equals(levelUniqueName)) {
// Ok, got a match, so now make a measue
//makeLevel(level, xxxxolumn);
// Now can we find a column in the aggTable that matches the
// Level's column
String columnName = level.getColumnName();
for (JdbcSchema.Table.Column aggColumn
: aggTable.getColumns())
{
if (aggColumn.getName().equals(columnName)) {
makeLevel(
aggColumn,
hierarchy,
hierarchyUsage,
getColumnName(rlevel.getKeyExp()),
columnName,
rlevel.getName());
return true;
}
}
}
}
return false;
} finally {
msgRecorder.popContextName();
}
}
示例7: matchLevel
import mondrian.olap.Hierarchy; //导入依赖的package包/类
/**
* Create level usages.
*
* <p> A Matcher is created using the Hierarchy's name, the RolapLevel
* name, and the column name associated with the RolapLevel's key
* expression. The aggregate table columns are search for the first match
* and, if found, a level usage is created for that column and true is
* returned.
*/
protected boolean matchLevel(
final Hierarchy hierarchy,
final HierarchyUsage hierarchyUsage,
final RolapLevel level)
{
msgRecorder.pushContextName("DefaultRecognizer.matchLevel");
try {
String usagePrefix = hierarchyUsage.getUsagePrefix();
String hierName = hierarchy.getName();
String levelName = level.getName();
String levelColumnName = getColumnName(level.getKeyExp());
Recognizer.Matcher matcher = getRules().getLevelMatcher(
usagePrefix, hierName, levelName, levelColumnName);
for (JdbcSchema.Table.Column aggColumn : aggTable.getColumns()) {
if (matcher.matches(aggColumn.getName())) {
makeLevel(
aggColumn,
hierarchy,
hierarchyUsage,
getColumnName(level.getKeyExp()),
getColumnName(level.getKeyExp()),
level.getName());
return true;
}
}
return false;
} finally {
msgRecorder.popContextName();
}
}
示例8: getSharedDimensions
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public NamedList<Dimension> getSharedDimensions() throws OlapException {
NamedList<MondrianOlap4jDimension> list =
new NamedListImpl<MondrianOlap4jDimension>();
final MondrianOlap4jConnection olap4jConnection =
olap4jCatalog.olap4jDatabaseMetaData.olap4jConnection;
for (Hierarchy hierarchy : schema.getSharedHierarchies()) {
list.add(olap4jConnection.toOlap4j(hierarchy.getDimension()));
}
return Olap4jUtil.cast(list);
}
示例9: parseParameter
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public Expr parseParameter(String value) {
// is it a String (enclose in double or single quotes ?
String trimmed = value.trim();
int len = trimmed.length();
if (trimmed.charAt(0) == '"' && trimmed.charAt(len - 1) == '"') {
debug("parseParameter. STRING_TYPE: " + trimmed);
return new Expr(
trimmed.substring(1, trimmed.length() - 1),
Expr.Type.STRING);
}
if (trimmed.charAt(0) == '\'' && trimmed.charAt(len - 1) == '\'') {
debug("parseParameter. STRING_TYPE: " + trimmed);
return new Expr(
trimmed.substring(1, trimmed.length() - 1),
Expr.Type.STRING);
}
// is it a Number ?
Number number = null;
try {
number = nf.parse(trimmed);
} catch (ParseException pex) {
// nothing to do, should be member
}
if (number != null) {
debug("parseParameter. NUMERIC_TYPE: " + number);
return new Expr(number, Expr.Type.NUMERIC);
}
debug("parseParameter. MEMBER_TYPE: " + trimmed);
Query query = this.connection.parseQuery(this.mdxCmd);
// dont have to execute
//this.connection.execute(query);
// assume member, dimension, hierarchy, level
OlapElement element = Util.lookup(query, Util.parseIdentifier(trimmed));
debug(
"parseParameter. exp="
+ ((element == null) ? "null" : element.getClass().getName()));
if (element instanceof Member) {
Member member = (Member) element;
return new Expr(member, Expr.Type.MEMBER);
} else if (element instanceof mondrian.olap.Level) {
mondrian.olap.Level level = (mondrian.olap.Level) element;
return new Expr(level, Expr.Type.MEMBER);
} else if (element instanceof Hierarchy) {
Hierarchy hier = (Hierarchy) element;
return new Expr(hier, Expr.Type.MEMBER);
} else if (element instanceof Dimension) {
Dimension dim = (Dimension) element;
return new Expr(dim, Expr.Type.MEMBER);
}
return null;
}
示例10: testLevelVisibility
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public void testLevelVisibility() throws Exception {
for (Boolean testValue : new Boolean[] {true, false}) {
String cubeDef =
"<Cube name=\"Foo\">\n"
+ " <Table name=\"store\"/>\n"
+ " <Dimension name=\"Bar\">\n"
+ " <Hierarchy name=\"Bacon\" hasAll=\"false\">\n"
+ " <Level name=\"Samosa\" column=\"store_type\" uniqueMembers=\"true\" visible=\"@[email protected]\"/>\n"
+ " </Hierarchy>\n"
+ " </Dimension>\n"
+ " <Measure name=\"Store Sqft\" column=\"store_sqft\" aggregator=\"sum\"\n"
+ " formatString=\"#,###\"/>\n"
+ "</Cube>\n";
cubeDef = cubeDef.replace(
"@[email protected]",
String.valueOf(testValue));
final TestContext context =
TestContext.instance().create(
null, cubeDef, null, null, null, null);
final Cube cube =
context.getConnection().getSchema()
.lookupCube("Foo", true);
Dimension dim = null;
for (Dimension dimCheck : cube.getDimensions()) {
if (dimCheck.getName().equals("Bar")) {
dim = dimCheck;
}
}
assertNotNull(dim);
final Hierarchy hier = dim.getHierarchy();
assertNotNull(hier);
assertEquals(
MondrianProperties.instance().SsasCompatibleNaming.get()
? "Bacon"
: "Bar.Bacon",
hier.getName());
final mondrian.olap.Level level = hier.getLevels()[0];
assertEquals("Samosa", level.getName());
assertTrue(testValue.equals(level.isVisible()));
}
}
示例11: parseQuery
import mondrian.olap.Hierarchy; //导入依赖的package包/类
protected void parseQuery(Query query)
{
QueryAxis[] axes = query.getAxes();
for (QueryAxis axis : axes)
{
IROlapResultAxis jrAxis = new IROlapResultAxis();
((IROlapResult)xmlaResult).addAxis(jrAxis);
Hierarchy[] hierarchies = query.getMdxHierarchiesOnAxis(axis.getAxisOrdinal());
for (Hierarchy hierarchy : hierarchies)
{
boolean addMeasures = false;
IROlapHierarchy jrHierarchy = new IROlapHierarchy(hierarchy.getName());
if (hierarchy.getName().equals("Measures"))
{
addMeasures = true;
}
jrHierarchy.setHierarchyUniqueName( hierarchy.getUniqueName() );
Level[] levels = hierarchy.getLevels();
for (Level level : levels)
{
IROlapHierarchyLevel jrLevel = new IROlapHierarchyLevel(level.getName(), level.getDepth());
jrHierarchy.addHierarchyLevel(jrLevel);
}
jrAxis.addHierarchy(jrHierarchy);
// Add axis tubles for measures...
if (addMeasures)
{
Set<Member> memberSet = query.getMeasuresMembers();
IROlapMemberTuple tuple = new IROlapMemberTuple();
Iterator iter = memberSet.iterator();
while (iter.hasNext())
{
Member m = (Member)iter.next();
JRXmlaMember member = new JRXmlaMember(m.getName(), m.getUniqueName(), m.getDimension().getName(), m.getLevel().getName(), m.getDepth());
tuple.addMember(member);
}
jrAxis.addTuple(tuple);
}
}
}
}
示例12: createFlattenedOutput
import mondrian.olap.Hierarchy; //导入依赖的package包/类
/**
* Retrieve the rows from the opened query.
* Also create a description of the flattened output of the query.
* This call populated rowMetaInterface and rows
* The query needs to be opened beforehand.
* @throws KettleDatabaseException in case something goes wrong
*
* TODO: this is not quite working for our purposes.
*/
public void createFlattenedOutput() throws KettleDatabaseException {
final Axis[] axes = result.getAxes();
rows = new ArrayList<List<Object>>();
headings = new ArrayList<String>();
// Compute headings. Each heading is a hierarchy name. If there are say
// 2 members on the columns, and 3 members on the rows axis, then there
// will be 5 headings.
//
for (Axis axis : axes) {
final List<Position> positions = axis.getPositions();
if (positions.isEmpty()) {
// Result set is empty. There is no data to print, and we cannot
// even deduce column headings.
return;
}
for (Member member : positions.get(0)) {
Hierarchy hierarchy = member.getHierarchy();
headings.add(hierarchy.getUniqueName());
}
}
int[] coords = new int[axes.length];
outputFlattenedRecurse(result, rows, new ArrayList<Object>(), coords, 0);
outputRowMeta = new RowMeta();
// Just scan the first row to see what data types we received...
//
for (int i=0 ; i<rows.size() && i<1 ; i++) {
List<Object> rowValues = rows.get(i);
for (int c=0 ;c<rowValues.size();c++) {
ValueMetaInterface valueMeta = new ValueMeta(headings.get(c));
Object valueData = rowValues.get(c);
if (valueData instanceof String) {
valueMeta.setType(ValueMetaInterface.TYPE_STRING);
}
else if (valueData instanceof Date) {
valueMeta.setType(ValueMetaInterface.TYPE_DATE);
}
else if (valueData instanceof Boolean) {
valueMeta.setType(ValueMetaInterface.TYPE_BOOLEAN);
}
else if (valueData instanceof Long) {
valueMeta.setType(ValueMetaInterface.TYPE_INTEGER);
}
else if (valueData instanceof Double) {
valueMeta.setType(ValueMetaInterface.TYPE_NUMBER);
}
else if (valueData instanceof BigDecimal) {
valueMeta.setType(ValueMetaInterface.TYPE_BIGNUMBER);
}
else {
throw new KettleDatabaseException("Unhandled data type found '"+valueData.getClass().toString()+"'");
}
outputRowMeta.addValueMeta(valueMeta);
}
}
// Now that we painstakingly found the metadata that comes out of the Mondrian database, cache it please...
//
DBCacheEntry cacheEntry = new DBCacheEntry(databaseMeta.getName(), queryString);
DBCache.getInstance().put(cacheEntry, outputRowMeta);
}
示例13: matchLevel
import mondrian.olap.Hierarchy; //导入依赖的package包/类
/**
* Match a aggregate table column given the hierarchy, hierarchy usage, and
* rolap level returning true if a match is found.
*/
protected abstract boolean matchLevel(
final Hierarchy hierarchy,
final HierarchyUsage hierarchyUsage,
final RolapLevel level);
示例14: evaluateDimension
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public Dimension evaluateDimension(Evaluator evaluator) {
Hierarchy hierarchy =
hierarchyCalc.evaluateHierarchy(evaluator);
return hierarchy.getDimension();
}
示例15: evaluateHierarchy
import mondrian.olap.Hierarchy; //导入依赖的package包/类
public Hierarchy evaluateHierarchy(Evaluator evaluator) {
Level level = levelCalc.evaluateLevel(evaluator);
return level.getHierarchy();
}