private void saveComment() {
if (skipAddingComment) {
return;
}
ProcessToolContext ctx = getCurrentContext();
ProcessComment pc = dialog.getProcessComment();
pc.setAuthor(ctx.getUserDataDAO().loadOrCreateUserByLogin(loggedUser));
pc.setAuthorSubstitute(substitutingUser != null ? ctx.getUserDataDAO().loadOrCreateUserByLogin(substitutingUser) : null);
pc.setCreateTime(new Date());
pc.setProcessState(task.getTaskName());
ProcessInstance pi = task.getProcessInstance().getRootProcessInstance();
ProcessComments comments = pi.findAttributeByClass(ProcessComments.class);
if (comments == null) {
comments = new ProcessComments();
comments.setProcessInstance(pi);
comments.setKey(ProcessComments.class.getName());
pi.getProcessAttributes().add(comments);
}
comments.getComments().add(pc);
pc.setComments(comments);
pi.setSimpleAttribute("commentAdded", "true");
}