public String showTask(@PathVariable("id") String id,
@RequestParam(value = TASK_HISTORY_PARAM, required = true) Boolean historyParam,
@RequestParam(value = PROC_ID, required = true) String procId, Model model,
HttpServletRequest request) throws TaskHandlerException {
Task currentTask = null;
HistoricTaskInstance historyTask = null;
IProcessEntity linkedObject = getLinkedObject(procId);
if (Boolean.FALSE.equals(historyParam)) {
request.setAttribute(TASK_HISTORY_PARAM, false);
currentTask = getCurrentTask(id);
// living task instance requested, but already completed by other actor
if (currentTask == null) {
historyTask = getHistoryTask(id);
if (historyTask != null) {
// force historic view with additional info, who and when already completed task
request.setAttribute(TASK_HISTORY_PARAM, true);
Object[] arguments = new Object[2];
arguments[0] = historyTask.getAssignee();
arguments[1] = new SimpleDateFormat(InfrastructureConstants.ISO_DATE_TIME_FORMAT)
.format(historyTask.getEndTime());
model.addAttribute(MODEL_ATTR_TASK_COMPLETED,
messageSource.getMessage(InfrastructureConstants.TASK_ALREADY_COMPLETED,
arguments, InfrastructureConstants.UNDEFINED_MESSAGE, request.getLocale()));
} else {
// there is not living, nor historic instance, task is non existing / was deleted
request.getSession()
.setAttribute(InfrastructureConstants.SESSION_ATTR_FROM_NON_EXISTING_TASK, true);
return "redirect:/" + getLinkedObjectViewPath() +
WebUtil.encodeUrlPathSegment(linkedObject.getId().toString(),
request);
}
}
} else {
request.setAttribute(TASK_HISTORY_PARAM, true);
historyTask = getHistoryTask(id);
}
String taskName = currentTask != null ? currentTask.getName() : historyTask.getName();
// taskId is the same for active or history process task
String taskId = currentTask != null ? currentTask.getId() : historyTask.getId();
if (Boolean.FALSE.equals(historyParam)) {
request.getSession().setAttribute(SESSION_ATTR_TASK_ID, taskId);
request.getSession().setAttribute(SESSION_ATTR_PROC_ID, procId);
}
String path = UNDEFINED_TASK; // unknown task type