Package mondrian.olap

Examples of mondrian.olap.Connection


     * Executes a query.
     *
     * @param queryString Query string
     */
    public Result executeQuery(String queryString) {
        Connection connection = getConnection();
        queryString = upgradeQuery(queryString);
        Query query = connection.parseQuery(queryString);
        final Result result = connection.execute(query);

        // If we're deep testing, check that we never return the dummy null
        // value when cells are null. TestExpDependencies isn't the perfect
        // switch to enable this, but it will do for now.
        if (MondrianProperties.instance().TestExpDependencies.booleanValue()) {
View Full Code Here


    public void assertParameterizedExprReturns(
        String expr,
        String expected,
        Object... paramValues)
    {
        Connection connection = getConnection();
        String queryString = generateExpression(expr);
        Query query = connection.parseQuery(queryString);
        assert paramValues.length % 2 == 0;
        for (int i = 0; i < paramValues.length;) {
            final String paramName = (String) paramValues[i++];
            final Object value = paramValues[i++];
            query.setParameter(paramName, value);
        }
        final Result result = connection.execute(query);
        final Cell cell = result.getCell(new int[]{0});

        if (expected == null) {
            expected = ""; // null values are formatted as empty string
        }
View Full Code Here

                + " select {[Measures].[Foo]} on columns from " + cubeName;
        } else {
            queryString =
                "SELECT {" + expression + "} ON COLUMNS FROM " + cubeName;
        }
        Connection connection = getConnection();
        Query query = connection.parseQuery(queryString);
        final Exp exp;
        if (scalar) {
            exp = query.getFormulas()[0].getExpression();
        } else {
            exp = query.getAxes()[0].getSet();
View Full Code Here

    public void assertAxisThrows(
        String expression,
        String pattern)
    {
        Throwable throwable = null;
        Connection connection = getConnection();
        try {
            final String cubeName = getDefaultCubeName();
            final String queryString =
                    "select {" + expression + "} on columns from " + cubeName;
            Query query = connection.parseQuery(queryString);
            connection.execute(query);
        } catch (Throwable e) {
            throwable = e;
        }
        checkThrowable(throwable, pattern);
    }
View Full Code Here

     * dimensions.
     */
    public void assertSetExprDependsOn(String expr, String dimList) {
        // Construct a query, and mine it for a parsed expression.
        // Use a fresh connection, because some tests define their own dims.
        final Connection connection = getConnection();
        final String queryString =
                "SELECT {" + expr + "} ON COLUMNS FROM [Sales]";
        final Query query = connection.parseQuery(queryString);
        query.resolve();
        final Exp expression = query.getAxes()[0].getSet();

        // Build a list of the dimensions which the expression depends upon,
        // and check that it is as expected.
View Full Code Here

     * Asserts that an MDX expression depends upon a given list of dimensions.
     */
    public void assertExprDependsOn(String expr, String hierList) {
        // Construct a query, and mine it for a parsed expression.
        // Use a fresh connection, because some tests define their own dims.
        final Connection connection = getConnection();
        final String queryString =
            "WITH MEMBER [Measures].[Foo] AS "
            + Util.singleQuoteString(expr)
            + " SELECT FROM [Sales]";
        final Query query = connection.parseQuery(queryString);
        query.resolve();
        final Formula formula = query.getFormulas()[0];
        final Exp expression = formula.getExpression();

        // Build a list of the dimensions which the expression depends upon,
View Full Code Here

        final Util.PropertyList propertyList =
            getConnectionProperties().clone();
        propertyList.put(
            RolapConnectionProperties.Ignore.name(),
            "true");
        final Connection connection =
            withProperties(propertyList).getConnection();
        return connection.getSchema().getWarnings();
    }
View Full Code Here

     *
     * @return whether a database is present and correct
     */
    public boolean databaseIsValid() {
        try {
            Connection connection = getConnection();
            String cubeName = getDefaultCubeName();
            if (cubeName.indexOf(' ') >= 0) {
                cubeName = Util.quoteMdxIdentifier(cubeName);
            }
            Query query = connection.parseQuery("select from " + cubeName);
            Result result = connection.execute(query);
            Util.discard(result);
            connection.close();
            return true;
        } catch (RuntimeException e) {
            Util.discard(e);
            return false;
        }
View Full Code Here

    public void testSchema3withVersion() {
        TestContext testContext =
            TestContext.instance().withSchema(SCHEMA_3_VHEADER + SCHEMA_3_BODY);
        Util.PropertyList connectInfo =
            testContext.getConnectionProperties();
        Connection conn = DriverManager.getConnection(connectInfo, null);
        assertNotNull(conn);
        conn.close();
    }
View Full Code Here

    public void testSchema3noVersion() {
        TestContext testContext =
            TestContext.instance().withSchema(SCHEMA_3_HEADER + SCHEMA_3_BODY);
        Util.PropertyList connectInfo =
            testContext.getConnectionProperties();
        Connection conn = DriverManager.getConnection(connectInfo, null);
        assertNotNull(conn);
        conn.close();
    }
View Full Code Here

TOP

Related Classes of mondrian.olap.Connection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.