Esempio n. 1
0
  public Map<String, SaikuFilter> getValidFilters(
      String queryName, Map<String, SaikuFilter> allFilters) {
    IQuery query = getIQuery(queryName);
    Cube c = query.getCube();
    Map<String, SaikuFilter> filteredMap = new HashMap<String, SaikuFilter>();
    for (SaikuFilter sf : allFilters.values()) {
      if (StringUtils.isBlank(sf.getName()) || sf.getDimension() == null) continue;

      String dimensionName = sf.getDimension().getName();
      String hierarchyName = sf.getHierarchy().getName();
      boolean hasDimension = c.getDimensions().indexOfName(dimensionName) >= 0;
      boolean hasHierarchy = c.getHierarchies().indexOfName(hierarchyName) >= 0;
      if (hasDimension || hasHierarchy) {
        filteredMap.put(sf.getName(), sf);
      }
    }
    return filteredMap;
  }
Esempio n. 2
0
  public SaikuQuery applyFilter(String queryname, SaikuFilter filter) throws Exception {
    IQuery query = getIQuery(queryname);
    if (filter != null
        && filter.getName() != null
        && filter.getDimension() != null
        && filter.getMembers() != null) {
      query.setFilter(filter);
      QueryDimension qDim = query.getDimension(filter.getDimension().getName());

      if (qDim != null) {
        qDim.clearInclusions();
        query.moveDimension(qDim, Axis.FILTER);
        for (SimpleCubeElement member : filter.getMembers()) {
          List<IdentifierSegment> memberList =
              IdentifierNode.parseIdentifier(member.getUniqueName()).getSegmentList();
          qDim.include(memberList);
        }
      }
    }
    return ObjectUtil.convert(query);
  }