public void generate( UserInfoInterface userInfo, ProcessData process, ParserContext ch, Field field, boolean even) throws SAXException { Logger.info(userInfo.getUtilizador(), this, "generate", "Generating from template"); // TODO if disabled, return; String template = field.getProperties().get("template"); IFlowData flow = BeanFactory.getFlowHolderBean().getFlow(userInfo, process.getFlowId()); Form formTemplate = null; if (flow != null) formTemplate = flow.getFormTemplate(template); if (null == formTemplate) { // ignore or throw error? Logger.error( userInfo.getUtilizador(), this, "generate", "Could not parse template: '" + template + "'"); ch.startElement("field"); ch.addElement("type", "message"); ch.addElement("text", "Template de formulário inválida"); ch.addElement("even_field", String.valueOf(even)); ch.endElement("field"); return; } // allways get first tab Tab tab = formTemplate.getTabs().get(0); for (Field subField : tab.getFields()) { IWidget subfieldWidget = newWidget(subField.getType()); subfieldWidget.generate(userInfo, process, ch, subField, even); even = !even; } }
/** * Executes the block main action * * @param dataSet a value of type 'DataSet' * @return the port to go to the next block */ public Port after(UserInfoInterface userInfo, ProcessData procData) { Port outPort = portFalse; try { String sLogin = null; String sPass = null; sLogin = this.getAttribute(LOGIN_ATTR); sLogin = procData.transform(userInfo, sLogin); try { sPass = procData.transform(userInfo, this.getAttribute(PASS_ATTR)); } catch (Exception ee) { } AuthProfile ap = BeanFactory.getAuthProfileBean(); boolean bOk = ap.checkUser(sLogin, sPass); Logger.info( userInfo.getUtilizador(), this, "after", "[" + procData.getFlowId() + "," + procData.getPid() + "," + procData.getSubPid() + "] " + "checked authentication for " + sLogin + ": " + bOk); if (bOk) { outPort = portTrue; } else { outPort = portFalse; } } catch (Exception e) { Logger.error( userInfo.getUtilizador(), this, "after", procData.getSignature(this.getId()) + "Exception caught: " + e.getMessage()); e.printStackTrace(); } return outPort; }