Exemplo n.º 1
0
  public List getModifiableMonitors(Table paramTable, UserWebImpl usr) throws Exception {
    // this = (this = TableManager.getInstance()).getTable("ad_monitor");
    Table mo_table = TableManager.getInstance().getTable("ad_monitor");
    QueryRequestImpl query;
    query = QueryEngine.getInstance().createRequest(usr.getSession());
    query.setMainTable(mo_table.getId());
    query.addSelection(mo_table.getColumn("id").getId());
    query.addSelection(mo_table.getColumn("name").getId());
    query.addSelection(mo_table.getColumn("monitor_type").getId());
    query.addSelection(mo_table.getColumn("check_type").getId());
    query.addSelection(mo_table.getColumn("isactive").getId());

    query.addOrderBy(new int[] {mo_table.getColumn("name").getId()}, true);

    Expression localExpression =
        (localExpression =
                (localExpression =
                        (localExpression =
                                new Expression(
                                    new ColumnLink("ad_monitor.monitor_type"), "=obj", null))
                            .combine(
                                new Expression(
                                    new ColumnLink("ad_monitor.monitor_type"), "=list", null),
                                2,
                                null))
                    .combine(usr.getSecurityFilter(mo_table.getName(), 3), 1, null))
            .combine(
                new Expression(
                    new ColumnLink("ad_monitor.ad_table_id"), "=" + paramTable.getId(), null),
                1,
                null);
    query.addParam(localExpression);
    logger.debug("getModifiableMonitors sql is:" + query.toSQL());
    return QueryEngine.getInstance().doQueryList(query.toSQL());
  }
Exemplo n.º 2
0
  /**
   * 事实表和关联报表属于当前传入数组的交叉报表
   *
   * @param request
   * @param tables elements are table.id
   * @return elements are ArrayList, first is cxtab id, second is cxtab name
   */
  public List getCxtabs(HttpServletRequest request, List<Integer> tables) {
    TableManager manager = TableManager.getInstance();
    UserWebImpl userWeb =
        ((UserWebImpl)
            WebUtils.getSessionContextManager(request.getSession())
                .getActor(nds.util.WebKeys.USER));
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < tables.size(); i++) {
      // Table t= tables.get(i);
      if (i > 0) sb.append(",");
      sb.append(tables.get(i));
    }
    String ts = sb.toString();
    try {
      Table cxtabTable = manager.getTable("AD_CXTAB");
      QueryRequestImpl queryData;
      // only pk,dk will be selected, order by ak asc
      queryData = QueryEngine.getInstance().createRequest(userWeb.getSession());
      queryData.setMainTable(cxtabTable.getId());

      queryData.addSelection(cxtabTable.getPrimaryKey().getId());
      queryData.addSelection(cxtabTable.getDisplayKey().getId());

      Column colOrderNo = cxtabTable.getColumn("orderno");
      queryData.setOrderBy(new int[] {colOrderNo.getId()}, true);
      queryData.setRange(0, Integer.MAX_VALUE);

      Expression expr =
          new Expression(
              null,
              "(AD_CXTAB.AD_TABLE_ID in ("
                  + ts
                  + ") or exists (select 1 from ad_cxtab_reftable r where r.ad_cxtab_id=AD_CXTAB.id and r.ad_table_id in ("
                  + ts
                  + ")))",
              null);

      // set reporttype to "S"
      expr =
          expr.combine(
              new Expression(new ColumnLink("AD_CXTAB.REPORTTYPE"), "=S", null),
              SQLCombination.SQL_AND,
              null);
      expr =
          expr.combine(
              new Expression(new ColumnLink("AD_CXTAB.ISACTIVE"), "=Y", null),
              SQLCombination.SQL_AND,
              null);
      expr =
          expr.combine(
              new Expression(new ColumnLink("AD_CXTAB.ISPUBLIC"), "=Y", null),
              SQLCombination.SQL_AND,
              null);
      expr =
          expr.combine(
              userWeb.getSecurityFilter(cxtabTable.getName(), 1), SQLCombination.SQL_AND, null);
      queryData.addParam(expr); // read permission

      return QueryEngine.getInstance().doQueryList(queryData.toSQL());
    } catch (Throwable t) {
      logger.error(
          "Fail to load reports for user " + userWeb.getUserId() + " with table ids: " + ts, t);
    }
    return Collections.EMPTY_LIST;
  }