public void addNewGroup(ActionEvent event) {

    super.collect();

    ServicesFactory.getInstance()
        .getIvrEditorService()
        .getBean()
        .setComplementPageEditor("/pages/forms/OperationGroup.xhtml");

    ServicesFactory.getInstance().getOperationGroupEditorService().getBean().setOperationBean(this);
  }
  @Override
  public void update(ActionEvent event) {
    // TODO Auto-generated method stub
    RequestContext context = RequestContext.getCurrentInstance();
    boolean saved = true;

    if (this.operationGroups.size() == 0) {
      FacesMessage msg =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR,
              "Operation",
              "Please, configure at least one Operation Group.");

      FacesContext.getCurrentInstance().addMessage(null, msg);
      return;
    }
    this.operation.setListOperationGroup(this.operationGroups);

    logicalFlow.validateNodes();
    // logicalFlow.align();

    FacesMessage msg =
        new FacesMessage(
            FacesMessage.SEVERITY_INFO, "Operation", this.operation.getName() + " - Updated!");

    ServicesFactory.getInstance().getIvrEditorService().getBean().setEditing(true);
    FacesContext.getCurrentInstance().addMessage(null, msg);
    context.addCallbackParam("saved", saved);
  }
  @Override
  public void edit(String id) {
    collect();

    ServicesFactory.getInstance()
        .getIvrEditorService()
        .getBean()
        .setComplementPageEditor("/pages/forms/OperationGroup.xhtml");

    ServicesFactory.getInstance().getOperationGroupEditorService().getBean().setOperationBean(this);

    for (OperationGroupEntity group : this.operationGroups) {
      if (group.getId().equals(id)) {
        ServicesFactory.getInstance()
            .getOperationGroupEditorService()
            .getBean()
            .setOperationGroup(group);
      }
    }
  }
Exemple #4
0
  @Override
  public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {

    if ((submittedValue != null) && (!submittedValue.equals(""))) {
      try {
        return ServicesFactory.getInstance().getPromptService().get(submittedValue);
      } catch (Exception e) {

      }
    }
    return new PromptEntity();
  }
Exemple #5
0
  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;
      }
    }
  }
  public void save(ActionEvent event) {

    if (this.logicNodeBean != null) {

      List<LogicNodeOperationEntity> listEntity = this.logicNodeBean.getListNodeOperation();

      for (int index = 0; index < listEntity.size(); index++) {
        LogicNodeOperationEntity operation = listEntity.get(index);
        if (!operation.getId().equals(this.nodeOperation.getId())) {
          if (operation.getOrderNum().equals(this.nodeOperation.getOrderNum())) {

            FacesMessage msg =
                new FacesMessage(
                    FacesMessage.SEVERITY_ERROR,
                    "Logic Node Operation",
                    "Number Order '"
                        + this.nodeOperation.getOrderNum()
                        + "' already exists on Logic Node "
                        + this.logicNodeBean.getLogicNode().getName());

            FacesContext.getCurrentInstance().addMessage(null, msg);

            return;
          }
        }
      }
      if (this.listNodeOperationValue.size() == 0) {
        FacesMessage msg =
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR,
                "Logic Node Operation",
                "You must configure at least one value on field 'Values'");

        FacesContext.getCurrentInstance().addMessage(null, msg);

        return;
      }
      for (LogicNodeValueEntity value : this.listNodeOperationValue) {
        if (value.getResultService().equals(1)) {
          if (this.logicNodeBean.getMapId() != null && this.logicNodeBean.getMapId().length() > 0) {
            LogicMapEntity map =
                ServicesFactory.getInstance()
                    .getLogicMapService()
                    .get(this.logicNodeBean.getMapId());
            if (map.getReturnType().equals("TEXT")
                && (value.getOperation().equals(">")
                    || value.getOperation().equals("<")
                    || value.getOperation().equals("BETWEEN"))) {
              FacesMessage msg =
                  new FacesMessage(
                      FacesMessage.SEVERITY_ERROR,
                      "Logic Node Operation",
                      "Return of MAP is TEXT and doesn't work properly with logical test '"
                          + value.getOperation()
                          + "' in VALUE number order '"
                          + value.getOrderNum()
                          + "' ");
              FacesContext.getCurrentInstance().addMessage(null, msg);
              return;
            }
          }
        }
      }
      this.nodeOperation.setListLogicNodeValues(this.listNodeOperationValue);

      if (this.insert) {
        this.logicNodeBean.getListNodeOperation().add(this.nodeOperation);
      }

      init();

      RequestContext context = RequestContext.getCurrentInstance();
      boolean saved = true;
      context.addCallbackParam("saved", saved);
    }
  }