Class MCRMarkManager

java.lang.Object
org.mycore.datamodel.common.MCRMarkManager

public class MCRMarkManager extends Object
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:

  1. An user delete's a parent object with 500 children.
  2. MyCoRe tries to delete the parent, but first, it has to delete all children.
  3. MyCoRe runs through each child and deletes it.
  4. BUT after the deletion of ONE child, the parent object will be updated.
  5. 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:

  1. An import is started with a bunch of hierarchic objects.
  2. MyCoRe imports all the objects and does a "create" update.
  3. BUT for each object created the parent is updated again (because a child was added)!
  4. 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.

TODO: check side effects
Author:
Matthias Eichner
  • Method Details

    • instance

      public static MCRMarkManager instance()
      Returns the instance to the singleton MCRMarkManager.
      Returns:
      instance of MCRMarkManager
    • mark

      Marks a single object with the given operation.
      Parameters:
      mcrId - the mycore object identifier
      operation - the operation
      Returns:
      the previous Operation associated with the mycore identifier or null
    • remove

      public void remove(MCRObjectID mcrId)
      Removes the current mark for the given mycore identifier.
      Parameters:
      mcrId - the object where the mark should be removed
    • isMarked

      public boolean isMarked(MCRObjectID mcrId)
      Checks if the object is marked.
      Parameters:
      mcrId - the mcr identifier
      Returns:
      true if its marked
    • isMarked

      public boolean isMarked(MCRBase base)
      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

      public boolean isMarkedForDeletion(MCRObjectID mcrId)
      Checks if the object is marked for deletion.
      Parameters:
      mcrId - the mcr identifier
      Returns:
      true if its marked for deletion
    • isMarkedForDeletion

      public boolean isMarkedForDeletion(MCRDerivate derivate)
      Checks if the derivate or the corresponding mycore object is marked for deletion.
      Returns:
      true if one of them is marked for deletion
    • isMarkedForImport

      public boolean isMarkedForImport(MCRObjectID mcrId)
      Checks if the object is marked for import.
      Parameters:
      mcrId - the mcr identifier
      Returns:
      true if its marked for import