Commit 8b547c1c authored by Michael Becker's avatar Michael Becker
Browse files

import original agent name (400,700) from GND

parent f89ba0ae
......@@ -170,6 +170,26 @@
"multiValued": false
}
},
{
"add-field": {
"name": "agent_preferredname_original",
"type": "dpt_agent_text_sort_general",
"indexed": true,
"stored": true,
"docValues": false,
"multiValued": false
}
},
{
"add-field": {
"name": "agent_preferredname_original_lang",
"type": "dpt_agent_text_sort_general",
"indexed": true,
"stored": true,
"docValues": false,
"multiValued": false
}
},
{
"add-field": {
"name": "agent_name_all",
......
......@@ -242,6 +242,15 @@
</xsl:choose>
</field>
<xsl:if test="./metadata/def.preferredName/preferredName[@type='original']">
<field name="agent_preferredname_original">
<xsl:value-of select="./metadata/def.preferredName/preferredName[@type='original'][1]/fullname/text()"/>
</field>
<field name="agent_preferredname_original_lang">
<xsl:value-of select="./metadata/def.preferredName/preferredName[@type='original'][1]/@xml:lang"/>
</field>
</xsl:if>
<!-- field name="agent_identifier" type="string" multiValued="true" stored="true" -->
<!-- field name="agent_identifier_gnd" type="string" multiValued="true" stored="false" -->
<!-- field name="agent_identifier_lcnaf" type="string" multiValued="true" stored="false" -->
......
......@@ -29,7 +29,7 @@
<preferredName inherited="0" xml:lang="de">
<xsl:if test="@ind1 = '0' and marcxml:subfield[@code = 'a']">
<firstname>
<xsl:value-of select="marcxml:subfield[@code = 'a']/text()" />
<xsl:value-of select="marcxml:subfield[@code = 'a']/text()"/>
</firstname>
</xsl:if>
<xsl:if test="@ind1 = '0' and marcxml:subfield[@code = 'b']">
......@@ -98,9 +98,104 @@
<preferredName inherited="0" xml:lang="de">
<xsl:if test="marcxml:subfield[@code = 'a']">
<fullname>
<xsl:value-of select="marcxml:subfield[@code = 'a']/text()" />
<xsl:value-of select="marcxml:subfield[@code = 'a']/text()"/>
</fullname>
</xsl:if>
</preferredName>
</xsl:for-each>
<!-- original name -->
<xsl:for-each
select="/marcxml:record/marcxml:datafield[@tag='400' and marcxml:subfield[@code='9']/text() = 'v:Original']">
<xsl:variable name="lang">
<xsl:call-template name="gndLangToLangCode">
<xsl:with-param name="gndLang" select="marcxml:subfield[@code='9' and starts-with(text(), 'U:')]"/>
</xsl:call-template>
</xsl:variable>
<preferredName inherited="0" xml:lang="{$lang}" type="original">
<xsl:if test="@ind1 = '0' and marcxml:subfield[@code = 'a']">
<firstname>
<xsl:value-of select="marcxml:subfield[@code = 'a']/text()"/>
</firstname>
</xsl:if>
<xsl:if test="@ind1 = '0' and marcxml:subfield[@code = 'b']">
<numeration>
<xsl:value-of select="marcxml:subfield[@code = 'b']/text()"/>
</numeration>
</xsl:if>
<xsl:if test="@ind1 = '0' and marcxml:subfield[@code = 'c']">
<title>
<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>
<xsl:if test="@ind1 = '1' and marcxml:subfield[@code = 'a']">
<fullname>
<xsl:value-of select="marcxml:subfield[@code = 'a']/text()"/>
</fullname>
</xsl:if>
<xsl:variable name="academic">
<xsl:for-each
select="/marcxml:record/marcxml:datafield[@tag='550' and marcxml:subfield[@code = '4'] = 'akad']">
<xsl:value-of select="./marcxml:subfield[@code = 'a']"/>
<xsl:text></xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$academic">
<academic>
<xsl:value-of select="$academic"/>
</academic>
</xsl:if>
</preferredName>
</xsl:for-each>
<xsl:for-each
select="/marcxml:record/marcxml:datafield[@tag='700' and marcxml:subfield[@code='9']/text() = 'v:Original']">
<xsl:variable name="lang">
<xsl:call-template name="gndLangToLangCode">
<xsl:with-param name="gndLang" select="marcxml:subfield[@code='9' and starts-with(text(), 'U:')]"/>
</xsl:call-template>
</xsl:variable>
<preferredName inherited="0" xml:lang="{$lang}" type="original">
<xsl:if test="@ind1 = '0' and marcxml:subfield[@code = 'a']">
<firstname>
<xsl:value-of select="marcxml:subfield[@code = 'a']/text()"/>
</firstname>
</xsl:if>
<xsl:if test="@ind1 = '0' and marcxml:subfield[@code = 'b']">
<numeration>
<xsl:value-of select="marcxml:subfield[@code = 'b']/text()"/>
</numeration>
</xsl:if>
<xsl:if test="@ind1 = '0' and marcxml:subfield[@code = 'c']">
<title>
<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>
<xsl:if test="@ind1 = '1' and marcxml:subfield[@code = 'a']">
<fullname>
<xsl:value-of select="marcxml:subfield[@code = 'a']/text()"/>
</fullname>
</xsl:if>
<xsl:variable name="academic">
<xsl:for-each
select="/marcxml:record/marcxml:datafield[@tag='550' and marcxml:subfield[@code = '4'] = 'akad']">
<xsl:value-of select="./marcxml:subfield[@code = 'a']"/>
<xsl:text></xsl:text>
</xsl:for-each>
</xsl:variable>
<xsl:if test="$academic">
<academic>
<xsl:value-of select="$academic"/>
</academic>
</xsl:if>
</preferredName>
</xsl:for-each>
</def.preferredName>
......@@ -858,4 +953,17 @@
</xsl:if>
</xsl:template>
<xsl:template name="gndLangToLangCode">
<xsl:param name="gndLang"/>
<xsl:choose>
<xsl:when test="$gndLang = 'U:Arab'">
<xsl:value-of select="'ar'"/>
</xsl:when>
<xsl:when test="$gndLang = 'U:per'">
<xsl:value-of select="'fa'"/>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
......@@ -7,6 +7,7 @@ import org.junit.Test;
import org.mycore.test.AbstractDptBaseTest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
......@@ -28,6 +29,21 @@ public class Agent2SolrTest extends AbstractDptBaseTest {
assertThat(relations.get(1).getText(), is("MyMssPerson_agent_00007071#agentAgRelOn:hasFriend"));
}
@Test
public void testPreferrednameOriginal() throws Exception {
final Document result = parse(Collections.emptyMap(), SOLR_XSL, xmlTest("test2Solr", AGENT_XML));
final List<Element> preferredNameValue =
getField("agent_preferredname_original", result.getRootElement().getChildren("field"));
final List<Element> preferredNameLang =
getField("agent_preferredname_original_lang", result.getRootElement().getChildren("field"));
assertThat(preferredNameValue.size(), is(1));
assertThat(preferredNameValue.get(0).getText(), is("أنصاري, زكريا ابن محمد ال"));
assertThat(preferredNameLang.size(), is(1));
assertThat(preferredNameLang.get(0).getText(), is("ar"));
}
protected List<Element> getField(String name, List<Element> fields) {
List<Element> result = new ArrayList<>();
......
......@@ -23,6 +23,7 @@ import org.jdom2.transform.JDOMResult;
import org.jdom2.transform.JDOMSource;
import org.junit.Test;
import org.mycore.common.content.MCRFileContent;
import org.mycore.datamodel.language.MCRLanguageFactory;
import org.mycore.datamodel.metadata.MCRMetaElement;
import org.mycore.datamodel.metadata.MCRMetaHistoryDate;
import org.mycore.datamodel.metadata.MCRMetaLangText;
......@@ -56,6 +57,23 @@ public class MCRAgentAuthorityFileUtilsTest extends AbstractDptBaseTest {
assertThat(object, is(notNullValue()));
}
@Test
public void testParseOriginalName() throws Exception {
MCRLanguageFactory.instance().getLanguage("ar");
final MCRObject mcrObject = new MCRObject(transformGND("/118952331_marcxml.mrcx"));
final MCRMetaElement prefName = mcrObject.getMetadata().getMetadataElement("def.preferredName");
assertThat(prefName.size(), is(3));
assertThat(prefName.getElement(0).getLang(), is("de"));
assertThat(((MCRMetaPersonName) prefName.getElement(0)).getFullName(), is("Anwarī, Auḥad-ad-Dīn"));
assertThat(prefName.getElement(1).getLang(), is("ar"));
assertThat(prefName.getElement(1).getType(), is("original"));
assertThat(((MCRMetaPersonName) prefName.getElement(1)).getFullName(), is("انوری, اوحد الدین محمد"));
assertThat(prefName.getElement(2).getLang(), is("ar"));
assertThat(prefName.getElement(2).getType(), is("original"));
assertThat(((MCRMetaPersonName) prefName.getElement(2)).getFullName(), is("انوری, اوحد الدین"));
}
@Test
public void testParseDates() throws Exception {
// contains date ca. -ca. 1639/40
......
......@@ -9,6 +9,9 @@
<preferredName xml:lang="de" inherited="0">
<fullname>Person B</fullname>
</preferredName>
<preferredName xml:lang="ar" type="original" inherited="0">
<fullname>أنصاري, زكريا ابن محمد ال</fullname>
</preferredName>
</def.preferredName>
<def.relation class="MCRMetaLinkID" heritable="false" notinherit="true">
<relation type="agentAgRelOn:hasPhysician" inherited="0" xlink:type="locator" xlink:title="#T.V." xlink:href="MyMssPerson_agent_00007374" />
......
Supports Markdown
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