Skip to content

Commit

Permalink
process a single class from create entity on api.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsilaghi committed Dec 11, 2024
1 parent 2ce5a63 commit ea7b5ba
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,37 @@ protected CreateClassesFromApiResult createActionResult(ChangeApplicationResult<
CreateClassesFromApiAction action,
ExecutionContext executionContext) {

Set<OWLClass> 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()
);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
import static edu.stanford.protege.webprotege.icd.actions.CreateClassesFromApiAction.CHANNEL;

@JsonTypeName(CHANNEL)
public record CreateClassesFromApiResult(ChangeRequestId changeRequestId, ProjectId projectId, Set<String> newEntityIris) implements Response, Result {
public record CreateClassesFromApiResult(ChangeRequestId changeRequestId, ProjectId projectId, String newEntityIri) implements Response, Result {
}

0 comments on commit ea7b5ba

Please sign in to comment.