@Override public Skema getSkema(Questionnaire questionnaire) { Variable<String> readMessageId = new Variable<String>("readMessageId", String.class); Variable<String> userId = new Variable<String>("userId", String.class); Variable<Long> departmentId = new Variable<Long>("departmentId", Long.class); @SuppressWarnings("rawtypes") Variable<Map> departmentNameMap = new Variable<Map>("departmentNameMap", Map.class); Variable<String> title = new Variable<String>("title", String.class); Variable<String> text = new Variable<String>("text", String.class); OutputSkema outputSkema = new OutputSkema(); outputSkema.addVariable(readMessageId); outputSkema.addVariable(departmentId); outputSkema.addVariable(departmentNameMap); for (Variable<?> output : outputSkema.getOutput()) { questionnaire.addVariable(output); } // //////////////////////////////////////////////////////////////////////////////// EndNode end = new EndNode(questionnaire, "End"); MessageSendNode messageSendNode = new MessageSendNode(questionnaire, "messageSendNode"); messageSendNode.setDepartmentId(departmentId); messageSendNode.setTitle(title); messageSendNode.setText(text); messageSendNode.setHideTopPanel(true); MessageWriteNode messageWriteNode = new MessageWriteNode(questionnaire, "messageWriteNode"); messageWriteNode.setUserId(userId); messageWriteNode.setDepartmentId(departmentId); messageWriteNode.setTitle(title); messageWriteNode.setText(text); messageWriteNode.setWriteMessageNode(messageSendNode); MessageDialogNode messageDialogNode = new MessageDialogNode(questionnaire, "MessageDialogNode"); messageDialogNode.setDepartmentId(departmentId); messageDialogNode.setDepartmentNameMap(departmentNameMap); messageDialogNode.setNewMessageNode(messageWriteNode); MessageListNode messageListNode = new MessageListNode(questionnaire, "MessageListNode"); messageListNode.setDepartmentId(departmentId); messageListNode.setDepartmentNameMap2(departmentNameMap); messageListNode.setReadMessagesNode(messageDialogNode); messageSendNode.setNext(messageListNode); Skema skema = new Skema(); skema.setEndNode(end.getNodeName()); skema.setName("MESSAGE"); skema.setStartNode(messageListNode.getNodeName()); skema.setVersion("1.0"); skema.addNode(end); skema.addNode(messageListNode); try { skema.link(); } catch (UnknownNodeException e) { Log.e(TAG, "Got Exception", e); } return skema; }
@Override public Skema getSkema(Questionnaire questionnaire) { // Variable OutputSkema outputSkema = new OutputSkema(); Variable<String> skemaName = new Variable<String>("getSkema", String.class); outputSkema.addVariable(skemaName); // //////////////////////////////////////////////////////////////////////////////// EndNode end = new EndNode(questionnaire, "END"); // //////////////////////////////////////////////////////////////////////////////// UploadNode uploadNode = new UploadNode(questionnaire, "UPLOAD"); uploadNode.setNextNode(end); uploadNode.setHideTopPanel(true); // //////////////////////////////////////////////////////////////////////////////// DebugListPoolNode debugNode = new DebugListPoolNode(questionnaire, "MAIN"); debugNode.setNextNode(uploadNode); // //////////////////////////////////////////////////////////////////////////////// IONode uploadValg = new IONode(questionnaire, "uploadValg"); TextViewElement twe = new TextViewElement(uploadValg); twe.setText(Util.getString(R.string.run_skema_do_you_want_to_send_data, questionnaire)); uploadValg.addElement(twe); TwoButtonElement tbe = new TwoButtonElement(uploadValg); tbe.setLeftText(Util.getString(R.string.default_no, questionnaire)); tbe.setLeftNextNode(end); tbe.setRightText(Util.getString(R.string.default_yes, questionnaire)); uploadValg.addElement(tbe); @SuppressWarnings("unchecked") Variable<Boolean> showUploadDebugNode = (Variable<Boolean>) questionnaire.getValuePool().get(Util.VARIABLE_SHOW_UPLOAD_DEBUG); if (showUploadDebugNode.getExpressionValue().getValue()) { tbe.setRightNextNode(debugNode); } else { tbe.setRightNextNode(uploadNode); } // //////////////////////////////////////////////////////////////////////////////// RunQuestionnaireNode run = new RunQuestionnaireNode(questionnaire, "RUN"); run.setSkemaName(skemaName); run.setNextNode(uploadValg); // //////////////////////////////////////////////////////////////////////////////// IOSkemaMenuNode ioSkemaMenuNode = new IOSkemaMenuNode(questionnaire, "SKEMA-MENU"); ioSkemaMenuNode.setNextNode(run); ioSkemaMenuNode.setSkemaName(skemaName); Skema skema = new Skema(); skema.setEndNode(end.getNodeName()); skema.setName("RUN-SKEMA"); skema.setStartNode(ioSkemaMenuNode.getNodeName()); skema.setVersion("1.0"); skema.addNode(end); skema.addNode(uploadNode); skema.addNode(debugNode); skema.addNode(run); skema.addNode(ioSkemaMenuNode); for (Variable<?> output : outputSkema.getOutput()) { questionnaire.addVariable(output); skema.addVariable(output); } return skema; }