Class OrgClosureManager
- java.lang.Object
-
- com.evolveum.midpoint.repo.sql.helpers.OrgClosureManager
-
@Component @DependsOn("schemaChecker") 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 (http://vadimtropashko.wordpress.com/) namely from Chapter 6 (http://vadimtropashko.files.wordpress.com/2014/01/book_sql_chap6_v1.pdf). SQL queries were then optimized by hand for various database engines.
- Author:
- lazyman, mederly
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OrgClosureManager.Context
static class
OrgClosureManager.Edge
static class
OrgClosureManager.Operation
static class
OrgClosureManager.StartupAction
-
Constructor Summary
Constructors Constructor Description OrgClosureManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.void
cleanUpAfterOperation(OrgClosureManager.Context closureContext, org.hibernate.Session session)
long
getLastOperationDuration()
void
initialize()
boolean
isEnabled()
<T extends ObjectType>
OrgClosureManager.ContextonBeginTransactionAdd(org.hibernate.Session session, PrismObject<T> object, boolean overwrite)
<T extends ObjectType>
OrgClosureManager.ContextonBeginTransactionDelete(org.hibernate.Session session, Class<T> type, String oid)
<T extends ObjectType>
OrgClosureManager.ContextonBeginTransactionModify(org.hibernate.Session session, Class<T> type, String oid, Collection<? extends ItemDelta> modifications)
<T extends ObjectType>
voidupdateOrgClosure(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.
-
-
-
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.- Parameters:
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.
-
onBeginTransactionAdd
public <T extends ObjectType> OrgClosureManager.Context onBeginTransactionAdd(org.hibernate.Session session, PrismObject<T> object, boolean overwrite)
-
onBeginTransactionModify
public <T extends ObjectType> OrgClosureManager.Context onBeginTransactionModify(org.hibernate.Session session, Class<T> type, String oid, Collection<? extends ItemDelta> modifications)
-
onBeginTransactionDelete
public <T extends ObjectType> OrgClosureManager.Context onBeginTransactionDelete(org.hibernate.Session session, Class<T> type, String oid)
-
cleanUpAfterOperation
public void cleanUpAfterOperation(OrgClosureManager.Context closureContext, org.hibernate.Session session)
-
initialize
@PostConstruct public void initialize()
-
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()
-
-