Exemplo n.º 1
0
  /**
   * add Top/BottomCount Funcall to QueryAxis
   *
   * @param monAx
   * @param nShow
   */
  private void topBottomAxis(ParsedQuery pq, String function) {
    // TopCount(TopCount) and TopCount(Order) is not permitted

    QueryAxis[] queryAxes = pq.getAxes();
    QueryAxis qa = queryAxes[quaxToSort.getOrdinal()];
    Exp setForAx = qa.getExp();
    Exp sortExp;
    // if we got more than 1 position member, generate a tuple
    if (sortPosMembers.length > 1) {
      sortExp = new FunCall("()", (XMLA_Member[]) sortPosMembers, FunCall.TypeParentheses);
    } else {
      sortExp = (XMLA_Member) sortPosMembers[0];
    }

    Exp[] args = new Exp[3];
    args[0] = setForAx; // the set representing the query axis
    args[1] = Literal.create(new Integer(topBottomCount));
    args[2] = sortExp;
    FunCall topbottom = new FunCall(function, args, FunCall.TypeFunction);
    qa.setExp(topbottom);
  }
Exemplo n.º 2
0
  /**
   * add Order Funcall to QueryAxis
   *
   * @param monAx
   * @param monSortMode
   */
  private void orderAxis(ParsedQuery pq) {
    // Order(TopCount) is allowed, Order(Order) is not permitted
    QueryAxis[] queryAxes = pq.getAxes();
    QueryAxis qa = queryAxes[quaxToSort.getOrdinal()];
    Exp setForAx = qa.getExp();

    // setForAx is the top level Exp of the axis
    // put an Order FunCall around
    Exp[] args = new Exp[3];
    args[0] = setForAx; // the set to be sorted is the set representing the query axis
    // if we got more than 1 position member, generate a tuple for the 2.arg
    Exp sortExp;
    if (sortPosMembers.length > 1) {
      sortExp = new FunCall("()", (XMLA_Member[]) sortPosMembers, FunCall.TypeParentheses);
    } else {
      sortExp = (XMLA_Member) sortPosMembers[0];
    }
    args[1] = sortExp;
    args[2] = Literal.createString(sortMode2String(sortMode));
    FunCall order = new FunCall("Order", args, FunCall.TypeFunction);
    qa.setExp(order);
  }