Class RelationGraph
java.lang.Object
edu.internet2.middleware.grouper.app.graph.RelationGraph
Class to build a directed graph from Grouper relationships. The graph is
initialized from a single starting node. From there it will branch to the
node's parents and children recursively until exhausted. Nodes can be of a
subset of GrouperObject types -- Group, Stem, Subject (as GrouperObjectSubjectWrapper).
A pseudo-object for provisioners is also implemented in this package so that PSPNG
provisioning targets can be represented as nodes. For stems, it will get the parents
and children of all its child groups.
Each node contains an underlying GrouperObject type. Edges contain the directed relationship
from parent to child. The methods involved in building the graph are influenced by setup
parameters. For example, a build can include or exclude showing stems, or can filter certain
stems based on regular expressions. The build can also optionally count group memberships
and include the results as extra data within the nodes. As the build recursively follows parents
and children, it stored the distanec (number of hops) from each node to the start node.
After the build, The full set of nodes, edges, the starting node, and other information can be
retrieved from the graph object.
There is a hard limit of 100 levels, as an emergency stop against unforeseen cycles that miss
detection.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionassignChildLevels
(long theChildLevels) sets the maximum number of child levels to include in the graphassignIncludeGroupsInMemberCounts
(boolean includeGroupsInMemberCounts) flags whether to include groups in the count of group membersassignMaxSiblings
(long theMaxSiblings) The maximum number of objects of the same type to add as parents/children, or a value zero or less to include all objects.assignParentLevels
(long theParentLevels) sets the maximum number of parent levels to include in the graphassignShowAllMemberCounts
(boolean theShowAllMemberCounts) flags whether to count memberships (direct and indirect) for groupsassignShowDirectMemberCounts
(boolean theShowDirectMemberCounts) flags whether to count direct memberships for groupsassignShowLoaderJobs
(boolean theShowLoaderJobs) flags whether to show the loader jobs that populate groupsassignShowObjectTypes
(boolean theShowObjectTypes) flags whether to show the object type strings (e.g.assignShowProvisionTargets
(boolean theShowProvisionTargets) flags whether to show provisioner targets.assignShowStems
(boolean theShowStems) flags whether to show stemsassignSkipFolderNamePatterns
(Set<String> theSkipFolderNamePatterns) Assigns patterns for stem names to be filtered out.assignSkipGroupNamePatterns
(Set<String> theSkipGroupNamePatterns) Assigns patterns for group names to be filtered out.assignStartObject
(GrouperObject theStartObject) sets theGrouperObject
object to serve as the starting point of the graphassignStartObject
(Subject theStartSubject) sets the start object from a subject, by converting to aGrouperObjectSubjectWrapper
assignSubjectForIsMemberCheck
(Subject theSubject) If we're checking whether a subject is a member of each groupvoid
build()
Builds the directed graph.long
returns the number of child levels to include in the graphlong
after building, the total of all direct memberships in all groupsgetEdges()
after building, returns the set of all edgesreturns all the bottom level child nodes (nodes with no children)returns all the top level parent nodes (nodes with no parents)long
After building, returns the highest child distance from the starting node.long
After building, returns the highest parent distance from the starting node.long
returns the maximum number of objects of the same type to be included as parents or children of an objectgetNode
(GrouperObject object) retrieve a graph node based on its contained Grouper objectgetNodes()
after building, returns the set of all nodeslong
after building, returns how many groups have memberships loaded from loader jobslong
after building, returns how many groups have one or more provisioner targetslong
after building, returns how many loader jobs were encounteredlong
after building, returns how many distinct provisioners were encounteredlong
after building, returns how many folders were skipped as the result of filterslong
after building, returns how many groups were skipped as the result of filterskeep track of which types are used for legendlong
returns the number of parent levels to include in the graphreturns the filters for stems when building the graphreturns the filters for stems when building the graphstatic AttributeDefName
should be only useful forGraphNode
nodes needing the sql loader attribute within the context of the user sessionThe initializing object for the object, wrapped in a nodeIf we're checking whether a subject is a member of each grouplong
after building, the total of all memberships in all groupsboolean
returns whether to include groups in the count of group membersboolean
returns whether memberships are counted for Group nodesboolean
returns whether direct memberships are counted for Group nodesboolean
returns whether loader jobs should be included as graph nodesboolean
returns whether to show object types for stems and groupsboolean
returns whether provisioner targets should be included as graph nodesboolean
returns whether stems should be included as graph nodes
-
Field Details
-
RECURSIVE_LEVEL_LIMIT
public static final int RECURSIVE_LEVEL_LIMIT- See Also:
-
-
Constructor Details
-
RelationGraph
public RelationGraph()Create a new graph with default settings. Caller should call the various assign methods to set build parameters, and then call build() to construct the graph.
-
-
Method Details
-
assignStartObject
sets theGrouperObject
object to serve as the starting point of the graph- Parameters:
theStartObject
- Group, Stem, or GrouperObjectSubjectWrapper object to start the tree from- Returns:
-
assignStartObject
sets the start object from a subject, by converting to aGrouperObjectSubjectWrapper
- Parameters:
theStartSubject
- subject to start the tree from- Returns:
-
assignParentLevels
sets the maximum number of parent levels to include in the graph- Parameters:
theParentLevels
- number of parent steps to include, or -1 to include all levels- Returns:
-
assignChildLevels
sets the maximum number of child levels to include in the graph- Parameters:
theChildLevels
- number of child steps to include, or -1 to include all levels- Returns:
-
assignShowAllMemberCounts
flags whether to count memberships (direct and indirect) for groups- Parameters:
theShowAllMemberCounts
- whether to count memberships for groups- Returns:
-
assignShowDirectMemberCounts
flags whether to count direct memberships for groups- Parameters:
theShowDirectMemberCounts
- whether to count direct memberships for groups- Returns:
-
assignShowObjectTypes
flags whether to show the object type strings (e.g. ref, basis ...) for stems and groups- Parameters:
theShowObjectTypes
- whether to count direct memberships for groups- Returns:
-
assignShowLoaderJobs
flags whether to show the loader jobs that populate groups- Parameters:
theShowLoaderJobs
- whether to include loader jobs- Returns:
-
assignSubjectForIsMemberCheck
If we're checking whether a subject is a member of each group- Parameters:
theSearchSubject
-- Returns:
-
assignShowProvisionTargets
flags whether to show provisioner targets. If set, this requires that the attribute definition for etc:pspng:provision_to be created, otherwise an exception in the build will occur- Parameters:
theShowProvisionTargets
- whether to include provisioner targets- Returns:
-
assignShowStems
flags whether to show stems- Parameters:
theShowStems
- whether to include stems- Returns:
-
assignIncludeGroupsInMemberCounts
flags whether to include groups in the count of group members- Parameters:
includeGroupsInMemberCounts
- whether to consider groups when counting members- Returns:
-
assignSkipFolderNamePatterns
Assigns patterns for stem names to be filtered out. Will not skip the starting node even if it matches.- Parameters:
theSkipFolderNamePatterns
- the set of regular expressions to filter out matching stem names
-
assignSkipGroupNamePatterns
Assigns patterns for group names to be filtered out. Will not skip the starting node even if it matches.- Parameters:
theSkipGroupNamePatterns
- the set of regular expressions to filter out matching group names
-
assignMaxSiblings
The maximum number of objects of the same type to add as parents/children, or a value zero or less to include all objects. Any more than this will be excluded from the graph. The same "type" refers to the role; e.g., both loader jobs and members will be parents of a group, but are different types.- Parameters:
theMaxSiblings
- the maximum number of sibling objects before filtering out additional ones
-
getParentLevels
public long getParentLevels()returns the number of parent levels to include in the graph- Returns:
- the maximum number of parent levels to include in the graph
- See Also:
-
getChildLevels
public long getChildLevels()returns the number of child levels to include in the graph- Returns:
- the maximum number of child levels to include in the graph
- See Also:
-
isShowAllMemberCounts
public boolean isShowAllMemberCounts()returns whether memberships are counted for Group nodes- Returns:
- if memberships are counted for groups
- See Also:
-
isShowDirectMemberCounts
public boolean isShowDirectMemberCounts()returns whether direct memberships are counted for Group nodes- Returns:
- if direct memberships are counted for groups
- See Also:
-
isShowObjectTypes
public boolean isShowObjectTypes()returns whether to show object types for stems and groups- Returns:
- if showing object types
- See Also:
-
isShowLoaderJobs
public boolean isShowLoaderJobs()returns whether loader jobs should be included as graph nodes- Returns:
- if loader jobs should be included in the graph
- See Also:
-
isShowProvisionTargets
public boolean isShowProvisionTargets()returns whether provisioner targets should be included as graph nodes- Returns:
- if provisioners should be included in the graph
- See Also:
-
isShowStems
public boolean isShowStems()returns whether stems should be included as graph nodes- Returns:
- if stems should be included in the graph
- See Also:
-
isIncludeGroupsInMemberCounts
public boolean isIncludeGroupsInMemberCounts()returns whether to include groups in the count of group members- Returns:
- if groups are considered in the count of group members
- See Also:
-
getSkipFolderNamePatterns
returns the filters for stems when building the graph- Returns:
- the set of regular expressions to filter out matching stem names
- See Also:
-
getSkipGroupNamePatterns
returns the filters for stems when building the graph- Returns:
- the set of regular expressions to filter out matching stem names
- See Also:
-
getMaxSiblings
public long getMaxSiblings()returns the maximum number of objects of the same type to be included as parents or children of an object- Returns:
- the maximum number of objects of the same type to be included in relations
- See Also:
-
getStartNode
The initializing object for the object, wrapped in a node- Returns:
- the starting node
-
getEdges
after building, returns the set of all edges- Returns:
- The set of all edges in the built graph
-
getNodes
after building, returns the set of all nodes- Returns:
- The set of all nodes in the built graph
-
getNumSkippedFolders
public long getNumSkippedFolders()after building, returns how many folders were skipped as the result of filters- Returns:
- the number of folders skipped due to filters
-
getNumSkippedGroups
public long getNumSkippedGroups()after building, returns how many groups were skipped as the result of filters- Returns:
- the number of groups skipped due to filters
-
getNumLoaders
public long getNumLoaders()after building, returns how many loader jobs were encountered- Returns:
- the number of loader jobs in the graph
-
getNumGroupsFromLoaders
public long getNumGroupsFromLoaders()after building, returns how many groups have memberships loaded from loader jobs- Returns:
- the number of groups loaded from loader jobs
-
getNumProvisioners
public long getNumProvisioners()after building, returns how many distinct provisioners were encountered- Returns:
- the number of provisioning targets in the graph
-
getTotalMemberCount
public long getTotalMemberCount()after building, the total of all memberships in all groups- Returns:
- the total of all group memberships
-
getDirectMemberCount
public long getDirectMemberCount()after building, the total of all direct memberships in all groups- Returns:
- the total of direct group memberships
-
getSubjectForIsMemberCheck
If we're checking whether a subject is a member of each group- Returns:
- the subject
-
getNumGroupsToProvisioners
public long getNumGroupsToProvisioners()after building, returns how many groups have one or more provisioner targets- Returns:
- the number of groups loaded from loader jobs
-
getMaxParentDistance
public long getMaxParentDistance()After building, returns the highest parent distance from the starting node. This will always be a positive number, even though parents of the start node will have property distanceFromStartNode less than zero.- Returns:
- the the maximum parent distance from the starting node
-
getMaxChildDistance
public long getMaxChildDistance()After building, returns the highest child distance from the starting node. This will always be zero or greater.- Returns:
- the the maximum child distance from the starting node
-
getLeafParentNodes
returns all the top level parent nodes (nodes with no parents)- Returns:
- all nodes which do not have parent nodes
-
getLeafChildNodes
returns all the bottom level child nodes (nodes with no children)- Returns:
- all nodes which do not have child nodes
-
getNode
retrieve a graph node based on its contained Grouper object- Parameters:
object
- the Grouper object to query- Returns:
- the node containing this object, or null if not found
-
build
public void build()Builds the directed graph. Beginning with the starting node, will recursively walk its parents and children. For stems, will visit the parents and children of all its child groups. If starting with a subject, will only visit the children. -
getObjectTypesUsed
keep track of which types are used for legend- Returns:
- the objectTypesUsed
-
getSqlLoaderAttributeDefName
should be only useful forGraphNode
nodes needing the sql loader attribute within the context of the user session- Returns:
-