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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations