Skip to content

Instantly share code, notes, and snippets.

@darbio
Created May 26, 2016 02:50
Show Gist options
  • Save darbio/ee2a25d951fdbbd93491cd220f706a35 to your computer and use it in GitHub Desktop.
Save darbio/ee2a25d951fdbbd93491cd220f706a35 to your computer and use it in GitHub Desktop.
bpmn won't progress to next task
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="StartEvent_0u6igzm" name="Start">
<bpmn:outgoing>SequenceFlow_0dj0shd</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:task id="Task_1j1u5jd" name="Send email">
<bpmn:incoming>SequenceFlow_0dj0shd</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1yqx4t9</bpmn:outgoing>
</bpmn:task>
<bpmn:task id="Task_0fqh9ez" name="Create user">
<bpmn:incoming>SequenceFlow_1yqx4t9</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0c2y283</bpmn:outgoing>
</bpmn:task>
<bpmn:endEvent id="EndEvent_0lggshx" name="End">
<bpmn:incoming>SequenceFlow_0c2y283</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0dj0shd" sourceRef="StartEvent_0u6igzm" targetRef="Task_1j1u5jd" />
<bpmn:sequenceFlow id="SequenceFlow_1yqx4t9" sourceRef="Task_1j1u5jd" targetRef="Task_0fqh9ez" />
<bpmn:sequenceFlow id="SequenceFlow_0c2y283" sourceRef="Task_0fqh9ez" targetRef="EndEvent_0lggshx" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="StartEvent_0u6igzm_di" bpmnElement="StartEvent_0u6igzm">
<dc:Bounds x="27.204950495049502" y="43.07326732673266" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="0.20495049504950202" y="79.07326732673266" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1j1u5jd_di" bpmnElement="Task_1j1u5jd">
<dc:Bounds x="115.2049504950495" y="21" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_0fqh9ez_di" bpmnElement="Task_0fqh9ez">
<dc:Bounds x="276.2049504950495" y="21" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_0lggshx_di" bpmnElement="EndEvent_0lggshx">
<dc:Bounds x="432.2049504950495" y="43" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="405.2049504950495" y="79" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0dj0shd_di" bpmnElement="SequenceFlow_0dj0shd">
<di:waypoint xsi:type="dc:Point" x="63" y="61" />
<di:waypoint xsi:type="dc:Point" x="115" y="61" />
<bpmndi:BPMNLabel>
<dc:Bounds x="44" y="36" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1yqx4t9_di" bpmnElement="SequenceFlow_1yqx4t9">
<di:waypoint xsi:type="dc:Point" x="215" y="61" />
<di:waypoint xsi:type="dc:Point" x="276" y="61" />
<bpmndi:BPMNLabel>
<dc:Bounds x="200.5" y="36" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0c2y283_di" bpmnElement="SequenceFlow_0c2y283">
<di:waypoint xsi:type="dc:Point" x="376" y="61" />
<di:waypoint xsi:type="dc:Point" x="432" y="61" />
<bpmndi:BPMNLabel>
<dc:Bounds x="359" y="36" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
exports.Start = function (data, done) {
console.log("Started business process");
done();
};
exports.Send_email = function (data, done) {
console.log("Sending email");
done(data);
};
exports.Create_user = function (data, done) {
console.log("Creating user");
setTimeout(function() {
console.log("Created user");
done(data);
}, 2000);
};
exports.End = function (data, done) {
console.log("Ending business process");
done();
};
/**
* @param {String} eventType Possible types are: "activityFinishedEvent", "callHandler"
* @param {String?} currentFlowObjectName The current activity or event
* @param {String} handlerName
* @param {String} reason Possible reasons:
* - no handler given
* - process is not in a state to handle the incoming event
* - the event is not defined in the process
* - the current state cannot be left because there are no outgoing flows
*/
exports.defaultEventHandler = function(eventType, currentFlowObjectName, handlerName, reason, done) {
// Called, if no handler could be invoked.
console.log("-- Handled by default handler --")
console.log("* Flow object: \t" + currentFlowObjectName);
console.log("* Handler name: \t" + handlerName);
console.log("* Reason: \t" + reason);
console.log("--");
done();
};
exports.defaultErrorHandler = function(error, done) {
// Called if errors are thrown in the event handlers
console.error(error);
done();
};
exports.onBeginHandler = function(currentFlowObjectName, data, done) {
// do something
console.log("Begin: " + currentFlowObjectName);
done(data);
};
exports.onEndHandler = function(currentFlowObjectName, data, done) {
// do something
console.log("End: " + currentFlowObjectName);
done(data);
};
var bpmn = require("bpmn");
var logLevels = require('bpmn').logLevels;
console.log("Starting");
bpmn.createUnmanagedProcess(__dirname + "/diagram.bpmn", function(err, myProcess) {
myProcess.setLogLevel(logLevels.debug);
myProcess.triggerEvent("Start");
});
console.log("Finished");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment