Refine search
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 addComment(long taskId, Comment comment) { Task task = persistenceContext.findTask(taskId); if (persistenceContext.findUser(comment.getAddedBy().getId()) == null) { persistenceContext.persistUser(comment.getAddedBy()); } persistenceContext.persistComment(comment); persistenceContext.addCommentToTask(comment, task); return comment.getId(); }
protected void doCallbackOperationForComment(Comment comment, TaskContext context) { if (comment != null) { if (comment.getAddedBy() != null) { User entity = doCallbackAndReturnUserOperation(comment.getAddedBy().getId(), context); if (entity != null) { ((InternalComment)comment).setAddedBy(entity); } } } }
assertEquals("john", cm.getAddedBy().getId()); assertEquals("Another comment", cm.getText());
@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; }
/** * Removes the Comment specified by the commentId. * * @param commentId id of Comment to remove * @return removed Comment or null if one was not found with the id */ public Comment removeComment(final long commentId) { Comment removedComment = null; if (comments != null) { for (int index = comments.size() - 1; index >= 0; --index) { Comment currentComment = comments.get(index); if (currentComment.getId() == commentId) { removedComment = comments.remove(index); break; } } } return removedComment; }
/*Serializer*/ import org.springframework.stereotype.Component; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; @Component @Slf4j public class CommentSerializer extends JsonSerializer<Comment> { @Override public void serialize(Comment comment, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeStringField("id", comment.getId()); jgen.writeStringField("userId", comment.getUserId()); jgen.writeStringField("firstName", redisRepo.getName(comment.getUserId(), false)); jgen.writeStringField("discussionId", comment.getDiscussionId()); jgen.writeStringField("createdTime", String.valueOf(comment.getCreatedTime().getTime())); jgen.writeStringField("comment", comment.getComment()); jgen.writeEndObject(); } }
Iterator<Comment> commentIter = relevant.iterator(); Iterator<GitItem> itemIter = tree.iterator(); while (commentIter.hasNext() && itemIter.hasNext()) { Comment mc = commentIter.next(); GitItem gi = itemIter.next(); bb.buildBody(gi.getHash(), mc.getBody()); MutableComment mutable = commentManager.getMutableComment(mc.getId()); mutable.setBody(bb.sb.toString()); commentManager.update(mutable, true); }
@Override public Comment persistComment(Comment comment) { check(); this.em.persist( comment ); if( this.pessimisticLocking ) { this.em.flush(); return this.em.find(CommentImpl.class, comment.getId(), LockModeType.PESSIMISTIC_WRITE ); } return comment; }
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); } }
@Override public Comment removeCommentFromTask(Comment comment, Task task) { ((InternalTaskData) task.getTaskData()).removeComment(comment.getId()); EventManagerProvider.getInstance().get().update(new TaskInstanceView(task)); return comment; }
for (Comment comment : allCommentList) { assertNotNull(comment); assertNotNull(comment.getId()); assertTrue(comment.getId() > lastId); Comment savedComment = savedComments.get(comment.getId()); assertNotNull(savedComment); assertNotNull(comment.getAddedAt()); Assertions.assertThat(comment.getAddedAt()).isCloseTo(TODAY, 1000); assertEquals(savedComment.getText(), comment.getText()); assertEquals("Troll", comment.getAddedBy().getId()); lastId = comment.getId();
public boolean containsComment(int commentId) { for(Comment comment : getComments()){ if(comment.getId() == commentId){ return true; } } return false; }
assertEquals(commentId, commentById.getId()); Assertions.assertThat(commentById.getAddedAt()).isCloseTo(TODAY, 1000); assertEquals(user, commentById.getAddedBy()); assertEquals(txt, commentById.getText()); assertEquals(commentId, allCommentList.get(0).getId()); assertEquals(commentId2, allCommentList.get(1).getId());
/** * Removes the Comment specified by the commentId. * * @param commentId id of Comment to remove * @return removed Comment or null if one was not found with the id */ public Comment removeComment(final long commentId) { Comment removedComment = null; if (comments != null) { for (int index = comments.size() - 1; index >= 0; --index) { Comment currentComment = comments.get(index); if (currentComment.getId() == commentId) { removedComment = comments.remove(index); break; } } } return removedComment; }
InternalPeopleAssignments peopleAssignments = (InternalPeopleAssignments) TaskModelProvider.getFactory().newPeopleAssignments(); if (jaxbPeopleAssignments.getTaskInitiator() != null) { User user = createUser(this.getPeopleAssignments().getTaskInitiator().getId()); peopleAssignments.setTaskInitiator(user); for( Comment jaxbComment : jaxbComments ) { InternalComment comment = (InternalComment) TaskModelProvider.getFactory().newComment(); if( jaxbComment.getId() != null ) { comment.setId(jaxbComment.getId()); comment.setAddedAt(jaxbComment.getAddedAt()); comment.setAddedBy(createUser(((JaxbComment) jaxbComment).getAddedById())); comment.setText(jaxbComment.getText()); comments.add(comment);
@Override public Comment persistComment(Comment comment) { check(); this.em.persist( comment ); if( this.pessimisticLocking ) { this.em.flush(); return this.em.find(CommentImpl.class, comment.getId(), LockModeType.PESSIMISTIC_WRITE ); } return comment; }
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(); }
@Override public Comment removeCommentFromTask(Comment comment, Task task) { ((InternalTaskData) task.getTaskData()).removeComment(comment.getId()); EventManagerProvider.getInstance().get().update(new TaskInstanceView(task)); return comment; }
static CommentSummary adapt(Comment comment) { return new CommentSummary(comment.getId(), comment.getText(), comment.getAddedBy().toString(), comment.getAddedAt()); }