Package org.mycore.datamodel.common
Class MCRObjectMerger
java.lang.Object
org.mycore.datamodel.common.MCRObjectMerger
Helper class to merge mycore objects. Only metadata merging is
currently supported.
- Author:
- Matthias Eichner
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMCRObjectMerger
(MCRObject target) Creates a new instance of the object merger. -
Method Summary
Modifier and TypeMethodDescriptionget()
Returns a copy of the merged target object.boolean
mergeMetadata
(MCRObject source, boolean validate) Merges the metadata of the given source into the target object.protected boolean
Validates the given mcr object against its own schema.
-
Field Details
-
target
-
-
Constructor Details
-
MCRObjectMerger
Creates a new instance of the object merger. The target will be cloned for further processing. You will receive a copy when callingget()
.- Parameters:
target
- the target mycore object
-
-
Method Details
-
mergeMetadata
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 targetvalidate
- 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
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
Returns a copy of the merged target object.
-