Search in sources :

Example 1 with OntologyDiff2OntologyChanges

use of edu.stanford.bmir.protege.web.server.diff.OntologyDiff2OntologyChanges in project webprotege by protegeproject.

the class MergeUploadedProjectActionHandler method execute.

@Nonnull
@Override
public MergeUploadedProjectResult execute(@Nonnull MergeUploadedProjectAction action, @Nonnull ExecutionContext executionContext) {
    try {
        DocumentId documentId = action.getUploadedDocumentId();
        final OWLOntology uploadedRootOntology = loadUploadedOntology(documentId);
        ModifiedProjectOntologiesCalculator calculator = new ModifiedProjectOntologiesCalculator(ImmutableSet.copyOf(projectRootOntology.getImportsClosure()), ImmutableSet.copyOf(uploadedRootOntology.getImportsClosure()), new OntologyDiffCalculator(new AnnotationDiffCalculator(), new AxiomDiffCalculator()));
        Set<OntologyDiff> ontologyDiffSet = calculator.getModifiedOntologyDiffs();
        List<OWLOntologyChange> changeList = new ArrayList<>();
        HasGetOntologyById man = projectRootOntology.getOWLOntologyManager();
        for (OntologyDiff diff : ontologyDiffSet) {
            OntologyDiff2OntologyChanges diff2Changes = new OntologyDiff2OntologyChanges();
            List<OWLOntologyChange> changes = diff2Changes.getOntologyChangesFromDiff(diff, man);
            changeList.addAll(changes);
        }
        applyChanges(action.getCommitMessage(), changeList, executionContext);
    } catch (IOException | OWLOntologyCreationException e) {
        throw new ActionExecutionException(e);
    }
    return new MergeUploadedProjectResult();
}
Also used : DocumentId(edu.stanford.bmir.protege.web.shared.csv.DocumentId) ArrayList(java.util.ArrayList) MergeUploadedProjectResult(edu.stanford.bmir.protege.web.shared.merge.MergeUploadedProjectResult) IOException(java.io.IOException) OntologyDiff2OntologyChanges(edu.stanford.bmir.protege.web.server.diff.OntologyDiff2OntologyChanges) ActionExecutionException(edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException) OntologyDiff(edu.stanford.bmir.protege.web.shared.merge.OntologyDiff) Nonnull(javax.annotation.Nonnull)

Aggregations

OntologyDiff2OntologyChanges (edu.stanford.bmir.protege.web.server.diff.OntologyDiff2OntologyChanges)1 DocumentId (edu.stanford.bmir.protege.web.shared.csv.DocumentId)1 ActionExecutionException (edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException)1 MergeUploadedProjectResult (edu.stanford.bmir.protege.web.shared.merge.MergeUploadedProjectResult)1 OntologyDiff (edu.stanford.bmir.protege.web.shared.merge.OntologyDiff)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1