Package org.olap4j.metadata

Examples of org.olap4j.metadata.Cube


    public void testHashCompatibility() throws Exception {
        connection = tester.createConnection();
        OlapConnection olapConnection =
            tester.getWrapper().unwrap(connection, OlapConnection.class);
        Schema schema = olapConnection.getOlapSchema();
        Cube cube = schema.getCubes().get("Sales");

        Map<Dimension, String> dimensionMap =
            new HashMap<Dimension, String>();
        Dimension dim1 = cube.getDimensions().get("Promotion Media");
        dimensionMap.put(dim1, "Test1");
        assertTrue(dimensionMap.containsKey(dim1));
        assertEquals("Test1", dimensionMap.get(dim1));

        Map<Hierarchy, String> hierarchyMap =
View Full Code Here


        {
          if (parameterValue instanceof String)
          {
            final MemberType type = (MemberType) parameterType;
            final Hierarchy hierarchy = type.getHierarchy();
            final Cube cube = statement.getCube();
            parameterValue = findMember(hierarchy, cube, String.valueOf(parameterValue));
          }
          else if (!(parameterValue instanceof Member))
          {
            throw new ReportDataFactoryException(parameterValue + " is incorrect for type " + parameterType);
          }
        }
        if (parameterType instanceof SetType)
        {
          if (parameterValue instanceof String)
          {
            final SetType type = (SetType) parameterType;
            final Hierarchy hierarchy = type.getHierarchy();
            final Cube cube = statement.getCube();

            final String rawString = (String) parameterValue;
            final String[] memberStr = rawString.replaceFirst("^ *\\{", "").replaceFirst("} *$", "").split(",");
            final List<Member> list = new ArrayList<Member>(memberStr.length);

View Full Code Here

    {
      if (parameterValue instanceof String)
      {
        final MemberType type = (MemberType) parameterType;
        final Hierarchy hierarchy = type.getHierarchy();
        final Cube cube = statement.getCube();
        parameterValue = findMember(hierarchy, cube, String.valueOf(parameterValue));
      }
      else if (!(parameterValue instanceof Member))
      {
        throw new ReportDataFactoryException(parameterValue + " is incorrect for type " + parameterType);
      }
    }
    if (parameterType instanceof SetType)
    {
      if (parameterValue instanceof String)
      {
        final SetType type = (SetType) parameterType;
        final Hierarchy hierarchy = type.getHierarchy();
        final Cube cube = statement.getCube();

        final String rawString = (String) parameterValue;
        final String[] memberStr = rawString.replaceFirst("^ *\\{", "").replaceFirst("} *$", "").split(",");
        final List<Member> list = new ArrayList<Member>(memberStr.length);

View Full Code Here

  @NotNull
  public Map<String, Object> getProperties(@NotNull SaikuCube cube) {
    Map<String, Object> properties = new HashMap<String, Object>();
    try {
      Cube c = getNativeCube(cube);
      OlapConnection con = c.getSchema().getCatalog().getDatabase().getOlapConnection();
      properties.put("saiku.olap.query.drillthrough", c.isDrillThroughEnabled());
      properties.put("org.saiku.query.explain", con.isWrapperFor(RolapConnection.class));

      try {
        Boolean isScenario = c.getDimensions().get("Scenario") != null;
        properties.put("org.saiku.connection.scenario", isScenario);
      } catch (Exception e) {
        properties.put("org.saiku.connection.scenario", false);
      }
    } catch (Exception e) {
View Full Code Here

    return name;
  }

  public SaikuCube getSaikuCube() {
    try {
      Cube c = getCube();
      cube = new SaikuCube(
          cube.getConnection(),
          c.getUniqueName(),
          c.getName(),
          c.getCaption(),
          cube.getCatalog(),
          c.getSchema().getName());
    } catch (Exception e) {
      // we tried, but it just doesn't work, so let's return the last working cube
    }
    return cube;
  }
View Full Code Here

  }

  @NotNull
  public Boolean isDrillThroughEnabled() {
    try {
      Cube cube = getCube();
      return cube != null && cube.isDrillThroughEnabled();
    } catch (Exception e) {
      if (cube == null) {
        LOG.error("Cube is null");
      } else {
        LOG.error("Could not detect drillthrough", e.getCause());
View Full Code Here

  private final Format[] valueFormats;


  public TotalsListsBuilder(@NotNull Measure[] selectedMeasures, TotalAggregator[] aggrTempl, @NotNull CellSet cellSet,
                            @NotNull AxisInfo totalsAxisInfo, @NotNull AxisInfo dataAxisInfo) throws Exception {
    Cube cube;
    try {
      cube = cellSet.getMetaData().getCube();
    } catch (OlapException e) {
      throw new RuntimeException(e);
    }
    uniqueToSelected = new HashMap<String, Integer>();
    if (selectedMeasures.length > 0) {
      valueFormats = new Format[selectedMeasures.length];
      measures = selectedMeasures;
      for (int i = 0; i < valueFormats.length; i++) {
        valueFormats[i] = getMeasureFormat(selectedMeasures[i]);
        uniqueToSelected.put(selectedMeasures[i].getUniqueName(), i);
      }
    } else {
      Measure defaultMeasure = cube.getMeasures().get(0);
      if (cube.getDimensions().get("Measures") != null) {
        Member ms = cube.getDimensions().get("Measures").getDefaultHierarchy().getDefaultMember();
        if (ms instanceof Measure) {
          defaultMeasure = (Measure) ms;
        }
      }
      measures = new Measure[] { defaultMeasure };
View Full Code Here

    }

    private Member foo(int i) throws SQLException {
        final OlapConnection connection =
            getTestContext().getOlap4jConnection();
        final Cube cube;
        final Hierarchy measuresHierarchy;
        final CellSet cellSet;
        switch (i) {
        case 0:
            cellSet = connection.createStatement().executeOlapQuery(
                "select [Measures].[Unit Sales] on 0\n"
                + "from [Sales]");
            return cellSet.getAxes().get(0).getPositions().get(0)
                .getMembers().get(0);

        case 1:
            cellSet =
                connection.createStatement().executeOlapQuery(
                    "select [Measures].Members on 0\n"
                    + "from [Sales]");
            return cellSet.getAxes().get(0).getPositions().get(0)
                .getMembers().get(0);

        case 2:
            cellSet =
                connection.createStatement().executeOlapQuery(
                    "select [Measures].[Measures].Members on 0\n"
                    + "from [Sales]");
            return cellSet.getAxes().get(0).getPositions().get(0)
                .getMembers().get(0);

        case 3:
            cube = connection.getOlapSchema().getCubes().get("Sales");
            measuresHierarchy = cube.getHierarchies().get("Measures");
            final NamedList<Member> rootMembers =
                measuresHierarchy.getRootMembers();
            return rootMembers.get(0);

        case 4:
            cube = connection.getOlapSchema().getCubes().get("Sales");
            measuresHierarchy = cube.getHierarchies().get("Measures");
            final Level measuresLevel = measuresHierarchy.getLevels().get(0);
            final List<Member> levelMembers = measuresLevel.getMembers();
            return levelMembers.get(0);

        case 5:
            cube = connection.getOlapSchema().getCubes().get("Sales");
            measuresHierarchy = cube.getHierarchies().get("Measures");
            return measuresHierarchy.getDefaultMember();

        case 6:
            cube = connection.getOlapSchema().getCubes().get("Sales");
            return
                cube.lookupMember(
                    IdentifierNode.parseIdentifier("[Measures].[Unit Sales]")
                        .getSegmentList());
        default:
            throw new IllegalArgumentException("bad index " + i);
        }
View Full Code Here

            getTestContext().getOlap4jConnection();
        final CellSet cellSet =
            connection.createStatement().executeOlapQuery(
                "select from [Sales]");
        final CellSetMetaData metaData = cellSet.getMetaData();
        final Cube salesCube = metaData.getCube();
        Annotated annotated = ((OlapWrapper) salesCube).unwrap(Annotated.class);
        final Annotation annotation =
            annotated.getAnnotationMap().get("caption.fr_FR");
        assertEquals("Ventes", annotation.getValue());
View Full Code Here

                    }
                });
            thread.start();

            CacheControl cacheControl = testContext.getCacheControl();
            Cube cube0 =
                connection.getOlapSchema().getCubes().get("Sales");
            mondrian.olap.Cube cube =
                ((OlapWrapper) cube0).unwrap(mondrian.olap.Cube.class);
            CacheControl.CellRegion cellRegion =
                cacheControl.createMeasuresRegion(cube);
View Full Code Here

TOP

Related Classes of org.olap4j.metadata.Cube

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.