Class MCRMETSHierarchyGenerator

java.lang.Object
org.mycore.mets.model.MCRMETSAbstractGenerator
org.mycore.mets.model.MCRMETSHierarchyGenerator
All Implemented Interfaces:
MCRMETSGenerator

public abstract class MCRMETSHierarchyGenerator extends MCRMETSAbstractGenerator
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
  • Field Details

    • mcrDer

      protected MCRDerivate mcrDer
    • rootObj

      protected MCRObject 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
    • files

    • structLinkMap

      protected Map<org.mycore.mets.model.struct.LogicalDiv,List<org.mycore.mets.model.struct.PhysicalSubDiv>> structLinkMap
      Hashmap to store logical and physical ids.
  • Constructor Details

    • MCRMETSHierarchyGenerator

      public MCRMETSHierarchyGenerator()
  • Method Details

    • generate

      public org.mycore.mets.model.Mets generate() throws MCRException
      Description copied from interface: MCRMETSGenerator
      Creates a new METS pojo.
      Returns:
      the newly generated mets
      Throws:
      MCRException - unable to generate the mets
    • setup

      protected void setup(String derivateId)
      Initializes the derivate and the root object.
      Parameters:
      derivateId - the derivate id to setup
    • createMets

      protected org.mycore.mets.model.Mets createMets() throws IOException
      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

      protected org.mycore.mets.model.files.FileSec createFileSection() throws IOException
      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

      protected Optional<String> getOrderLabel(String fileId)
      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 object
      parentLogicalDiv - 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 handle
      mcrObject - 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 div
      to - physical div
    • getChildren

      protected List<MCRObject> getChildren(MCRObject parentObject)
      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

      protected Optional<String> getLinkedFile(MCRObject mcrObj)
      Returns the URI encoded file path of the first derivate link.
      Parameters:
      mcrObj - object which contains the derivate link
    • getType

      protected abstract String getType(MCRObject obj)
      Type attribute used in logical structure. Something like journal, article, book...
    • getLabel

      protected abstract String getLabel(MCRObject obj)
      Returns the label of an object. Used in logical structure.
    • getEnclosingDerivateLinkName

      protected abstract String getEnclosingDerivateLinkName()
      Enclosing name of the derivate link element. In journals this is 'derivateLinks', in archive 'def.derivateLink'.
    • getDerivateLinkName

      protected abstract String getDerivateLinkName()
      Name of the derivate link element. E.g. 'derivateLink'.
    • buildFileRef

      protected MCRMETSHierarchyGenerator.FileRef buildFileRef(MCRPath path, String contentType)