private boolean validadeFormPromptCollect(FormEntity form) { PromptCollectEntity promptCollect = (PromptCollectEntity) form.getFormId(); boolean error = false; String msgErro = ""; if (promptCollect.getGrammar() == null) { error = true; msgErro = "Grammar is missing"; } if (promptCollect.getPrompt() == null) { if (error) { msgErro += " / "; } error = true; msgErro += "Prompt is missing"; } if (promptCollect.getNoInput() == null) { if (error) { msgErro += " / "; } error = true; msgErro += "NoInput is missing"; } if (promptCollect.getNoMatch() == null) { if (error) { msgErro += " / "; } error = true; msgErro += "NoMatch is missing"; } form.setFormError(error); form.setErrorDescription(msgErro); return form.isFormError(); }
private boolean validadeFormMenu(FormEntity form) { MenuEntity menu = (MenuEntity) form.getFormId(); boolean error = false; String msgErro = ""; if (menu.getPrompt() == null) { error = true; msgErro = "Prompt is missing"; } if (menu.getNoInput() == null) { if (error) { msgErro += " / "; } error = true; msgErro += "NoInput is missing"; } if (menu.getNoMatch() == null) { if (error) { msgErro += " / "; } error = true; msgErro += "NoMatch is missing"; } if (menu.getChoices() == null || menu.getChoices().size() == 0) { if (error) { msgErro += " / "; } error = true; msgErro += "Choices is missing"; } form.setFormError(error); form.setErrorDescription(msgErro); return form.isFormError(); }
private boolean validadeFormAnnounce(FormEntity form) { AnnounceEntity announce = (AnnounceEntity) form.getFormId(); if (announce.getPrompt() == null) { form.setFormError(true); form.setErrorDescription("Prompt is missing"); } return form.isFormError(); }
private boolean validadeFormDecision(FormEntity form) { DecisionEntity decision = (DecisionEntity) form.getFormId(); if (decision.getListDecisionChance() == null || decision.getListDecisionChance().size() == 0) { form.setFormError(true); form.setErrorDescription("Chances is missing"); } return form.isFormError(); }
private boolean validadeFormTransfer(FormEntity form) { TransferEntity transfer = (TransferEntity) form.getFormId(); if (transfer.getTransferRules() == null || transfer.getTransferRules().size() == 0) { form.setFormError(true); form.setErrorDescription("Transfer Rules is missing"); } return form.isFormError(); }
private boolean validadeFormFlow(FormEntity form) { FlowEntity flow = (FlowEntity) form.getFormId(); if (flow.getFlowName() == null || flow.getFlowName().length() == 0) { form.setFormError(true); form.setErrorDescription("Flow Name is missing"); } return form.isFormError(); }
private boolean validadeFormOperation(FormEntity form) { OperationEntity operation = (OperationEntity) form.getFormId(); if (operation.getListOperationGroup() == null || operation.getListOperationGroup().size() == 0) { form.setFormError(true); form.setErrorDescription("Operation Group is missing"); } return form.isFormError(); }
public boolean existsStart() { for (Node nodeAux : listNode) { FormEntity formAux = (FormEntity) nodeAux.getElement().getData(); if (formAux.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_ANSWER)) { return true; } } return false; }
public Node getNode(FormEntity form) { for (Node node : listNode) { if (((FormEntity) node.getElement().getData()).getId().equals(form.getId())) { return node; } } return null; }
public void alingMenuChoices(Element element) { Node menuNode = getNode(element); // empura no input/nomatch para o final da lista boolean first = true; for (int indexA = 0; indexA < menuNode.getListTarget().size() - 2; indexA++) { Node choiceNodeA = menuNode.getListTarget().get(indexA); FormEntity formChoiceA = (FormEntity) choiceNodeA.getElement().getData(); if (formChoiceA.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_NOMATCHINPUT)) { int indexB = 0; Node choiceNodeB = null; if (first) { first = false; indexB = menuNode.getListTarget().size() - 2; choiceNodeB = menuNode.getListTarget().get(indexB); } else { indexB = menuNode.getListTarget().size() - 1; choiceNodeB = menuNode.getListTarget().get(indexB); } menuNode.getListTarget().set(indexB, choiceNodeA); menuNode.getListTarget().set(indexA, choiceNodeB); indexA = -1; } } // ordena as choices for (int indexA = 0; indexA < menuNode.getListTarget().size(); indexA++) { Node choiceNodeA = menuNode.getListTarget().get(indexA); FormEntity formChoiceA = (FormEntity) choiceNodeA.getElement().getData(); if (formChoiceA.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_CHOICE)) { for (int indexB = indexA; indexB < menuNode.getListTarget().size(); indexB++) { Node choiceNodeB = menuNode.getListTarget().get(indexB); FormEntity formChoiceB = (FormEntity) choiceNodeB.getElement().getData(); if (formChoiceB.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_CHOICE)) { if (((ChoiceEntity) formChoiceA.getFormId()) .compareTo((ChoiceEntity) formChoiceB.getFormId()) > 0) { menuNode.getListTarget().set(indexB, choiceNodeA); menuNode.getListTarget().set(indexA, choiceNodeB); indexA = -1; break; } } } } } }
public void disconnect(Element source, boolean allNodes) { Node nodeSource = getNode(source); FormEntity formSource = nodeSource.getForm(); List<Node> targets = nodeSource.getListTarget(); if (formSource.getFormType().getName().equals(Constants.FORM_TYPE_PROMPT_COLLECT) && !allNodes) { boolean found = false; for (int index = 0; index < targets.size() && !found; index++) { Node target = targets.get(index); FormEntity formTarget = target.getForm(); if (!(formTarget.getFormType().getName().equals(Constants.FORM_TYPE_NOINPUT) || formTarget.getFormType().getName().equals(Constants.FORM_TYPE_NOMATCH))) { target.remSource(nodeSource); if (target.getListSource().size() == 0) { listFirstNode.add(target); } nodeSource.remTarget(target); found = true; } } } else { for (Node target : targets) { target.remSource(nodeSource); if (target.getListSource().size() == 0) { listFirstNode.add(target); } } } nodeSource.setConnection(null); nodeSource.getForm().setNextForm(null); nodeSource.getForm().setTag(null); ((FormEntity) nodeSource.getElement().getData()).setTag(null); ((FormEntity) nodeSource.getElement().getData()).setNextForm(null); Object formId = ((FormEntity) nodeSource.getElement().getData()).getFormId(); ((AbstractFormEntity) formId).setNextForm(null); ((AbstractFormEntity) formId).setTag(null); }
private boolean validateFormByType(FormEntity form) { if (form.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_ANNOUNCE)) { return validadeFormAnnounce(form); } if (form.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_PROMPT_COLLECT)) { return validadeFormPromptCollect(form); } if (form.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_MENU)) { return validadeFormMenu(form); } if (form.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_DECISION)) { return validadeFormDecision(form); } if (form.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_OPERATION)) { return validadeFormOperation(form); } if (form.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_TRANSFER)) { return validadeFormTransfer(form); } if (form.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_FLOW)) { return validadeFormFlow(form); } return false; }
public void validateNodes() { for (Node node : listNode) { FormEntity form = (FormEntity) node.getElement().getData(); form.setFormError(false); form.setErrorDescription(""); if (form.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_PROMPT_COLLECT)) { boolean foundTarget = false; for (Node nodeTarget : node.getListTarget()) { if (!(nodeTarget .getForm() .getFormType() .getName() .equalsIgnoreCase(Constants.FORM_TYPE_NOINPUT) || nodeTarget .getForm() .getFormType() .getName() .equalsIgnoreCase(Constants.FORM_TYPE_NOMATCH))) { foundTarget = true; } } if (!foundTarget) { form.setFormError(true); form.setErrorDescription("Output is mandatory"); continue; } } FormEntity aux = ServicesFactory.getInstance().getFormService().getByName(form.getName(), true); if (aux != null && !aux.getId().equals(form.getId())) { form.setFormError(true); form.setErrorDescription( "Name " + form.getName() + " already assigned to another Element in another Flow"); continue; } int startFlow = 0; boolean stopFlow = false; for (Node nodeAux : listNode) { FormEntity formAux = (FormEntity) nodeAux.getElement().getData(); if (!formAux.getId().equalsIgnoreCase(form.getId()) && formAux.getName().equalsIgnoreCase(form.getName()) && !(formAux.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_CHOICE) || formAux.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_NOINPUT) || formAux.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_NOMATCH))) { form.setFormError(true); form.setErrorDescription( "Name " + form.getName() + " already assigned to another Element."); continue; } if (formAux.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_ANSWER)) { startFlow++; } if (formAux.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_DISCONNECT) || formAux.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_TRANSFER) || formAux.getFormType().getName().equalsIgnoreCase(Constants.FORM_TYPE_RETURN)) { stopFlow = true; } } if (validateFormByType(form)) { continue; } if (form.getFormType().getMandatoryInput() == 1 && node.getListSource().size() == 0) { form.setFormError(true); form.setErrorDescription("Input is mandatory"); continue; } if (form.getFormType().getMandatoryOutput() == 1 && node.getListTarget().size() == 0) { form.setFormError(true); form.setErrorDescription("Output is mandatory"); continue; } if (startFlow == 0) { form.setFormError(true); form.setErrorDescription("You have to start the flow with the node type 'Answer'"); continue; } else if (startFlow > 1) { form.setFormError(true); form.setErrorDescription("Node type 'Answer' is allowed only ONE per flow"); continue; } if (!stopFlow) { form.setFormError(true); form.setErrorDescription( "You have to finish the flow with the node type 'Disconnect', 'Transfer' or 'Return'"); continue; } } }