diff --git a/src/main/java/edu/stanford/protege/webprotege/icd/actions/CreateClassesFromApiActionHandler.java b/src/main/java/edu/stanford/protege/webprotege/icd/actions/CreateClassesFromApiActionHandler.java index 308057847..0e3e71732 100644 --- a/src/main/java/edu/stanford/protege/webprotege/icd/actions/CreateClassesFromApiActionHandler.java +++ b/src/main/java/edu/stanford/protege/webprotege/icd/actions/CreateClassesFromApiActionHandler.java @@ -85,35 +85,37 @@ protected CreateClassesFromApiResult createActionResult(ChangeApplicationResult< CreateClassesFromApiAction action, ExecutionContext executionContext) { - Set classes = changeApplicationResult.getSubject(); - classes.forEach(newClass -> - { - try { - linearizationManager.createLinearizationFromParent( - newClass.getIRI(), - IRI.create(action.parent()), - action.projectId(), - executionContext - ).get(); - } catch (InterruptedException | ExecutionException e) { - logger.error("CreateLinearizationsError: " + e); - } - try { - postcoordinationManager.createPostcoordinationFromParent( - newClass.getIRI(), - IRI.create(action.parent()), - action.projectId(), - executionContext - ).get(); - } catch (InterruptedException | ExecutionException e) { - logger.error("CreatePostcoordinationError: " + e); - } - } - ); - return new CreateClassesFromApiResult( - action.changeRequestId(), - action.projectId(), - classes.stream().map(OWLClass::toStringID).collect(toImmutableSet()) - ); + if (changeApplicationResult.getSubject().size() == 0) { + logger.error("Missing subject on create class from api with parent : " + action.parent()); + throw new RuntimeException("Missing subject on create class from api with parent : " + action.parent()); + } else { + OWLClass newClass = changeApplicationResult.getSubject().stream().findFirst().get(); + try { + linearizationManager.createLinearizationFromParent( + newClass.getIRI(), + IRI.create(action.parent()), + action.projectId(), + executionContext + ).get(); + } catch (InterruptedException | ExecutionException e) { + logger.error("CreateLinearizationsError: " + e); + } + try { + postcoordinationManager.createPostcoordinationFromParent( + newClass.getIRI(), + IRI.create(action.parent()), + action.projectId(), + executionContext + ).get(); + } catch (InterruptedException | ExecutionException e) { + logger.error("CreatePostcoordinationError: " + e); + } + return new CreateClassesFromApiResult( + action.changeRequestId(), + action.projectId(), + newClass.toStringID() + ); + } } + } diff --git a/src/main/java/edu/stanford/protege/webprotege/icd/actions/CreateClassesFromApiResult.java b/src/main/java/edu/stanford/protege/webprotege/icd/actions/CreateClassesFromApiResult.java index e2aee3a66..12c746de5 100644 --- a/src/main/java/edu/stanford/protege/webprotege/icd/actions/CreateClassesFromApiResult.java +++ b/src/main/java/edu/stanford/protege/webprotege/icd/actions/CreateClassesFromApiResult.java @@ -9,5 +9,5 @@ import static edu.stanford.protege.webprotege.icd.actions.CreateClassesFromApiAction.CHANNEL; @JsonTypeName(CHANNEL) -public record CreateClassesFromApiResult(ChangeRequestId changeRequestId, ProjectId projectId, Set newEntityIris) implements Response, Result { +public record CreateClassesFromApiResult(ChangeRequestId changeRequestId, ProjectId projectId, String newEntityIri) implements Response, Result { }