Search in sources :

Example 6 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class RoleImpl method checkDimensionAccessByCubeInheritance.

/**
 * This method is used to check if the access rights over a dimension
 * that might be inherited from the parent cube.
 * <p>It only checks for inherited access, and it presumes that there
 * are no dimension grants currently given to the dimension passed as an
 * argument.
 */
private Access checkDimensionAccessByCubeInheritance(Dimension dimension) {
    assert dimensionGrants.containsKey(dimension) == false || dimension.isMeasures();
    for (Map.Entry<Cube, Access> cubeGrant : cubeGrants.entrySet()) {
        final Access access = toAccess(cubeGrant.getValue());
        // The 'none' and 'custom' access level are not good enough
        if (access == Access.NONE || access == Access.CUSTOM) {
            continue;
        }
        final Dimension[] dimensions = cubeGrant.getKey().getDimensions();
        for (Dimension dimension1 : dimensions) {
            // we found an access rule.
            if (dimension == dimension1) {
                return cubeGrant.getValue();
            }
            // If not, skip to the next grant.
            if (dimension instanceof RolapCubeDimension && dimension.equals(dimension1) && !((RolapCubeDimension) dimension1).getCube().equals(cubeGrant.getKey())) {
                continue;
            }
            // to work with virtual cubes.
            if (cubeGrant.getKey() instanceof RolapCube && ((RolapCube) cubeGrant.getKey()).isVirtual() && dimension.equals(dimension1)) {
                return cubeGrant.getValue();
            }
        }
    }
    return Access.NONE;
}
Also used : RolapCube(mondrian.rolap.RolapCube) RolapCubeDimension(mondrian.rolap.RolapCubeDimension) RolapCubeDimension(mondrian.rolap.RolapCubeDimension) RolapCube(mondrian.rolap.RolapCube)

Example 7 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class XmlaHandlerTypeTest method testDatatypeConsistency.

/**
 * Checks whether Cell.getValue() returns a consistent datatype whether
 * retrieved from Olap4jXmla, Olap4j, or native Mondrian.
 * @throws SQLException
 */
public void testDatatypeConsistency() throws SQLException {
    TestContext context = getTestContext();
    // MDX cast expressions
    String[] castedTypes = { "Cast(1 as String)", "Cast(1 as Numeric)", "Cast(1 as Boolean)", "Cast(1 as Integer)" };
    for (String castedType : castedTypes) {
        String mdx = "with member measures.type as '" + castedType + "' " + "select measures.type on 0 from sales";
        CellSet olap4jXmlaCellset = context.executeOlap4jXmlaQuery(mdx);
        CellSet olap4jCellset = context.executeOlap4jQuery(mdx);
        Result nativeMondrianResult = context.executeQuery(mdx);
        assertEquals("Checking olap4jXmla datatype against native Mondrian. \n" + "Unexpected datatype when running mdx " + mdx + "\n", nativeMondrianResult.getCell(new int[] { 0 }).getValue().getClass(), olap4jXmlaCellset.getCell(0).getValue().getClass());
        assertEquals("Checking olap4jXmla datatype against native Mondrian. \n" + "Unexpected datatype when running mdx " + mdx + "\n", olap4jXmlaCellset.getCell(0).getValue().getClass(), olap4jCellset.getCell(0).getValue().getClass());
    }
    RolapCube cube = (RolapCube) context.executeQuery("select from sales").getQuery().getCube();
    Dialect dialect = cube.getStar().getSqlQueryDialect();
    if (!dialect.getDatabaseProduct().equals(Dialect.DatabaseProduct.MYSQL) && !dialect.getDatabaseProduct().equals(Dialect.DatabaseProduct.ORACLE)) {
        return;
    }
    // map of sql expressions to the corresponding (optional) datatype
    // attribute (RolapBaseCubeMeasure.Datatype)
    Map<String, String> expressionTypeMap = new HashMap<String, String>();
    expressionTypeMap.put("'StringValue'", "String");
    expressionTypeMap.put("cast(1.0001 as decimal)", null);
    expressionTypeMap.put("cast(1.0001 as decimal)", "Numeric");
    expressionTypeMap.put("cast(10.101 as decimal(10,8))", null);
    expressionTypeMap.put("cast(10.101 as decimal(10,8))", "Numeric");
    for (String expression : expressionTypeMap.keySet()) {
        String query = "Select measures.typeMeasure on 0 from Sales";
        context = getContextWithMeasureExpression(expression, expressionTypeMap.get(expression));
        CellSet olap4jXmlaCellset = context.executeOlap4jXmlaQuery(query);
        CellSet olap4jCellset = context.executeOlap4jQuery(query);
        Result nativeMondrianResult = context.executeQuery(query);
        assertEquals("Checking olap4jXmla datatype against native Mondrian. \n" + "Unexpected datatype for measure expression " + expression + " with datatype attribute " + expressionTypeMap.get(expression) + "\n", nativeMondrianResult.getCell(new int[] { 0 }).getValue().getClass(), olap4jXmlaCellset.getCell(0).getValue().getClass());
        assertEquals("Checking olap4jXmla datatype against olap4j in process. \n" + "Unexpected datatype for expression " + expression + " with datatype attribute " + expressionTypeMap.get(expression) + "\n", olap4jXmlaCellset.getCell(0).getValue().getClass(), olap4jCellset.getCell(0).getValue().getClass());
    }
}
Also used : Dialect(mondrian.spi.Dialect) RolapCube(mondrian.rolap.RolapCube) CellSet(org.olap4j.CellSet) Result(mondrian.olap.Result)

