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); } }
assertNotNull(comment.getAddedAt()); Assertions.assertThat(comment.getAddedAt()).isCloseTo(TODAY, 1000); assertEquals(savedComment.getText(), comment.getText()); assertEquals("Troll", comment.getAddedBy().getId());
assertNotNull(commentById); assertEquals(commentId, commentById.getId()); Assertions.assertThat(commentById.getAddedAt()).isCloseTo(TODAY, 1000); assertEquals(user, commentById.getAddedBy()); assertEquals(txt, commentById.getText());
comment.setId(jaxbComment.getId()); comment.setAddedAt(jaxbComment.getAddedAt()); comment.setAddedBy(createUser(((JaxbComment) jaxbComment).getAddedById())); comment.setText(jaxbComment.getText());
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; }
@Override public void setResult(List<org.kie.api.task.model.Comment> result) { List<Comment> newCommentList = null; if( result != null ) { newCommentList = new ArrayList<Comment>(result.size()); for( org.kie.api.task.model.Comment kieComment : result ) { Comment genComment = new Comment(); genComment.setAddedAt(ConversionUtil.convertDateToXmlGregorianCalendar(kieComment.getAddedAt())); User addedByUser = kieComment.getAddedBy(); if( addedByUser != null ) { genComment.setAddedBy(addedByUser.getId()); } genComment.setId(genComment.getId()); genComment.setText(genComment.getText()); newCommentList.add(genComment); } } this.commentList = newCommentList; }
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); }
genComment.setId(comment.getId()); genComment.setText(comment.getText()); genComment.setAddedAt(convertDateToXmlGregorianCalendar(comment.getAddedAt()));