Example #1
0
  public static void main1(String[] args) throws ClassNotFoundException, SQLException {
    OlapConnection conn = getConnection(url);
    CellSet cs = getResultSet(mdx, conn);
    // CellSetAxis c;

    int count = 0;
    if (cs.getAxes().size() > 1) {
      for (Position row : cs.getAxes().get(1)) {
        for (Position column : cs.getAxes().get(0)) {
          for (Member member : row.getMembers()) {
            System.out.println("rows:" + member.getUniqueName());
          }
          for (Member member : column.getMembers()) {
            System.out.println("columns:" + member.getUniqueName());
          }
          final Cell cell = cs.getCell(column, row);

          System.out.println("values:" + cell.getValue());

          Position[] positions = new Position[2];
          positions[0] = column;
          positions[1] = row;

          OlapCell oalpCell = new OlapCell(positions, cell.getValue());

          System.out.println("****" + oalpCell.toString());
          System.out.println(count++);
        }
      }
    }
  }
 private static String getParameterValue(
     TargetParameter parameter, WhatIfEngineInstance ei, SpagoBICellWrapper cell) {
   if (parameter.isAbsolute()) {
     return parameter.getValue();
   }
   String value = null;
   String dimensionName = parameter.getDimension();
   String hierarchyName = parameter.getHierarchy();
   String levelName = parameter.getLevel();
   String propertyName = parameter.getProperty();
   logger.debug(
       "Looking for dimension "
           + dimensionName
           + ", hierarchy "
           + hierarchyName
           + ", level "
           + levelName
           + ", property "
           + propertyName
           + " ...");
   Hierarchy hierarchy =
       getHierarchy(ei.getSpagoBIPivotModel().getCube(), ei.getModelConfig(), dimensionName);
   Member member = cell.getContextMember(hierarchy);
   logger.debug("Considering context member " + member.getUniqueName());
   logger.debug("Member hierarchy is " + hierarchy.getUniqueName());
   if (hierarchy.getUniqueName().equals(hierarchyName)) {
     if (propertyName == null || propertyName.trim().equals("")) {
       value = getLevelValue(member, levelName);
     } else {
       value = getMemberPropertyValue(member, propertyName);
     }
   }
   return value;
 }
Example #3
0
  public SaikuFilter getFilter(
      String queryName,
      String filtername,
      String dimensionName,
      String hierarchyName,
      String levelName) {
    IQuery query = getIQuery(queryName);
    CellSet cs = query.getCellset();
    List<SimpleCubeElement> members = new ArrayList<SimpleCubeElement>();
    SimpleCubeElement dimension = null;
    SimpleCubeElement hierarchy = null;
    Set<MetadataElement> mset = new HashSet<MetadataElement>();

    if (cs != null) {
      List<CellSetAxis> axes = new ArrayList<CellSetAxis>();
      axes.addAll(cs.getAxes());
      axes.add(cs.getFilterAxis());
      for (CellSetAxis axis : axes) {
        int posIndex = 0;
        for (Hierarchy h : axis.getAxisMetaData().getHierarchies()) {
          if (h.getName().equals(hierarchyName)) {
            if (hierarchy == null) {
              hierarchy = new SimpleCubeElement(h.getName(), h.getUniqueName(), h.getCaption());
              Dimension d = h.getDimension();
              dimension = new SimpleCubeElement(d.getName(), d.getUniqueName(), d.getCaption());
            }
            if (h.getLevels().size() == 1) {
              break;
            }

            for (Position pos : axis.getPositions()) {
              Member m = pos.getMembers().get(posIndex);
              if (m.getLevel().getName().equals(levelName)) {
                mset.add(m);
              }
            }
            break;
          }
          posIndex++;
        }
      }
      if (mset.size() == 0) {
        QueryDimension qd = query.getDimension(dimensionName);
        if (qd != null && qd.getAxis().getLocation() != null) {
          for (Selection sel : qd.getInclusions()) {
            if ((sel.getRootElement() instanceof Member)) {
              Member m = ((Member) sel.getRootElement());
              if (m.getLevel().getName().equals(levelName)) {
                mset.add(m);
              }
            }
          }
        }
      }
      members = ObjectUtil.convert2Simple(mset);
      Collections.sort(members, new SaikuUniqueNameComparator());
      log.debug("Create Filters: Found members in the result or query: " + members.size());
    }
    return new SaikuFilter(filtername, null, dimension, hierarchy, members);
  }
