Search in sources :

Example 1 with OntologyDiff

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

Example 2 with OntologyDiff

use of edu.stanford.bmir.protege.web.shared.merge.OntologyDiff in project webprotege by protegeproject.

the class ComputeProjectMergeActionHandler method execute.

@Nonnull
@Override
public ComputeProjectMergeResult execute(@Nonnull ComputeProjectMergeAction action, @Nonnull ExecutionContext executionContext) {
    try {
        DocumentId documentId = action.getProjectDocumentId();
        OWLOntology uploadedRootOntology = loadUploadedOntology(documentId);
        Set<OntologyDiff> diffs = computeDiff(uploadedRootOntology, projectRootOntology);
        List<DiffElement<String, SafeHtml>> transformedDiff = renderDiff(uploadedRootOntology, diffs);
        return new ComputeProjectMergeResult(transformedDiff);
    } catch (Exception e) {
        logger.info("An error occurred whilst merging ontologies", e);
        throw new RuntimeException(e);
    }
}
Also used : DiffElement(edu.stanford.bmir.protege.web.shared.diff.DiffElement) ComputeProjectMergeResult(edu.stanford.bmir.protege.web.shared.merge.ComputeProjectMergeResult) DocumentId(edu.stanford.bmir.protege.web.shared.csv.DocumentId) OntologyDiff(edu.stanford.bmir.protege.web.shared.merge.OntologyDiff) IOException(java.io.IOException) Nonnull(javax.annotation.Nonnull)

Aggregations

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