protected void initialize(Comment comment) { if( comment != null ) { this.id = comment.getId(); this.text = comment.getText(); User addedByUser = comment.getAddedBy(); if( addedByUser != null ) { this.addedBy = addedByUser.getId(); } this.addedAt = comment.getAddedAt(); } }
public Long execute(Context cntxt) { TaskContext context = (TaskContext) cntxt; Comment cmdComent = comment; if (cmdComent == null) { cmdComent = jaxbComment; } InternalComment commentImpl = (InternalComment) TaskModelProvider.getFactory().newComment(); commentImpl.setAddedAt(cmdComent.getAddedAt()); User cmdAddedBy = cmdComent.getAddedBy(); User addedBy = TaskModelProvider.getFactory().newUser(cmdAddedBy.getId()); commentImpl.setAddedBy(addedBy); commentImpl.setText(cmdComent.getText()); doCallbackOperationForComment(commentImpl, context); return context.getTaskCommentService().addComment(taskId, commentImpl); } }
Assertions.assertThat(commentById.getAddedAt()).isCloseTo(TODAY, 1000); assertEquals(user, commentById.getAddedBy()); assertEquals(txt, commentById.getText());
comment.setText(jaxbComment.getText()); comments.add(comment);
public static List<CommentSummary> adaptCollection(List<Comment> comments) { List<CommentSummary> commentsSummaries = new ArrayList<CommentSummary>(comments.size()); for (Comment comment : comments) { commentsSummaries.add(new CommentSummary(comment.getId(), comment.getText(), comment.getAddedBy().toString(), comment.getAddedAt())); } return commentsSummaries; }
static CommentSummary adapt(Comment comment) { return new CommentSummary(comment.getId(), comment.getText(), comment.getAddedBy().toString(), comment.getAddedAt()); }
private void setCommentFields(Comment comment) { this.addedAt = ConversionUtil.convertDateToXmlGregorianCalendar(comment.getAddedAt()); User addedByUser = comment.getAddedBy(); if( addedByUser != null ) { this.addedBy = addedByUser.getId(); } this.id = comment.getId(); this.text = comment.getText(); }
public String getCommentById(String containerId, Number taskId, Number commentId, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); Comment comment = userTaskService.getCommentById(containerId, taskId.longValue(), commentId.longValue()); if (comment == null) { throw new IllegalStateException("No comment found with id " + commentId + " on task " + taskId); } TaskComment taskComment = TaskComment.builder() .id(comment.getId()) .text(comment.getText()) .addedBy(comment.getAddedBy().getId()) .addedAt(comment.getAddedAt()) .build(); logger.debug("About to marshal task '{}' comment {}", taskId, taskComment); String response = marshallerHelper.marshal(containerId, marshallingType, taskComment); return response; }
public String getCommentsByTaskId(String containerId, Number taskId, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); List<Comment> comments = userTaskService.getCommentsByTaskId(containerId, taskId.longValue()); TaskComment[] taskComments = new TaskComment[comments.size()]; int counter = 0; for (Comment comment : comments) { TaskComment taskComment = TaskComment.builder() .id(comment.getId()) .text(comment.getText()) .addedBy(comment.getAddedBy().getId()) .addedAt(comment.getAddedAt()) .build(); taskComments[counter] = taskComment; counter++; } TaskCommentList result = new TaskCommentList(taskComments); logger.debug("About to marshal task '{}' comments {}", taskId, result); String response = marshallerHelper.marshal(containerId, marshallingType, result); return response; }
@Override public Long addComment(long taskId, Comment comment) { // fill jaxbComment org.kie.remote.jaxb.gen.Comment jaxbComment = new org.kie.remote.jaxb.gen.Comment(); Date addedAt = comment.getAddedAt(); if( addedAt != null ) { XMLGregorianCalendar jaxbAddedAt = convertDateToXmlGregorianCalendar(addedAt); jaxbComment.setAddedAt(jaxbAddedAt); } User addedBy = comment.getAddedBy(); if( addedBy != null ) { jaxbComment.setAddedBy(addedBy.getId()); } jaxbComment.setText(comment.getText()); jaxbComment.setId(comment.getId()); // create command AddCommentCommand cmd = new AddCommentCommand(); cmd.setTaskId(taskId); cmd.setJaxbComment(jaxbComment); return executeCommand(cmd); }
assertNotNull(cm); assertEquals("john", cm.getAddedBy().getId()); assertEquals("Another comment", cm.getText());
org.kie.remote.jaxb.gen.Comment genComment = new org.kie.remote.jaxb.gen.Comment(); genComment.setId(comment.getId()); genComment.setText(comment.getText()); genComment.setAddedAt(convertDateToXmlGregorianCalendar(comment.getAddedAt()));