Example 8 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class CmdRunner method setCubeAttribute.

public void setCubeAttribute(String cubename, String name, String value, StringBuilder buf) {
    Cube cube = getCube(cubename);
    if (cube == null) {
        buf.append("No cube found with name \"");
        buf.append(cubename);
        buf.append("\"");
    } else {
        if (name.equals("caching")) {
            RolapCube rcube = (RolapCube) cube;
            boolean isCache = Boolean.valueOf(value);
            rcube.setCacheAggregations(isCache);
        } else {
            buf.append("For cube \"");
            buf.append(cubename);
            buf.append("\" there is no attribute \"");
            buf.append(name);
            buf.append("\"");
        }
    }
}
Also used : RolapCube(mondrian.rolap.RolapCube) RolapCube(mondrian.rolap.RolapCube)

Example 9 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class CmdRunner method listCubeAttribues.

public void listCubeAttribues(String name, StringBuilder buf) {
    Cube cube = getCube(name);
    if (cube == null) {
        buf.append("No cube found with name \"");
        buf.append(name);
        buf.append("\"");
    } else {
        RolapCube rcube = (RolapCube) cube;
        buf.append("facttable=");
        buf.append(rcube.getStar().getFactTable().getAlias());
        buf.append(nl);
        buf.append("caching=");
        buf.append(rcube.isCacheAggregations());
        buf.append(nl);
    }
}
Also used : RolapCube(mondrian.rolap.RolapCube) RolapCube(mondrian.rolap.RolapCube)

Example 10 with RolapCube

use of mondrian.rolap.RolapCube in project mondrian by pentaho.

the class CmdRunner method noCubeCaching.

public void noCubeCaching() {
    Cube[] cubes = getCubes();
    for (Cube cube : cubes) {
        RolapCube rcube = (RolapCube) cube;
        rcube.setCacheAggregations(false);
    }
}
Also used : RolapCube(mondrian.rolap.RolapCube) RolapCube(mondrian.rolap.RolapCube)

Aggregations

RolapCube (mondrian.rolap.RolapCube)13 RolapHierarchy (mondrian.rolap.RolapHierarchy)5 UnaryTupleList (mondrian.calc.impl.UnaryTupleList)2 AbstractListCalc (mondrian.calc.impl.AbstractListCalc)1 AbstractMemberCalc (mondrian.calc.impl.AbstractMemberCalc)1 ArrayTupleList (mondrian.calc.impl.ArrayTupleList)1 Result (mondrian.olap.Result)1 RolapConnection (mondrian.rolap.RolapConnection)1 RolapCubeDimension (mondrian.rolap.RolapCubeDimension)1 RolapSchema (mondrian.rolap.RolapSchema)1 Execution (mondrian.server.Execution)1 Dialect (mondrian.spi.Dialect)1 CellSet (org.olap4j.CellSet)1