List all user tasks from bpm file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013 12:51 AM
String processInstanceId = processInstance.getId();List<Task> instanceTaskList = taskService.createTaskQuery().processInstanceId(processInstanceId).list();
On some of the forums, it is mentioned to use HistoricActivityInstance methods to populate the task. We have also used the below code.
For unfinished tasks:
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery() .processDefinitionId(processInstance.getProcessDefinitionId()) .unfinished() .listPage(0, 10);
For finished tasks:
List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery() .processDefinitionId(processInstance.getProcessDefinitionId()) .finished() .listPage(0, 10);
But it does not give us all the tasks defined.
For a test purpose we have used "Vacation Request" as an example.
BPM file :
<?xml version="1.0" encoding="UTF-8" ?><definitions id="definitions" targetNamespace="http://activiti.org/bpmn20" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <process id="vacationRequest" name="Vacation request"> <startEvent id="request" activiti:initiator="employeeName"> <extensionElements> <activiti:formProperty id="numberOfDays" name="Number of days" type="long" required="true">1</activiti:formProperty> <activiti:formProperty id="startDate" name="First day of holiday (dd-MM-yyy)" type="date" required="true" /> <activiti:formProperty id="vacationMotivation" name="Motivation" type="string" /> </extensionElements> </startEvent> <sequenceFlow id="flow1" sourceRef="request" targetRef="handleRequest" /> <userTask id="handleRequest" name="Handle vacation request" > <documentation> ${employeeName} would like to take ${numberOfDays} day(s) of vacation (Motivation: ${vacationMotivation}). </documentation> <extensionElements> <activiti:formProperty id="vacationApproved" name="Do you approve this vacation" type="enum" required="true"> <activiti:value id="true" name="Approve" /> <activiti:value id="false" name="Reject" /> </activiti:formProperty> <activiti:formProperty id="managerMotivation" name="Motivation" type="string" /> </extensionElements> <potentialOwner> <resourceAssignmentExpression> <formalExpression>Triage Queue</formalExpression> </resourceAssignmentExpression> </potentialOwner> </userTask> <sequenceFlow id="flow2" sourceRef="handleRequest" targetRef="requestApprovedDecision" /> <exclusiveGateway id="requestApprovedDecision" name="Request approved?" /> <sequenceFlow id="flow3" sourceRef="requestApprovedDecision" targetRef="sendApprovalMail"> <conditionExpression xsi:type="tFormalExpression">${vacationApproved == 'true'}</conditionExpression> </sequenceFlow> <task id="sendApprovalMail" name="Send confirmation e-mail" /> <sequenceFlow id="flow4" sourceRef="sendApprovalMail" targetRef="theEnd1" /> <endEvent id="theEnd1" /> <sequenceFlow id="flow5" sourceRef="requestApprovedDecision" targetRef="adjustVacationRequestTask"> <conditionExpression xsi:type="tFormalExpression">${vacationApproved == 'false'}</conditionExpression> </sequenceFlow> <userTask id="adjustVacationRequestTask" name="Adjust vacation request"> <documentation> Your manager has disapproved your vacation request for ${numberOfDays} days. Reason: ${managerMotivation} </documentation> <extensionElements> <activiti:formProperty id="numberOfDays" name="Number of days" type="long" required="true">${numberOfDays}</activiti:formProperty> <activiti:formProperty id="startDate" name="First day of holiday (dd-MM-yyy)" type="date" required="true" /> <activiti:formProperty id="vacationMotivation" name="Motivation" type="string" >${vacationMotivation}</activiti:formProperty> <activiti:formProperty id="resendRequest" name="Resend vacation request to manager?" type="enum" required="true"> <activiti:value id="true" name="Yes" /> <activiti:value id="false" name="No" /> </activiti:formProperty> </extensionElements> <humanPerformer> <resourceAssignmentExpression> <formalExpression>${employeeName}</formalExpression> </resourceAssignmentExpression> </humanPerformer> </userTask> <sequenceFlow id="flow6" sourceRef="adjustVacationRequestTask" targetRef="resendRequestDecision" /> <exclusiveGateway id="resendRequestDecision" name="Resend request?" /> <sequenceFlow id="flow7" sourceRef="resendRequestDecision" targetRef="handleRequest"> <conditionExpression xsi:type="tFormalExpression">${resendRequest == 'true'}</conditionExpression> </sequenceFlow> <sequenceFlow id="flow8" sourceRef="resendRequestDecision" targetRef="theEnd2"> <conditionExpression xsi:type="tFormalExpression">${resendRequest == 'false'}</conditionExpression> </sequenceFlow> <endEvent id="theEnd2" /> </process> </definitions>
Please guide us with your comments. Thanks in advance.
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013 06:20 AM
Use the following method on the RepositoryService to get a POJO representation of your process, allowing you to get all user tasks defined in the process:
<code>
/**
* Returns the {@link BpmnModel} corresponding with the process definition with
* the provided process definition id. The {@link BpmnModel} is a pojo versions
* of the BPMN 2.0 xml and can be used to introspect the process definition
* using regular Java.
*/
BpmnModel getBpmnModel(String processDefinitionId);
</code>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2013 06:50 AM
Below is the code I have used
<code>
ProcessDefinitionEntity processDefinition =
(ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
if (processDefinition != null) {
for (ActivityImpl activity : processDefinition.getActivities()) {
String type = (String) activity.getProperty("type");
String name = (String) activity.getProperty("name");
String taskId = activity.getId();
System.out.println("test "+type+" name "+name + " id: " + taskId);
}
}
</code>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2016 05:43 AM
I am using Activiti integrated with Liferay. I want to fetch all the task name associated with the Process Definition irrespective of the completed status. I tried using the Liferay-Activiti service,but no improvement. Please help me to get the task name.
Thanks in Advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2013 04:59 AM
How do i do the same using activiti-5.11? Can anybody helP?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2013 06:47 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2013 03:05 AM
thanks in advance..
regards,
Ambrish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2013 08:09 AM
Next time, create new topics for now questions instead of piggy-backing on old ones, may be lost otherwise…
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2013 08:03 AM
i tried that i got a CLASSCAST Exception : java.lang.ClassCastException: org.jboss.weld.proxies.RepositoryService$885673968$Proxy$_$$_WeldClientProxy cannot be cast to org.activiti.engine.impl.RepositoryServiceImpl

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2014 05:19 AM

