From 057dc57295687c1ef3ab78faae8a047b9a5065b8 Mon Sep 17 00:00:00 2001 From: alexsilaghi Date: Mon, 9 Dec 2024 13:47:01 +0200 Subject: [PATCH] removed cycle --- .../GetClassAncestorsActionHandler.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/main/java/edu/stanford/protege/webprotege/icd/actions/GetClassAncestorsActionHandler.java b/src/main/java/edu/stanford/protege/webprotege/icd/actions/GetClassAncestorsActionHandler.java index 12bb43c06..99dc5834f 100644 --- a/src/main/java/edu/stanford/protege/webprotege/icd/actions/GetClassAncestorsActionHandler.java +++ b/src/main/java/edu/stanford/protege/webprotege/icd/actions/GetClassAncestorsActionHandler.java @@ -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 { @@ -38,19 +36,15 @@ public Class getActionClass() { @NotNull @Override public GetClassAncestorsResult execute(@NotNull GetClassAncestorsAction action, @NotNull ExecutionContext executionContext) { - AncestorHierarchyNode classTree = classHierarchyProvider.getAncestorsTree(new OWLClassImpl(action.classIri())); - - AncestorHierarchyNode entityDataTree = mapToEntityData(classTree); - return new GetClassAncestorsResult(entityDataTree); - } - - private AncestorHierarchyNode mapToEntityData(AncestorHierarchyNode ancestorHierarchyNode) { + List> ancestors = classHierarchyProvider.getAncestors(new OWLClassImpl(action.classIri())).stream().map(owlCLass -> { + OWLEntityData entityData = renderingManager.getRendering(owlCLass); + AncestorHierarchyNode resp = new AncestorHierarchyNode<>(); + resp.setNode(entityData); + return resp; + }).toList(); AncestorHierarchyNode response = new AncestorHierarchyNode<>(); - response.setNode(renderingManager.getRendering(ancestorHierarchyNode.getNode())); - response.setChildren(new ArrayList<>()); - for(AncestorHierarchyNode 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<>()); } }