Example #4
0
  private void traverse(List<Integer>[] levels, List<TotalNode>[] totalLists) {
    int fullPosition = 0;
    final Member[] prevMemberBranch = new Member[memberBranch.length];

    nextpos:
    for (final Position p : dataAxisInfo.axis.getPositions()) {
      int depth = 1;
      int mI = 0;
      for (final Member m : p.getMembers()) {
        final int maxDepth = levels[mI].get(levels[mI].size() - 1);
        if (m.getDepth() < maxDepth) {
          continue nextpos;
        }
        positionMember(depth, m, levels[mI], memberBranch);
        depth += levels[mI].size();
        mI++;
      }

      int changedFrom = 1;
      while (changedFrom < memberBranch.length - 1
          && memberBranch[changedFrom].equals(prevMemberBranch[changedFrom])) {
        changedFrom++;
      }

      for (int i = totalBranch.length - 1; i >= changedFrom; i--) {
        if (totalBranch[i] != null) {
          totalBranch[i - 1].appendChild(totalBranch[i]);
        }
      }

      for (int i = changedFrom; i < totalBranch.length; i++) {
        String[] captions = measuresAt > i - 1 ? measuresCaptions : null;
        totalBranch[i] =
            new TotalNode(
                captions, measures, aggrTempl[i], this, totalsAxisInfo.fullPositions.size());
        totalLists[i].add(totalBranch[i]);
      }
      System.arraycopy(memberBranch, 0, prevMemberBranch, 0, prevMemberBranch.length);

      totalBranch[totalBranch.length - 1].setSpan(1);
      totalBranch[totalBranch.length - 1].setWidth(1);

      for (int t = 0; t < totalsAxisInfo.fullPositions.size(); t++) {
        Cell cell = getCellAt(fullPosition, t);
        for (int branchNode = 0; branchNode < totalBranch.length; branchNode++) {
          if (aggrTempl[branchNode] != null) {
            totalBranch[branchNode].addData(getMemberIndex(branchNode, fullPosition), t, cell);
          }
        }
      }
      fullPosition++;
    }
    for (int i = totalBranch.length - 1; i > 0; i--) {
      totalBranch[i - 1].appendChild(totalBranch[i]);
    }

    for (TotalNode n : totalLists[totalLists.length - 1]) {
      n.setWidth(0);
    }
  }
Example #5
0
  /** @return the filterNode */
  public TreeNode getFilterNode() {
    if (model != null && model.isInitialized()) {
      Hierarchy hierarchy = getHierarchy();

      if (filterNode == null && hierarchy != null) {
        this.filterNode = new DefaultTreeNode();

        filterNode.setExpanded(true);

        List<Member> members;
        boolean isMeasure;

        try {
          members = hierarchy.getRootMembers();
          isMeasure = hierarchy.getDimension().getDimensionType() == Type.MEASURE;
        } catch (OlapException e) {
          throw new FacesException(e);
        }

        for (Member member : members) {
          if (isMeasure && !member.isVisible()) {
            continue;
          }

          MemberNode node = new MemberNode(member);

          node.setNodeFilter(this);
          node.setExpanded(true);
          node.setSelectable(true);
          node.setSelected(isSelected(member));

          filterNode.getChildren().add(node);
        }

        List<TreeNode> initialSelection =
            ((DefaultTreeNode) filterNode)
                .collectNodes(
                    new NodeCollector() {

                      @Override
                      public boolean collectNode(TreeNode node) {
                        return node.isSelected();
                      }

                      @Override
                      public boolean searchNode(TreeNode node) {
                        return node.isExpanded();
                      }
                    });

        this.selection = initialSelection.toArray(new TreeNode[initialSelection.size()]);
      }
    } else {
      this.filterNode = null;
    }

    return filterNode;
  }
Example #6
0
 private int getMemberIndex(int depth, int index) {
   if (depth - 1 < measuresAt) {
     Member m =
         dataAxisInfo.fullPositions.get(index).getMembers().get(dataAxisInfo.measuresMember);
     if (uniqueToSelected.containsKey(m.getUniqueName())) {
       return uniqueToSelected.get(m.getUniqueName());
     }
   }
   return 0;
 }
