Class DataCiteMetadataFactory
java.lang.Object
edu.ucsb.nceas.metacat.doi.datacite.DataCiteMetadataFactory
- Direct Known Subclasses:
DefaultDataCiteFactory
,EML2DataCiteFactory
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 Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected static XPath
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Document
addIdentifier
(Document doc, String identifier, String scheme) Add the identifier element to the root document.protected Document
addLanguage
(Document doc, String language) Append a subject to the document.protected Document
addPublicationYear
(Document doc, String publicationYear) Add the publication year nodeprotected Document
addPublisher
(Document doc, String publisher) Add the publisher nodeprotected Document
addResourceType
(Document doc, String resourceTypeGeneral, String resourceType) Add the resource type to the documentprotected Document
appendCreator
(String creatorName, Document doc, String affiliation, String nameIdentifier, String nameIdentifierSchemeURI, String nameIdentifierScheme) Append a creator element to the root element.protected Document
appendDescription
(String description, Document doc, String language, String descriptionType) Append a description to the document.protected Document
appendFormat
(Document doc, String format) Add the format (MIME type) of the metadata object to the documentprotected Document
appendSubject
(String subject, Document doc, String language) Append a subject to the documentappendTitle
(String title, Document doc, String language) Append a title to the title list elementabstract boolean
canProcess
(String namespace) Determine if the factory can handle the metadata with the given name spaceabstract String
generateMetadata
(org.dataone.service.types.v1.Identifier identifier, org.dataone.service.types.v2.SystemMetadata sysmeta) Method to generate the datacite metadata xml string for an object with the given system metadata.protected Document
Generate the blank DOM document for the datacite namespacestatic String
lookupFormat
(org.dataone.service.types.v2.SystemMetadata sysMeta) Figure out the format (mime type) of the data objectprotected String
removeIdSchemePrefix
(String id, String scheme) Remove the scheme prefix for a given id.protected String
serializeDoc
(Document doc) Serialize the given doc object to a string
-
Field Details
-
EN
- See Also:
-
XML_LANG
- See Also:
-
NAMESPACE
- See Also:
-
SCHEMALOCATION
- See Also:
-
RESOURCE
- See Also:
-
CREATORS
- See Also:
-
CREATOR
- See Also:
-
CREATORNAME
- See Also:
-
TITLES
- See Also:
-
SUBJECTS
- See Also:
-
DESCRIPTIONS
- See Also:
-
FORMATS
- See Also:
-
DOI
- See Also:
-
ABSTRACT
- See Also:
-
INVALIDCODE
- See Also:
-
xpath
-
-
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
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
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 modifiedidentifier
- 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 modifiednameIdentifier
- the value of the name identifier, e.g., 0000-0003-0003-2515nameIdentifierSchemeURI
- the URI of the name identifier scheme, e.g., http://orcid.org/nameIdentifierScheme
- the name of the name identifier scheme, e.g., ORCIDaffiliation
- 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 modifiedtitle
- the title will be appendedlanguage
- 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 modifiedpublisher
- 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 modifiedpublicationYear
- 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 appendeddoc
- the document will be modifiedlanguage
- 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
Append a subject to the document. The language will be changed to the ISO639 code- Parameters:
doc
- the document object will be modifiedlanguage
- 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
Add the resource type to the document- Parameters:
doc
- the document object will be modifiedresourceType
- 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
Add the format (MIME type) of the metadata object to the document- Parameters:
doc
- the document object will be modifiedformat
- 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 descriptiondoc
- the document object will be modifiedlanguage
- the language is used in the descriptiondescriptionType
- 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
Serialize the given doc object to a string- Parameters:
doc
- the document will be serialized- Returns:
- the string representation of the document object
-
lookupFormat
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
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 schemescheme
- the scheme of the identifier- Returns:
- string without the scheme
-