Package org.saiku.query

Examples of org.saiku.query.QueryHierarchy


  private static void convertDimension(
      @NotNull QueryDimension qD, @NotNull org.saiku.query.QueryAxis sAxis, @NotNull org.saiku.query.Query sQuery)
      throws Exception {
    boolean first = true;
    String hierarchyName = null;
    QueryHierarchy qh = null;
    for (Selection sel : qD.getInclusions()) {
      if (first) {
        if (sel.getRootElement() instanceof Member) {
          hierarchyName = ((Member) sel.getRootElement()).getHierarchy().getUniqueName();
        } else {
          hierarchyName = ((Level) sel.getRootElement()).getHierarchy().getUniqueName();
        }

        qh = sQuery.getHierarchy(hierarchyName);
        first = false;
      }

      if (sel.getSelectionContext() != null) {
        throw new SaikuIncompatibleException("Cannot convert queries with selection context");
      }
      if (sel.getRootElement() instanceof Member) {
        if (sel.getOperator().equals(Operator.MEMBER)) {
          qh.includeMember(sel.getRootElement().getUniqueName());
        } else {
          throw new SaikuIncompatibleException("Cannot convert member selection using operator: " + sel.getOperator());
        }
      } else {
        qh.includeLevel(sel.getRootElement().getName());
      }
    }
    sAxis.addHierarchy(qh);

  }
View Full Code Here


          }
        }


        for (Hierarchy h : memberSelection.keySet()) {
          QueryHierarchy qh = q.getHierarchy(h);
          for (QueryLevel ql : qh.getActiveQueryLevels()) {
            ql.getInclusions().clear();
            ql.getExclusions().clear();
            ql.setMdxSetExpression(null);
          }
          for (Member m : memberSelection.get(h)) {
            qh.includeMember(m);
          }
        }
        ThinQuery tqAfter = Thin.convert(q, old.getCube());
        q = null;
        return tqAfter;
View Full Code Here

        throw new SaikuServiceException("Cannot drill across. Last CellSet empty");
      }
      for (int i = 0; i < cellPosition.size(); i++) {
        List<Member> members = cs.getAxes().get(i).getPositions().get(cellPosition.get(i)).getMembers();
        for (Member m : members) {
          QueryHierarchy qh = query.getHierarchy(m.getHierarchy());
          if (qh.getHierarchy().getDimension().getName().equals("Measures")) {
            Measure measure = query.getMeasure(m.getName());
            if (!query.getDetails().getMeasures().contains(measure)) {
              query.getDetails().add(measure);
            }

          } else {
            qh.clearSelection();
            qh.clearFilters();
            qh.clearSort();
            query.moveHierarchy(qh, Axis.FILTER);
            qh.includeMember(m);
            levelSet.add(m.getLevel());
          }

        }
      }
      boolean clearedMeasures = false;

      if (levels != null) {
        for (String key : levels.keySet()) {
          String dimensionName = key.split("###")[0];

          if ("Measures".equals(dimensionName)) {
            if (!clearedMeasures) {
              query.getDetails().getMeasures().clear();
              clearedMeasures = true;
            }
            for (String measureName : levels.get(key)) {
              Measure measure = query.getMeasure(measureName);
              if (measure != null) {
                query.getDetails().add(measure);
              } else {
                for (Measure m : cub.getMeasures()) {
                  if (m.getUniqueName().equals(measureName)) {
                    query.getDetails().add(m);
                  }
                }
              }
            }
            continue;
          }
          String hierarchyName = key.split("###")[1];
          Dimension d = cub.getDimensions().get(dimensionName);
          Hierarchy h = d.getHierarchies().get(hierarchyName);
          QueryHierarchy qh = query.getHierarchy(h);
          for (Level l : h.getLevels()) {
            for (String levelU : levels.get(key)) {
              if (l.getUniqueName().equals(levelU) || l.getName().equals(levelU)) {
                qh.includeLevel(l);
              }
            }
          }
          if (qh.getActiveQueryLevels().size() > 0) {
            query.moveHierarchy(qh, Axis.ROWS);
          }
        }
      }
      if (query.getDetails().getMeasures().size() == 0) {
        QueryHierarchy qh = query.getHierarchy("Measures");
        Member defaultMeasure = qh.getHierarchy().getDefaultMember();
        query.getDetails().add(query.getMeasure(defaultMeasure.getName()));
      }
      return Thin.convert(query, old.getCube());
    } catch (Exception e) {
      throw new SaikuServiceException("Error drilling across: " + queryName, e);
View Full Code Here

TOP

Related Classes of org.saiku.query.QueryHierarchy

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.