Skip to content

Commit f345425

Browse files
committed
update fork draft
1 parent 1e52e57 commit f345425

File tree

7 files changed

+134
-15
lines changed

7 files changed

+134
-15
lines changed

website/docs/operations/06-fork.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ When drafting workflows that need conditional branching, use `WIO.draft.choice()
1717
```scala file=./main/scala/workflows4s/example/docs/DraftForkExample.scala start=start_draft end=end_draft
1818
```
1919

20+
<OperationOutputs name="draft-choice"/>
21+
2022
The draft choice operation simplifies the API by:
2123
- Not requiring explicit condition functions
22-
- Not requiring explicit event handling
23-
- Automatically generating names from the context if not provided
24-
- Providing a more intuitive interface for creating conditional branches
24+
- Automatically generating names from the context if not provided

workflows4s-example/src/main/scala/workflows4s/example/docs/DraftForkExample.scala

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,13 @@ object DraftForkExample {
88
import DraftContext._
99

1010
// start_draft
11-
// Create a simple approval workflow with conditional branching
1211
val approveStep = WIO.draft.step("Approve")
1312
val rejectStep = WIO.draft.step("Reject")
1413

1514
val approvalWorkflow = WIO.draft.choice("Review Decision")(
1615
"Approved" -> approveStep,
1716
"Rejected" -> rejectStep
1817
)
19-
20-
// Create a more complex workflow with multiple branches
21-
val processStep = WIO.draft.step("Process")
22-
val notifyStep = WIO.draft.step("Notify")
23-
val archiveStep = WIO.draft.step("Archive")
24-
25-
val complexWorkflow = WIO.draft.choice("Action Type")(
26-
"Process" -> (processStep >>> notifyStep),
27-
"Archive" -> archiveStep,
28-
"Skip" -> WIO.draft.step("Skip Processing")
29-
)
3018
// end_draft
3119
}
3220

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<definitions xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="definitions_0" targetNamespace="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">
3+
<process camunda:historyTimeToLive="P180D" id="process_2" isExecutable="true">
4+
<startEvent id="startEvent_13">
5+
<outgoing>sequenceFlow_5</outgoing>
6+
</startEvent>
7+
<exclusiveGateway id="exclusiveGateway_0" name="Review Decision">
8+
<incoming>sequenceFlow_5</incoming>
9+
<outgoing>sequenceFlow_6</outgoing>
10+
<outgoing>sequenceFlow_8</outgoing>
11+
</exclusiveGateway>
12+
<sequenceFlow id="sequenceFlow_5" sourceRef="startEvent_13" targetRef="exclusiveGateway_0"/>
13+
<sequenceFlow id="sequenceFlow_6" name="Approved" sourceRef="exclusiveGateway_0" targetRef="serviceTask_3">
14+
<conditionExpression id="conditionExpression_11"/>
15+
</sequenceFlow>
16+
<serviceTask id="serviceTask_3" name="Approve">
17+
<incoming>sequenceFlow_6</incoming>
18+
<outgoing>sequenceFlow_7</outgoing>
19+
</serviceTask>
20+
<exclusiveGateway id="exclusiveGateway_1">
21+
<incoming>sequenceFlow_7</incoming>
22+
<incoming>sequenceFlow_9</incoming>
23+
<outgoing>sequenceFlow_10</outgoing>
24+
</exclusiveGateway>
25+
<sequenceFlow id="sequenceFlow_7" sourceRef="serviceTask_3" targetRef="exclusiveGateway_1"/>
26+
<sequenceFlow id="sequenceFlow_8" name="Rejected" sourceRef="exclusiveGateway_0" targetRef="serviceTask_4">
27+
<conditionExpression id="conditionExpression_12"/>
28+
</sequenceFlow>
29+
<serviceTask id="serviceTask_4" name="Reject">
30+
<incoming>sequenceFlow_8</incoming>
31+
<outgoing>sequenceFlow_9</outgoing>
32+
</serviceTask>
33+
<sequenceFlow id="sequenceFlow_9" sourceRef="serviceTask_4" targetRef="exclusiveGateway_1"/>
34+
<endEvent id="endEvent_14">
35+
<incoming>sequenceFlow_10</incoming>
36+
</endEvent>
37+
<sequenceFlow id="sequenceFlow_10" sourceRef="exclusiveGateway_1" targetRef="endEvent_14"/>
38+
</process>
39+
<bpmndi:BPMNDiagram id="BpmnDiagram_0">
40+
<bpmndi:BPMNPlane bpmnElement="process_2" id="BpmnPlaneImpl_12">
41+
<bpmndi:BPMNShape bpmnElement="startEvent_13" id="BpmnShapeImpl_6">
42+
<dc:Bounds height="36.0" width="36.0" x="100.0" y="100.0"/>
43+
</bpmndi:BPMNShape>
44+
<bpmndi:BPMNShape bpmnElement="exclusiveGateway_0" id="BpmnShapeImpl_7" isMarkerVisible="true">
45+
<dc:Bounds height="50.0" width="50.0" x="186.0" y="93.0"/>
46+
</bpmndi:BPMNShape>
47+
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_5" id="BpmnEdgeImpl_0">
48+
<di:waypoint x="136.0" y="118.0"/>
49+
<di:waypoint x="186.0" y="118.0"/>
50+
</bpmndi:BPMNEdge>
51+
<bpmndi:BPMNShape bpmnElement="serviceTask_3" id="BpmnShapeImpl_8">
52+
<dc:Bounds height="80.0" width="100.0" x="286.0" y="78.0"/>
53+
</bpmndi:BPMNShape>
54+
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_6" id="BpmnEdgeImpl_1">
55+
<di:waypoint x="236.0" y="118.0"/>
56+
<di:waypoint x="286.0" y="118.0"/>
57+
</bpmndi:BPMNEdge>
58+
<bpmndi:BPMNShape bpmnElement="exclusiveGateway_1" id="BpmnShapeImpl_9" isMarkerVisible="true">
59+
<dc:Bounds height="50.0" width="50.0" x="436.0" y="93.0"/>
60+
</bpmndi:BPMNShape>
61+
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_7" id="BpmnEdgeImpl_2">
62+
<di:waypoint x="386.0" y="118.0"/>
63+
<di:waypoint x="436.0" y="118.0"/>
64+
</bpmndi:BPMNEdge>
65+
<bpmndi:BPMNShape bpmnElement="serviceTask_4" id="BpmnShapeImpl_10">
66+
<dc:Bounds height="80.0" width="100.0" x="286.0" y="208.0"/>
67+
</bpmndi:BPMNShape>
68+
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_8" id="BpmnEdgeImpl_3">
69+
<di:waypoint x="211.0" y="143.0"/>
70+
<di:waypoint x="211.0" y="248.0"/>
71+
<di:waypoint x="286.0" y="248.0"/>
72+
</bpmndi:BPMNEdge>
73+
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_9" id="BpmnEdgeImpl_4">
74+
<di:waypoint x="386.0" y="248.0"/>
75+
<di:waypoint x="436.0" y="118.0"/>
76+
</bpmndi:BPMNEdge>
77+
<bpmndi:BPMNShape bpmnElement="endEvent_14" id="BpmnShapeImpl_11">
78+
<dc:Bounds height="36.0" width="36.0" x="536.0" y="100.0"/>
79+
</bpmndi:BPMNShape>
80+
<bpmndi:BPMNEdge bpmnElement="sequenceFlow_10" id="BpmnEdgeImpl_5">
81+
<di:waypoint x="486.0" y="118.0"/>
82+
<di:waypoint x="536.0" y="118.0"/>
83+
</bpmndi:BPMNEdge>
84+
</bpmndi:BPMNPlane>
85+
</bpmndi:BPMNDiagram>
86+
</definitions>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"branches" : [
3+
{
4+
"meta" : {
5+
"name" : "Approve",
6+
"error" : null,
7+
"description" : null
8+
},
9+
"_type" : "RunIO"
10+
},
11+
{
12+
"meta" : {
13+
"name" : "Reject",
14+
"error" : null,
15+
"description" : null
16+
},
17+
"_type" : "RunIO"
18+
}
19+
],
20+
"meta" : {
21+
"name" : "Review Decision",
22+
"branches" : [
23+
{
24+
"name" : "Approved"
25+
},
26+
{
27+
"name" : "Rejected"
28+
}
29+
]
30+
},
31+
"_type" : "Fork"
32+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
flowchart TD
2+
node0@{ shape: circle, label: "Start"}
3+
node1@{ shape: hex, label: "Review Decision"}
4+
node0 --> node1
5+
node2["Approve"]
6+
node1 -->|"Approved"| node2
7+
node3["Reject"]
8+
node1 -->|"Rejected"| node3

workflows4s-example/src/test/resources/docs/draft-choice.svg

Lines changed: 4 additions & 0 deletions
Loading

workflows4s-example/src/test/scala/workflows4s/example/docs/ExamplesTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class ExamplesTest extends AnyFreeSpec {
2424
ExampleConfig("loop", LoopExample.loop),
2525
ExampleConfig("draft-loop", DraftLoopExample.loop),
2626
ExampleConfig("fork", ForkExample.fork),
27+
ExampleConfig("draft-choice", DraftForkExample.approvalWorkflow),
2728
ExampleConfig("parallel", ParallelExample.parallel),
2829
ExampleConfig("draft-parallel", DraftParallelExample.parallelWorkflow),
2930
ExampleConfig("interruption-signal", InterruptionExample.interruptedThroughSignal),

0 commit comments

Comments
 (0)