Class DataCiteMetadataFactory

java.lang.Object
edu.ucsb.nceas.metacat.doi.datacite.DataCiteMetadataFactory
Direct Known Subclasses:
DefaultDataCiteFactory, EML2DataCiteFactory

public abstract class DataCiteMetadataFactory extends Object
A factory abstract class to generate the datacite metadata (xml format) for an DOI object. If you want to add a new factory for a metadata standard, you can extend this class and also register the new factory on the property "guid.ezid.datacite.factories" on the metacat.properties file.
Author:
tao
  • Field Details

  • Constructor Details

    • DataCiteMetadataFactory

      public DataCiteMetadataFactory()
  • Method Details

    • generateMetadata

      public abstract String generateMetadata(org.dataone.service.types.v1.Identifier identifier, org.dataone.service.types.v2.SystemMetadata sysmeta) throws org.dataone.service.exceptions.InvalidRequest, org.dataone.service.exceptions.ServiceFailure
      Method to generate the datacite metadata xml string for an object with the given system metadata.
      Parameters:
      sysmeta - the system metadata information of a given object
      Returns:
      the xml string of the datacite metadata.
      Throws:
      org.dataone.service.exceptions.InvalidRequest
      org.dataone.service.exceptions.ServiceFailure
    • canProcess

      public abstract boolean canProcess(String namespace)
      Determine if the factory can handle the metadata with the given name space
      Parameters:
      namespace - the name space of the metadata
      Returns:
      true if this factory can process it; false otherwise.
    • generateROOTDoc

      protected Document generateROOTDoc() throws Exception
      Generate the blank DOM document for the datacite namespace
      Returns:
      a blank DOM document of the datacite document
      Throws:
      Exception
    • addIdentifier

      protected Document addIdentifier(Document doc, String identifier, String scheme) throws org.dataone.service.exceptions.InvalidRequest
      Add the identifier element to the root document. This method must be called after we call the generateROOTDoc method, and it can be called only once
      Parameters:
      doc - the DOM document will be modified
      identifier - the identifier will be added
      Returns:
      the modified document
      Throws:
      org.dataone.service.exceptions.InvalidRequest
    • appendCreator

      protected Document appendCreator(String creatorName, Document doc, String affiliation, String nameIdentifier, String nameIdentifierSchemeURI, String nameIdentifierScheme) throws XPathExpressionException
      Append a creator element to the root element. This method should be called immediately after we call the method addIdentifier. It can be called more than one time.
      Parameters:
      creatorName - the name of the creator. If it is a person, it should be this format - lastName, firstName.
      doc - the DOM document will be modified
      nameIdentifier - the value of the name identifier, e.g., 0000-0003-0003-2515
      nameIdentifierSchemeURI - the URI of the name identifier scheme, e.g., http://orcid.org/
      nameIdentifierScheme - the name of the name identifier scheme, e.g., ORCID
      affiliation - the affiliation the creator associates with
      Returns:
      the modified document
      Throws:
      XPathExpressionException
    • appendTitle

      public Document appendTitle(String title, Document doc, String language) throws XPathExpressionException
      Append a title to the title list element
      Parameters:
      doc - the document which will be modified
      title - the title will be appended
      language - the language which the tile uses. This method will transform the language to the ISO 639 two-letter code. If it is null, EN will be used
      Returns:
      the modified document object
      Throws:
      XPathExpressionException
    • addPublisher

      protected Document addPublisher(Document doc, String publisher) throws org.dataone.service.exceptions.InvalidRequest
      Add the publisher node
      Parameters:
      doc - the doc needs to be modified
      publisher - the publisher will be added
      Returns:
      Throws:
      org.dataone.service.exceptions.InvalidRequest
    • addPublicationYear

      protected Document addPublicationYear(Document doc, String publicationYear) throws org.dataone.service.exceptions.InvalidRequest
      Add the publication year node
      Parameters:
      doc - the doc needs to be modified
      publicationYear - the publication year will be added
      Returns:
      Throws:
      org.dataone.service.exceptions.InvalidRequest
    • appendSubject

      protected Document appendSubject(String subject, Document doc, String language) throws XPathExpressionException
      Append a subject to the document
      Parameters:
      subject - the subject will be appended
      doc - the document will be modified
      language - the language which the subject is using. This method will transform the language string to the ISO 639 two-letter code. If it is null, EN will be used.
      Returns:
      the modified document object
      Throws:
      XPathExpressionException
    • addLanguage

      protected Document addLanguage(Document doc, String language)
      Append a subject to the document. The language will be changed to the ISO639 code
      Parameters:
      doc - the document object will be modified
      language - the language is used in the metadata. This method will transform the language string to the ISO 639 two-letter code.
      Returns:
      the modified document object
    • addResourceType

      protected Document addResourceType(Document doc, String resourceTypeGeneral, String resourceType)
      Add the resource type to the document
      Parameters:
      doc - the document object will be modified
      resourceType - it should be one of those options: "Audiovisual" "Collection" "Dataset" "Event" "Image" "InteractiveResource" "Model" "PhysicalObject" "Service" "Software "Sound" "Text" "Workflow" "Other"
      Returns:
      the modified document object
    • appendFormat

      protected Document appendFormat(Document doc, String format) throws XPathExpressionException
      Add the format (MIME type) of the metadata object to the document
      Parameters:
      doc - the document object will be modified
      format - the format of the metadata object
      Returns:
      the modified document
      Throws:
      XPathExpressionException
    • appendDescription

      protected Document appendDescription(String description, Document doc, String language, String descriptionType) throws XPathExpressionException
      Append a description to the document. This method can be called multiple times.
      Parameters:
      description - the value of the description
      doc - the document object will be modified
      language - the language is used in the description
      descriptionType - the type of the description. It only can be the these options: "Abstract" "Methods" "SeriesInformation" "TableOfContents" "Other"
      Returns:
      the modified document object
      Throws:
      XPathExpressionException
    • serializeDoc

      protected String serializeDoc(Document doc)
      Serialize the given doc object to a string
      Parameters:
      doc - the document will be serialized
      Returns:
      the string representation of the document object
    • lookupFormat

      public static String lookupFormat(org.dataone.service.types.v2.SystemMetadata sysMeta)
      Figure out the format (mime type) of the data object
      Parameters:
      sysMeta - the system metadata which has the format information
      Returns:
      the format type of this given system metadata
    • removeIdSchemePrefix

      protected String removeIdSchemePrefix(String id, String scheme)
      Remove the scheme prefix for a given id. For example, it returns 123 for given doi:123 and doi.
      Parameters:
      id - the identifier which will be removed the scheme
      scheme - the scheme of the identifier
      Returns:
      string without the scheme