Skip to content

Commit 315045b

Browse files
author
Tihomir Surdilovic
committed
Update to latest spec schemas
Signed-off-by: Tihomir Surdilovic <[email protected]>
1 parent ce94794 commit 315045b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+353
-371
lines changed
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@
1919
import com.fasterxml.jackson.core.JsonParser;
2020
import com.fasterxml.jackson.databind.DeserializationContext;
2121
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
22-
import io.serverlessworkflow.api.events.EventsActions;
22+
import io.serverlessworkflow.api.events.OnEvents;
2323
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
2424
import org.slf4j.Logger;
2525
import org.slf4j.LoggerFactory;
2626

2727
import java.io.IOException;
2828

29-
public class EventsActionsActionModeDeserializer extends StdDeserializer<EventsActions.ActionMode> {
29+
public class OnEventsActionModeDeserializer extends StdDeserializer<OnEvents.ActionMode> {
3030

3131
private static final long serialVersionUID = 510l;
32-
private static Logger logger = LoggerFactory.getLogger(EventsActionsActionModeDeserializer.class);
32+
private static Logger logger = LoggerFactory.getLogger(OnEventsActionModeDeserializer.class);
3333

3434
private WorkflowPropertySource context;
3535

36-
public EventsActionsActionModeDeserializer() {
37-
this(EventsActions.ActionMode.class);
36+
public OnEventsActionModeDeserializer() {
37+
this(OnEvents.ActionMode.class);
3838
}
3939

40-
public EventsActionsActionModeDeserializer(WorkflowPropertySource context) {
41-
this(EventsActions.ActionMode.class);
40+
public OnEventsActionModeDeserializer(WorkflowPropertySource context) {
41+
this(OnEvents.ActionMode.class);
4242
this.context = context;
4343
}
4444

45-
public EventsActionsActionModeDeserializer(Class<?> vc) {
45+
public OnEventsActionModeDeserializer(Class<?> vc) {
4646
super(vc);
4747
}
4848

4949
@Override
50-
public EventsActions.ActionMode deserialize(JsonParser jp,
50+
public OnEvents.ActionMode deserialize(JsonParser jp,
5151
DeserializationContext ctxt) throws IOException {
5252

5353
String value = jp.getText();
@@ -56,16 +56,16 @@ public EventsActions.ActionMode deserialize(JsonParser jp,
5656
String result = context.getPropertySource().getProperty(value);
5757

5858
if (result != null) {
59-
return EventsActions.ActionMode.fromValue(result);
59+
return OnEvents.ActionMode.fromValue(result);
6060
} else {
61-
return EventsActions.ActionMode.fromValue(jp.getText());
61+
return OnEvents.ActionMode.fromValue(jp.getText());
6262
}
6363
} catch (Exception e) {
6464
logger.info("Exception trying to evaluate property: {}", e.getMessage());
65-
return EventsActions.ActionMode.fromValue(jp.getText());
65+
return OnEvents.ActionMode.fromValue(jp.getText());
6666
}
6767
} else {
68-
return EventsActions.ActionMode.fromValue(jp.getText());
68+
return OnEvents.ActionMode.fromValue(jp.getText());
6969
}
7070
}
7171
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.fasterxml.jackson.databind.module.SimpleModule;
2020
import io.serverlessworkflow.api.deserializers.*;
2121
import io.serverlessworkflow.api.events.EventDefinition;
22-
import io.serverlessworkflow.api.events.EventsActions;
22+
import io.serverlessworkflow.api.events.OnEvents;
2323
import io.serverlessworkflow.api.interfaces.Extension;
2424
import io.serverlessworkflow.api.interfaces.State;
2525
import io.serverlessworkflow.api.interfaces.WorkflowPropertySource;
@@ -28,7 +28,6 @@
2828
import io.serverlessworkflow.api.states.DefaultState;
2929
import io.serverlessworkflow.api.states.OperationState;
3030
import io.serverlessworkflow.api.states.ParallelState;
31-
import io.serverlessworkflow.api.switchconditions.DataCondition;
3231

3332
public class WorkflowModule extends SimpleModule {
3433

@@ -70,8 +69,8 @@ private void addDefaultDeserializers() {
7069
new StateDeserializer(workflowPropertySource));
7170
addDeserializer(String.class,
7271
new StringValueDeserializer(workflowPropertySource));
73-
addDeserializer(EventsActions.ActionMode.class,
74-
new EventsActionsActionModeDeserializer(workflowPropertySource));
72+
addDeserializer(OnEvents.ActionMode.class,
73+
new OnEventsActionModeDeserializer(workflowPropertySource));
7574
addDeserializer(OperationState.ActionMode.class,
7675
new OperationStateActionModeDeserializer(workflowPropertySource));
7776
addDeserializer(DefaultState.Type.class,

api/src/main/resources/schema/branches/branch.json

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,22 @@
1515
"$ref": "../actions/action.json"
1616
}
1717
},
18-
"states": {
19-
"type": "array",
20-
"description": "State Definitions",
21-
"items": {
22-
"type": "object",
23-
"existingJavaType": "io.serverlessworkflow.api.interfaces.State"
24-
}
18+
"workflowId": {
19+
"type": "string",
20+
"description": "Unique Id of a workflow to be executed in this branch"
2521
}
2622
},
2723
"oneOf": [
2824
{
2925
"required": [
3026
"name",
31-
"states"
27+
"actions"
3228
]
3329
},
3430
{
3531
"required": [
3632
"name",
37-
"actions"
33+
"workflowId "
3834
]
3935
}
4036
]

api/src/main/resources/schema/events/eventsactions.json renamed to api/src/main/resources/schema/events/onevents.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"type": "object",
3-
"javaType": "io.serverlessworkflow.api.events.EventsActions",
3+
"javaType": "io.serverlessworkflow.api.events.OnEvents",
44
"description": "Actions to be performed on Events arrival",
55
"properties": {
66
"eventRefs": {
@@ -28,7 +28,6 @@
2828
"$ref": "../actions/action.json"
2929
}
3030
},
31-
3231
"eventDataFilter": {
3332
"$ref": "../filters/eventdatafilter.json"
3433
}

api/src/main/resources/schema/states/eventstate.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
"default": true,
1515
"description": "If true consuming one of the defined events causes its associated actions to be performed. If false all of the defined events must be consumed in order for actions to be performed"
1616
},
17-
"eventsActions": {
17+
"onEvents": {
1818
"type": "array",
1919
"description": "Define what events trigger one or more actions to be performed",
2020
"items": {
2121
"type": "object",
22-
"$ref": "../events/eventsactions.json"
22+
"$ref": "../events/onevents.json"
2323
}
2424
},
2525
"timeout": {
@@ -28,6 +28,6 @@
2828
}
2929
},
3030
"required": [
31-
"eventsActions"
31+
"onevents"
3232
]
3333
}

api/src/main/resources/schema/states/foreachstate.json

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,29 @@
44
"javaInterfaces": [
55
"io.serverlessworkflow.api.interfaces.State"
66
],
7-
"description": "Execute a set of defined states for each element of the data input array",
7+
"description": "Execute a set of defined actions or workflows for each element of a data array",
88
"extends": {
99
"$ref": "defaultstate.json"
1010
},
1111
"properties": {
1212
"inputCollection": {
1313
"type": "string",
14-
"description": "JSONPath expression selecting an JSON array element of the states data input"
14+
"description": "JsonPath expression selecting an array element of the states data"
1515
},
1616
"outputCollection": {
1717
"type": "string",
18-
"description": "JSONPath expression specifying where in the states data output to place the final data output of each iteration of the executed states"
18+
"description": "JsonPath expression specifying an array element of the states data to add the results of each iteration"
1919
},
20-
"inputParameter": {
20+
"iterationParam": {
2121
"type": "string",
22-
"description": "JSONPath expression specifying an JSON object field of the states data input. For each parallel iteration, this field will get populated with a unique element of the inputCollection array"
22+
"description": "Name of the iteration parameter that can be referenced in actions/workflow. For each parallel iteration, this param should contain an unique element of the inputCollection array"
2323
},
2424
"max": {
2525
"type": "integer",
2626
"default": "0",
2727
"minimum": 0,
2828
"description": "Specifies how upper bound on how many iterations may run in parallel"
2929
},
30-
"timeDelay": {
31-
"type": "string",
32-
"description": "Amount of time (ISO 8601 format) to wait between each iteration "
33-
},
3430
"actions": {
3531
"type": "array",
3632
"description": "Actions to be executed for each of the elements of inputCollection",
@@ -39,13 +35,9 @@
3935
"$ref": "../actions/action.json"
4036
}
4137
},
42-
"states": {
43-
"type": "array",
44-
"description": "States to be executed for each of the elements of inputCollection",
45-
"items": {
46-
"type": "object",
47-
"existingJavaType": "io.serverlessworkflow.api.interfaces.State"
48-
}
38+
"workflowId": {
39+
"type": "string",
40+
"description": "Unique Id of a workflow to be executed for each of the elements of inputCollection"
4941
}
5042
},
5143
"oneOf": [
@@ -55,7 +47,7 @@
5547
"type",
5648
"inputCollection",
5749
"inputParameter",
58-
"states",
50+
"workflowId",
5951
"end"
6052
]
6153
},
@@ -65,7 +57,7 @@
6557
"type",
6658
"inputCollection",
6759
"inputParameter",
68-
"states",
60+
"workflowId",
6961
"transition"
7062
]
7163
},
@@ -76,7 +68,7 @@
7668
"type",
7769
"inputCollection",
7870
"inputParameter",
79-
"states",
71+
"workflowId",
8072
"end"
8173
]
8274
},
@@ -87,7 +79,7 @@
8779
"type",
8880
"inputCollection",
8981
"inputParameter",
90-
"states",
82+
"workflowId",
9183
"transition"
9284
]
9385
},

