Class GraphHelper


  • public class GraphHelper
    extends java.lang.Object
    Factors common code out of GraphQuery implementations for reuse.
    Since:
    5.2.3
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphHelper​(Helper helper, ome.services.graphs.GraphPathBean graphPathBean)
      Construct a helper for a graph request instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkIsAdministrator​(ome.model.enums.AdminPrivilege requiredPrivilege)
      Check if the current user is an administrator.
      java.util.Set<java.lang.Class<? extends ome.model.IObject>> getClassesFromNames​(java.util.Collection<java.lang.String> classNames)
      Given class names provided by the user, find the corresponding set of actual classes.
      com.google.common.collect.SetMultimap<java.lang.String,​java.lang.Long> getTargetMultimap​(java.util.Set<java.lang.Class<? extends ome.model.IObject>> legalClasses, java.util.Map<java.lang.String,​java.util.List<java.lang.Long>> targetObjects)
      Converts the Ice StringLongListMap to a multimap.
      java.util.Set<java.lang.String> getTargetSet​(java.util.Set<java.lang.Class<? extends ome.model.IObject>> legalClasses, java.util.Collection<java.lang.String> targetClasses)
      Converts the Ice StringSet to a set.
      java.util.Set<java.lang.String> getTopLevelNames​(java.lang.Iterable<java.lang.Class<? extends ome.model.IObject>> modelClasses)
      Get the simple names of the top-level superclasses of the given classes.
      ome.services.graphs.GraphTraversal prepareGraphTraversal​(java.util.List<ChildOption> childOptions, java.util.Set<ome.services.graphs.GraphPolicy.Ability> requiredPermissions, ome.services.graphs.GraphPolicy graphPolicy, java.lang.Iterable<java.util.function.Function<ome.services.graphs.GraphPolicy,​ome.services.graphs.GraphPolicy>> graphPolicyAdjusters, ome.security.ACLVoter aclVoter, ome.services.graphs.GraphPathBean graphPathBean, com.google.common.collect.SetMultimap<java.lang.String,​java.lang.String> unnullable, ome.services.graphs.GraphTraversal.Processor processor, boolean dryRun)
      Construct a graph traversal manager for a GraphQuery request.
      void publishEventLog​(org.springframework.context.ApplicationContext context, java.lang.String action, java.lang.String className, java.util.Collection<java.lang.Long> ids)
      Publish database changes to the event log.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GraphHelper

        public GraphHelper​(Helper helper,
                           ome.services.graphs.GraphPathBean graphPathBean)
        Construct a helper for a graph request instance.
        Parameters:
        helper - the general request helper for the graph request instance
        graphPathBean - the graph path bean
    • Method Detail

      • checkIsAdministrator

        public boolean checkIsAdministrator​(ome.model.enums.AdminPrivilege requiredPrivilege)
        Check if the current user is an administrator.
        Parameters:
        requiredPrivilege - the privilege that the administrator must have if they are a light administrator
        Returns:
        if the current user is an administrator
      • getClassesFromNames

        public java.util.Set<java.lang.Class<? extends ome.model.IObject>> getClassesFromNames​(java.util.Collection<java.lang.String> classNames)
        Given class names provided by the user, find the corresponding set of actual classes.
        Parameters:
        classNames - names of model object classes
        Returns:
        the named classes
      • prepareGraphTraversal

        public ome.services.graphs.GraphTraversal prepareGraphTraversal​(java.util.List<ChildOption> childOptions,
                                                                        java.util.Set<ome.services.graphs.GraphPolicy.Ability> requiredPermissions,
                                                                        ome.services.graphs.GraphPolicy graphPolicy,
                                                                        java.lang.Iterable<java.util.function.Function<ome.services.graphs.GraphPolicy,​ome.services.graphs.GraphPolicy>> graphPolicyAdjusters,
                                                                        ome.security.ACLVoter aclVoter,
                                                                        ome.services.graphs.GraphPathBean graphPathBean,
                                                                        com.google.common.collect.SetMultimap<java.lang.String,​java.lang.String> unnullable,
                                                                        ome.services.graphs.GraphTraversal.Processor processor,
                                                                        boolean dryRun)
        Construct a graph traversal manager for a GraphQuery request.
        Parameters:
        childOptions - the child options set on the request
        requiredPermissions - the abilities that the user must have to operate upon an object for it to be included
        graphPolicy - the graph policy for the request
        graphPolicyAdjusters - the adjusters to be applied to the graph policy
        aclVoter - ACL voter for permissions checking
        graphPathBean - the graph path bean
        unnullable - properties that, while nullable, may not be nulled by a graph traversal operation
        processor - how to operate on the resulting target object graph
        dryRun - if the request should skip the actual model object updates
        Returns:
        the new graph traversal manager
      • getTargetSet

        public java.util.Set<java.lang.String> getTargetSet​(java.util.Set<java.lang.Class<? extends ome.model.IObject>> legalClasses,
                                                            java.util.Collection<java.lang.String> targetClasses)
        Converts the Ice StringSet to a set.
        Parameters:
        legalClasses - legal target object classes
        targetClasses - the actual target object classes
        Returns:
        a set of the legal model objects to process
        Throws:
        ome.conditions.InternalException - if any of the target classes are illegal
      • getTargetMultimap

        public com.google.common.collect.SetMultimap<java.lang.String,​java.lang.Long> getTargetMultimap​(java.util.Set<java.lang.Class<? extends ome.model.IObject>> legalClasses,
                                                                                                              java.util.Map<java.lang.String,​java.util.List<java.lang.Long>> targetObjects)
        Converts the Ice StringLongListMap to a multimap.
        Parameters:
        legalClasses - legal target object classes
        targetObjects - the model objects to process
        Returns:
        a multimap of the legal model objects to process
        Throws:
        ome.conditions.InternalException - if any of the target object classes are illegal
      • getTopLevelNames

        public java.util.Set<java.lang.String> getTopLevelNames​(java.lang.Iterable<java.lang.Class<? extends ome.model.IObject>> modelClasses)
        Get the simple names of the top-level superclasses of the given classes.
        Parameters:
        modelClasses - some model classes
        Returns:
        the simple names of their top-level classes
      • publishEventLog

        public void publishEventLog​(org.springframework.context.ApplicationContext context,
                                    java.lang.String action,
                                    java.lang.String className,
                                    java.util.Collection<java.lang.Long> ids)
        Publish database changes to the event log.
        Parameters:
        context - the context for publishing the application event
        action - the name of the change action
        className - the class of objects that were changed
        ids - the IDs of the objects that were changed