if (jbpmTasks == null) {
return Collections.emptyList();
}
for (HistoryTask jbpmHistoryTask : jbpmTasks) {
final Task task = taskService.getTask(jbpmHistoryTask.getId());
String name = "";
if (task != null) {
name = task != null ? task.getName() : "";
} else {
// So nice !
List<HistoryActivityInstance> l = historyService.createHistoryActivityInstanceQuery().processInstanceId(jbpmHistoryTask.getExecutionId()).list();
for (HistoryActivityInstance activityInstance : l) {
if (activityInstance.getStartTime().equals(jbpmHistoryTask.getCreateTime()) &&
activityInstance.getEndTime() != null && activityInstance.getEndTime().equals(jbpmHistoryTask.getEndTime())) {
name = activityInstance.getActivityName();
break;
}
}
}
historyItems
.add(new HistoryWorkflowTask(jbpmHistoryTask.getId(), jbpmHistoryTask.getExecutionId(), name,
getKey(), jbpmHistoryTask.getAssignee(), jbpmHistoryTask.getCreateTime(), jbpmHistoryTask.getEndTime(),
jbpmHistoryTask.getOutcome()));
}
WorkflowDefinition def = getHistoryWorkflows(Collections.singletonList(processId), locale).get(0).getWorkflowDefinition();
for (HistoryWorkflowTask task : historyItems) {
ResourceBundle resourceBundle = null;
if (locale != null) {
resourceBundle = getResourceBundle(locale, def.getKey());
try {
task.setDisplayName(
resourceBundle.getString(task.getName().replaceAll(" ", ".").trim().toLowerCase()));
} catch (Exception e) {
task.setDisplayName(task.getName());
}
}
String outcome = task.getOutcome();
if (outcome != null) {
String key = task.getName().replaceAll(" ", ".").trim().toLowerCase() + "." +
outcome.replaceAll(" ", ".").trim().toLowerCase();
if (locale != null) {
String displayOutcome;
try {
displayOutcome = resourceBundle.getString(key);
} catch (Exception e) {
logger.info("Missing ressource : " + key + " in " + resourceBundle);
displayOutcome = outcome;
}
task.setDisplayOutcome(displayOutcome);
}
}
}