Package org.mycore.mets.model
Class MCRMETSHierarchyGenerator
java.lang.Object
org.mycore.mets.model.MCRMETSAbstractGenerator
org.mycore.mets.model.MCRMETSHierarchyGenerator
- All Implemented Interfaces:
MCRMETSGenerator
This class generates a METS xml file for the METS-Editor. In difference to the default
implementation, the hierarchy of the MCRObjects and their derivate links are considered.
Starting from the root element, all children are hierarchically recorded in the logical
structure map of the METS file. If your application supports derivate links, the struct link
part links to those files.
- Author:
- Matthias Eichner
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.mycore.mets.model.sections.AmdSec
protected org.mycore.mets.model.sections.DmdSec
protected List<MCRMETSHierarchyGenerator.FileRef>
protected org.mycore.mets.model.files.FileSec
protected org.mycore.mets.model.struct.LogicalStructMap
protected MCRDerivate
protected org.mycore.mets.model.header.MetsHdr
protected org.mycore.mets.model.struct.PhysicalStructMap
protected MCRObject
protected org.mycore.mets.model.struct.StructLink
protected Map<org.mycore.mets.model.struct.LogicalDiv,
List<org.mycore.mets.model.struct.PhysicalSubDiv>> Hashmap to store logical and physical ids. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addFile
(MCRMETSHierarchyGenerator.FileRef fileRef, org.mycore.mets.model.files.FileGrp fileGroup) protected void
addToStructLinkMap
(org.mycore.mets.model.struct.LogicalDiv from, org.mycore.mets.model.struct.PhysicalSubDiv to) Adds the physical div to the logical div.protected MCRMETSHierarchyGenerator.FileRef
buildFileRef
(MCRPath path, String contentType) protected org.mycore.mets.model.sections.AmdSec
Creates a new empty amd section.protected org.mycore.mets.model.sections.DmdSec
Creates a new empty dmd section.protected org.mycore.mets.model.files.FileSec
Creates the file section.protected org.mycore.mets.model.struct.LogicalStructMap
Creates the logical struct map.protected org.mycore.mets.model.Mets
Does the mets creation.protected org.mycore.mets.model.header.MetsHdr
Creates a new mets header with current dates and record status = autogenerated.protected org.mycore.mets.model.struct.PhysicalStructMap
This method creates the physical structure map.protected org.mycore.mets.model.struct.StructLink
Creates the mets:structLink part of the mets.xmlorg.mycore.mets.model.Mets
generate()
Creates a new METS pojo.getChildren
(MCRObject parentObject) Returns all children id's of this MCRObject.protected abstract String
Name of the derivate link element.protected abstract String
Enclosing name of the derivate link element.protected abstract String
Returns the label of an object.getLinkedFile
(MCRObject mcrObj) Returns the URI encoded file path of the first derivate link.getOrderLabel
(String fileId) Returns the order label for the given file.protected abstract String
Type attribute used in logical structure.protected void
mergeOldLogicalStructMap
(org.mycore.mets.model.struct.LogicalStructMap logicalStructMap) Runs through the logical part of the old mets and copies the ALTO part (mets:fptr/mets:seq/mets:area) to the newly created logical struct map.protected org.mycore.mets.model.struct.LogicalStructMap
protected void
newLogicalStructMap
(MCRObject parentObject, org.mycore.mets.model.struct.LogicalDiv parentLogicalDiv) Creates the logical structure recursive.protected void
Initializes the derivate and the root object.protected void
updateStructLinkMapUsingALTO
(org.mycore.mets.model.struct.LogicalDiv logicalDiv) Fills the structLinkMap for a single logical mets:div using mets:area/@FILEID information.protected void
updateStructLinkMapUsingDerivateLinks
(org.mycore.mets.model.struct.LogicalDiv logicalDiv, MCRObject mcrObject, org.mycore.mets.model.files.FileGrp group) Fills the structLinkMap for a single logical mets:div using derivate link information.Methods inherited from class org.mycore.mets.model.MCRMETSAbstractGenerator
getDerivatePath, getIgnorePaths, getOldMets, getOwner, setDerivatePath, setIgnorePaths, setOldMets
-
Field Details
-
mcrDer
-
rootObj
-
metsHdr
protected org.mycore.mets.model.header.MetsHdr metsHdr -
amdSection
protected org.mycore.mets.model.sections.AmdSec amdSection -
dmdSection
protected org.mycore.mets.model.sections.DmdSec dmdSection -
fileSection
protected org.mycore.mets.model.files.FileSec fileSection -
physicalStructMap
protected org.mycore.mets.model.struct.PhysicalStructMap physicalStructMap -
logicalStructMap
protected org.mycore.mets.model.struct.LogicalStructMap logicalStructMap -
structLink
protected org.mycore.mets.model.struct.StructLink structLink -
files
-
structLinkMap
protected Map<org.mycore.mets.model.struct.LogicalDiv,List<org.mycore.mets.model.struct.PhysicalSubDiv>> structLinkMapHashmap to store logical and physical ids.
-
-
Constructor Details
-
MCRMETSHierarchyGenerator
public MCRMETSHierarchyGenerator()
-
-
Method Details
-
generate
Description copied from interface:MCRMETSGenerator
Creates a new METS pojo.- Returns:
- the newly generated mets
- Throws:
MCRException
- unable to generate the mets
-
setup
Initializes the derivate and the root object.- Parameters:
derivateId
- the derivate id to setup
-
createMets
Does the mets creation.- Returns:
- the new created mets
- Throws:
IOException
- files of the path couldn't be read
-
createMetsHdr
protected org.mycore.mets.model.header.MetsHdr createMetsHdr()Creates a new mets header with current dates and record status = autogenerated.- Returns:
- generated mets header section.
-
createAmdSection
protected org.mycore.mets.model.sections.AmdSec createAmdSection()Creates a new empty amd section. Id is amd_{derivate id}.- Returns:
- generated amd section.
-
createDmdSection
protected org.mycore.mets.model.sections.DmdSec createDmdSection()Creates a new empty dmd section. Id is dmd_{derivate id}.- Returns:
- generated dmd section.
-
createFileSection
Creates the file section.- Returns:
- generated file secion.
- Throws:
IOException
-
addFile
protected void addFile(MCRMETSHierarchyGenerator.FileRef fileRef, org.mycore.mets.model.files.FileGrp fileGroup) -
createPhysicalStruct
protected org.mycore.mets.model.struct.PhysicalStructMap createPhysicalStruct()This method creates the physical structure map.- Returns:
- generated pyhiscal struct map secion.
-
getOrderLabel
Returns the order label for the given file.- Parameters:
fileId
- of the mets:file in the mets:fileSec- Returns:
- optional order label
-
createLogicalStruct
protected org.mycore.mets.model.struct.LogicalStructMap createLogicalStruct()Creates the logical struct map.- Returns:
- a newly created logical struct map
-
newLogicalStructMap
protected org.mycore.mets.model.struct.LogicalStructMap newLogicalStructMap() -
newLogicalStructMap
protected void newLogicalStructMap(MCRObject parentObject, org.mycore.mets.model.struct.LogicalDiv parentLogicalDiv) Creates the logical structure recursive.- Parameters:
parentObject
- mycore objectparentLogicalDiv
- parent div
-
mergeOldLogicalStructMap
protected void mergeOldLogicalStructMap(org.mycore.mets.model.struct.LogicalStructMap logicalStructMap) Runs through the logical part of the old mets and copies the ALTO part (mets:fptr/mets:seq/mets:area) to the newly created logical struct map. This is done by comparing the mets:div @ID's of the old and the new logical struct map. If two @ID's are equal, we can assume that it is the same mets:div and we just copy all the old mets:fptr's.- Parameters:
logicalStructMap
- the logical struct map to enhance
-
updateStructLinkMapUsingDerivateLinks
protected void updateStructLinkMapUsingDerivateLinks(org.mycore.mets.model.struct.LogicalDiv logicalDiv, MCRObject mcrObject, org.mycore.mets.model.files.FileGrp group) Fills the structLinkMap for a single logical mets:div using derivate link information.- Parameters:
logicalDiv
- the logical div to handlemcrObject
- the mycore object linked in the logical div (mets:div/@ID == mycore object id)group
- the group to search the corresponding File ID. this is usally the MASTER group
-
updateStructLinkMapUsingALTO
protected void updateStructLinkMapUsingALTO(org.mycore.mets.model.struct.LogicalDiv logicalDiv) Fills the structLinkMap for a single logical mets:div using mets:area/@FILEID information.- Parameters:
logicalDiv
- the logical div to handle
-
addToStructLinkMap
protected void addToStructLinkMap(org.mycore.mets.model.struct.LogicalDiv from, org.mycore.mets.model.struct.PhysicalSubDiv to) Adds the physical div to the logical div. Required to build the mets:structLink section.- Parameters:
from
- logical divto
- physical div
-
getChildren
Returns all children id's of this MCRObject.- Parameters:
parentObject
- the mycore object
-
createStructLink
protected org.mycore.mets.model.struct.StructLink createStructLink()Creates the mets:structLink part of the mets.xml- Returns:
- a newly generated StructLink.
-
getLinkedFile
Returns the URI encoded file path of the first derivate link.- Parameters:
mcrObj
- object which contains the derivate link
-
getType
Type attribute used in logical structure. Something like journal, article, book... -
getLabel
Returns the label of an object. Used in logical structure. -
getEnclosingDerivateLinkName
Enclosing name of the derivate link element. In journals this is 'derivateLinks', in archive 'def.derivateLink'. -
getDerivateLinkName
Name of the derivate link element. E.g. 'derivateLink'. -
buildFileRef
-