api/src/test/java/io/serverlessworkflow/api/test/MarkupToWorkflowTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public class MarkupToWorkflowTest {
4242
"/examples/solvemathproblems.json", "/examples/solvemathproblems.yml",
4343
"/examples/foreachstatewithactions.json", "/examples/foreachstatewithactions.yml",
4444
"/examples/periodicinboxcheck.json", "/examples/periodicinboxcheck.yml",
45-
"/examples/vetappointmentservice.json", "/examples/vetappointmentservice.yml"
45+
"/examples/vetappointmentservice.json", "/examples/vetappointmentservice.yml",
46+
"/examples/eventbasedtransition.json", "/examples/eventbasedtransition.yml"
4647
})
4748
public void testSpecExamplesParsing(String workflowLocation) {
4849
Workflow workflow = Workflow.fromSource(WorkflowTestUtils.readWorkflowFile(workflowLocation));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"functionRef": {
5252
"refName": "sendRejectionEmailFunction",
5353
"parameters": {
54-
"applicant": "$.applicant"
54+
"applicant": "{{ $.applicant }}"
5555
}
5656
}
5757
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
id: applicantrequest
32
version: '1.0'
43
name: Applicant Request Decision Workflow
@@ -32,6 +31,6 @@ states:
3231
- functionRef:
3332
refName: sendRejectionEmailFunction
3433
parameters:
35-
applicant: "$.applicant"
34+
applicant: "{{ $.applicant }}"
3635
end:
37-
kind: default
36+
kind: default

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
}
2929
},
3030
"exclusive": true,
31-
"eventsActions": [
31+
"onEvents": [
3232
{
3333
"eventRefs": ["CarBidEvent"],
3434
"actions": [{
3535
"functionRef": {
3636
"refName": "StoreBidFunction",
3737
"parameters": {
38-
"bid": "$.bid"
38+
"bid": "{{ $.bid }}"
3939
}
4040
}
4141
}]

0 commit comments

Comments
 (0)