Search in sources :

Example 1 with EventTag

use of edu.stanford.bmir.protege.web.shared.event.EventTag in project webprotege by protegeproject.

the class AbstractProjectChangeHandler method execute.

@Nonnull
@Override
public final R execute(@Nonnull A action, @Nonnull ExecutionContext executionContext) {
    EventTag tag = eventManager.getCurrentTag();
    ChangeListGenerator<T> changeListGenerator = getChangeListGenerator(action, executionContext);
    ChangeApplicationResult<T> result = applyChanges.applyChanges(executionContext.getUserId(), changeListGenerator);
    EventList<ProjectEvent<?>> eventList = eventManager.getEventsFromTag(tag);
    return createActionResult(result, action, executionContext, eventList);
}
Also used : EventTag(edu.stanford.bmir.protege.web.shared.event.EventTag) ProjectEvent(edu.stanford.bmir.protege.web.shared.event.ProjectEvent) Nonnull(javax.annotation.Nonnull)

Example 2 with EventTag

use of edu.stanford.bmir.protege.web.shared.event.EventTag in project webprotege by protegeproject.

the class AbstractUpdateFrameHandler method execute.

/**
 * Executes the specified action, against the specified project in the specified context.
 * @param action The action to be handled/executed
 * @param executionContext The {@link edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext} that should be
 * used to provide details such as the
 * {@link edu.stanford.bmir.protege.web.shared.user.UserId} of the user who requested the action be executed.
 * @return The result of the execution to be returned to the client.
 */
@Nonnull
@Override
public Result execute(@Nonnull A action, @Nonnull ExecutionContext executionContext) {
    LabelledFrame<F> from = action.getFrom();
    LabelledFrame<F> to = action.getTo();
    final EventTag startTag = eventManager.getCurrentTag();
    if (from.equals(to)) {
        return createResponse(action.getTo(), eventManager.getEventsFromTag(startTag));
    }
    UserId userId = executionContext.getUserId();
    FrameTranslator<F, S> translator = createTranslator();
    final FrameChangeGenerator<F, S> changeGenerator = new FrameChangeGenerator<>(from.getFrame(), to.getFrame(), translator, rootOntology, changeDescriptionGeneratorFactory);
    ChangeDescriptionGenerator<S> generator = changeDescriptionGeneratorFactory.get("Edited " + from.getDisplayName());
    applyChanges.applyChanges(userId, changeGenerator);
    EventList<ProjectEvent<?>> events = eventManager.getEventsFromTag(startTag);
    return createResponse(action.getTo(), events);
}
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 3 with EventTag

use of edu.stanford.bmir.protege.web.shared.event.EventTag in project webprotege by protegeproject.

the class AddWatchActionHandler method execute.

@Nonnull
@Override
public AddWatchResult execute(@Nonnull AddWatchAction action, @Nonnull ExecutionContext executionContext) {
    EventTag startTag = eventManager.getCurrentTag();
    watchManager.addWatch(action.getWatch());
    return new AddWatchResult(eventManager.getEventsFromTag(startTag));
}
Also used : AddWatchResult(edu.stanford.bmir.protege.web.shared.watches.AddWatchResult) EventTag(edu.stanford.bmir.protege.web.shared.event.EventTag) Nonnull(javax.annotation.Nonnull)

Example 4 with EventTag

use of edu.stanford.bmir.protege.web.shared.event.EventTag in project webprotege by protegeproject.

the class SetEntityWatchesActionHandler method execute.