Example #7
0
 private final void positionMember(
     final int depth, Member m, final List<Integer> levels, final Member[] branch) {
   for (int i = levels.size() - 1; i >= 0; ) {
     branch[depth + i] = m;
     i--;
     do {
       m = m.getParentMember();
     } while (i >= 0 && m != null && m.getDepth() != levels.get(i));
   }
 }
Example #8
0
  public ResultSet drillthrough(
      String queryName, List<Integer> cellPosition, Integer maxrows, String returns) {
    OlapStatement stmt = null;
    try {
      IQuery query = getIQuery(queryName);
      CellSet cs = query.getCellset();
      SaikuCube cube = getQuery(queryName).getCube();
      final OlapConnection con = olapDiscoverService.getNativeConnection(cube.getConnectionName());
      stmt = con.createStatement();

      String select = null;
      StringBuffer buf = new StringBuffer();
      buf.append("SELECT (");
      for (int i = 0; i < cellPosition.size(); i++) {
        List<Member> members =
            cs.getAxes().get(i).getPositions().get(cellPosition.get(i)).getMembers();
        for (int k = 0; k < members.size(); k++) {
          Member m = members.get(k);
          if (k > 0 || i > 0) {
            buf.append(", ");
          }
          buf.append(m.getUniqueName());
        }
      }
      buf.append(") ON COLUMNS \r\n");
      buf.append("FROM " + cube.getCubeName() + "\r\n");

      SelectNode sn = (new DefaultMdxParserImpl().parseSelect(getMDXQuery(queryName)));
      final Writer writer = new StringWriter();
      sn.getFilterAxis().unparse(new ParseTreeWriter(new PrintWriter(writer)));
      if (StringUtils.isNotBlank(writer.toString())) {
        buf.append("WHERE " + writer.toString());
      }
      select = buf.toString();
      if (maxrows > 0) {
        select = "DRILLTHROUGH MAXROWS " + maxrows + " " + select + "\r\n";
      } else {
        select = "DRILLTHROUGH " + select + "\r\n";
      }
      if (StringUtils.isNotBlank(returns)) {
        select += "\r\n RETURN " + returns;
      }

      log.debug("Drill Through for query (" + queryName + ") : \r\n" + select);
      ResultSet rs = stmt.executeQuery(select);
      return rs;
    } catch (Exception e) {
      throw new SaikuServiceException("Error DRILLTHROUGH: " + queryName, e);
    } finally {
      try {
        if (stmt != null) stmt.close();
      } catch (Exception e) {
      }
    }
  }
Example #9
0
  public OlapCell(Position[] positions, Object value) {
    v = value;
    for (int i = 0; i < positions.length; i++) {
      Set<String> set = new HashSet<String>();

      for (Member member : positions[i].getMembers()) {
        set.add(member.getUniqueName());
      }

      coordinate.put(String.valueOf(i), set);
    }
  }
Example #10
0
  public List<SaikuMember> getResultMetadataMembers(
      String queryName,
      boolean preferResult,
      String dimensionName,
      String hierarchyName,
      String levelName) {
    IQuery query = getIQuery(queryName);
    CellSet cs = query.getCellset();
    List<SaikuMember> members = new ArrayList<SaikuMember>();
    Set<Level> levels = new HashSet<Level>();

    if (cs != null && preferResult) {
      for (CellSetAxis axis : cs.getAxes()) {
        int posIndex = 0;
        for (Hierarchy h : axis.getAxisMetaData().getHierarchies()) {
          if (h.getUniqueName().equals(hierarchyName)) {
            log.debug("Found hierarchy in the result: " + hierarchyName);
            if (h.getLevels().size() == 1) {
              break;
            }
            Set<Member> mset = new HashSet<Member>();
            for (Position pos : axis.getPositions()) {
              Member m = pos.getMembers().get(posIndex);
              if (!m.getLevel().getLevelType().equals(Type.ALL)) {
                levels.add(m.getLevel());
              }
              if (m.getLevel().getUniqueName().equals(levelName)) {
                mset.add(m);
              }
            }

            members = ObjectUtil.convertMembers(mset);
            Collections.sort(members, new SaikuUniqueNameComparator());

            break;
          }
          posIndex++;
        }
      }
      log.debug("Found members in the result: " + members.size());
    }
    if (cs == null || !preferResult || members.size() == 0 || levels.size() == 1) {
      members =
          olapDiscoverService.getLevelMembers(
              query.getSaikuCube(), dimensionName, hierarchyName, levelName);
    }

    return members;
  }
 /**
  * Prints an axis and its members.
  *
  * @param pw Print writer
  * @param axis Axis
  */
 private static void printAxis(PrintWriter pw, CellSetAxis axis) {
   List<Position> positions = axis.getPositions();
   for (Position position : positions) {
     boolean firstTime = true;
     pw.print("{");
     for (Member member : position.getMembers()) {
       if (!firstTime) {
         pw.print(", ");
       }
       pw.print(member.getUniqueName());
       firstTime = false;
     }
     pw.println("}");
   }
 }
 private static String getMemberPropertyValue(Member member, String propertyName) {
   logger.debug("IN: Member is " + member.getUniqueName() + ", propertyName is " + propertyName);
   String toReturn = null;
   Property property = member.getProperties().get(propertyName);
   if (property != null) {
     try {
       toReturn = member.getPropertyValue(property).toString();
     } catch (OlapException e) {
       logger.error("Error getting the property " + propertyName + " from the cube ", e);
       throw new SpagoBIEngineRuntimeException(
           "Error getting the property " + propertyName + " ", e);
     }
   }
   logger.debug("OUT: returning " + toReturn);
   return toReturn;
 }
