Commit 76c53246 authored by ki124fuzo's avatar ki124fuzo

some changes to handle preferredName

parent c9d2d485
......@@ -127,7 +127,7 @@ public class MCRVIAFAuthorityFileUpdateUtils {
MCRMetaElement clone_metadata_tag = old_metadata_tag.clone();
for (int i = 0; i < clone_metadata_tag.size(); i++) {
MCRMetaInterface clone_metadata_subtag = clone_metadata_tag.getElement(i);
if (clone_metadata_subtag.getType() == null || !clone_metadata_subtag.getType().equals("gnd")) {
if (clone_metadata_subtag.getType() != null && clone_metadata_subtag.getType().equals("gnd")) {
clone_metadata_tag.removeElement(i);
i--;
}
......
......@@ -104,6 +104,7 @@ public class MCRVIAFAuthorityFileUtils {
public static final String PREFERRED_PROVIDER = CONFIG.getString("MCR.Dptbase.Viaf.Metadata.PreferredProvider");
public static final MCRObject getGNDAsMarc21XML(MCRServletJob job, String gnd) throws Exception {
MCRVIAFAuthorityFileUtils.LOGGER.debug("Read a GND Marc21 dataset and transform it to MyCoRe.");
Transformer trans = MCRVIAFAuthorityFileUtils.getTransformer(MCRVIAFAuthorityFileUtils.GND_TRANSFORMER);
URL url = new URL("https://d-nb.info/gnd/" + gnd + "/about/marcxml");
Document doc = new SAXBuilder().build(url);
......@@ -125,15 +126,20 @@ public class MCRVIAFAuthorityFileUtils {
JDOMSource source = new JDOMSource(doc2);
JDOMResult result = new JDOMResult();
MCRObject obj = null;
try {
trans.transform(source, result);
(new MCRJDOMContent(result.getDocument())).sendTo(System.out);
Document object_doc = result.getDocument();
obj = new MCRObject(object_doc);
if (MCRVIAFAuthorityFileUtils.LOGGER.isDebugEnabled()) {
(new MCRJDOMContent(object_doc)).sendTo(System.out);
}
} catch (Exception e) {
e.printStackTrace();
job.getResponse()
.sendRedirect(job.getResponse().encodeRedirectURL(MCRVIAFAuthorityFileUtils.GND_IMPORT_ERROR_PAGE));
}
MCRObject obj = new MCRObject(result.getDocument());
MCRVIAFAuthorityFileUtils.LOGGER.debug("GND to MyCoRe transformation is finished.");
return obj;
}
......@@ -250,12 +256,13 @@ public class MCRVIAFAuthorityFileUtils {
MCRMetaClassification record_source = (MCRMetaClassification) viaf_record_sources
.getElementByName("recordSource");
String type = record_source.getCategId();
MCRVIAFAuthorityFileUtils.LOGGER.debug("The type of object " + viaf_id + " is " + type);
// make update
if (type.equals("local")) {
MCRVIAFAuthorityFileUtils.LOGGER.info("Object " + viaf_id + " is a local dataset. Continue.");
MCRVIAFAuthorityFileUtils.LOGGER.warn("Object " + viaf_id + " is a local dataset. Continue.");
return;
} else if (type.equals("mcrid")) {
MCRVIAFAuthorityFileUtils.LOGGER.info("Object " + viaf_id + " is a MyCoRe dataset. Continue.");
MCRVIAFAuthorityFileUtils.LOGGER.warn("Object " + viaf_id + " is a MyCoRe dataset. Continue.");
try {
MCRObject new_obj = MCRVIAFAuthorityFileUtils.getMCRObjectAsXML(null, viaf_id);
MCRVIAFAuthorityFileUtils.replaceVIAF(viaf_obj, new_obj, "replace");
......@@ -284,7 +291,7 @@ public class MCRVIAFAuthorityFileUtils {
return;
}
if (type.equals("gnd")) {
MCRVIAFAuthorityFileUtils.LOGGER.info("Object " + viaf_id + " is a gnd dataset");
MCRVIAFAuthorityFileUtils.LOGGER.info("Object " + viaf_id + " is a gnd dataset for action " + replace_or_update);
try {
MCRObject new_obj = MCRVIAFAuthorityFileUtils.getGNDAsMarc21XML(null, viaf_text.getText());
MCRVIAFAuthorityFileUtils.replaceVIAF(viaf_obj, new_obj, replace_or_update);
......@@ -320,6 +327,7 @@ public class MCRVIAFAuthorityFileUtils {
* @param replace_or_update replace a String 'replace' or 'update'
*/
public static final void replaceVIAF(MCRObject old_obj, MCRObject new_obj, String replace_or_update) {
MCRVIAFAuthorityFileUtils.LOGGER.debug("Replace or update oln MyCoRe object with newer from GND with action " + replace_or_update);
// set old ID
new_obj.setId(old_obj.getId());
......
......@@ -7,7 +7,7 @@
xmlns:marc21="xalan://org.mycore.frontend.marc21.MCRGetIDForMarc21"
xmlns:ld="xalan://org.mycore.common.MCRLanguageDetector"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:marcxml="http://www.loc.gov/MARC21/slim" extension-element-prefixes="marc21 xlink xalan">
xmlns:marcxml="http://www.loc.gov/MARC21/slim" extension-element-prefixes="ld marcxml marc21 xlink xalan">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
......@@ -129,6 +129,11 @@
<xsl:value-of select="marcxml:subfield[@code = 'c']/text()" />
</title>
</xsl:if>
<xsl:if test="@ind1 = '1' and marcxml:subfield[@code = 'c']">
<peerage>
<xsl:value-of select="marcxml:subfield[@code = 'c']/text()" />
</peerage>
</xsl:if>
</variantName>
</xsl:if>
<xsl:if test="@ind1 = '1' and marcxml:subfield[@code = 'a']">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment