Search in sources :

Example 16 with OWLEntityData

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);
    });
}
Also used : OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)

Example 17 with OWLEntityData

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));
}
Also used : GetEntityDiscussionThreadsResult(edu.stanford.bmir.protege.web.shared.issues.GetEntityDiscussionThreadsResult) EntityDiscussionThread(edu.stanford.bmir.protege.web.shared.issues.EntityDiscussionThread) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) Nonnull(javax.annotation.Nonnull)

Example 18 with OWLEntityData

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);
}
Also used : OWLEntity(org.semanticweb.owlapi.model.OWLEntity) OWLEntityData(edu.stanford.bmir.protege.web.shared.entity.OWLEntityData) EventTag(edu.stanford.bmir.protege.web.shared.event.EventTag) UserId(edu.stanford.bmir.protege.web.shared.user.UserId) ProjectEvent(edu.stanford.bmir.protege.web.shared.event.ProjectEvent) Nonnull(javax.annotation.Nonnull)

Aggregations

OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)18 Nonnull (javax.annotation.Nonnull)5 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)5 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)3 EntitySuggestion (edu.stanford.bmir.protege.web.client.library.suggest.EntitySuggestion)2 AnnotationPropertyFrame (edu.stanford.bmir.protege.web.shared.frame.AnnotationPropertyFrame)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 Tag (edu.stanford.bmir.protege.web.shared.tag.Tag)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Inject (javax.inject.Inject)2 IRI (org.semanticweb.owlapi.model.IRI)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 EntityLabel (edu.stanford.bmir.protege.web.client.library.entitylabel.EntityLabel)1 PrimitiveDataParserImpl (edu.stanford.bmir.protege.web.client.primitive.PrimitiveDataParserImpl)1 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)1 ProjectResource.forProject (edu.stanford.bmir.protege.web.server.access.ProjectResource.forProject)1 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)1 ApplicationNameSupplier (edu.stanford.bmir.protege.web.server.app.ApplicationNameSupplier)1