Search in sources :

Example 1 with Watch

use of edu.stanford.bmir.protege.web.shared.watches.Watch 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 2 with Watch

use of edu.stanford.bmir.protege.web.shared.watches.Watch in project webprotege by protegeproject.

the class WatchedChangesManager method getProjectChangesForWatches.

public ImmutableList<ProjectChange> getProjectChangesForWatches(Set<Watch> watches) {
    Set<OWLEntity> superEntities = new HashSet<>();
    Set<OWLEntity> directWatches = new HashSet<>();
    for (Watch watch : watches) {
        if (watch.getType() == BRANCH) {
            OWLEntity entity = watch.getEntity();
            superEntities.add(entity);
            directWatches.add(entity);
        } else {
            directWatches.add(watch.getEntity());
        }
    }
    if (superEntities.isEmpty() && directWatches.isEmpty()) {
        return ImmutableList.of();
    }
    ImmutableList.Builder<ProjectChange> result = ImmutableList.builder();
    List<Revision> revisionsCopy = changeManager.getRevisions();
    for (Revision revision : revisionsCopy) {
        for (OWLEntity watchedEntity : getWatchedEntities(superEntities, directWatches, revision)) {
            ImmutableList<ProjectChange> changes = projectChangesManager.getProjectChangesForSubjectInRevision(watchedEntity, revision);
            result.addAll(changes);
        }
    }
    return result.build();
}
Also used : Revision(edu.stanford.bmir.protege.web.server.revision.Revision) ImmutableList(com.google.common.collect.ImmutableList) Watch(edu.stanford.bmir.protege.web.shared.watches.Watch) ProjectChange(edu.stanford.bmir.protege.web.shared.change.ProjectChange) HashSet(java.util.HashSet)

Aggregations

Watch (edu.stanford.bmir.protege.web.shared.watches.Watch)2 ImmutableList (com.google.common.collect.ImmutableList)1 Revision (edu.stanford.bmir.protege.web.server.revision.Revision)1 ProjectChange (edu.stanford.bmir.protege.web.shared.change.ProjectChange)1 EventTag (edu.stanford.bmir.protege.web.shared.event.EventTag)1 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)1 SetEntityWatchesResult (edu.stanford.bmir.protege.web.shared.watches.SetEntityWatchesResult)1 HashSet (java.util.HashSet)1 Nonnull (javax.annotation.Nonnull)1