Skip to content

Commit

Permalink
removed cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsilaghi committed Dec 9, 2024
1 parent 25987b5 commit 057dc57
Showing 1 changed file with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import edu.stanford.protege.webprotege.ipc.ExecutionContext;
import edu.stanford.protege.webprotege.renderer.RenderingManager;
import org.jetbrains.annotations.NotNull;
import org.semanticweb.owlapi.model.OWLClass;
import uk.ac.manchester.cs.owl.owlapi.OWLClassImpl;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@JsonTypeName("webprotege.entities.GetClassAncestors")
public class GetClassAncestorsActionHandler extends AbstractProjectActionHandler<GetClassAncestorsAction, GetClassAncestorsResult> {
Expand All @@ -38,19 +36,15 @@ public Class<GetClassAncestorsAction> getActionClass() {
@NotNull
@Override
public GetClassAncestorsResult execute(@NotNull GetClassAncestorsAction action, @NotNull ExecutionContext executionContext) {
AncestorHierarchyNode<OWLClass> classTree = classHierarchyProvider.getAncestorsTree(new OWLClassImpl(action.classIri()));

AncestorHierarchyNode<OWLEntityData> entityDataTree = mapToEntityData(classTree);
return new GetClassAncestorsResult(entityDataTree);
}

private AncestorHierarchyNode<OWLEntityData> mapToEntityData(AncestorHierarchyNode<OWLClass> ancestorHierarchyNode) {
List<AncestorHierarchyNode<OWLEntityData>> ancestors = classHierarchyProvider.getAncestors(new OWLClassImpl(action.classIri())).stream().map(owlCLass -> {
OWLEntityData entityData = renderingManager.getRendering(owlCLass);
AncestorHierarchyNode<OWLEntityData> resp = new AncestorHierarchyNode<>();
resp.setNode(entityData);
return resp;
}).toList();
AncestorHierarchyNode<OWLEntityData> response = new AncestorHierarchyNode<>();
response.setNode(renderingManager.getRendering(ancestorHierarchyNode.getNode()));
response.setChildren(new ArrayList<>());
for(AncestorHierarchyNode<OWLClass> child: ancestorHierarchyNode.getChildren()) {
response.getChildren().add(mapToEntityData(child));
}
return response;
response.setNode(renderingManager.getRendering(new OWLClassImpl(action.classIri())));
response.setChildren(ancestors);
return new GetClassAncestorsResult(new AncestorHierarchyNode<>());
}
}

0 comments on commit 057dc57

Please sign in to comment.