Search in sources :

Example 1 with ActionExecutionException

use of edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException in project webprotege by protegeproject.

the class DispatchServiceCallbackWithProgress_TestCase method shouldCall_handleExecutionException.

@Test
public void shouldCall_handleExecutionException() {
    ActionExecutionException actionExecutionException = mock(ActionExecutionException.class);
    Throwable cause = mock(Throwable.class);
    when(actionExecutionException.getCause()).thenReturn(cause);
    callback.onFailure(actionExecutionException);
    verify(callback, times(1)).handleExecutionException(cause);
    verify(messageDisplay, times(1)).displayGeneralErrorMessage(anyString(), anyString());
}
Also used : ActionExecutionException(edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException) Test(org.junit.Test)

Example 2 with ActionExecutionException

use of edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException in project webprotege by protegeproject.

the class DispatchServiceCallback_TestCase method shouldCall_handleExecutionException.

@Test
public void shouldCall_handleExecutionException() {
    ActionExecutionException actionExecutionException = mock(ActionExecutionException.class);
    Throwable cause = mock(Throwable.class);
    when(actionExecutionException.getCause()).thenReturn(cause);
    callback.onFailure(actionExecutionException);
    verify(callback, times(1)).handleExecutionException(cause);
    verify(messageDisplay, times(1)).displayGeneralErrorMessage(anyString(), anyString());
}
Also used : ActionExecutionException(edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException) Test(org.junit.Test)

Example 3 with ActionExecutionException

use of edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException 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

ActionExecutionException (edu.stanford.bmir.protege.web.shared.dispatch.ActionExecutionException)3 Test (org.junit.Test)2 OntologyDiff2OntologyChanges (edu.stanford.bmir.protege.web.server.diff.OntologyDiff2OntologyChanges)1 DocumentId (edu.stanford.bmir.protege.web.shared.csv.DocumentId)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