コード例 #1
0
  public XMLADimensionInfo[] requestDimensions(XMLAClient xmlaClient) {
    dimensionInfos.clear();

    try {
      XMLARestrictions rest = setRestrictions();
      XMLAProperties prop = new XMLAProperties();

      String connectionName = xmlaClient.getConnections()[0].getName();
      prop.setDataSourceInfo(connectionName);
      prop.setCatalog(cube.getDatabase().getId());

      Document result = xmlaClient.getDimensionList(rest, prop);
      NodeList nl = result.getElementsByTagName("row");

      if (nl == null || nl.getLength() == 0) {
        return new XMLADimensionInfo[0];
      }
      parseXMLANodeList(nl, connectionName, xmlaClient);
    } catch (Exception e) {
      e.printStackTrace();
      return new XMLADimensionInfo[0];
    }

    return dimensionInfos.toArray(new XMLADimensionInfo[0]);
  }
コード例 #2
0
  protected void parseResult(
      HashMap<String, String> result, String connectionName, XMLAClient xmlaClient) {
    String name = result.get(ITEM_DIMENSION_CAPTION);
    String id = result.get(ITEM_DIMENSION_UNIQUE_NAME);
    XMLADimensionInfo dimInfo =
        new XMLADimensionInfo(
            xmlaClient, name, id, (XMLADatabaseInfo) cube.getDatabase(), cube.getId(), connection);
    dimInfo.setDimensionUniqueName(id);
    try {
      dimInfo.setElementCount(Integer.parseInt(result.get(ITEM_DIMENSION_CARDINALITY)));
    } catch (Exception e) {
    }
    try {
      int type = Integer.parseInt(result.get(ITEM_DIMENSION_TYPE));
      dimInfo.setXmlaType(
          type == 2 ? XMLADimensionInfo.XMLA_TYPE_MEASURES : XMLADimensionInfo.XMLA_TYPE_NORMAL);
    } catch (Exception e) {
    }

    String ourId = XMLADimensionInfo.getIDString(result.get(ITEM_DEFAULT_HIERARCHY), cube.getId());
    HierarchyInfo hierarchy = connection.getHierarchy(dimInfo, ourId);
    if (hierarchy == null) {
      HierarchyInfo[] allHierarchies = connection.getHierarchies(dimInfo);
      if (allHierarchies != null) {
        for (HierarchyInfo hier : allHierarchies) {
          if (hier != null) {
            hierarchy = hier;
            break;
          }
        }
      }
    }
    dimInfo.setDefaultHierarchy((XMLAHierarchyInfo) hierarchy);
    dimInfo.setHierarchyUniqueName(hierarchy.getId());
    dimensionInfos.add(dimInfo);
  }