Package org.mycore.pi

Class MCRGenericPIGenerator


public class MCRGenericPIGenerator extends MCRPIGenerator<MCRPersistentIdentifier>
MCR.PI.Generator.myGenerator=org.mycore.pi.urn.MCRGenericPIGenerator Set a generic pattern. MCR.PI.Generator.myGenerator.GeneralPattern=urn:nbn:de:gbv:$CurrentDate-$1-$2-$ObjectType-$ObjectProject-$ObjectNumber-$Count- MCR.PI.Generator.myGenerator.GeneralPattern=urn:nbn:de:gbv:$ObjectDate-$ObjectType-$Count MCR.PI.Generator.myGenerator.GeneralPattern=urn:nbn:de:gbv:$ObjectDate-$Count MCR.PI.Generator.myGenerator.GeneralPattern=urn:nbn:de:gbv:$ObjectType-$Count MCR.PI.Generator.myGenerator.GeneralPattern=urn:nbn:de:gbv:$0-$1-$Count Set a optional DateFormat, if not set the ddMMyyyy is just used as value. (SimpleDateFormat) MCR.PI.Generator.myGenerator.DateFormat=ddMMyyyy Set a optional ObjectType mapping, if not set the ObjectType is just used as value MCR.PI.Generator.myGenerator.TypeMapping=document:doc,disshab:diss,Thesis:Thesis,bundle:doc,mods:test You can also map the projectid Set a optional Count precision, if not set or set to -1 the pure number is used (1,2,.., 999). Count always relativ to type and date. MCR.PI.Generator.myGenerator.CountPrecision=3 # will produce 001, 002, ... , 999 Set the Type of the generated pi. MCR.PI.Generator.myGenerator.Type=dnbURN Set the Xpaths MCR.PI.Generator.myGenerator.XPath.1=/mycoreobject/metadata/def.shelf/shelf/ MCR.PI.Generator.myGenerator.XPath.2=/mycoreobject/metadata/def.path2/path2/
Author:
Sebastian Hofmann
  • Constructor Details

    • MCRGenericPIGenerator

      public MCRGenericPIGenerator()
  • Method Details

    • init

      public void init(String property)
      Overrides:
      init in class MCRPIGenerator<MCRPersistentIdentifier>
    • generate

      public MCRPersistentIdentifier generate(MCRBase mcrBase, String additional) throws MCRPersistentIdentifierException
      Description copied from class: MCRPIGenerator
      Specified by:
      generate in class MCRPIGenerator<MCRPersistentIdentifier>
      Parameters:
      mcrBase - the mycore object for which the identifier is generated
      additional - additional information dedicated to the object like a mcrpath
      Returns:
      a unique persistence identifier
      Throws:
      MCRPersistentIdentifierException - if something goes wrong while generating
    • readCountFromDatabase

      protected AtomicInteger readCountFromDatabase(String countPattern)
    • setType

      public void setType(String type)
    • getGeneralPattern

      public String getGeneralPattern()
    • setGeneralPattern

      public void setGeneralPattern(String generalPattern)
    • getDateFormat

      public SimpleDateFormat getDateFormat()
    • setDateFormat

      public void setDateFormat(SimpleDateFormat dateFormat)
    • getObjectTypeMapping

      public String getObjectTypeMapping()
    • setObjectTypeMapping

      public void setObjectTypeMapping(String typeMapping)
    • getCountPrecision

      public int getCountPrecision()
    • setCountPrecision

      public void setCountPrecision(int countPrecision)
    • getCount

      public final int getCount(String pattern)
      Gets the count for a specific pattern and increase the internal counter. If there is no internal counter it will look into the Database and detect the highest count with the pattern.
      Parameters:
      pattern - a reg exp pattern which will be used to detect the highest count. The first group is the count. e.G. [0-9]+-mods-2017-([0-9][0-9][0-9][0-9])-[0-9] will match 31-mods-2017-0003-3 and the returned count will be 4 (3+1).
      Returns:
      the next count
    • getObjectProjectMapping

      public String getObjectProjectMapping()
    • setObjectProjectMapping

      public void setObjectProjectMapping(String objectProjectMapping)