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()); }
/** * Find sesstion attribute "nds.control.web.ValidateMServlet" defined in ValidateMServlet, and * compare with user input named "verifyCode" */ public NDSEvent processRequest(HttpServletRequest request) throws NDSEventException { String serverValidCode = (String) request.getSession().getAttribute("nds.control.web.ValidateMServlet"); if (serverValidCode == null) throw new NDSEventException( "Internal error, nds.control.web.ValidateMServlet not set in session attribute"); String userValidCode = request.getParameter("verifyCode"); if (serverValidCode.equalsIgnoreCase(userValidCode)) { } else { throw new NDSEventException("@error-verify-code@"); } DefaultWebEvent event = new DefaultWebEvent("CommandEvent"); event.setParameter("command", "RegistrateUser"); /** * add param named "nds.query.querysession", which hold QuerySession object * * @since 2.0 */ SessionContextManager scmanager = WebUtils.getSessionContextManager(request.getSession(true)); UserWebImpl usr = (UserWebImpl) scmanager.getActor(WebKeys.USER); if (usr != null && usr.getSession() != null) event.put("nds.query.querysession", usr.getSession()); event.put("JAVA.UTIL.LOCALE", usr.getLocale()); Enumeration enu = request.getParameterNames(); while (enu.hasMoreElements()) { String name = (String) enu.nextElement(); String[] value = request.getParameterValues(name); if (name.equalsIgnoreCase("command")) { /* ############# tony 's method was deferred to EJB layer to implement, see nds.control.ejb.CommandFactory event.setParameter(name, commandName(value[0])); ######## yfzhu marked above */ event.setParameter(name, value[0]); // nmdemo, ObjectPermit and ObjectRollback will also need spName // if(value[0].endsWith("Submit")) event.setParameter("spName", value[0]); } else if (value.length == 1) event.setParameter(name, value[0]); else event.setParameter(name, value); } return event; }
/** * 事实表和关联报表属于当前传入数组的交叉报表 * * @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; }