FormService formService = processEngine.getFormService();
String taskFormKey = formService.getTaskFormKey(
task.getProcessDefinitionId(), task.getTaskDefinitionKey());
FormTemplate formTemplate = formTemplateManager.findUniqueBy("code",
taskFormKey);
model.addAttribute("formTemplate", formTemplate);
FormInfo formInfo = new FormInfo();
formInfo.setTaskId(taskId);
model.addAttribute("formInfo", formInfo);
List<BpmConfOperation> bpmConfOperations = bpmConfOperationManager
.find("from BpmConfOperation where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
task.getProcessDefinitionId(),
task.getTaskDefinitionKey());
for (BpmConfOperation bpmConfOperation : bpmConfOperations) {
formInfo.getButtons().add(bpmConfOperation.getValue());
}
String processDefinitionId = task.getProcessDefinitionId();
String activityId = task.getTaskDefinitionKey();
formInfo.setProcessDefinitionId(processDefinitionId);
formInfo.setActivityId(activityId);
List<BpmConfForm> bpmConfForms = bpmConfFormManager
.find("from BpmConfForm where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
processDefinitionId, activityId);
if (!bpmConfForms.isEmpty()) {
if (Integer.valueOf(1).equals(bpmConfForms.get(0).getType())) {
String redirectUrl = bpmConfForms.get(0).getValue()
+ "?taskId=" + taskId;
return "redirect:" + redirectUrl;
}
}
if ((formTemplate != null)
&& Integer.valueOf(1).equals(formTemplate.getType())) {
String redirectUrl = formTemplate.getContent() + "?taskId="
+ taskId;
return "redirect:" + redirectUrl;
}