浏览代码

调用活动节点

caixiaofeng 6 月之前
父节点
当前提交
be7a64cf0e

+ 2 - 0
flow-workflow/flow-workflow-entity/src/main/java/com/flow/constant/NodeTypeConstant.java

@@ -33,4 +33,6 @@ public interface NodeTypeConstant {
     String SUB = "sub";
     // 结束
     String END = "end";
+    // 调用活动
+    String CALL = "call";
 }

+ 43 - 0
flow-workflow/flow-workflow-entity/src/main/java/com/flow/entity/node/CallNode.java

@@ -0,0 +1,43 @@
+package com.flow.entity.node;
+
+import com.google.common.collect.Lists;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.flowable.bpmn.model.CallActivity;
+import org.flowable.bpmn.model.FlowElement;
+import org.flowable.bpmn.model.SequenceFlow;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class CallNode extends Node{
+    private String definitionId;
+    @Override
+    public List<FlowElement> convert() {
+        ArrayList<FlowElement> elements = Lists.newArrayList();
+        CallActivity callActivity = new CallActivity();
+        callActivity.setId(this.getId());
+        callActivity.setName(this.getName());
+        callActivity.setExecutionListeners(this.buidEventListener());
+        callActivity.setInheritVariables(true);
+        callActivity.setInheritBusinessKey(true);
+        callActivity.setCalledElementType("id");
+        callActivity.setCalledElement(this.definitionId);
+        callActivity.setProcessInstanceName(this.getName());
+        elements.add(callActivity);
+        // 下一个节点的连线
+        Node next = this.getNext();
+        SequenceFlow sequenceFlow = this.buildSequence(next);
+        elements.add(sequenceFlow);
+        // 下一个节点
+        if (Objects.nonNull(next)) {
+            next.setBranchId(this.getBranchId());
+            List<FlowElement> flowElements = next.convert();
+            elements.addAll(flowElements);
+        }
+        return elements;
+    }
+}

+ 1 - 0
flow-workflow/flow-workflow-entity/src/main/java/com/flow/entity/node/Node.java

@@ -36,6 +36,7 @@ import java.util.stream.Collectors;
         @JsonSubTypes.Type(value = HttpNode.class, name = NodeTypeConstant.HTTP),
         @JsonSubTypes.Type(value = ServiceNode.class, name = NodeTypeConstant.SERVICE),
         @JsonSubTypes.Type(value = SubNode.class, name = NodeTypeConstant.SUB),
+        @JsonSubTypes.Type(value = CallNode.class, name = NodeTypeConstant.CALL),
         @JsonSubTypes.Type(value = EndNode.class, name = NodeTypeConstant.END)
 })
 @JsonIgnoreProperties(ignoreUnknown = true)