@Nonnull
@Override
public SetEntityWatchesResult execute(@Nonnull SetEntityWatchesAction action, @Nonnull ExecutionContext executionContext) {
    EventTag startTag = eventManager.getCurrentTag();
    UserId userId = action.getUserId();
    Set<Watch> watches = watchManager.getDirectWatches(action.getEntity(), userId);
    for (Watch watch : watches) {
        watchManager.removeWatch(watch);
    }
    for (Watch watch : action.getWatches()) {
        watchManager.addWatch(watch);
    }
    return new SetEntityWatchesResult(eventManager.getEventsFromTag(startTag));
}
Also used : UserId(edu.stanford.bmir.protege.web.shared.user.UserId) SetEntityWatchesResult(edu.stanford.bmir.protege.web.shared.watches.SetEntityWatchesResult) Watch(edu.stanford.bmir.protege.web.shared.watches.Watch) EventTag(edu.stanford.bmir.protege.web.shared.event.EventTag) Nonnull(javax.annotation.Nonnull)

Example 5 with EventTag

use of edu.stanford.bmir.protege.web.shared.event.EventTag in project webprotege by protegeproject.

the class EventManager method getEventsFromTag.

/**
 * Gets the live events posted to this manager which have a tag greater or equal to the specified tag.  Events are coalesced
 * where possible.  That is, if event E1 is posted at time t1 and event E2 is posted at time t2 and E1 and E2 are
 * equal then a list containing only E2 will be returned.
 * @param fromTag The tag that denotes the point after which events will be retrieved.  Not {@code null}.
 * @return The list of live events that happened since the specified tag.  Not {@code null}.
 * @throws NullPointerException if {@code tag} is {@code null}.
 */
public EventList<E> getEventsFromTag(EventTag fromTag) {
    checkNotNull(fromTag, "tag must not be null");
    List<E> resultList = new ArrayList<>();
    final EventTag curTag;
    try {
        readLock.lock();
        curTag = currentTag;
        for (EventBucket bucket : eventQueue) {
            if (bucket.getTag().isGreaterOrEqualTo(fromTag)) {
                resultList.addAll(bucket.getEvents());
            }
        }
    } finally {
        readLock.unlock();
    }
    final EventTag toTag = curTag.next();
    if (resultList.isEmpty()) {
        return new EventList<>(fromTag, toTag);
    }
    // Prune duplicates
    LinkedHashSet<E> events = new LinkedHashSet<>(resultList);
    return new EventList<>(fromTag, events, toTag);
}
Also used : EventList(edu.stanford.bmir.protege.web.shared.event.EventList) EventTag(edu.stanford.bmir.protege.web.shared.event.EventTag)

Aggregations

EventTag (edu.stanford.bmir.protege.web.shared.event.EventTag)12 Nonnull (javax.annotation.Nonnull)10 ProjectEvent (edu.stanford.bmir.protege.web.shared.event.ProjectEvent)7 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)4 EventList (edu.stanford.bmir.protege.web.shared.event.EventList)3 AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)2 AbstractProjectActionHandler (edu.stanford.bmir.protege.web.server.dispatch.AbstractProjectActionHandler)2 ExecutionContext (edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext)2 EventManager (edu.stanford.bmir.protege.web.server.events.EventManager)2 BuiltInAction (edu.stanford.bmir.protege.web.shared.access.BuiltInAction)2 edu.stanford.bmir.protege.web.shared.issues (edu.stanford.bmir.protege.web.shared.issues)2 ProjectId (edu.stanford.bmir.protege.web.shared.project.ProjectId)2 Optional (java.util.Optional)2 Nullable (javax.annotation.Nullable)2 Inject (javax.inject.Inject)2 EDIT_OWN_OBJECT_COMMENT (edu.stanford.bmir.protege.web.shared.access.BuiltInAction.EDIT_OWN_OBJECT_COMMENT)1 SET_OBJECT_COMMENT_STATUS (edu.stanford.bmir.protege.web.shared.access.BuiltInAction.SET_OBJECT_COMMENT_STATUS)1 OWLEntityData (edu.stanford.bmir.protege.web.shared.entity.OWLEntityData)1 SetProjectTagsResult (edu.stanford.bmir.protege.web.shared.tag.SetProjectTagsResult)1 UpdateEntityTagsResult (edu.stanford.bmir.protege.web.shared.tag.UpdateEntityTagsResult)1