Skip to content

Commit 383dcc2

Browse files
author
Tihomir Surdilovic
committed
Update to spec - switch state data conditions
Signed-off-by: Tihomir Surdilovic <[email protected]>
1 parent 0b4cdf1 commit 383dcc2

File tree

9 files changed

+15
-137
lines changed

9 files changed

+15
-137
lines changed

api/src/main/java/io/serverlessworkflow/api/deserializers/DataConditionOperatorDeserializer.java

Lines changed: 0 additions & 71 deletions
This file was deleted.

api/src/main/java/io/serverlessworkflow/api/mapper/WorkflowModule.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ private void addDefaultDeserializers() {
7676
new OperationStateActionModeDeserializer(workflowPropertySource));
7777
addDeserializer(DefaultState.Type.class,
7878
new DefaultStateTypeDeserializer(workflowPropertySource));
79-
addDeserializer(DataCondition.Operator.class,
80-
new DataConditionOperatorDeserializer(workflowPropertySource));
8179
addDeserializer(EventDefinition.Kind.class, new EventDefinitionKindDeserializer(workflowPropertySource));
8280
addDeserializer(ParallelState.CompletionType.class, new ParallelStateCompletionTypeDeserializer(workflowPropertySource));
8381
addDeserializer(Schedule.DirectInvoke.class, new ScheduleDirectInvokeDeserializer(workflowPropertySource));

api/src/main/resources/schema/switchconditions/datacondition.json

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,17 @@
66
],
77
"description": "Switch state data based condition",
88
"properties": {
9-
"path": {
9+
"condition": {
1010
"type": "string",
11-
"description": "JSONPath expression that selects elements of state data"
12-
},
13-
"value": {
14-
"type": "string",
15-
"description": "Matching value"
16-
},
17-
"operator": {
18-
"type": "string",
19-
"enum": [
20-
"exists",
21-
"notexists",
22-
"null",
23-
"notnull",
24-
"equals",
25-
"notequals",
26-
"lessthan",
27-
"lessthanorequals",
28-
"greaterthan",
29-
"greaterthanorequals",
30-
"matches",
31-
"notmatches",
32-
"custom"
33-
],
34-
"description": "Condition operator"
11+
"description": "JsonPath expression evaluated against state data. True if results are not empty"
3512
},
3613
"transition": {
3714
"$ref": "../transitions/transition.json",
3815
"description": "Next transition of the workflow if there is valid matches"
3916
}
4017
},
4118
"required": [
42-
"path",
43-
"value",
44-
"operator",
19+
"condition",
4520
"transition"
4621
]
4722
}

api/src/test/resources/examples/applicantrequest.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@
1818
},
1919
"dataConditions": [
2020
{
21-
"path": "$.applicant.age",
22-
"value": "18",
23-
"operator": "greaterthanorequals",
21+
"condition": "{{ $.applicants[?(@.age >= 18)] }}",
2422
"transition": {
2523
"nextState": "StartApplication"
2624
}
2725
},
2826
{
29-
"path": "$.applicant.age",
30-
"value": "18",
31-
"operator": "lessthan",
27+
"condition": "{{ $.applicants[?(@.age < 18)] }}",
3228
"transition": {
3329
"nextState": "RejectApplication"
3430
}

api/src/test/resources/examples/applicantrequest.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,10 @@ states:
1212
start:
1313
kind: default
1414
dataConditions:
15-
- path: "$.applicant.age"
16-
value: '18'
17-
operator: greaterthanorequals
15+
- condition: "{{ $.applicants[?(@.age >= 18)] }}"
1816
transition:
1917
nextState: StartApplication
20-
- path: "$.applicant.age"
21-
value: '18'
22-
operator: lessthan
18+
- condition: "{{ $.applicants[?(@.age < 18)] }}"
2319
transition:
2420
nextState: RejectApplication
2521
default:

api/src/test/resources/examples/creditcheck.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,13 @@
5252
"type": "switch",
5353
"dataConditions": [
5454
{
55-
"path": "$.creditCheck.decision",
56-
"value": "Approved",
57-
"operator": "equals",
55+
"condition": "{{ $.creditCheck[?(@.decision == 'Approved')] }}",
5856
"transition": {
5957
"nextState": "StartApplication"
6058
}
6159
},
6260
{
63-
"path": "$.creditCheck.decision",
64-
"value": "Denied",
65-
"operator": "equals",
61+
"condition": "{{ $.creditCheck[?(@.decision == 'Denied')] }}",
6662
"transition": {
6763
"nextState": "RejectApplication"
6864
}

api/src/test/resources/examples/creditcheck.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@ states:
3232
- name: EvaluateDecision
3333
type: switch
3434
dataConditions:
35-
- path: "$.creditCheck.decision"
36-
value: Approved
37-
operator: equals
35+
- condition: "{{ $.creditCheck[?(@.decision == 'Approved')] }}"
3836
transition:
3937
nextState: StartApplication
40-
- path: "$.creditCheck.decision"
41-
value: Denied
42-
operator: equals
38+
- condition: "{{ $.creditCheck[?(@.decision == 'Denied')] }}"
4339
transition:
4440
nextState: RejectApplication
4541
default:

api/src/test/resources/examples/jobmonitoring.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,13 @@
8686
"type":"switch",
8787
"dataConditions": [
8888
{
89-
"path": "$.jobstatus",
90-
"value": "SUCCEEDED",
91-
"operator": "equals",
89+
"condition": "{{ $[?(@.jobstatus == 'SUCCEEDED')] }}",
9290
"transition": {
9391
"nextState": "JobSucceeded"
9492
}
9593
},
9694
{
97-
"path": "$.jobstatus",
98-
"value": "FAILED",
99-
"operator": "equals",
95+
"condition": "{{ $[?(@.jobstatus == 'FAILED')] }}",
10096
"transition": {
10197
"nextState": "JobFailed"
10298
}

api/src/test/resources/examples/jobmonitoring.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,10 @@ states:
5151
- name: DetermineCompletion
5252
type: switch
5353
dataConditions:
54-
- path: "$.jobstatus"
55-
value: SUCCEEDED
56-
operator: equals
54+
- condition: "{{ $[?(@.jobstatus == 'SUCCEEDED')] }}"
5755
transition:
5856
nextState: JobSucceeded
59-
- path: "$.jobstatus"
60-
value: FAILED
61-
operator: equals
57+
- condition: "{{ $[?(@.jobstatus == 'FAILED')] }}"
6258
transition:
6359
nextState: JobFailed
6460
default:

0 commit comments

Comments
 (0)