Search in sources :

Example 56 with UserId

use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.

the class AddEntityCommentHandler method execute.

@Nonnull
@Override
public AddEntityCommentResult execute(@Nonnull AddEntityCommentAction action, @Nonnull ExecutionContext executionContext) {
    UserId createdBy = executionContext.getUserId();
    long createdAt = System.currentTimeMillis();
    CommentRenderer r = new CommentRenderer();
    String rawComment = action.getComment();
    String renderedComment = r.renderComment(rawComment);
    Comment comment = new Comment(CommentId.create(), createdBy, createdAt, Optional.empty(), rawComment, renderedComment);
    ThreadId threadId = action.getThreadId();
    repository.addCommentToThread(threadId, comment);
    EventTag startTag = eventManager.getCurrentTag();
    postCommentPostedEvent(threadId, comment);
    EventList<ProjectEvent<?>> eventList = eventManager.getEventsFromTag(startTag);
    sendOutNotifications(threadId, comment);
    return new AddEntityCommentResult(action.getProjectId(), threadId, comment, renderedComment, eventList);
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) EventTag(edu.stanford.bmir.protege.web.shared.event.EventTag) ProjectEvent(edu.stanford.bmir.protege.web.shared.event.ProjectEvent) Nonnull(javax.annotation.Nonnull)

Example 57 with UserId

use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.

the class CommentConverter method fromDocument.

@Override
public Comment fromDocument(@Nonnull Document document) {
    UserId createdBy = UserId.getUserId(document.getString(CREATED_BY));
    long createdAt = document.getLong(CREATED_AT);
    Optional<Long> updatedAt = Optional.ofNullable(document.getLong(UPDATED_AT));
    String body = document.getString(BODY);
    return new Comment(CommentId.create(), createdBy, createdAt, updatedAt, body, body);
}
Also used : Comment(edu.stanford.bmir.protege.web.shared.issues.Comment) UserId(edu.stanford.bmir.protege.web.shared.user.UserId)

Example 58 with UserId

use of edu.stanford.bmir.protege.web.shared.user.UserId 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)

Example 59 with UserId

use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.

the class UserIdRangeConverter method fromDocument.

@Override
public UserIdRange fromDocument(@Nonnull Document document) {
    UserId userId = UserId.getUserId(document.getString(USER_ID));
    long start = document.getLong(START);
    long end = document.getLong(END);
    return new UserIdRange(userId, start, end);
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) UserIdRange(edu.stanford.bmir.protege.web.shared.crud.oboid.UserIdRange)

Example 60 with UserId

use of edu.stanford.bmir.protege.web.shared.user.UserId in project webprotege by protegeproject.

the class GetCurrentUserInSessionActionHandler method execute.

@Nonnull
@Override
public GetCurrentUserInSessionResult execute(@Nonnull GetCurrentUserInSessionAction action, @Nonnull ExecutionContext executionContext) {
    UserId userId = executionContext.getUserId();
    UserInSession userInSession = userInSessionFactory.getUserInSession(userId);
    return new GetCurrentUserInSessionResult(userInSession);
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) GetCurrentUserInSessionResult(edu.stanford.bmir.protege.web.shared.dispatch.actions.GetCurrentUserInSessionResult) UserInSession(edu.stanford.bmir.protege.web.shared.app.UserInSession) Nonnull(javax.annotation.Nonnull)

Aggregations

UserId (edu.stanford.bmir.protege.web.shared.user.UserId)64 Nonnull (javax.annotation.Nonnull)20 Test (org.junit.Test)14 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)13 Inject (javax.inject.Inject)6 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)6 List (java.util.List)5 ImmutableList (com.google.common.collect.ImmutableList)4 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)4 WebProtegeSession (edu.stanford.bmir.protege.web.server.session.WebProtegeSession)4 WebProtegeSessionImpl (edu.stanford.bmir.protege.web.server.session.WebProtegeSessionImpl)4 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)4 EventTag (edu.stanford.bmir.protege.web.shared.event.EventTag)4 ArrayList (java.util.ArrayList)4 DispatchServiceCallback (edu.stanford.bmir.protege.web.client.dispatch.DispatchServiceCallback)3 Subject.forUser (edu.stanford.bmir.protege.web.server.access.Subject.forUser)3 Optional (java.util.Optional)3 Stopwatch (com.google.common.base.Stopwatch)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 ProjectResource (edu.stanford.bmir.protege.web.server.access.ProjectResource)2