Search in sources :

Example 1 with GetHierarchyChildrenResult

use of edu.stanford.bmir.protege.web.shared.hierarchy.GetHierarchyChildrenResult in project webprotege by protegeproject.

the class GetEntityHierarchyChildrenActionHandler method execute.

@Nonnull
@Override
public GetHierarchyChildrenResult execute(@Nonnull GetHierarchyChildrenAction action, @Nonnull ExecutionContext executionContext) {
    HierarchyId hierarchyId = action.getHierarchyId();
    Optional<HierarchyProvider<OWLEntity>> hierarchyProvider = hierarchyProviderMapper.getHierarchyProvider(hierarchyId);
    if (!hierarchyProvider.isPresent()) {
        return emptyResult();
    }
    OWLEntity parent = action.getEntity();
    GraphNode<EntityHierarchyNode> parentNode = nodeRenderer.toGraphNode(parent, hierarchyProvider.get());
    SuccessorMap.Builder<EntityHierarchyNode> successorMap = SuccessorMap.builder();
    hierarchyProvider.get().getChildren(parent).stream().filter(child -> isNotDeprecatedTopLevelEntity(parent, child)).map(child -> nodeRenderer.toGraphNode(child, hierarchyProvider.get())).forEach(childNode -> successorMap.add(parentNode, childNode));
    successorMap.sort(comparing(GraphNode::getUserObject));
    return new GetHierarchyChildrenResult(successorMap.build());
}
Also used : HierarchyId(edu.stanford.bmir.protege.web.shared.hierarchy.HierarchyId) GetHierarchyChildrenAction(edu.stanford.bmir.protege.web.shared.hierarchy.GetHierarchyChildrenAction) GraphNode(edu.stanford.protege.gwt.graphtree.shared.graph.GraphNode) VIEW_PROJECT(edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_PROJECT) BuiltInAction(edu.stanford.bmir.protege.web.shared.access.BuiltInAction) SuccessorMap(edu.stanford.protege.gwt.graphtree.shared.graph.SuccessorMap) DeprecatedEntityChecker(edu.stanford.bmir.protege.web.server.mansyntax.render.DeprecatedEntityChecker) EntityHierarchyNode(edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode) Inject(javax.inject.Inject) AbstractProjectActionHandler(edu.stanford.bmir.protege.web.server.dispatch.AbstractProjectActionHandler) AccessManager(edu.stanford.bmir.protege.web.server.access.AccessManager) HierarchyId(edu.stanford.bmir.protege.web.shared.hierarchy.HierarchyId) ExecutionContext(edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) Optional(java.util.Optional) GetHierarchyChildrenResult(edu.stanford.bmir.protege.web.shared.hierarchy.GetHierarchyChildrenResult) Comparator.comparing(java.util.Comparator.comparing) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) EntityHierarchyNode(edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode) GetHierarchyChildrenResult(edu.stanford.bmir.protege.web.shared.hierarchy.GetHierarchyChildrenResult) OWLEntity(org.semanticweb.owlapi.model.OWLEntity) SuccessorMap(edu.stanford.protege.gwt.graphtree.shared.graph.SuccessorMap) Nonnull(javax.annotation.Nonnull)

Aggregations

AccessManager (edu.stanford.bmir.protege.web.server.access.AccessManager)1 AbstractProjectActionHandler (edu.stanford.bmir.protege.web.server.dispatch.AbstractProjectActionHandler)1 ExecutionContext (edu.stanford.bmir.protege.web.server.dispatch.ExecutionContext)1 DeprecatedEntityChecker (edu.stanford.bmir.protege.web.server.mansyntax.render.DeprecatedEntityChecker)1 BuiltInAction (edu.stanford.bmir.protege.web.shared.access.BuiltInAction)1 VIEW_PROJECT (edu.stanford.bmir.protege.web.shared.access.BuiltInAction.VIEW_PROJECT)1 EntityHierarchyNode (edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode)1 GetHierarchyChildrenAction (edu.stanford.bmir.protege.web.shared.hierarchy.GetHierarchyChildrenAction)1 GetHierarchyChildrenResult (edu.stanford.bmir.protege.web.shared.hierarchy.GetHierarchyChildrenResult)1 HierarchyId (edu.stanford.bmir.protege.web.shared.hierarchy.HierarchyId)1 GraphNode (edu.stanford.protege.gwt.graphtree.shared.graph.GraphNode)1 SuccessorMap (edu.stanford.protege.gwt.graphtree.shared.graph.SuccessorMap)1 Comparator.comparing (java.util.Comparator.comparing)1 Optional (java.util.Optional)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)1