Skip to content

Commit

Permalink
Merge pull request #11 from 5minds/feature/emit-event-in-process-engine
Browse files Browse the repository at this point in the history
Feature/emit event in engine
  • Loading branch information
moellenbeck authored Jun 19, 2024
2 parents 0af97c3 + 510fd9b commit 0e7d1a1
Show file tree
Hide file tree
Showing 9 changed files with 374 additions and 657 deletions.
41 changes: 41 additions & 0 deletions message-event-trigger.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script type="text/javascript">
RED.nodes.registerType('message-event-trigger',{
category: 'ProcessCube',
color: '#00aed7',
defaults: {
name: {value: ""},
engine: {value: "", type: "processcube-engine-config"},
messagename: {value: "", required: true},
processInstanceId: {value:""}
},
inputs: 1,
outputs: 1,
icon: "font-awesome/fa-envelope-open",
label: function() {
return this.name||"message-event-trigger";
}
});
</script>

<script type="text/html" data-template-name="message-event-trigger">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine</label>
<input type="text" id="node-input-engine" placeholder="Engine">
</div>
<div class="form-row">
<label for="node-input-messagename"><i class="fa fa-tag"></i> Message Name</label>
<input type="text" id="node-input-messagename" placeholder="Name of the Message-Event">
</div>
<div class="form-row">
<label for="node-input-processinstanceid"><i class="fa fa-tag"></i> Process Instance Id</label>
<input type="text" id="node-input-processinstanceid" placeholder="Id of the recipient process instance">
</div>
</script>

<script type="text/html" data-help-name="externaltask-input">
<p>A node which emmits an message event to the Engine.</p>
</script>
44 changes: 44 additions & 0 deletions message-event-trigger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const process = require('process');

const engine_client = require('@5minds/processcube_engine_client');

