protected void mappCommentsFromTaskToStep(CoreSession session, DocumentModel docStep) throws ClientException { List<String> comments = new ArrayList<String>(); RoutingTask task = getRoutingTask(context); if (task == null) { log.error("No task found on the operation context"); return; } List<TaskComment> taskComments = task.getComments(); for (TaskComment taskComment : taskComments) { StringBuilder commentBuilder = new StringBuilder(); commentBuilder.append(taskComment.getAuthor()); commentBuilder.append(" : "); commentBuilder.append(taskComment.getText()); comments.add(commentBuilder.toString()); } if (docStep.hasFacet(RoutingTaskConstants.TASK_STEP_FACET_NAME)) { docStep.setPropertyValue( RoutingTaskConstants.TASK_STEP_COMMENTS_PROPERTY_NAME, (Serializable) comments); session.saveDocument(docStep); } } }
public DashBoardItemImpl(Task task, DocumentModel document, Locale locale) { this.task = task; this.document = document; this.locale = locale; id = task.getId(); name = task.getName(); description = task.getDescription(); dueDate = task.getDueDate(); startDate = task.getCreated(); directive = task.getDirective(); List<TaskComment> comments = task.getComments(); if (comments != null && !comments.isEmpty()) { comment = comments.get(comments.size() - 1).getText(); } else { comment = null; } if (dueDate != null) { Date today = new Date(); expired = dueDate.before(today); } else { expired = false; } }
protected void finishTask(CoreSession session, GraphRoute graph, GraphNode node, Task task, boolean delete, String status) throws DocumentRouteException { DocumentRoutingService routing = Framework.getService(DocumentRoutingService.class); DocumentModelList docs = graph.getAttachedDocumentModels(); routing.removePermissionsForTaskActors(session, docs, task); // delete task if (delete) { session.removeDocument(new IdRef(task.getId())); } // get the last comment on the task, if there are several: // task might have been previously reassigned or delegated List<TaskComment> comments = task.getComments(); String comment = comments.size() > 0 ? comments.get(comments.size() - 1).getText() : ""; // actor NuxeoPrincipal principal = session.getPrincipal(); String actor = principal.getActingUser(); node.updateTaskInfo(task.getId(), true, status, actor, comment); }
jg.writeStartObject(); jg.writeStringField("author", comment.getAuthor()); jg.writeStringField("text", comment.getText()); jg.writeStringField("date", DateParser.formatW3CDateTime(comment.getCreationDate().getTime())); jg.writeEndObject();