<userTask id="handleRequest" name="Handle vacation request" activiti:candidateGroups="management">
<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>
<activiti:value id="false" name="Reject"></activiti:value>
</activiti:formProperty>
<activiti:formProperty id="managerMotivation" name="Motivation" type="string"></activiti:formProperty>
</extensionElements>
</userTask>
考虑上面的用户任务,你可以这样做
//passing Task Id and Process definition Id
def getFormForTask(taskId,pdId) {
RepositoryService repositoryService =processEngine.getRepositoryService()
// getting model
BpmnModel model = repositoryService.getBpmnModel(pdId);
// getting list process from model including tasks
List<Process> processes = model.getProcesses()
List<FormProperty> taskFormPropertyList =[]
for(Process proc : processes) {
for(Object obj : proc.getFlowElements()) {
// need form Property only for User Task
if(obj instanceof UserTask) {
UserTask userTask = (UserTask)obj
if(userTask.getId() == taskId){
// getting list of Form Property from task that matches taskId
taskFormPropertyList = userTask.getFormProperties()
}
}
}
}
// loop through from Property
taskFormPropertyList.each {
// getFormValues() returns Property values for the form Property (like enum)
def fvlist = it.getFormValues()
fvlist.each {
// prints id, in this case true and false
println it.getId()
// prints name, in this case Approve and Reject
println it.getName()
}
}
}