module.exports = function(RED) {
function MessageEventTrigger(config) {
RED.nodes.createNode(this, config);
var node = this;
var nodeContext = node.context();

this.engine = this.server = RED.nodes.getNode(config.engine);

const engineUrl = this.engine?.url || process.env.ENGINE_URL || 'http://engine:8000';

var client = nodeContext.get('client');

if (!client) {
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
client = nodeContext.get('client');
}

node.on('input', function(msg) {

client.events.triggerMessageEvent(
config.messagename,
{
processInstanceId: config.processinstanceid,
payload: msg.payload
}

).then((result) => {

msg.payload = result;

node.send(msg);
node.status({fill: "blue", shape: "dot", text: `message event triggered`});

}).catch((error) => {
node.error(error);
});
});
}
RED.nodes.registerType("message-event-trigger", MessageEventTrigger);
}
102 changes: 51 additions & 51 deletions nodered/.node-red-contrib-processcube-flows.json.backup
Original file line number Diff line number Diff line change
Expand Up @@ -168,33 +168,6 @@
"w": 712,
"h": 142
},
{
"id": "bd2bef99e757d7bf",
"type": "group",
"z": "b195bc3ca2e1a665",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"3ad37ecdb59b7314",
"54a2572d4a48cf34",
"4813eab6c5a5faf9",
"1a237533ba8a9376",
"4f4ff5d35037207a",
"19184f75b76893d0",
"df4a9e9bf8c4077e"
],
"x": 14,
"y": 619,
"w": 852,
"h": 182
},
{
"id": "02fef81e2129ea71",
"type": "group",
Expand Down Expand Up @@ -252,10 +225,37 @@
"605e432d57d4a7e6"
],
"x": 14,
"y": 819,
"y": 839,
"w": 1512,
"h": 282
},
{
"id": "bd2bef99e757d7bf",
"type": "group",
"z": "b195bc3ca2e1a665",
"style": {
"stroke": "#999999",
"stroke-opacity": "1",
"fill": "none",
"fill-opacity": "1",
"label": true,
"label-position": "nw",
"color": "#a4a4a4"
},
"nodes": [
"3ad37ecdb59b7314",
"54a2572d4a48cf34",
"4813eab6c5a5faf9",
"1a237533ba8a9376",
"4f4ff5d35037207a",
"19184f75b76893d0",
"df4a9e9bf8c4077e"
],
"x": 14,
"y": 639,
"w": 852,
"h": 182
},
{
"id": "d042a4c68f51d6ab",
"type": "processcube-engine-config",
Expand Down Expand Up @@ -2375,7 +2375,7 @@
"name": "Message für neue UserTasks",
"info": "",
"x": 160,
"y": 680,
"y": 700,
"wires": []
},
{
Expand All @@ -2387,7 +2387,7 @@
"engine": "d042a4c68f51d6ab",
"multisend": false,
"x": 140,
"y": 760,
"y": 780,
"wires": [
[
"4813eab6c5a5faf9",
Expand All @@ -2413,7 +2413,7 @@
"className": "",
"name": "",
"x": 750,
"y": 760,
"y": 780,
"wires": [
[]
]
Expand All @@ -2432,7 +2432,7 @@
"finalize": "",
"libs": [],
"x": 550,
"y": 760,
"y": 780,
"wires": [
[
"4f4ff5d35037207a"
Expand All @@ -2448,7 +2448,7 @@
"engine": "d042a4c68f51d6ab",
"multisend": false,
"x": 360,
"y": 760,
"y": 780,
"wires": [
[
"1a237533ba8a9376",
Expand All @@ -2470,7 +2470,7 @@
"statusVal": "",
"statusType": "auto",
"x": 560,
"y": 660,
"y": 680,
"wires": []
},
{
Expand Down Expand Up @@ -2574,7 +2574,7 @@
"name": "Laden von Prozessen, die gestartet werden können",
"info": "",
"x": 250,
"y": 860,
"y": 880,
"wires": []
},
{
Expand All @@ -2585,7 +2585,7 @@
"ui": "26a45d43c064bdb6",
"name": "",
"x": 140,
"y": 980,
"y": 1000,
"wires": [
[
"20f5318774b56550"
Expand All @@ -2611,7 +2611,7 @@
"repair": false,
"outputs": 1,
"x": 380,
"y": 1000,
"y": 1020,
"wires": [
[
"eb1669dc281aacda"
Expand All @@ -2637,7 +2637,7 @@
"repair": false,
"outputs": 1,
"x": 400,
"y": 940,
"y": 960,
"wires": [
[
"a5074076a34de015"
Expand All @@ -2662,7 +2662,7 @@
"senderr": false,
"headers": [],
"x": 410,
"y": 1060,
"y": 1080,
"wires": [
[
"85d11ea49087d7a8"
Expand All @@ -2688,7 +2688,7 @@
"payload": "do",
"payloadType": "str",
"x": 150,
"y": 1060,
"y": 1080,
"wires": [
[
"eb1669dc281aacda"
Expand All @@ -2709,7 +2709,7 @@
"finalize": "",
"libs": [],
"x": 610,
"y": 1060,
"y": 1080,
"wires": [
[
"0061d335785a97c5",
Expand All @@ -2731,7 +2731,7 @@
"statusVal": "",
"statusType": "auto",
"x": 800,
"y": 1060,
"y": 1080,
"wires": []
},
{
Expand All @@ -2752,7 +2752,7 @@
"selectionType": "click",
"columns": [],
"x": 810,
"y": 1000,
"y": 1020,
"wires": [
[
"807dd2529783550b",
Expand Down Expand Up @@ -2783,10 +2783,10 @@
"topic": "topic",
"topicType": "msg",
"x": 120,
"y": 940,
"y": 1040,
"wires": [
[
"20f5318774b56550"
"eb1669dc281aacda"
]
]
},
Expand All @@ -2804,7 +2804,7 @@
"statusVal": "",
"statusType": "auto",
"x": 1000,
"y": 1060,
"y": 1080,
"wires": []
},
{
Expand All @@ -2817,7 +2817,7 @@
"processmodel": "",
"startevent": "",
"x": 1250,
"y": 1000,
"y": 1020,
"wires": [
[
"605e432d57d4a7e6"
Expand All @@ -2838,7 +2838,7 @@
"finalize": "",
"libs": [],
"x": 1030,
"y": 1000,
"y": 1020,
"wires": [
[
"176a754c8b39063c"
Expand All @@ -2864,7 +2864,7 @@
"payload": "{\"processModelName\":\"Sample_UserTask\",\"startEventName\":\"Start\",\"processModelId\":\"Sample_UserTask_Process\",\"startEventId\":\"StartEvent_1\"}",
"payloadType": "json",
"x": 830,
"y": 940,
"y": 960,
"wires": [
[
"b185b133c9ab43f9"
Expand Down Expand Up @@ -2901,7 +2901,7 @@
"a4f0eee35f06b1ff"
],
"x": 295,
"y": 720,
"y": 740,
"wires": []
},
{
Expand All @@ -2918,7 +2918,7 @@
"statusVal": "",
"statusType": "auto",
"x": 1420,
"y": 1000,
"y": 1020,
"wires": []
}
]
Loading

0 comments on commit 0e7d1a1

Please sign in to comment.