Package org.mycore.datamodel.common
Class MCRMarkManager
java.lang.Object
org.mycore.datamodel.common.MCRMarkManager
Experimental class to improve performance on delete and import operations.
You can mark object's as "will be deleted" or "will be imported". You can
use this information on
MCREventHandler
's to exclude those
marked objects from operations which makes no sense.
Current delete behavior:
- An user delete's a parent object with 500 children.
- MyCoRe tries to delete the parent, but first, it has to delete all children.
- MyCoRe runs through each child and deletes it.
- BUT after the deletion of ONE child, the parent object will be updated.
- This results in updating the parent 500 times, before its actually deleted.
What this class tries to solve:
We mark the parent as "will be deleted". When a child is deleted, and the EventHandler tries
to removed the child from its parent, the parent will not be updated because its "marked as
deleted".
Current import behavior:
- An import is started with a bunch of hierarchic objects.
- MyCoRe imports all the objects and does a "create" update.
- BUT for each object created the parent is updated again (because a child was added)!
- This results in unnecessary updates.
What this class tries to solve:
We mark all objects as "will be imported". On import, we ignore all solr index call for
those objects. After the import, we delete all marks and do an solr import for all
objects at once.
- Author:
- Matthias Eichner
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic MCRMarkManager
instance()
Returns the instance to the singletonMCRMarkManager
.boolean
Checks if the given base object is marked.boolean
isMarked
(MCRObjectID mcrId) Checks if the object is marked.boolean
isMarkedForDeletion
(MCRDerivate derivate) Checks if the derivate or the corresponding mycore object is marked for deletion.boolean
isMarkedForDeletion
(MCRObjectID mcrId) Checks if the object is marked for deletion.boolean
isMarkedForImport
(MCRObjectID mcrId) Checks if the object is marked for import.mark
(MCRObjectID mcrId, MCRMarkManager.Operation operation) Marks a single object with the given operation.void
remove
(MCRObjectID mcrId) Removes the current mark for the given mycore identifier.
-
Method Details
-
instance
Returns the instance to the singletonMCRMarkManager
.- Returns:
- instance of
MCRMarkManager
-
mark
Marks a single object with the given operation.- Parameters:
mcrId
- the mycore object identifieroperation
- the operation- Returns:
- the previous Operation associated with the mycore identifier or null
-
remove
Removes the current mark for the given mycore identifier.- Parameters:
mcrId
- the object where the mark should be removed
-
isMarked
Checks if the object is marked.- Parameters:
mcrId
- the mcr identifier- Returns:
- true if its marked
-
isMarked
Checks if the given base object is marked. If base is an instance of MCRDerivate, this method checks also if the linked object is marked.- Parameters:
base
- the mycore object- Returns:
- true if its marked
-
isMarkedForDeletion
Checks if the object is marked for deletion.- Parameters:
mcrId
- the mcr identifier- Returns:
- true if its marked for deletion
-
isMarkedForDeletion
Checks if the derivate or the corresponding mycore object is marked for deletion.- Returns:
- true if one of them is marked for deletion
-
isMarkedForImport
Checks if the object is marked for import.- Parameters:
mcrId
- the mcr identifier- Returns:
- true if its marked for import
-