use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.
the class AddEntityCommentHandler method postCommentPostedEvent.
/**
* Post a {@link CommentPostedEvent} to the project event bus.
*
* @param threadId The thread that the comment was added to.
* @param comment The comment that was added.
*/
private void postCommentPostedEvent(@Nonnull ThreadId threadId, @Nonnull Comment comment) {
Optional<EntityDiscussionThread> thread = repository.getThread(threadId);
thread.ifPresent(t -> {
OWLEntityData entityData = renderer.getRendering(t.getEntity());
int commentCount = repository.getCommentsCount(projectId, t.getEntity());
int openCommentCount = repository.getOpenCommentsCount(projectId, t.getEntity());
CommentPostedEvent event = new CommentPostedEvent(projectId, threadId, comment, Optional.of(entityData), commentCount, openCommentCount);
eventManager.postEvent(event);
});
}
use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.
the class GetEntityDiscussionThreadsHandler method execute.
@Nonnull
@Override
public GetEntityDiscussionThreadsResult execute(@Nonnull GetEntityDiscussionThreadsAction action, @Nonnull ExecutionContext executionContext) {
List<EntityDiscussionThread> threads = repository.findThreads(action.getProjectId(), action.getEntity());
OWLEntityData entityData = renderingManager.getRendering(action.getEntity());
return new GetEntityDiscussionThreadsResult(entityData, ImmutableList.copyOf(threads));
}
use of edu.stanford.bmir.protege.web.shared.entity.OWLEntityData in project webprotege by protegeproject.
the class CreateEntityDiscussionThreadHandler method execute.
@Nonnull
@Override
public CreateEntityDiscussionThreadResult execute(@Nonnull CreateEntityDiscussionThreadAction action, @Nonnull ExecutionContext executionContext) {
String rawComment = action.getComment();
CommentRenderer commentRenderer = new CommentRenderer();
String renderedComment = commentRenderer.renderComment(rawComment);
UserId commentingUser = executionContext.getUserId();
Comment comment = new Comment(CommentId.create(), commentingUser, System.currentTimeMillis(), Optional.empty(), rawComment, renderedComment);
OWLEntity entity = action.getEntity();
EntityDiscussionThread thread = new EntityDiscussionThread(ThreadId.create(), action.getProjectId(), entity, Status.OPEN, ImmutableList.of(comment));
repository.saveThread(thread);
EventTag startTag = eventManager.getCurrentTag();
eventManager.postEvent(new DiscussionThreadCreatedEvent(thread));
int commentCount = repository.getCommentsCount(projectId, entity);
int openCommentCount = repository.getOpenCommentsCount(projectId, entity);
Optional<OWLEntityData> rendering = Optional.of(renderer.getRendering(entity));
eventManager.postEvent(new CommentPostedEvent(projectId, thread.getId(), comment, rendering, commentCount, openCommentCount));
EventList<ProjectEvent<?>> eventList = eventManager.getEventsFromTag(startTag);
setOutNotifications(thread, comment);
List<EntityDiscussionThread> threads = repository.findThreads(projectId, entity);
return new CreateEntityDiscussionThreadResult(ImmutableList.copyOf(threads), eventList);
}
Aggregations