本文整理汇总了Java中mondrian.olap.Position类的典型用法代码示例。如果您正苦于以下问题:Java Position类的具体用法?Java Position怎么用?Java Position使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Position类属于mondrian.olap包,在下文中一共展示了Position类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JRMondrianAxis
import mondrian.olap.Position; //导入依赖的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]);
}
}
示例2: executeSingletonAxis
import mondrian.olap.Position; //导入依赖的package包/类
/**
* Executes a set expression which is expected to return 0 or 1 members.
* It is an error if the expression returns tuples (as opposed to members),
* or if it returns two or more members.
*
* @param expression Expression string
* @return Null if axis returns the empty set, member if axis returns one
* member. Throws otherwise.
*/
public Member executeSingletonAxis(String expression) {
final String cubeName = getDefaultCubeName();
Result result = executeQuery(
"select {" + expression + "} on columns from " + cubeName);
Axis axis = result.getAxes()[0];
switch (axis.getPositions().size()) {
case 0:
// The mdx "{...}" operator eliminates null members (that is,
// members for which member.isNull() is true). So if "expression"
// yielded just the null member, the array will be empty.
return null;
case 1:
// Java nulls should never happen during expression evaluation.
Position position = axis.getPositions().get(0);
Util.assertTrue(position.size() == 1);
Member member = position.get(0);
Util.assertTrue(member != null);
return member;
default:
throw Util.newInternal(
"expression " + expression
+ " yielded " + axis.getPositions().size() + " positions");
}
}
示例3: toString
import mondrian.olap.Position; //导入依赖的package包/类
/**
* Converts a set of positions into a string. Useful if you want to check
* that an axis has the results you expected.
*/
public static String toString(List<Position> positions) {
StringBuilder buf = new StringBuilder();
int i = 0;
for (Position position : positions) {
if (i > 0) {
buf.append(nl);
}
if (position.size() != 1) {
buf.append("{");
}
for (int j = 0; j < position.size(); j++) {
Member member = position.get(j);
if (j > 0) {
buf.append(", ");
}
buf.append(member.getUniqueName());
}
if (position.size() != 1) {
buf.append("}");
}
i++;
}
return buf.toString();
}
示例4: testAllMemberCaption
import mondrian.olap.Position; //导入依赖的package包/类
public void testAllMemberCaption() {
TestContext testContext = TestContext.instance()
.createSubstitutingCube(
"Sales",
"<Dimension name=\"Gender3\" foreignKey=\"customer_id\">\n"
+ " <Hierarchy hasAll=\"true\" allMemberName=\"All Gender\"\n"
+ " allMemberCaption=\"Frauen und Maenner\" primaryKey=\"customer_id\">\n"
+ " <Table name=\"customer\"/>\n"
+ " <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\"/>\n"
+ " </Hierarchy>\n"
+ "</Dimension>");
String mdx = "select {[Gender3].[All Gender]} on columns from Sales";
Result result = testContext.executeQuery(mdx);
Axis axis0 = result.getAxes()[0];
Position pos0 = axis0.getPositions().get(0);
Member allGender = pos0.get(0);
String caption = allGender.getCaption();
Assert.assertEquals(caption, "Frauen und Maenner");
}
示例5: testAllLevelName
import mondrian.olap.Position; //导入依赖的package包/类
public void testAllLevelName() {
TestContext testContext = TestContext.instance()
.createSubstitutingCube(
"Sales",
"<Dimension name=\"Gender4\" foreignKey=\"customer_id\">\n"
+ " <Hierarchy hasAll=\"true\" allMemberName=\"All Gender\"\n"
+ " allLevelName=\"GenderLevel\" primaryKey=\"customer_id\">\n"
+ " <Table name=\"customer\"/>\n"
+ " <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\"/>\n"
+ " </Hierarchy>\n"
+ "</Dimension>");
String mdx = "select {[Gender4].[All Gender]} on columns from Sales";
Result result = testContext.executeQuery(mdx);
Axis axis0 = result.getAxes()[0];
Position pos0 = axis0.getPositions().get(0);
Member allGender = pos0.get(0);
String caption = allGender.getLevel().getName();
Assert.assertEquals(caption, "GenderLevel");
}
示例6: toString
import mondrian.olap.Position; //导入依赖的package包/类
public static String toString(List<Position> pl) {
StringBuilder buf = new StringBuilder();
for (Position p : pl) {
buf.append('{');
boolean firstTime = true;
for (Member m : p) {
if (! firstTime) {
buf.append(", ");
}
buf.append(m.getUniqueName());
firstTime = false;
}
buf.append('}');
buf.append('\n');
}
return buf.toString();
}
示例7: iterator
import mondrian.olap.Position; //导入依赖的package包/类
public Iterator<Position> iterator() {
return new Iterator<Position>() {
private final Iterator it = list.iterator();
private int cursor = 0;
public boolean hasNext() {
return it.hasNext();
}
public Position next() {
it.next();
return get(cursor++);
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例8: testMany
import mondrian.olap.Position; //导入依赖的package包/类
public void testMany() {
Axis[] axes = new Axis[3];
List<Position> positions = new PositionList(4);
axes[0] = new RolapAxis.PositionList(positions);
positions = new PositionList(3);
axes[1] = new RolapAxis.PositionList(positions);
positions = new PositionList(3);
axes[2] = new RolapAxis.PositionList(positions);
Modulos modulos = Modulos.Generator.createMany(axes);
int ordinal = 23;
int[] pos = modulos.getCellPos(ordinal);
assertTrue("Pos length equals 3", pos.length == 3);
assertTrue("Pos[0] length equals 3", pos[0] == 3);
assertTrue("Pos[1] length equals 2", pos[1] == 2);
assertTrue("Pos[2] length equals 1", pos[2] == 1);
}
示例9: executeSingletonAxis
import mondrian.olap.Position; //导入依赖的package包/类
/**
* Executes a set expression which is expected to return 0 or 1 members.
* It is an error if the expression returns tuples (as opposed to members),
* or if it returns two or more members.
*
* @param expression Expression string
* @return Null if axis returns the empty set, member if axis returns one
* member. Throws otherwise.
*/
public Member executeSingletonAxis(String expression) {
final String cubeName = getDefaultCubeName();
Result result = executeQuery(
"select {" + expression + "} on columns from " + cubeName);
Axis axis = result.getAxes()[0];
switch (axis.getPositions().size()) {
case 0:
// The mdx "{...}" operator eliminates null members (that is,
// members for which member.isNull() is true). So if "expression"
// yielded just the null member, the array will be empty.
return null;
case 1:
// Java nulls should never happen during expression evaluation.
Position position = axis.getPositions().get(0);
Util.assertTrue(position.size() == 1);
Member member = position.get(0);
Util.assertTrue(member != null);
return member;
default:
throw Util.newInternal(
"expression " + expression
+ " yielded " + axis.getPositions().size() + " positions");
}
}
示例10: JRMondrianTuple
import mondrian.olap.Position; //导入依赖的package包/类
public JRMondrianTuple(Position position, JRMondrianFactory factory)
{
members = new JRMondrianMember[position.size()];
int idx = 0;
for (Iterator<Member> it = position.iterator(); it.hasNext(); ++idx)
{
Member member = it.next();
members[idx] = factory.createMember(member);
}
}
示例11: assertVisibility
import mondrian.olap.Position; //导入依赖的package包/类
private void assertVisibility(
Result result,
int ordinal,
String expectedName,
boolean expectedVisibility)
{
List<Position> columnPositions = result.getAxes()[0].getPositions();
Member measure = columnPositions.get(ordinal).get(0);
assertEquals(expectedName, measure.getName());
assertEquals(
expectedVisibility,
measure.getPropertyValue(Property.VISIBLE.name));
}
示例12: testVirtualCubeMeasureCaption
import mondrian.olap.Position; //导入依赖的package包/类
/**
* Test case for bug <a href="http://jira.pentaho.com/browse/MONDRIAN-352">
* MONDRIAN-352, "Caption is not set on RolapVirtualCubeMesure"</a>.
*/
public void testVirtualCubeMeasureCaption() {
TestContext testContext = TestContext.instance().create(
null,
"<Cube name=\"TestStore\">\n"
+ " <Table name=\"store\"/>\n"
+ " <Dimension name=\"HCB\" caption=\"Has coffee bar caption\">\n"
+ " <Hierarchy hasAll=\"true\">\n"
+ " <Level name=\"Has coffee bar\" column=\"coffee_bar\" uniqueMembers=\"true\"\n"
+ " type=\"Boolean\"/>\n"
+ " </Hierarchy>\n"
+ " </Dimension>\n"
+ " <Measure name=\"Store Sqft\" caption=\"Store Sqft Caption\" column=\"store_sqft\" aggregator=\"sum\" formatString=\"#,###\"/>\n"
+ "</Cube>\n",
"<VirtualCube name=\"VirtualTestStore\">\n"
+ " <VirtualCubeDimension cubeName=\"TestStore\" name=\"HCB\"/>\n"
+ " <VirtualCubeMeasure cubeName=\"TestStore\" name=\"[Measures].[Store Sqft]\"/>\n"
+ "</VirtualCube>",
null,
null,
null);
Result result = testContext.executeQuery(
"select {[Measures].[Store Sqft]} ON COLUMNS,"
+ "{[HCB]} ON ROWS "
+ "from [VirtualTestStore]");
Axis[] axes = result.getAxes();
List<Position> positions = axes[0].getPositions();
Member m0 = positions.get(0).get(0);
String caption = m0.getCaption();
assertEquals("Store Sqft Caption", caption);
}
示例13: assertResultValid
import mondrian.olap.Position; //导入依赖的package包/类
/**
* Checks that a {@link Result} is valid.
*
* @param result Query result
*/
private void assertResultValid(Result result) {
for (Cell cell : cellIter(result)) {
final Object value = cell.getValue();
// Check that the dummy value used to represent null cells never
// leaks into the outside world.
Assert.assertNotSame(value, Util.nullValue);
Assert.assertFalse(
value instanceof Number
&& ((Number) value).doubleValue() == FunUtil.DoubleNull);
// Similarly empty values.
Assert.assertNotSame(value, Util.EmptyValue);
Assert.assertFalse(
value instanceof Number
&& ((Number) value).doubleValue() == FunUtil.DoubleEmpty);
// Cells should be null if and only if they are null or empty.
if (cell.getValue() == null) {
Assert.assertTrue(cell.isNull());
} else {
Assert.assertFalse(cell.isNull());
}
}
// There should be no null members.
for (Axis axis : result.getAxes()) {
for (Position position : axis.getPositions()) {
for (Member member : position) {
Assert.assertNotNull(member);
}
}
}
}
示例14: assertCellSetValid
import mondrian.olap.Position; //导入依赖的package包/类
/**
* Checks that a {@link CellSet} is valid.
*
* @param cellSet Cell set
*/
private void assertCellSetValid(CellSet cellSet) {
for (org.olap4j.Cell cell : cellIter(cellSet)) {
final Object value = cell.getValue();
// Check that the dummy value used to represent null cells never
// leaks into the outside world.
Assert.assertNotSame(value, Util.nullValue);
Assert.assertFalse(
value instanceof Number
&& ((Number) value).doubleValue() == FunUtil.DoubleNull);
// Similarly empty values.
Assert.assertNotSame(value, Util.EmptyValue);
Assert.assertFalse(
value instanceof Number
&& ((Number) value).doubleValue() == FunUtil.DoubleEmpty);
// Cells should be null if and only if they are null or empty.
if (cell.getValue() == null) {
Assert.assertTrue(cell.isNull());
} else {
Assert.assertFalse(cell.isNull());
}
}
// There should be no null members.
for (CellSetAxis axis : cellSet.getAxes()) {
for (org.olap4j.Position position : axis.getPositions()) {
for (org.olap4j.metadata.Member member : position.getMembers())
{
Assert.assertNotNull(member);
}
}
}
}
示例15: outputFlattenedRecurse
import mondrian.olap.Position; //导入依赖的package包/类
private static void outputFlattenedRecurse(
Result result,
List<List<Object>> rows,
List<Object> rowValues,
int[] coords,
int axisOrdinal)
{
final Axis[] axes = result.getAxes();
if (axisOrdinal == axes.length) {
final Cell cell = result.getCell(coords);
// Output the raw (unformatted) value of the cell.
// NOTE: We could output other properties of the cell here, such as its
// formatted value, too.
rowValues.add(cell.getValue());
// Add a copy of the completed row to the list of rows.
rows.add(new ArrayList<Object>(rowValues));
} else {
final Axis axis = axes[axisOrdinal];
int k = -1;
int saveLength = rowValues.size();
for (Position position : axis.getPositions()) {
coords[axisOrdinal] = ++k;
for (Member member : position) {
rowValues.add(member.getUniqueName());
}
outputFlattenedRecurse(
result, rows, rowValues, coords, axisOrdinal + 1);
while (rowValues.size() > saveLength) {
rowValues.remove(rowValues.size() - 1);
}
}
}
}