Last active
June 24, 2020 13:52
-
-
Save ricardozanini/fdeaa2ffa0446d7f4c5f384b7be77853 to your computer and use it in GitHub Desktop.
order-approval.sw.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "neworderapproval", | |
"name": "New Order Approval", | |
"version": "1.0", | |
"events": [ | |
{ | |
"name": "newOrder", | |
"source": "orders/new", | |
"type": "knative", | |
"kind": "consumed" | |
}, | |
{ | |
"name": "orderDecision", | |
"source": "orders/decision", | |
"type": "knative", | |
"kind": "produced" | |
} | |
], | |
"functions": [ | |
{ | |
"name": "postOrderToFTP", | |
"type": "integration", | |
"resource": "camel:to:ftp:${{user}}@${{password}}:${{hostname}}", | |
"metadata": { | |
"config-map": "ftp-config", | |
"secret": "ftp-credentials" | |
} | |
}, | |
{ | |
"name": "needsApproval", | |
"type": "decision", | |
"resource": "git@github.com:myproject/orders-functions.git", | |
"metadata": { | |
"reference": "master", | |
"path": "decisions/src/order-manager-approval.dmn" | |
} | |
}, | |
{ | |
"name": "managementOrderApproval", | |
"type": "task", | |
"metadata": { | |
"taskname": "managerApproval", | |
"actorid": "managers", | |
"groupid": "managers" | |
} | |
} | |
], | |
"states": [ | |
{ | |
"name": "HandleNewOrder", | |
"type": "event", | |
"start": { | |
"kind": "default" | |
}, | |
"eventsActions": [ | |
{ | |
"eventRefs": [ | |
"newOrder" | |
], | |
"actions": [ | |
{ | |
"functionRef": { | |
"refName": "needsApproval" | |
} | |
} | |
] | |
} | |
], | |
"transition": { | |
"nextState": "CheckIfNeedManagerApproval" | |
} | |
}, | |
{ | |
"name": "CheckIfNeedManagerApproval", | |
"type": "switch", | |
"dataConditions": [ | |
{ | |
"path": "$.decision", | |
"value": "Approved", | |
"operator": "equals", | |
"transition": { | |
"nextState": "OrderAutoApproved" | |
} | |
}, | |
{ | |
"path": "$.decision", | |
"value": "NeedManagerApproval", | |
"operator": "equals", | |
"transition": { | |
"nextState": "OrderManagerApproval" | |
} | |
} | |
], | |
"default": { | |
"nextState": "OrderManagerApproval" | |
} | |
}, | |
{ | |
"name": "OrderAutoApproved", | |
"type": "inject", | |
"data": { | |
"finalDecision": "Approved" | |
}, | |
"end": { | |
"kind": "event", | |
"produceEvent": { | |
"eventRef": "orderDecision" | |
} | |
} | |
}, | |
{ | |
"name": "OrderManagerApproval", | |
"type": "operation", | |
"actionMode": "sequential", | |
"actions": [ | |
{ | |
"name": "managerAprovalAction", | |
"functionRef": { | |
"refName": "managementOrderApproval" | |
} | |
} | |
], | |
"end": { | |
"kind": "event", | |
"produceEvent": { | |
"eventRef": "orderDecision" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment