public void disconnectAll(Element element, boolean allNode) { Node node = getNode(element); List<Node> sources = node.getListSource(); for (Node source : sources) { disconnect(source.getElement(), allNode); } disconnect(element, allNode); }
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); }
public void disconnect(Element source, Element target) { Node nodeSource = getNode(source); Node nodeTarget = getNode(target); List<Node> targets = nodeSource.getListTarget(); for (Node targetAux : targets) { if (targetAux.equals(nodeTarget)) { targetAux.remSource(nodeSource); if (targetAux.getListSource().size() == 0) { listFirstNode.add(targetAux); } } } nodeSource.remTarget(nodeTarget); 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); }
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; } } }