Skip to content

Commit 2a7cd56

Browse files
authored
Merge pull request #1052 from lfbertucci/AddProceedOnCancelToDslDefinitionLoader
Add ProceedOnCancel to WorkflowCore.DSL definition loader
2 parents 8fa1fb7 + 449843d commit 2a7cd56

File tree

9 files changed

+81
-3
lines changed

9 files changed

+81
-3
lines changed

src/WorkflowCore.DSL/Models/v1/StepSourceV1.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace WorkflowCore.Models.DefinitionStorage.v1
77
public class StepSourceV1
88
{
99
public string StepType { get; set; }
10-
10+
1111
public string Id { get; set; }
1212

1313
public string Name { get; set; }
@@ -29,8 +29,9 @@ public class StepSourceV1
2929
public ExpandoObject Inputs { get; set; } = new ExpandoObject();
3030

3131
public Dictionary<string, string> Outputs { get; set; } = new Dictionary<string, string>();
32-
32+
3333
public Dictionary<string, string> SelectNextStep { get; set; } = new Dictionary<string, string>();
3434

35+
public bool ProceedOnCancel { get; set; } = false;
3536
}
3637
}

src/WorkflowCore.DSL/Services/DefinitionLoader.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ private WorkflowStepCollection ConvertSteps(ICollection<StepSourceV1> source, Ty
101101
targetStep.ErrorBehavior = nextStep.ErrorBehavior;
102102
targetStep.RetryInterval = nextStep.RetryInterval;
103103
targetStep.ExternalId = $"{nextStep.Id}";
104+
targetStep.ProceedOnCancel = nextStep.ProceedOnCancel;
104105

105106
AttachInputs(nextStep, dataType, stepType, targetStep);
106107
AttachOutputs(nextStep, dataType, stepType, targetStep);

test/WorkflowCore.IntegrationTests/Scenarios/StoredJsonScenario.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public void should_execute_branch1()
3131
data.Counter6.Should().Be(1);
3232
data.Counter7.Should().Be(1);
3333
data.Counter8.Should().Be(0);
34+
data.Counter10.Should().Be(1);
3435
}
3536

3637
[Fact(DisplayName = "Execute branch 2")]
@@ -50,6 +51,7 @@ public void should_execute_branch2()
5051
data.Counter6.Should().Be(1);
5152
data.Counter7.Should().Be(0);
5253
data.Counter8.Should().Be(1);
54+
data.Counter10.Should().Be(1);
5355
}
5456

5557
[Fact]
@@ -64,7 +66,8 @@ public void should_execute_json_workflow_with_dynamic_data()
6466
["Counter3"] = 0,
6567
["Counter4"] = 0,
6668
["Counter5"] = 0,
67-
["Counter6"] = 0
69+
["Counter6"] = 0,
70+
["Counter10"] = 0
6871
};
6972

7073
var workflowId = StartWorkflow(TestAssets.Utils.GetTestDefinitionDynamicJson(), initialData);
@@ -79,6 +82,7 @@ public void should_execute_json_workflow_with_dynamic_data()
7982
data["Counter4"].Should().Be(1);
8083
data["Counter5"].Should().Be(0);
8184
data["Counter6"].Should().Be(1);
85+
data["Counter10"].Should().Be(1);
8286
}
8387
}
8488
}

test/WorkflowCore.IntegrationTests/Scenarios/StoredYamlScenario.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public void should_execute_yaml_workflow()
2929
data.Counter4.Should().Be(1);
3030
data.Counter5.Should().Be(0);
3131
data.Counter6.Should().Be(1);
32+
data.Counter10.Should().Be(1);
3233
}
3334
}
3435
}

test/WorkflowCore.TestAssets/DataTypes/CounterBoard.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class CounterBoard
1313
public int Counter7 { get; set; }
1414
public int Counter8 { get; set; }
1515
public int Counter9 { get; set; }
16+
public int Counter10 { get; set; }
1617
public bool Flag1 { get; set; }
1718
public bool Flag2 { get; set; }
1819
public bool Flag3 { get; set; }

