public void resetAxisSelections(QueryAxis axis) { for (QueryDimension dim : axis.getDimensions()) { dim.clearInclusions(); dim.clearExclusions(); dim.clearSort(); } }
public SaikuQuery removeFilter(String queryname) { IQuery query = getIQuery(queryname); if (query != null && query.getFilter() != null) { SaikuFilter filter = query.getFilter(); QueryDimension qDim = query.getDimension(filter.getDimension().getName()); if (qDim != null) { qDim.clearInclusions(); query.moveDimension(qDim, null); } query.removeFilter(); } return ObjectUtil.convert(query); }
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); }
private IQuery applyTag(IQuery query, OlapConnection con, SaikuTag t) throws Exception { String xml = query.toXml(); QueryDeserializer qd = new QueryDeserializer(); query = qd.unparse(xml, con); List<SimpleCubeElement> doneDimension = new ArrayList<SimpleCubeElement>(); Map<String, QueryDimension> dimensionMap = new HashMap<String, QueryDimension>(); if (t.getSaikuTupleDimensions() != null) { for (SimpleCubeElement st : t.getSaikuTupleDimensions()) { if (!doneDimension.contains(st)) { QueryDimension dim = query.getDimension(st.getName()); dimensionMap.put(st.getUniqueName(), dim); dim.clearExclusions(); dim.clearInclusions(); query.moveDimension(dim, null); doneDimension.add(st); } } if (t.getSaikuTupleDimensions().size() > 0) { SimpleCubeElement rootDim = t.getSaikuTupleDimensions().get(0); QueryDimension dim = query.getDimension(rootDim.getName()); query.moveDimension(dim, Axis.COLUMNS); for (SaikuTuple tuple : t.getSaikuTuples()) { SaikuMember m = tuple.getSaikuMember(rootDim.getUniqueName()); List<SaikuMember> others = tuple.getOtherSaikuMembers(rootDim.getUniqueName()); Selection sel = dim.createSelection(IdentifierParser.parseIdentifier(m.getUniqueName())); for (SaikuMember context : others) { QueryDimension otherDim = dimensionMap.get(context.getDimensionUniqueName()); query.moveDimension(otherDim, Axis.COLUMNS); Selection ctxSel = otherDim.createSelection(IdentifierParser.parseIdentifier(context.getUniqueName())); sel.addContext(ctxSel); } dim.getInclusions().add(sel); } } } if (t.getSaikuDimensionSelections() != null) { for (SaikuDimensionSelection dimsel : t.getSaikuDimensionSelections()) { if (!dimsel.getName().equals("Measures")) { QueryDimension filterDim = query.getDimension(dimsel.getName()); query.moveDimension(filterDim, Axis.FILTER); filterDim.clearInclusions(); for (SaikuSelection ss : dimsel.getSelections()) { if (ss.getType() == SaikuSelection.Type.MEMBER) { Selection sel = filterDim.createSelection(IdentifierParser.parseIdentifier(ss.getUniqueName())); if (!filterDim.getInclusions().contains(sel)) { filterDim.getInclusions().add(sel); } } } // TODO: Move it to columns since drilling through with 2 filter items of the same // dimension doesn't work // if (filterDim.getInclusions().size() > 1) { // query.moveDimension(filterDim, Axis.COLUMNS); // } } } } return query; }