Search in sources :

Example 1 with ProjectChange

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

Example 2 with ProjectChange

use of edu.stanford.bmir.protege.web.shared.change.ProjectChange in project webprotege by protegeproject.

the class ProjectChangesManager method getProjectChangesForRevision.

private void getProjectChangesForRevision(Revision revision, Optional<OWLEntity> subject, ImmutableList.Builder<ProjectChange> changesBuilder) {
    if (subject.isPresent() && !entitiesByRevisionCache.containsEntity(revision, subject.get())) {
        return;
    }
    Map<Optional<IRI>, List<OWLOntologyChangeRecord>> recordsBySubject = getChangeRecordsBySubject(revision);
    List<OWLOntologyChangeRecord> limitedRecords = new ArrayList<>();
    final int totalChanges;
    if (subject.isPresent()) {
        List<OWLOntologyChangeRecord> records = recordsBySubject.get(subject.map(OWLEntity::getIRI));
        if (records == null) {
            // Nothing in this revision that changes the subject
            return;
        }
        totalChanges = records.size();
        limitedRecords.addAll(records);
    } else {
        totalChanges = revision.getSize();
        for (Map.Entry<Optional<IRI>, List<OWLOntologyChangeRecord>> entry : recordsBySubject.entrySet()) {
            limitedRecords.addAll(entry.getValue());
            if (limitedRecords.size() >= DEFAULT_CHANGE_LIMIT) {
                break;
            }
        }
    }
    Revision2DiffElementsTranslator translator = new Revision2DiffElementsTranslator(ontologyIRIShortFormProvider);
    List<DiffElement<String, OWLOntologyChangeRecord>> axiomDiffElements = translator.getDiffElementsFromRevision(limitedRecords);
    sortDiff(axiomDiffElements);
    List<DiffElement<String, SafeHtml>> renderedDiffElements = renderDiffElements(axiomDiffElements);
    int pageElements = renderedDiffElements.size();
    int pageCount;
    if (pageElements == 0) {
        pageCount = 1;
    } else {
        pageCount = totalChanges / pageElements + (totalChanges % pageElements);
    }
    Page<DiffElement<String, SafeHtml>> page = new Page<>(1, pageCount, renderedDiffElements, totalChanges);
    ProjectChange projectChange = new ProjectChange(revision.getRevisionNumber(), revision.getUserId(), revision.getTimestamp(), revision.getHighLevelDescription(), totalChanges, page);
    changesBuilder.add(projectChange);
}
Also used : DiffElement(edu.stanford.bmir.protege.web.shared.diff.DiffElement) Page(edu.stanford.bmir.protege.web.shared.pagination.Page) ProjectChange(edu.stanford.bmir.protege.web.shared.change.ProjectChange) Revision2DiffElementsTranslator(edu.stanford.bmir.protege.web.server.diff.Revision2DiffElementsTranslator) OWLOntologyChangeRecord(org.semanticweb.owlapi.change.OWLOntologyChangeRecord) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)2 ProjectChange (edu.stanford.bmir.protege.web.shared.change.ProjectChange)2 Revision2DiffElementsTranslator (edu.stanford.bmir.protege.web.server.diff.Revision2DiffElementsTranslator)1 Revision (edu.stanford.bmir.protege.web.server.revision.Revision)1 DiffElement (edu.stanford.bmir.protege.web.shared.diff.DiffElement)1 Page (edu.stanford.bmir.protege.web.shared.pagination.Page)1 Watch (edu.stanford.bmir.protege.web.shared.watches.Watch)1 HashSet (java.util.HashSet)1 OWLOntologyChangeRecord (org.semanticweb.owlapi.change.OWLOntologyChangeRecord)1