Skip to content

Instantly share code, notes, and snippets.

View meyerdan's full-sized avatar

Daniel Meyer meyerdan

View GitHub Profile
@meyerdan
meyerdan / gist:9112021
Created February 20, 2014 11:59
Fluent Bpmn Model API Example
BpmnModelInstance modelInstance = Bpmn.createProcess()
.name("Example process")
.executable()
.startEvent()
.userTask()
.name("Some work to do")
.endEvent()
.done();
@meyerdan
meyerdan / gist:9112096
Created February 20, 2014 12:05
Bpmn Model API Repository Service access
// get the BpmnModelInstance for a deployed process
BpmnModelInstance processModel = runtimeService.getBpmnModelInstance("someProcessDefinitionId");
// find all User Tasks
ModelElementType taskType = processModel.getModel().getType(UserTask.class);
Collection<ModelElementInstance> taskInstances = modelInstance.getModelElementsByType(taskType);
// Iterate the tasks ...
@meyerdan
meyerdan / gist:9112186
Last active August 29, 2015 13:56
Bpmn Model Api Delegation Code
public class ExampleServiceTask implements JavaDelegate {
public void execute(DelegateExecution execution) throws Exception {
BpmnModelInstance modelInstance = execution.getBpmnModelInstance();
ServiceTask serviceTask = (ServiceTask) execution.getBpmnModelElementInstance();
// read properties from model:
serviceTask.getIoSpecification();
//...
}
@meyerdan
meyerdan / gist:9112468
Created February 20, 2014 12:30
User Operation Log Query Example
// who worked on this task?
historyService.createUserOperationLogQuery()
.taskId("someTaskId")
.list();
// all operations performed by a given user
historyService.createUserOperationLogQuery()
.userId("jonny")
.list();
@meyerdan
meyerdan / without camunda BPM assert.java
Last active August 29, 2015 14:02
without camunda BPM assert
// make sure process instance is started
assertNotNull(runtimeService.createProcessInstanceQuery()
.processInstanceId(processInstance.getId())
.singleResult());
// make sure the task with id "approveInvoice" & candidate group "backoffice" exists
Task task = taskService.createTaskQuery()
.taskCandidateGroup("backoffice")
.processInstanceId(processInstance.getId())
.taskDefinitionKey("approveInvoice")
@meyerdan
meyerdan / camundaBpmAssert.java
Created June 3, 2014 06:53
With camunda BPM assert
assertThat(processInstance).isStarted()
.task().hasDefinitionKey("approveInvoice")
.hasCandidateGroup("backoffice")
.isNotAssigned();
@meyerdan
meyerdan / bpmnIoMapping.xml
Last active August 29, 2015 14:02
I/O mapping
<bpmn2:serviceTask id="requestScore" name="Request Rating Score">
<bpmn2:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="customer">${ XML(customers).xPath('/customers/customer[1]').element() }</camunda:inputParameter>
<camunda:inputParameter name="requestedAmount">${ amount }</camunda:inputParameter>
<camunda:inputParameter name="someData">
<camunda:map>
<camunda:entry key="a">${b}</camunda:entry>
<camunda:entry key="c">${d}</camunda:entry>
@meyerdan
meyerdan / xpathEl.xml
Last active August 29, 2015 14:02
xpath in el
<bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression">
<![CDATA[
${ XML(someVariable).xPath('/customers/customer[@id='+customerId+']/@score' ).number() >= 100 }
]]>
</bpmn2:conditionExpression>
@meyerdan
meyerdan / async-berfore-and-after.xml
Last active August 29, 2015 14:04
Asynchronous continuations
<!-- AFTER (new) -->
<serviceTask id="service1" name="Generate Invoice" camunda:asyncAfter="true"
camunda:class="my.custom.Delegate" />
<!-- BEFORE -->
<serviceTask id="service1" name="Generate Invoice" camunda:asyncBefore="true"
camunda:class="my.custom.Delegate" />
@meyerdan
meyerdan / CreateAndComplete.java
Created July 17, 2014 09:54
CMMN Loan Application Example
// deploy the case definition
repositoryService.createDeployment()
.addClasspathResource("org/camunda/bpm/engine/test/examples/cmmn/loan-application.cmmn")
.deploy();
// create a new case instance
CaseInstance caseInstance = caseService
.withCaseDefinitionByKey("loanApplication")
.setVariable("applicantId", "some id ...")
.create();