Example #13
0
 public Format getValueFormat(int position, int member) {
   int formatIndex = 0;
   if (dataAxisInfo.measuresMember >= 0) {
     formatIndex = member;
   } else if (totalsAxisInfo.measuresMember >= 0) {
     Member m =
         totalsAxisInfo
             .fullPositions
             .get(position)
             .getMembers()
             .get(totalsAxisInfo.measuresMember);
     if (uniqueToSelected.containsKey(m.getUniqueName())) {
       formatIndex = uniqueToSelected.get(m.getUniqueName());
     }
   }
   return valueFormats[formatIndex];
 }
 public String toString() {
   final StringBuilder sb = new StringBuilder();
   sb.append("LocalizedString");
   sb.append("{description=").append(description);
   sb.append(", member=").append(member.getUniqueName());
   sb.append('}');
   return sb.toString();
 }
Example #15
0
  public List<SaikuMember> getMemberChildren(SaikuCube cube, String uniqueMemberName)
      throws SaikuOlapException {
    List<SaikuMember> members = new ArrayList<SaikuMember>();
    try {
      Cube nativeCube = getNativeCube(cube);
      List<IdentifierSegment> memberList =
          IdentifierNode.parseIdentifier(uniqueMemberName).getSegmentList();
      Member m = nativeCube.lookupMember(memberList);
      if (m != null) {
        for (Member c : m.getChildMembers()) {
          SaikuMember sm = ObjectUtil.convert(c);
          members.add(sm);
        }
      }
    } catch (OlapException e) {
      throw new SaikuOlapException("Cannot get child members of member:" + uniqueMemberName, e);
    }

    return members;
  }
 /**
  * Computes a description of an axis.
  *
  * @param axis Axis
  * @return Description of axis
  */
 private AxisInfo computeAxisInfo(final CellSetAxis axis) {
   if (axis == null) {
     return new AxisInfo(0);
   }
   final AxisInfo axisInfo = new AxisInfo(axis.getAxisMetaData().getHierarchies().size());
   int p = -1;
   for (final Position position : axis.getPositions()) {
     ++p;
     int k = -1;
     for (final Member member : position.getMembers()) {
       ++k;
       final AxisOrdinalInfo axisOrdinalInfo = axisInfo.ordinalInfos.get(k);
       if (!axisOrdinalInfo.getDepths().contains(member.getDepth())) {
         axisOrdinalInfo.getDepths().add(member.getDepth());
         axisOrdinalInfo.addLevel(member.getDepth(), member.getLevel());
         Collections.sort(axisOrdinalInfo.depths);
       }
     }
   }
   return axisInfo;
 }
 private static String getLevelValue(Member member, String levelName) {
   logger.debug("IN: Member is " + member.getUniqueName() + ", levelName is " + levelName);
   String toReturn = null;
   Level level = member.getLevel();
   logger.debug("Member level is " + level.getUniqueName());
   if (level.getUniqueName().equals(levelName)) {
     logger.debug("Member level matches input level name " + levelName + "!!");
     String uniqueName = member.getUniqueName();
     toReturn =
         uniqueName.substring(uniqueName.lastIndexOf("].[") + 3, uniqueName.lastIndexOf("]"));
   } else {
     logger.debug("Member level does NOT match input level name " + levelName + "!!");
     // look for parent member at parent level
     Member parent = member.getParentMember();
     if (parent == null) {
       return null;
     } else {
       return getLevelValue(parent, levelName);
     }
   }
   logger.debug("OUT: returning " + toReturn);
   return toReturn;
 }
Example #18
0
  public SaikuTag createTag(String queryName, String tagName, List<List<Integer>> cellPositions) {
    try {
      IQuery query = getIQuery(queryName);
      CellSet cs = query.getCellset();
      List<SaikuTuple> tuples = new ArrayList<SaikuTuple>();
      List<SimpleCubeElement> dimensions = new ArrayList<SimpleCubeElement>();
      for (List<Integer> cellPosition : cellPositions) {
        List<Member> members = new ArrayList<Member>();
        for (int i = 0; i < cellPosition.size(); i++) {
          members.addAll(cs.getAxes().get(i).getPositions().get(cellPosition.get(i)).getMembers());
        }
        List<SaikuMember> sm = ObjectUtil.convertMembers(members);
        SaikuTuple tuple = new SaikuTuple(sm);
        tuples.add(tuple);

        if (dimensions.size() == 0) {
          for (Member m : members) {
            SimpleCubeElement sd =
                new SimpleCubeElement(
                    m.getDimension().getName(),
                    m.getDimension().getUniqueName(),
                    m.getDimension().getCaption());
            if (!dimensions.contains(sd)) {
              dimensions.add(sd);
            }
          }
        }
      }
      List<SaikuDimensionSelection> filterSelections = getAxisSelection(queryName, "FILTER");
      SaikuTag t = new SaikuTag(tagName, dimensions, tuples, filterSelections);
      return t;

    } catch (Exception e) {
      throw new SaikuServiceException("Error addTag:" + tagName + " for query: " + queryName, e);
    }
  }
 public static String buildClickableUrl(Member member, List<TargetClickable> targetsClickable) {
   logger.debug("IN");
   Level level = member.getLevel();
   String url = new String();
   for (TargetClickable tc : targetsClickable) {
     if (tc.getUniqueName().equalsIgnoreCase(level.getUniqueName())) {
       String targetDocumentParameters = "";
       for (Map.Entry<String, String> entry : tc.getParametersList().entrySet()) {
         String key = entry.getKey();
         String value = entry.getValue();
         targetDocumentParameters += key + "=" + value + "&";
       }
       url =
           "javascript:parent.execCrossNavigation(window.name, ''"
               + tc.getTargetDocument()
               + "'', ''"
               + targetDocumentParameters
               + "''";
       if (tc.getTitle() != null
           && tc.getTarget() != null
           && tc.getTarget().equalsIgnoreCase("tab")) {
         url += ",null,''" + tc.getTitle() + "'',''tab''";
       } else if (tc.getTitle() != null) {
         url += ",null,''" + tc.getTitle() + "''";
       }
       url += ");";
       // int lastIndex=member.getUniqueName().lastIndexOf("].[");
       // String newName=member.getUniqueName().substring(lastIndex+3,
       // member.getUniqueName().length()-1);
       String newName = getLevelValue(member, tc.getUniqueName());
       Object[] args = new Object[] {newName};
       url = MessageFormat.format(url, args);
       return url;
     } else {
       url = null;
     }
   }
   return url;
 }
