Пример #1
0
  public void addValue(ActionEvent event) {

    this.collect();

    for (LogicNodeValueEntity value : this.listNodeOperationValue) {
      if (value.getOrderNum().equals(this.nodeOperationValue.getOrderNum())) {
        FacesMessage msg =
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR,
                "Logic Node Operaton - Value",
                "Order Number(" + this.nodeOperationValue.getOrderNum() + ") already exists!");
        FacesContext.getCurrentInstance().addMessage(null, msg);
        return;
      }
    }

    if (this.nodeOperationValue.getResultService().equals(0)) {
      if (this.nodeOperationValue.getResultContext() == null
          || this.nodeOperationValue.getResultContext().length() == 0) {
        FacesMessage msg =
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR,
                "Logic Node Operaton - Value",
                "You must inform the context, ex: call.ani");
        FacesContext.getCurrentInstance().addMessage(null, msg);
        return;
      }
    }

    if (this.nodeOperationValue.getValue1() == null
        || this.nodeOperationValue.getValue1().length() == 0) {
      FacesMessage msg =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR,
              "Logic Node Operation - Value",
              "Please, inform Value1!");
      FacesContext.getCurrentInstance().addMessage(null, msg);
      return;
    }
    if (!(this.nodeOperationValue.getOperation().equals("=")
            || this.nodeOperationValue.getOperation().equals("<")
            || this.nodeOperationValue.getOperation().equals(">"))
        && (this.nodeOperationValue.getValue2() == null
            || this.nodeOperationValue.getValue2().length() == 0)) {
      FacesMessage msg =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR,
              "Logic Node Operation - Value",
              "Please, inform Value2!");
      FacesContext.getCurrentInstance().addMessage(null, msg);
      return;
    }
    this.nodeOperationValue.setId(Util.getUID());
    this.listNodeOperationValue.add(this.nodeOperationValue);

    this.nodeOperationValue = new LogicNodeValueEntity();
  }
Пример #2
0
 public void removeValue(String valueId) {
   boolean find = false;
   for (int index = 0; index < listNodeOperationValue.size() && !find; index++) {
     LogicNodeValueEntity value = listNodeOperationValue.get(index);
     if (value.getId().equals(valueId)) {
       find = true;
       listNodeOperationValue.remove(index);
     }
   }
 }
Пример #3
0
 public String describeCompareWith(String id) {
   String result = "";
   for (LogicNodeValueEntity value : this.listNodeOperationValue) {
     if (value.getId().equals(id)) {
       if (value.getResultService().equals(1)) {
         result = "MAP(";
         if (this.logicNodeBean != null) {
           if (this.logicNodeBean.getLogicNode().getLogicMap() != null) {
             result += this.logicNodeBean.getLogicNode().getLogicMap().getName() + ")";
           } else {
             result += "undefined)";
           }
         } else {
           result += "undefined)";
         }
       } else {
         result = "CONTEXT(" + value.getResultContext() + ")";
       }
     }
   }
   return result;
 }
Пример #4
0
  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);
    }
  }