test/WorkflowCore.TestAssets/stored-definition.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,26 @@
5858
"Inputs": { "Value": "data.Counter5" },
5959
"Outputs": { "Counter5": "step.Value" }
6060
}
61+
],
62+
[
63+
{
64+
"Id": "Step3.3.1",
65+
"StepType": "WorkflowCore.Primitives.WaitFor, WorkflowCore",
66+
"NextStepId": "Step3.3.2",
67+
"CancelCondition": "data.Flag2",
68+
"ProceedOnCancel": true,
69+
"Inputs": {
70+
"EventName": "\"Event1\"",
71+
"EventKey": "\"Key1\"",
72+
"EffectiveDate": "DateTime.Now"
73+
}
74+
},
75+
{
76+
"Id": "Step3.3.2",
77+
"StepType": "WorkflowCore.TestAssets.Steps.Counter, WorkflowCore.TestAssets",
78+
"Inputs": { "Value": "data.Counter10" },
79+
"Outputs": { "Counter10": "step.Value" }
80+
}
6181
]
6282
]
6383
},

test/WorkflowCore.TestAssets/stored-definition.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ Steps:
5050
Value: data.Counter5
5151
Outputs:
5252
Counter5: step.Value
53+
- - Id: Step3.3.1
54+
StepType: WorkflowCore.Primitives.WaitFor, WorkflowCore
55+
NextStepId: Step3.3.2
56+
CancelCondition: data.Flag2
57+
ProceedOnCancel: true
58+
Inputs:
59+
EventName: '"Event1"'
60+
EventKey: '"Key1"'
61+
EffectiveDate: DateTime.Now
62+
- Id: Step3.3.2
63+
StepType: WorkflowCore.TestAssets.Steps.Counter, WorkflowCore.TestAssets
64+
Inputs:
65+
Value: data.Counter10
66+
Outputs:
67+
Counter10: step.Value
5368
- Id: Step4
5469
StepType: WorkflowCore.TestAssets.Steps.Counter, WorkflowCore.TestAssets
5570
Inputs:

test/WorkflowCore.TestAssets/stored-dynamic-definition.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@
5757
"Inputs": { "Value": "data[\"Counter5\"]" },
5858
"Outputs": { "Counter5": "step.Value" }
5959
}
60+
],
61+
[
62+
{
63+
"Id": "Step3.3.1",
64+
"StepType": "WorkflowCore.Primitives.WaitFor, WorkflowCore",
65+
"NextStepId": "Step3.3.2",
66+
"CancelCondition": "object.Equals(data[\"Flag2\"], true)",
67+
"ProceedOnCancel": true,
68+
"Inputs": {
69+
"EventName": "\"Event1\"",
70+
"EventKey": "\"Key1\"",
71+
"EffectiveDate": "DateTime.Now"
72+
}
73+
},
74+
{
75+
"Id": "Step3.3.2",
76+
"StepType": "WorkflowCore.TestAssets.Steps.Counter, WorkflowCore.TestAssets",
77+
"Inputs": { "Value": "data[\"Counter10\"]" },
78+
"Outputs": { "Counter10": "step.Value" }
79+
}
6080
]
6181
]
6282
},

test/WorkflowCore.TestAssets/stored-dynamic-definition.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ Steps:
5050
Value: data.Counter5
5151
Outputs:
5252
Counter5: step.Value
53+
- - Id: Step3.3.1
54+
StepType: WorkflowCore.Primitives.WaitFor, WorkflowCore
55+
NextStepId: Step3.3.2
56+
CancelCondition: data.Flag2
57+
ProceedOnCancel: true
58+
Inputs:
59+
EventName: '"Event1"'
60+
EventKey: '"Key1"'
61+
EffectiveDate: DateTime.Now
62+
- Id: Step3.3.2
63+
StepType: WorkflowCore.TestAssets.Steps.Counter, WorkflowCore.TestAssets
64+
Inputs:
65+
Value: data.Counter10
66+
Outputs:
67+
Counter10: step.Value
5368
- Id: Step4
5469
StepType: WorkflowCore.TestAssets.Steps.Counter, WorkflowCore.TestAssets
5570
Inputs:

0 commit comments

Comments
 (0)