Example #20
0
  public TotalsListsBuilder(
      Measure[] selectedMeasures,
      TotalAggregator[] aggrTempl,
      CellSet cellSet,
      AxisInfo totalsAxisInfo,
      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};
      valueFormats = new Format[] {getMeasureFormat(defaultMeasure)};
    }
    this.cellSet = cellSet;
    this.dataAxisInfo = dataAxisInfo;
    this.totalsAxisInfo = totalsAxisInfo;
    final int maxDepth = dataAxisInfo.maxDepth + 1;
    boolean hasMeasuresOnDataAxis = false;
    int measuresAt = 0;
    int measuresMember = 0;
    final List<Member> members =
        dataAxisInfo.axis.getPositionCount() > 0
            ? dataAxisInfo.axis.getPositions().get(0).getMembers()
            : Collections.<Member>emptyList();
    for (; measuresMember < members.size(); measuresMember++) {
      Member m = members.get(measuresMember);
      if ("Measures".equals(m.getDimension().getName())) {
        hasMeasuresOnDataAxis = true;
        break;
      }
      measuresAt += dataAxisInfo.levels[measuresMember].size();
    }
    if (hasMeasuresOnDataAxis) {
      this.measuresAt = measuresAt;
      measuresCaptions = new String[selectedMeasures.length];
      for (int i = 0; i < measuresCaptions.length; i++) {
        measuresCaptions[i] = selectedMeasures[i].getCaption();
      }
    } else {
      this.measuresAt = Integer.MIN_VALUE;
      measuresCaptions = null;
    }

    totalBranch = new TotalNode[maxDepth];
    TotalNode rootNode =
        new TotalNode(
            measuresCaptions, measures, aggrTempl[0], this, totalsAxisInfo.fullPositions.size());
    col = Axis.ROWS.equals(dataAxisInfo.axis.getAxisOrdinal()) ? 1 : 0;
    row = (col + 1) & 1;
    this.aggrTempl = aggrTempl;

    totalBranch[0] = rootNode;
    totalsLists = new List[maxDepth];
    for (int i = 0; i < totalsLists.length; i++) {
      totalsLists[i] = new ArrayList<TotalNode>();
    }
    totalsLists[0].add(rootNode);
    memberBranch = new Member[dataAxisInfo.maxDepth + 1];
  }
 public String getValue(final Locale locale) {
   if (description) {
     return member.getDescription();
   }
   return member.getCaption();
 }
  /**
   * Populates cells in the matrix corresponding to a particular axis.
   *
   * @param matrix Matrix to populate
   * @param axis Axis
   * @param axisInfo Description of axis
   * @param isColumns True if columns, false if rows
   * @param offset Ordinal of first cell to populate in matrix
   */
  private void populateAxis(
      final Matrix matrix,
      final CellSetAxis axis,
      final AxisInfo axisInfo,
      final boolean isColumns,
      final int offset) {

    if (axis == null) return;
    final Member[] prevMembers = new Member[axisInfo.getWidth()];
    final MemberCell[] prevMemberInfo = new MemberCell[axisInfo.getWidth()];
    final Member[] members = new Member[axisInfo.getWidth()];

    for (int i = 0; i < axis.getPositions().size(); i++) {
      final int x = offset + i;
      final Position position = axis.getPositions().get(i);
      int yOffset = 0;
      final List<Member> memberList = position.getMembers();
      final Map<Hierarchy, List<Integer>> lvls = new HashMap<>();
      for (int j = 0; j < memberList.size(); j++) {
        Member member = memberList.get(j);
        final AxisOrdinalInfo ordinalInfo = axisInfo.ordinalInfos.get(j);
        List<Integer> depths = ordinalInfo.depths;
        Collections.sort(depths);
        lvls.put(member.getHierarchy(), depths);
        if (ordinalInfo.getDepths().size() > 0
            && member.getDepth() < ordinalInfo.getDepths().get(0)) break;
        final int y = yOffset + ordinalInfo.depths.indexOf(member.getDepth());
        members[y] = member;
        yOffset += ordinalInfo.getWidth();
      }

      boolean expanded = false;
      boolean same = true;
      for (int y = 0; y < members.length; y++) {
        final MemberCell memberInfo = new MemberCell();
        final Member member = members[y];
        expanded = false;
        int index = memberList.indexOf(member);
        if (index >= 0) {
          final AxisOrdinalInfo ordinalInfo = axisInfo.ordinalInfos.get(index);
          int depth_i = ordinalInfo.getDepths().indexOf(member.getDepth());
          if (depth_i > 0) {
            expanded = true;
          }
        }
        memberInfo.setExpanded(expanded);
        same = same && i > 0 && Olap4jUtil.equal(prevMembers[y], member);

        if (member != null) {
          if (lvls != null && lvls.get(member.getHierarchy()) != null) {
            memberInfo.setProperty(
                "levelindex",
                "" + lvls.get(member.getHierarchy()).indexOf(member.getLevel().getDepth()));
          }
          if (x - 1 == offset) memberInfo.setLastRow(true);

          matrix.setOffset(offset);
          memberInfo.setRawValue(member.getUniqueName());
          memberInfo.setFormattedValue(member.getCaption()); // First try to get a formatted value
          memberInfo.setParentDimension(member.getDimension().getName());
          memberInfo.setHierarchy(member.getHierarchy().getUniqueName());
          memberInfo.setLevel(member.getLevel().getUniqueName());
          memberInfo.setUniquename(member.getUniqueName());
          //					try {
          //						memberInfo.setChildMemberCount(member.getChildMemberCount());
          //					} catch (OlapException e) {
          //						e.printStackTrace();
          //						throw new RuntimeException(e);
          //					}
          //					NamedList<Property> values = member.getLevel().getProperties();
          //					for(int j=0; j<values.size();j++){
          //						String val;
          //						try {
          //							val = member.getPropertyFormattedValue(values.get(j));
          //						} catch (OlapException e) {
          //							e.printStackTrace();
          //							throw new RuntimeException(e);
          //						}
          //						memberInfo.setProperty(values.get(j).getCaption(), val);
          //					}

          //					if (y > 0) {
          //						for (int previ = y-1; previ >= 0;previ--) {
          //							if(prevMembers[previ] != null) {
          //								memberInfo.setRightOf(prevMemberInfo[previ]);
          //								memberInfo.setRightOfDimension(prevMembers[previ].getDimension().getName());
          //								previ = -1;
          //							}
          //						}
          //					}
          //
          //
          //					if (member.getParentMember() != null)
          //						memberInfo.setParentMember(member.getParentMember().getUniqueName());

        } else {
          memberInfo.setRawValue(null);
          memberInfo.setFormattedValue(null);
          memberInfo.setParentDimension(null);
        }

        if (isColumns) {
          memberInfo.setRight(false);
          memberInfo.setSameAsPrev(same);
          if (member != null) memberInfo.setParentDimension(member.getDimension().getName());
          matrix.set(x, y, memberInfo);
        } else {
          memberInfo.setRight(false);
          memberInfo.setSameAsPrev(false);
          matrix.set(y, x, memberInfo);
        }
        int x_parent = isColumns ? x : y - 1;
        int y_parent = isColumns ? y - 1 : x;
        if (index >= 0) {
          final AxisOrdinalInfo ordinalInfo = axisInfo.ordinalInfos.get(index);
          int depth_i = ordinalInfo.getDepths().indexOf(member.getDepth());
          while (depth_i > 0) {
            depth_i--;
            int parentDepth = (ordinalInfo.getDepths().get(depth_i));
            Member parent = member.getParentMember();
            while (parent != null && parent.getDepth() > parentDepth) {
              parent = parent.getParentMember();
            }
            final MemberCell pInfo = new MemberCell();
            if (parent != null) {
              pInfo.setRawValue(parent.getUniqueName());
              pInfo.setFormattedValue(parent.getCaption()); // First try to get a formatted value
              pInfo.setParentDimension(parent.getDimension().getName());
              pInfo.setHierarchy(parent.getHierarchy().getUniqueName());
              pInfo.setUniquename(parent.getUniqueName());
              pInfo.setLevel(parent.getLevel().getUniqueName());
            } else {
              pInfo.setRawValue("");
              pInfo.setFormattedValue(""); // First try to get a formatted value
              pInfo.setParentDimension(member.getDimension().getName());
              pInfo.setHierarchy(member.getHierarchy().getUniqueName());
              pInfo.setLevel(member.getLevel().getUniqueName());
              pInfo.setUniquename("");
            }
            matrix.set(x_parent, y_parent, pInfo);
            if (isColumns) {
              y_parent--;
            } else {
              x_parent--;
            }
          }
        }
        prevMembers[y] = member;
        prevMemberInfo[y] = memberInfo;
        members[y] = null;
      }
    }
  }
 public String getUniqueName() {
   return member.getUniqueName();
 }
 public Object getPropertyValue(String propertyName) {
   NamedList<Property> properties = member.getProperties();
   return properties.get(propertyName);
 }
 public String getName() {
   return member.getName();
 }
 public int getDepth() {
   return member.getDepth();
 }
 public Olap4jMember(Member member, Olap4jFactory factory) {
   this.member = member;
   this.parent = factory.createMember(member.getParentMember());
 }