Class PathCompletion

  • All Implemented Interfaces:
    Cloneable

    public class PathCompletion
    extends Object
    implements Cloneable
    An OrgPolicy must always result in a list of agents. In order to prevent having to explicitly type a complete function path from e.g. OrgGroup down to Agent there are standard semantics that implicitly do this. And PathCompletion holds this information and even allows to change it.

    It's possible to define more than one completion for a certain entity type of which all of them have to be evaluated. Basically this means that if more than one completion exists, the whole path up to this point has to be duplicated and followed for each completion. These new paths must be combined using OR.
    It may even be that there are no completions for a certain entity type at all, which may of course cause OrgPolicies to fail.

    In any case, one should be careful about changing the default behaviour of PathCompletion as any change may have a great impact on the results of existing OrgPolicies or may even cause them to be no longer resolvable at all (as opposed to policies that can be resolved but produce an empty result list).

    There can't be a completion for Agent as this entity type obviously doesn't need one.

    Author:
    Patrick Schmidt, Ulrich Kreher
    • Constructor Detail

      • PathCompletion

        public PathCompletion()
        Constructs a new PathCompletion with these default values:
        Path completions per entity type.
        end of pathcompleted to
        OrgPosition.getAgents()
        OrgUnit.getOrgPositions()
        OrgGroup.getOrgUnits()
        ProjectGroup.getOrgUnits() + .getOrgPositions()
        Ability.getRoles() + .getAgents()
        Role.getOrgPositions()
        SubstitutionRule.getSubstitute()
      • PathCompletion

        public PathCompletion​(Map<EntityType,​NavFunction[]> completions)
        Constructs a new PathCompletion with the designated values. Entity types that do not have a completion in the designated map will be set to the default path completion.
        Parameters:
        completions - The path completions for entity types. The functions are not chained but OR’ed. Not all entity types need to be set here. For unset completions the default will be used.
    • Method Detail

      • getCompletionsFor

        public NavFunction[] getCompletionsFor​(EntityType entType)
        Returns the path completion(s) for the given entity type or null if there is no completion defined. See the class description for more information on what the NavFunction array contains.
        Parameters:
        entType - the entity type for which to return the completions
        Returns:
        the path completion(s) for the given entity type or null if there is no completion defined
      • setCompletionsFor

        public void setCompletionsFor​(EntityType entType,
                                      NavFunction... functions)
        Sets the path completions for the given entity type. If more than one function is specified they're not interpreted as a function chain but instead as a fork in the function path where all sub-paths have to be evaluated equally.
        Parameters:
        entType - the entity type to set the path completion for
        functions - the function(s) a path ending on the given entity type should be completed with
      • clearCompletionsFor

        public void clearCompletionsFor​(EntityType entType,
                                        boolean resetToDefaults)
        Clears the completions for the given entity type and optionally resets them back to the default values.
        Parameters:
        entType - the entity type for which the path completions should be cleared or reset
        resetToDefaults - whether the completions should be reset to the default values
      • checkConsistency

        public String checkConsistency()
        Checks the consistency of this path completion, that is, whether it contains a cycle. This has to be done before actually incorporating the path completion in the OrgModelManager.
        Returns:
        Whether this path completion has consistency problems (which returns a describing text) or not (which returns null).
      • clonePathCompletion

        public PathCompletion clonePathCompletion()
        Clones this path completion by returning a new path completion object having the same path completions as this object.
        Returns:
        A new path completion object having the same path completions as this object.