mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-14 13:33:08 +00:00
Added DataCite XML based metadata mapping option for EZIDIdentifierProvider module.
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
|
||||
package org.dspace.identifier;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.dspace.content.DSpaceObject;
|
||||
import org.dspace.content.crosswalk.DisseminationCrosswalk;
|
||||
import org.dspace.core.PluginManager;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.output.XMLOutputter;
|
||||
|
||||
/**
|
||||
* Provide XML based metadata crosswalk for EZID Identifier provider module.
|
||||
*
|
||||
* @author mohideen
|
||||
*/
|
||||
|
||||
public class DataCiteXMLCreator
|
||||
{
|
||||
/** log4j category */
|
||||
private static Logger log = Logger.getLogger(DataCiteXMLCreator.class);
|
||||
|
||||
/**
|
||||
* Name of crosswalk to convert metadata into DataCite Metadata Scheme.
|
||||
*/
|
||||
protected String CROSSWALK_NAME = "DataCite";
|
||||
|
||||
/**
|
||||
* DisseminationCrosswalk to map local metadata into DataCite metadata. The
|
||||
* name of the crosswalk is set by {@link setDisseminationCrosswalk(String)
|
||||
* setDisseminationCrosswalk} which instantiates the crosswalk.
|
||||
*/
|
||||
protected DisseminationCrosswalk xwalk;
|
||||
|
||||
public String getXMLString(DSpaceObject dso)
|
||||
{
|
||||
if (dso == null)
|
||||
{
|
||||
log.info("Invalid object: " + dso);
|
||||
return null;
|
||||
}
|
||||
|
||||
this.prepareXwalk();
|
||||
|
||||
if (!this.xwalk.canDisseminate(dso))
|
||||
{
|
||||
log.error("Crosswalk " + this.CROSSWALK_NAME
|
||||
+ " cannot disseminate DSO with type " + dso.getType()
|
||||
+ " and ID " + dso.getID() + ".");
|
||||
return null;
|
||||
}
|
||||
|
||||
Element root = null;
|
||||
try
|
||||
{
|
||||
root = xwalk.disseminateElement(dso);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error(
|
||||
"Exception while crosswolking DSO " + "with type "
|
||||
+ dso.getType() + " and ID " + dso.getID() + ".", e);
|
||||
return null;
|
||||
}
|
||||
|
||||
XMLOutputter xOut = new XMLOutputter();
|
||||
|
||||
return xOut.outputString(root);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the dissemination crosswalk used to convert the metadata
|
||||
* into DataCite Metadata Schema. Used by spring dependency injection.
|
||||
*
|
||||
* @param CROSSWALK_NAME
|
||||
* The name of the dissemination crosswalk to use.
|
||||
*/
|
||||
public void setDisseminationCrosswalkName(String CROSSWALK_NAME)
|
||||
{
|
||||
this.CROSSWALK_NAME = CROSSWALK_NAME;
|
||||
}
|
||||
|
||||
protected void prepareXwalk()
|
||||
{
|
||||
if (null != this.xwalk)
|
||||
return;
|
||||
|
||||
this.xwalk = (DisseminationCrosswalk) PluginManager.getNamedPlugin(
|
||||
DisseminationCrosswalk.class, this.CROSSWALK_NAME);
|
||||
|
||||
if (this.xwalk == null)
|
||||
{
|
||||
throw new RuntimeException("Can't find crosswalk '"
|
||||
+ CROSSWALK_NAME + "'!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -53,16 +53,25 @@ import org.springframework.beans.factory.annotation.Required;
|
||||
*
|
||||
* <p>Then there are properties injected using Spring:</p>
|
||||
* <ul>
|
||||
* <li>There is a Map (with the property name "crosswalk") from EZID
|
||||
* metadata field names into DSpace field names, injected by Spring. Specify
|
||||
* the fully-qualified names of all metadata fields to be looked up on a DSpace
|
||||
* object and their values set on mapped fully-qualified names in the object's
|
||||
* DataCite metadata.</li>
|
||||
* <li>There is a Map (with the property name "crosswalk") from EZID metadata
|
||||
* field names into DSpace field names, injected by Spring. Specify the
|
||||
* fully-qualified names of all metadata fields to be looked up on a DSpace
|
||||
* object and their values set on mapped fully-qualified names in the object's
|
||||
* DataCite metadata.</li>
|
||||
*
|
||||
* <li>A second map ("crosswalkTransform") provides Transform instances
|
||||
* mapped from EZID metadata field names. This allows the crosswalk to rewrite
|
||||
* field values where the form maintained by DSpace is not directly usable in
|
||||
* EZID metadata.</li>
|
||||
* <li>A second map ("crosswalkTransform") provides Transform instances mapped
|
||||
* from EZID metadata field names. This allows the crosswalk to rewrite field
|
||||
* values where the form maintained by DSpace is not directly usable in EZID
|
||||
* metadata.</li>
|
||||
*
|
||||
* <li>Optional: A boolean property ("generateDataciteXML") that controls the
|
||||
* creation and inclusion of DataCite xml schema during the metadata
|
||||
* crosswalking. The default "DataCite" dissemination plugin uses
|
||||
* DIM2DataCite.xsl for crosswalking. Default value: false.</li>
|
||||
*
|
||||
* <li>Optional: A string property ("disseminationCrosswalkName") that can be
|
||||
* used to set the name of the dissemination crosswalk plugin for metadata
|
||||
* crosswalking. Default value: "DataCite".</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author mwood
|
||||
@@ -90,6 +99,10 @@ public class EZIDIdentifierProvider
|
||||
|
||||
private static final String DOI_SCHEME = "doi:";
|
||||
|
||||
protected boolean GENERATE_DATACITE_XML = false;
|
||||
|
||||
protected String DATACITE_XML_CROSSWALK = "DataCite";
|
||||
|
||||
/** Map DataCite metadata into local metadata. */
|
||||
private static Map<String, String> crosswalk = new HashMap<String, String>();
|
||||
|
||||
@@ -661,8 +674,17 @@ public class EZIDIdentifierProvider
|
||||
}
|
||||
}
|
||||
|
||||
if (GENERATE_DATACITE_XML == true)
|
||||
{
|
||||
DataCiteXMLCreator xmlGen = new DataCiteXMLCreator();
|
||||
xmlGen.setDisseminationCrosswalkName(DATACITE_XML_CROSSWALK);
|
||||
String xmlString = xmlGen.getXMLString(dso);
|
||||
mapped.put("datacite", xmlString);
|
||||
}
|
||||
|
||||
// Supply a default publisher, if the Item has none.
|
||||
if (!mapped.containsKey(DATACITE_PUBLISHER))
|
||||
if (!mapped.containsKey(DATACITE_PUBLISHER)
|
||||
&& !mapped.containsKey("datacite"))
|
||||
{
|
||||
String publisher = configurationService.getPropertyAsType(CFG_PUBLISHER, "unknown");
|
||||
log.info("Supplying default publisher: {}", publisher);
|
||||
@@ -670,7 +692,8 @@ public class EZIDIdentifierProvider
|
||||
}
|
||||
|
||||
// Supply current year as year of publication, if the Item has none.
|
||||
if (!mapped.containsKey(DATACITE_PUBLICATION_YEAR))
|
||||
if (!mapped.containsKey(DATACITE_PUBLICATION_YEAR)
|
||||
&& !mapped.containsKey("datacite"))
|
||||
{
|
||||
String year = String.valueOf(Calendar.getInstance().get(Calendar.YEAR));
|
||||
log.info("Supplying default publication year: {}", year);
|
||||
@@ -694,6 +717,16 @@ public class EZIDIdentifierProvider
|
||||
transforms = transformMap;
|
||||
}
|
||||
|
||||
public void setGenerateDataciteXML(boolean GENERATE_DATACITE_XML)
|
||||
{
|
||||
this.GENERATE_DATACITE_XML = GENERATE_DATACITE_XML;
|
||||
}
|
||||
|
||||
public void setDisseminationCrosswalkName(String DATACITE_XML_CROSSWALK)
|
||||
{
|
||||
this.DATACITE_XML_CROSSWALK = DATACITE_XML_CROSSWALK;
|
||||
}
|
||||
|
||||
@Required
|
||||
public static void setRequestFactory(EZIDRequestFactory aRequestFactory)
|
||||
{
|
||||
|
@@ -792,6 +792,8 @@ org.dspace.app.batchitemimport.work.dir = ${dspace.dir}/imports
|
||||
#identifier.doi.ezid.user = apitest
|
||||
#identifier.doi.ezid.password = apitest
|
||||
# A default publisher, for Items not previously published.
|
||||
# (If generateDataciteXML bean property is enabled. Set default publisher in the
|
||||
# XSL file configured by: crosswalk.dissemination.DataCite.stylesheet file.)
|
||||
#identifier.doi.ezid.publisher = a publisher
|
||||
|
||||
|
||||
|
@@ -67,6 +67,11 @@
|
||||
|
||||
<!-- Provider to mint and register DOIs using EZID as the registrar.
|
||||
-->
|
||||
<!--
|
||||
Set generateDataciteXML to true to send metadata in DataCite xml schema for EZID DOI mint requests.
|
||||
When generateDataciteXML is enabled, EZIDIdentifierProvider uses
|
||||
dspace.cfg:crosswalk.dissemination.DataCite.stylesheet XSL configuration for metadata mapping
|
||||
-->
|
||||
<!-- Uncomment to enable DOI using EZID
|
||||
<bean id="org.dspace.identifier.EZIDIdentifierProvider"
|
||||
class="org.dspace.identifier.EZIDIdentifierProvider"
|
||||
@@ -97,6 +102,9 @@
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name='generateDataciteXML' value='false'/>
|
||||
<property name='disseminationCrosswalkName' value='DataCite'/>
|
||||
|
||||
</bean>
|
||||
-->
|
||||
|
||||
|
Reference in New Issue
Block a user