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