コード例 #1
0
  /**
   * Needed for hyperlink form switches...
   *
   * @param request
   * @throws DatabaseException
   */
  private void doXrefselect(Tuple request) throws DatabaseException {
    // also set the parent menu
    if (getParent() != null && getParent() instanceof MenuController) {
      // set the filter to select the xref-ed entity
      pager.resetFilters();
      getModel().setUserRules(new ArrayList<QueryRule>());
      QueryRule rule =
          new QueryRule(
              request.getString("attribute"),
              QueryRule.Operator.valueOf(request.getString("operator")),
              request.getString("value"));
      pager.addFilter(rule);

      // tell "my" menu to select me
      Tuple parentRequest = new SimpleTuple();
      String aChildName = getModel().getName();
      ScreenController<?> aParent = getParent();
      while (aParent != null) {
        if (aParent instanceof MenuModel) {
          parentRequest.set("select", aChildName);
          MenuController c = (MenuController) aParent;
          c.doSelect(parentRequest);
        }
        aChildName = aParent.getName();
        aParent = aParent.getParent();
      }
    }
  }
コード例 #2
0
  private Show addFilters(DatabasePager<E> pager, Database db, Tuple request)
      throws DatabaseException, MolgenisModelException {
    List<QueryRule> userRules = new ArrayList<QueryRule>();
    for (int i = 0; i < MAX_FILTERS; ++i) {
      // suffix: __filter_value, __filter_value1, __filter_value2 etc.
      String suffix = i > 0 ? i + "" : "";

      String filterAttr = request.getString("__filter_attribute" + suffix);
      if (filterAttr == null) break;

      String operatorStr = request.getString("__filter_operator" + suffix);
      Operator operator = QueryRule.Operator.valueOf(operatorStr);
      String filterValue = request.getString("__filter_value" + suffix);

      QueryRule filterRule;
      if (filterAttr.equals(FILTER_ATTRIBUTE_ALL)) {
        filterRule = createFilterRule(db, operator, filterValue);
      } else {
        String fieldName = toFieldName(filterAttr);
        filterRule = createFilterRule(db, fieldName, operator, filterValue);
      }
      userRules.add(filterRule);
    }

    FormModel<E> model = getModel();
    model.getUserRules().addAll(userRules);

    // reset pager
    List<QueryRule> rules = new ArrayList<QueryRule>();
    rules.addAll(model.getUserRules());
    rules.addAll(model.getSystemRules());
    pager.resetFilters(rules);
    pager.first(db);

    return Show.SHOW_MAIN;
  }