Search in sources :

Example 6 with EntityHierarchyNode

use of edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode 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)

Example 7 with EntityHierarchyNode

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

the class EntityHierarchyNodeUpdater method handleEntityTagsChanged.

private void handleEntityTagsChanged(EntityTagsChangedEvent event) {
    if (model == null) {
        throw createHierarchyModelIsNullException();
    }
    model.getHierarchyNode(event.getEntity()).ifPresent(node -> {
        EntityHierarchyNode updatedNode = new EntityHierarchyNode(node.getEntity(), node.getBrowserText(), node.isDeprecated(), node.getWatches(), node.getOpenCommentCount(), event.getTags());
        model.updateNode(updatedNode);
    });
}
Also used : EntityHierarchyNode(edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode)

Example 8 with EntityHierarchyNode

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

the class EntityHierarchyNodeUpdater method handleEntityDeprecatedChanged.

private void handleEntityDeprecatedChanged(EntityDeprecatedChangedEvent event) {
    if (model == null) {
        throw createHierarchyModelIsNullException();
    }
    model.getHierarchyNode(event.getEntity()).ifPresent(node -> {
        EntityHierarchyNode updatedNode = new EntityHierarchyNode(node.getEntity(), node.getBrowserText(), event.isDeprecated(), node.getWatches(), node.getOpenCommentCount(), node.getTags());
        model.updateNode(updatedNode);
    });
}
Also used : EntityHierarchyNode(edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode)

Example 9 with EntityHierarchyNode

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

the class EntityHierarchyNodeUpdater method handleCommentPosted.

private void handleCommentPosted(CommentPostedEvent event) {
    if (model == null) {
        throw createHierarchyModelIsNullException();
    }
    event.getEntity().ifPresent(entity -> {
        model.getHierarchyNode(entity.getEntity()).ifPresent(node -> {
            EntityHierarchyNode updatedNode = new EntityHierarchyNode(node.getEntity(), node.getBrowserText(), node.isDeprecated(), node.getWatches(), event.getOpenCommentCountForEntity(), node.getTags());
            model.updateNode(updatedNode);
        });
    });
}
Also used : EntityHierarchyNode(edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode)

Aggregations

EntityHierarchyNode (edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode)9 OWLEntity (org.semanticweb.owlapi.model.OWLEntity)2 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 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 MoveHierarchyNodeAction (edu.stanford.bmir.protege.web.shared.hierarchy.MoveHierarchyNodeAction)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