Interface OrgUnitHierarchyService

All Known Implementing Classes:
DefaultOrgUnitHierarchyService

public interface OrgUnitHierarchyService
Service interface for generating and updating the value of the path attribute of OrgUnitModel objects. The path attribute of an OrgUnitModel is a flat String representation of the path of traversal to reach the unit from the root of its organization and contains the UIDs of all units on this path separated by a delimiter.
  • Method Details

    • generateUnitPaths

      <T extends OrgUnitModel> void generateUnitPaths(Class<T> unitType)
      Generates the path value of all OrgUnitModel objects of the given unit type. The process starts with the root units, i.e. the ones that don't have a parent of the same type, and will traverse the hierarchy tree for each of them. All changes to affected items are persisted.
      Parameters:
      unitType - Determines the type to generate path values for. Sub-types will be ignored. May not be null.
      Throws:
      IllegalArgumentException - In case the passed unitType is null.
      OrgUnitHierarchyException - In case inconsistencies are discovered during the path generation process or the process failed for other reasons.
    • saveChangesAndUpdateUnitPath

      void saveChangesAndUpdateUnitPath(OrgUnitModel unit)
      Saves all changes to the given OrgUnitModel and updates its path value as well as the path values for all its descendants of the same type subsequently. All changes to affected items are persisted.

      This method should be called whenever changes to the unit include a change of its parent unit. Implementations have to make sure that all changes are rolled back in case the creation of path values fails.
      Parameters:
      unit - The OrgUnitModel to update. May not be null.
      Throws:
      IllegalArgumentException - In case the passed unit is null.
      OrgUnitHierarchyException - In case inconsistencies are discovered during the path generation process or the process failed for other reasons.