Class MCRObjectMerger

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

public class MCRObjectMerger extends Object
Helper class to merge mycore objects. Only metadata merging is currently supported.
Author:
Matthias Eichner
  • Field Details

  • Constructor Details

    • MCRObjectMerger

      public MCRObjectMerger(MCRObject target)
      Creates a new instance of the object merger. The target will be cloned for further processing. You will receive a copy when calling get().
      Parameters:
      target - the target mycore object
  • Method Details

    • mergeMetadata

      public boolean mergeMetadata(MCRObject source, boolean validate)
      Merges the metadata of the given source into the target object. Be aware that performance isn't that good when validation is activated, due checking against the schema each time a change is made.
      Parameters:
      source - the source which is merged into the target
      validate - If true, every change is tracked and validated against the xml schema of the mycore object. When a change is invalid it will be canceled and the merging continues. When set to false the mycore object will be merged without validation. This can result in an invalid object.
      Returns:
      true if something was merged
    • validate

      protected boolean validate(MCRObject mcrobj)
      Validates the given mcr object against its own schema.
      Parameters:
      mcrobj - the object to validate
      Returns:
      true if the object is valid, otherwise false
    • get

      public MCRObject get()
      Returns a copy of the merged target object.