07-24-2013 04:36 AM
07-24-2013 05:55 AM
07-24-2013 06:39 AM
// Create Activiti process engine
ProcessEngine processEngine = ProcessEngineConfiguration
.createStandaloneProcessEngineConfiguration()
.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
.setJobExecutorActivate(true)
.buildProcessEngine();
// Get Activiti services
RepositoryService repositoryService = processEngine.getRepositoryService();
RuntimeService runtimeService = processEngine.getRuntimeService();
// Deploy the process definition
repositoryService.createDeployment()
.addClasspathResource("MyProcess2.bpmn")
.deploy();
// Start a process instance
String procId = runtimeService.startProcessInstanceByKey("myProcess2").getId();
// Get the first task
TaskService taskService = processEngine.getTaskService();
List<Task> tasks = taskService.createTaskQuery().taskAssignee("Worker1").list();
for (Task task : tasks)
{
System.out.println("Following task is available for Worker No.1: " + task.getName());
// claim that task
taskService.claim(task.getId(), "Worker1");
}
// Verify Worker1 can now retrieve the task
tasks = taskService.createTaskQuery().taskAssignee("Worker1").list();
for (Task task : tasks)
{
System.out.println("Task for Worker No.1: " + task.getName());
// Complete the task
taskService.complete(task.getId());
System.out.println("Task completed.");
}
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns
mgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns
mgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="myProcess2" name="My process" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<scriptTask id="scripttask1" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
<script>out
rintln "started"
execution.setVariable("counter",0)</script>
</scriptTask>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="scripttask1"></sequenceFlow>
<sequenceFlow id="flow2" sourceRef="scripttask1" targetRef="parallelgateway1"></sequenceFlow>
<intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent">
<timerEventDefinition>
<timeDuration>PT10S</timeDuration>
</timerEventDefinition>
</intermediateCatchEvent>
<scriptTask id="scripttask2" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
<script>out
rintln "ended"</script>
</scriptTask>
<sequenceFlow id="flow3" sourceRef="parallelgateway2" targetRef="scripttask5"></sequenceFlow>
<sequenceFlow id="flow4" sourceRef="scripttask2" targetRef="endevent1"></sequenceFlow>
<parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
<parallelGateway id="parallelgateway2" name="Parallel Gateway"></parallelGateway>
<scriptTask id="scripttask3" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
<script>out
rintln "I'm done in parallel"</script>
</scriptTask>
<sequenceFlow id="flow5" sourceRef="parallelgateway1" targetRef="timerintermediatecatchevent1"></sequenceFlow>
<sequenceFlow id="flow6" sourceRef="parallelgateway1" targetRef="scripttask3"></sequenceFlow>
<sequenceFlow id="flow7" sourceRef="scripttask3" targetRef="parallelgateway2"></sequenceFlow>
<sequenceFlow id="flow8" sourceRef="timerintermediatecatchevent1" targetRef="parallelgateway2"></sequenceFlow>
<scriptTask id="scripttask4" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
<script>counter=counter+1
out
rintln ("Counter-Value: "+counter)</script>
</scriptTask>
<exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
<sequenceFlow id="flow9" sourceRef="parallelgateway1" targetRef="scripttask4"></sequenceFlow>
<sequenceFlow id="flow10" sourceRef="scripttask4" targetRef="exclusivegateway1"></sequenceFlow>
<sequenceFlow id="flow11" name="counter=10" sourceRef="exclusivegateway1" targetRef="parallelgateway2">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${counter>=10}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow12" name="counter<10" sourceRef="exclusivegateway1" targetRef="scripttask4">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${counter<10}]]></conditionExpression>
</sequenceFlow>
<scriptTask id="scripttask5" name="Script Task" scriptFormat="groovy" activiti:autoStoreVariables="true">
<script>out
rintln "10secs are up"</script>
</scriptTask>
<userTask id="usertask1" name="User Task 1" activiti:assignee="Worker1"></userTask>
<sequenceFlow id="flow13" sourceRef="scripttask5" targetRef="usertask1"></sequenceFlow>
<sequenceFlow id="flow14" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
<userTask id="usertask2" name="User Task 2" activiti:assignee="Worker1"></userTask>
<sequenceFlow id="flow15" sourceRef="usertask2" targetRef="scripttask2"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_myProcess2">
<bpmndi:BPMNPlane bpmnElement="myProcess2" id="BPMNPlane_myProcess2">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="10.0" y="50.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="scripttask1" id="BPMNShape_scripttask1">
<omgdc:Bounds height="55.0" width="105.0" x="62.0" y="40.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="725.0" y="230.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="timerintermediatecatchevent1" id="BPMNShape_timerintermediatecatchevent1">
<omgdc:Bounds height="35.0" width="35.0" x="284.0" y="9.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="scripttask2" id="BPMNShape_scripttask2">
<omgdc:Bounds height="55.0" width="105.0" x="596.0" y="220.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
<omgdc:Bounds height="40.0" width="40.0" x="189.0" y="47.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="parallelgateway2" id="BPMNShape_parallelgateway2">
<omgdc:Bounds height="40.0" width="40.0" x="379.0" y="47.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="scripttask3" id="BPMNShape_scripttask3">
<omgdc:Bounds height="55.0" width="105.0" x="249.0" y="80.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="scripttask4" id="BPMNShape_scripttask4">
<omgdc:Bounds height="55.0" width="105.0" x="249.0" y="160.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
<omgdc:Bounds height="40.0" width="40.0" x="377.0" y="167.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="scripttask5" id="BPMNShape_scripttask5">
<omgdc:Bounds height="55.0" width="105.0" x="450.0" y="40.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="596.0" y="40.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="55.0" width="105.0" x="596.0" y="130.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="45.0" y="67.0"></omgdi:waypoint>
<omgdi:waypoint x="62.0" y="67.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="167.0" y="67.0"></omgdi:waypoint>
<omgdi:waypoint x="189.0" y="67.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="419.0" y="67.0"></omgdi:waypoint>
<omgdi:waypoint x="450.0" y="67.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="701.0" y="247.0"></omgdi:waypoint>
<omgdi:waypoint x="725.0" y="247.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="209.0" y="47.0"></omgdi:waypoint>
<omgdi:waypoint x="209.0" y="26.0"></omgdi:waypoint>
<omgdi:waypoint x="284.0" y="26.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
<omgdi:waypoint x="209.0" y="87.0"></omgdi:waypoint>
<omgdi:waypoint x="209.0" y="108.0"></omgdi:waypoint>
<omgdi:waypoint x="249.0" y="107.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
<omgdi:waypoint x="354.0" y="107.0"></omgdi:waypoint>
<omgdi:waypoint x="399.0" y="108.0"></omgdi:waypoint>
<omgdi:waypoint x="399.0" y="87.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
<omgdi:waypoint x="319.0" y="26.0"></omgdi:waypoint>
<omgdi:waypoint x="399.0" y="26.0"></omgdi:waypoint>
<omgdi:waypoint x="399.0" y="47.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
<omgdi:waypoint x="209.0" y="87.0"></omgdi:waypoint>
<omgdi:waypoint x="209.0" y="187.0"></omgdi:waypoint>
<omgdi:waypoint x="249.0" y="187.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow10" id="BPMNEdge_flow10">
<omgdi:waypoint x="354.0" y="187.0"></omgdi:waypoint>
<omgdi:waypoint x="377.0" y="187.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow11" id="BPMNEdge_flow11">
<omgdi:waypoint x="397.0" y="167.0"></omgdi:waypoint>
<omgdi:waypoint x="399.0" y="87.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="55.0" x="2.0" y="24.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
<omgdi:waypoint x="397.0" y="207.0"></omgdi:waypoint>
<omgdi:waypoint x="396.0" y="247.0"></omgdi:waypoint>
<omgdi:waypoint x="210.0" y="247.0"></omgdi:waypoint>
<omgdi:waypoint x="210.0" y="188.0"></omgdi:waypoint>
<omgdi:waypoint x="249.0" y="187.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="55.0" x="125.0" y="-40.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow13" id="BPMNEdge_flow13">
<omgdi:waypoint x="555.0" y="67.0"></omgdi:waypoint>
<omgdi:waypoint x="596.0" y="67.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
<omgdi:waypoint x="648.0" y="95.0"></omgdi:waypoint>
<omgdi:waypoint x="648.0" y="130.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
<omgdi:waypoint x="648.0" y="185.0"></omgdi:waypoint>
<omgdi:waypoint x="648.0" y="220.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
07-25-2013 05:13 AM
taskService.createTaskQuery().taskAssingee("Worker1").list().isEmpty = true
false
" with the existing db-problem, so usertask was executed immediatly]). 07-25-2013 05:52 AM
07-25-2013 06:16 AM
07-25-2013 08:23 AM
07-25-2013 08:34 AM
07-26-2013 08:56 AM
07-30-2013 08:33 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.