Created
May 26, 2016 03:08
-
-
Save darbio/18c42ae537b97ddc4d73714b189520be to your computer and use it in GitHub Desktop.
Task bpmn code
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
var bpmn = require("bpmn"); | |
var logLevels = require('bpmn').logLevels; | |
console.log("Starting"); | |
bpmn.createUnmanagedProcess(__dirname + "/task.bpmn", function(err, myProcess) { | |
myProcess.setLogLevel(logLevels.debug); | |
myProcess.triggerEvent("MyStart"); | |
}); | |
console.log("Finished"); |
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
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:debugger="http://e2e.ch/bpmneditor/debugger"> | |
<bpmn:extensionElements> | |
<debugger:position href="http://localhost:7261/grapheditor/debugger/position"/> | |
</bpmn:extensionElements> | |
<bpmn:process id="PROCESS_1"> | |
<bpmn:startEvent name="MyStart" label="MyStart" id="2"> | |
<mxCell style="shape=mxgraph.bpmn.none_start_event;verticalLabelPosition=bottom;verticalAlign=top;" vertex="1" parent="1"> | |
<mxGeometry x="91" y="91" width="40" height="40" as="geometry"/> | |
</mxCell> | |
</bpmn:startEvent> | |
<bpmn:task name="MyTask" label="MyTask" id="3"> | |
<mxCell style="shape=mxgraph.bpmn.task;" vertex="1" parent="1"> | |
<mxGeometry x="240" y="81" width="140" height="60" as="geometry"/> | |
</mxCell> | |
</bpmn:task> | |
<bpmn:sequenceFlow name="" sourceRef="2" targetRef="3" id="4"> | |
<mxCell style="endArrow=block;endFill=1;endSize=6;edgeStyle=orthogonalEdgeStyle" edge="1" parent="1" source="2" target="3"> | |
<mxGeometry x="1" y="1" as="geometry"> | |
<mxPoint as="sourcePoint"/> | |
<mxPoint x="30" y="30" as="targetPoint"/> | |
</mxGeometry> | |
</mxCell> | |
</bpmn:sequenceFlow> | |
<bpmn:endEvent name="MyEnd" label="MyEnd" id="5"> | |
<mxCell style="shape=mxgraph.bpmn.none_end_event;verticalLabelPosition=bottom;verticalAlign=top;" vertex="1" parent="1"> | |
<mxGeometry x="470" y="91" width="40" height="40" as="geometry"/> | |
</mxCell> | |
</bpmn:endEvent> | |
<bpmn:sequenceFlow name="" sourceRef="3" targetRef="5" id="6"> | |
<mxCell style="endArrow=block;endFill=1;endSize=6;edgeStyle=orthogonalEdgeStyle" edge="1" parent="1" source="3" target="5"> | |
<mxGeometry x="1" y="1" as="geometry"> | |
<mxPoint as="sourcePoint"/> | |
<mxPoint x="30" y="30" as="targetPoint"/> | |
</mxGeometry> | |
</mxCell> | |
</bpmn:sequenceFlow> | |
</bpmn:process> | |
</bpmn:definitions> |
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
/*global module exports console */ | |
exports.MyStart = function( data , done ){ | |
// called after the start event arrived at MyStart | |
console.log("MyStart"); | |
done(); | |
}; | |
exports.MyTask = function( data , done ){ | |
// called at the beginning of MyTask | |
console.log("MyTask"); | |
done(); | |
}; | |
exports.MyTaskDone = function( data , done ){ | |
// Called after the process has been notified that the task has been finished | |
// by invoking myProcess.taskDone("MyTask"). | |
// Note: <task name> + "Done" handler are only called for | |
// user tasks, manual task, and unspecified tasks | |
console.log("MyTaskDone"); | |
done(); | |
}; | |
exports.MyEnd = function( data , done ){ | |
// Called after MyEnd has been reached | |
console.log("MyEnd"); | |
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. | |
done(data); | |
}; | |
exports.defaultErrorHandler = function(error, done) { | |
// Called if errors are thrown in the event handlers | |
done(); | |
}; | |
exports.onBeginHandler = function(currentFlowObjectName, data, done) { | |
// do something | |
done(data); | |
}; | |
exports.onEndHandler = function(currentFlowObjectName, data, done) { | |
// do something | |
done(data); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment