コード例 #1
0
 @Override
 public ValidationIssue<NodeWithDefaultFlowMustHaveConditionOneOtherEdge, AbstractNode>
     applyValidation(final AbstractNode node) {
   int defaultCount = 0;
   int conditionalCount = 0;
   int totalCount = 0;
   for (FlexoPostCondition p : node.getOutgoingPostConditions()) {
     if (p instanceof TokenEdge) {
       totalCount++;
       if (p.getIsDefaultFlow()) {
         defaultCount++;
       } else if (p.getIsConditional()) {
         conditionalCount++;
       }
     }
   }
   if (defaultCount > 0 && totalCount != defaultCount + conditionalCount) {
     if (node instanceof OperatorNode && ((OperatorNode) node).isExclusiveGateway()) {
       return null; // There is a rule on the post conditions to prevent this already!
     } else {
       ValidationWarning<NodeWithDefaultFlowMustHaveConditionOneOtherEdge, AbstractNode>
           warning =
               new ValidationWarning<
                   NodeWithDefaultFlowMustHaveConditionOneOtherEdge, AbstractNode>(
                   this,
                   node,
                   "node_($object.name)_has_one_default_outgoing_flow_and_so_other_edges_must_be_conditionnal");
       return warning;
     }
   }
   return null;
 }
コード例 #2
0
 @Override
 public ValidationIssue<NodeCannotHaveMoreThanOneDefaultOutgoingTokenEdge, AbstractNode>
     applyValidation(final AbstractNode node) {
   boolean hasAlreadyOne = false;
   for (FlexoPostCondition p : node.getOutgoingPostConditions()) {
     if (p instanceof TokenEdge && p.getIsDefaultFlow()) {
       if (hasAlreadyOne) {
         ValidationWarning<NodeCannotHaveMoreThanOneDefaultOutgoingTokenEdge, AbstractNode>
             warning =
                 new ValidationWarning<
                     NodeCannotHaveMoreThanOneDefaultOutgoingTokenEdge, AbstractNode>(
                     this, node, "node_($object.name)_has_more_than_one_default_outgoing_edge");
         return warning;
       } else {
         hasAlreadyOne = true;
       }
     }
   }
   return null;
 }
コード例 #3
0
    @Override
    public ValidationIssue<
            NodeWithConditionalEdgeOrDefaultEdgeMustHaveMoreThanOneEdge, AbstractNode>
        applyValidation(final AbstractNode node) {
      int defaultCount = 0;
      int conditionalCount = 0;
      int regular = 0;
      Vector<FlexoPostCondition<?, ?>> listOfAllPostToConsider =
          new Vector<FlexoPostCondition<?, ?>>();
      listOfAllPostToConsider.addAll(node.getOutgoingPostConditions());

      if ((node instanceof ActivityNode || node instanceof OperationNode)) {
        FlexoNode startNode = (FlexoNode) node;
        if (startNode.isEndNode()) {
          // try to find other brother end node with outgoing post
          for (PetriGraphNode brotherNode : startNode.getParentPetriGraph().getNodes()) {
            if (brotherNode instanceof FlexoNode) {
              if (((FlexoNode) brotherNode).isEndNode() && brotherNode != startNode) {
                return null;
              }
            }
          }
          if (startNode.getParentPetriGraph().getContainer() instanceof SubProcessNode) {
            SubProcessNode sub = (SubProcessNode) startNode.getParentPetriGraph().getContainer();
            if (sub.getPortMapRegistery().getAllOutPortmaps().size() > 0) {
              return null;
            }
          }
        }
      } else if (node instanceof FlexoPortMap && ((FlexoPortMap) node).isOutputPort()) {
        SubProcessNode sub = ((FlexoPortMap) node).getSubProcessNode();
        if (sub.getPortMapRegistery().getAllOutPortmaps().size() > 0) {
          return null;
        }
        if (sub.getOperationPetriGraph() != null
            && sub.getOperationPetriGraph().getAllEndNodes().size() > 0) {
          return null;
        }
      }

      for (FlexoPostCondition p : listOfAllPostToConsider) {
        if (p.getIsDefaultFlow()) {
          defaultCount++;
        } else if (p.getIsConditional()) {
          conditionalCount++;
        } else {
          regular++;
        }
      }
      if (defaultCount > 0 && (regular + conditionalCount) == 0) {
        if (node instanceof OperatorNode && ((OperatorNode) node).isExclusiveGateway()) {
          return null; // There is a rule on the post conditions to prevent this already!
        } else {
          ValidationWarning<
                  NodeWithConditionalEdgeOrDefaultEdgeMustHaveMoreThanOneEdge, AbstractNode>
              warning =
                  new ValidationWarning<
                      NodeWithConditionalEdgeOrDefaultEdgeMustHaveMoreThanOneEdge, AbstractNode>(
                      this,
                      node,
                      "node_($object.name)_has_one_default_outgoing_edge_should_have_at_least_another_outgoing_edge");
          return warning;
        }
      }
      if (conditionalCount == 1
          && regular == 0
          && defaultCount == 0
          && !listOfAllPostToConsider.firstElement().mustBeConditional()) {
        if (node instanceof OperatorNode && ((OperatorNode) node).isExclusiveGateway()) {
          return null; // There is a rule on the post conditions to prevent this already!
        } else {
          ValidationWarning<
                  NodeWithConditionalEdgeOrDefaultEdgeMustHaveMoreThanOneEdge, AbstractNode>
              warning =
                  new ValidationWarning<
                      NodeWithConditionalEdgeOrDefaultEdgeMustHaveMoreThanOneEdge, AbstractNode>(
                      this,
                      node,
                      "node_($object.name)_has_one_conditional_outgoing_edge_should_have_at_least_another_outgoing_edge");
          return warning;
        }
      }
      return null;
    }