Class OrgClosureManager

  • @Component
    public class OrgClosureManager
    extends Object
    This class and its subclasses provides org. closure table handling.

    Data structures used are:

    (1) Repo object graph G = (V, E) where V is a set of vertices (repo objects) and E is a set of edges (parentRef relations). There is an edge e = (V1, V2) in E [i.e. edge from V1 to V2] if and only if V1.parentRef contains V2 [i.e. V2 is a parent of V1].

    (2) OrgClosure table. OrgClosure(D, A, N) iff there are exactly N paths in object graph from D (descendant) to A (ancestor). It is transitive reflexive closure, i.e. OrgClosure(V, V, 1) items are there as well.

    Algorithms taken from "SQL Design Patterns" book by Vadim Tropashko ( namely from Chapter 6 ( SQL queries were then optimized by hand for various database engines.

    lazyman, mederly
    • Constructor Detail

      • OrgClosureManager

        public OrgClosureManager()
    • Method Detail

      • updateOrgClosure

        public <T extends ObjectType> void updateOrgClosure​(PrismObject<? extends ObjectType> originalObject,
                                                            Collection<? extends ItemDelta> modifications,
                                                            org.hibernate.Session session,
                                                            String oid,
                                                            Class<T> type,
                                                            OrgClosureManager.Operation operation,
                                                            OrgClosureManager.Context closureContext)
        Main method called from SQL repository service to update the closure table during an operation.
        originalObject - Original state of the object - before applying modification in the repository. It is used only in case of MODIFY (note that "overwriting ADD" is present here as MODIFY!)
        modifications - Collection of modifications to be applied to the object.
        session - Database session to use.
        oid - OID of the object.
        type - Type of the object.
        operation - Operation that is carried out.
      • cleanUpAfterOperation

        public void cleanUpAfterOperation​(OrgClosureManager.Context closureContext,
                                          org.hibernate.Session session)
      • isEnabled

        public boolean isEnabled()
      • checkAndOrRebuild

        public void checkAndOrRebuild​(boolean check,
                                      boolean rebuild,
                                      boolean stopOnFailure,
                                      boolean quickCheckOnly,
                                      OperationResult result)
        Does a consistency check (either quick or thorough one) and rebuilds the closure table if necessary.

        Quick check is conducted by comparing whether are there any orgs without entries in closure (the reverse direction is ensured via foreign keys in m_org_closure).

        Thorough check is conducted by recomputing the closure table.

      • getLastOperationDuration

        public long getLastOperationDuration()