Search in sources :

Example 1 with Statement

use of mondrian.server.Statement in project mondrian by pentaho.

the class RolapCube method createCalculatedMember.

/**
 * Creates a calculated member.
 *
 * <p>The member will be called [{dimension name}].[{name}].
 *
 * <p>Not for public use.
 *
 * @param hierarchy Hierarchy the calculated member belongs to
 * @param name Name of member
 * @param calc Compiled expression
 */
RolapMember createCalculatedMember(RolapHierarchy hierarchy, String name, Calc calc) {
    final List<Id.Segment> segmentList = new ArrayList<Id.Segment>();
    segmentList.addAll(Util.parseIdentifier(hierarchy.getUniqueName()));
    segmentList.add(new Id.NameSegment(name));
    final Formula formula = new Formula(new Id(segmentList), createDummyExp(calc), new MemberProperty[0]);
    final Statement statement = schema.getInternalConnection().getInternalStatement();
    try {
        final Query query = new Query(statement, this, new Formula[] { formula }, new QueryAxis[0], null, new QueryPart[0], new Parameter[0], false);
        query.createValidator().validate(formula);
        calculatedMemberList.add(formula);
        return (RolapMember) formula.getMdxMember();
    } finally {
        statement.close();
    }
}
Also used : Statement(mondrian.server.Statement) IdentifierSegment(org.olap4j.mdx.IdentifierSegment)

Example 2 with Statement

use of mondrian.server.Statement in project mondrian by pentaho.

the class CustomizedParserTest method getParsedQueryForExpr.

private Query getParsedQueryForExpr(CustomizedFunctionTable cftab, String expr, boolean strictValidation) {
    String mdx = wrapExpr(expr);
    final ConnectionBase connectionBase = (ConnectionBase) getConnection();
    final Statement statement = connectionBase.getInternalStatement();
    try {
        return (Query) connectionBase.parseStatement(statement, mdx, cftab, strictValidation);
    } finally {
        statement.close();
    }
}
Also used : Statement(mondrian.server.Statement)

Example 3 with Statement

use of mondrian.server.Statement in project mondrian by pentaho.

the class ParserTest method testMultiplication.

/**
 * Verifies that calculated measures made of several '*' operators
 * can resolve them correctly.
 */
public void testMultiplication() {
    Parser p = new Parser();
    final String mdx = wrapExpr("([Measures].[Unit Sales]" + " * [Measures].[Store Cost]" + " * [Measures].[Store Sales])");
    final Statement statement = ((ConnectionBase) getConnection()).getInternalStatement();
    try {
        final QueryPart query = p.parseInternal(new Parser.FactoryImpl(), statement, mdx, false, funTable, false);
        assertTrue(query instanceof Query);
        ((Query) query).resolve();
    } finally {
        statement.close();
    }
}
Also used : Statement(mondrian.server.Statement)

Example 4 with Statement

use of mondrian.server.Statement in project mondrian by pentaho.

the class QueryTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    TestContext testContext = getTestContext();
    ConnectionBase connection = (ConnectionBase) testContext.getConnection();
    final Statement statement = connection.getInternalStatement();
    try {
        queryWithCellProps = new Query(statement, formulas, axes, "Sales", null, cellProps, false);
        queryWithoutCellProps = new Query(statement, formulas, axes, "Sales", null, new QueryPart[0], false);
    } finally {
        statement.close();
    }
}
Also used : Statement(mondrian.server.Statement) TestContext(mondrian.test.TestContext)

Example 5 with Statement

use of mondrian.server.Statement in project mondrian by pentaho.

the class MemberCacheControlTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    propSaver.set(MondrianProperties.instance().EnableRolapCubeMemberCache, false);
    RolapSchemaPool.instance().clear();
    final RolapConnection conn = (RolapConnection) getConnection();
    final Statement statement = conn.getInternalStatement();
    final Execution execution = new Execution(statement, 0);
    locus = new Locus(execution, getName(), null);
    Locus.push(locus);
}
Also used : Execution(mondrian.server.Execution) Statement(mondrian.server.Statement) Locus(mondrian.server.Locus)

Aggregations

Statement (mondrian.server.Statement)5 Execution (mondrian.server.Execution)1 Locus (mondrian.server.Locus)1 TestContext (mondrian.test.TestContext)1 IdentifierSegment (org.olap4j.mdx.IdentifierSegment)1