Skip to content

Commit 9518a69

Browse files
authored
Merge pull request DSpace#11815 from the-library-code/datacite-nametype
Add nameType attribute to creator and contributor in DataCite export
2 parents 295ea7a + 66c3f6b commit 9518a69

6 files changed

Lines changed: 74 additions & 13 deletions

File tree

dspace-api/src/test/java/org/dspace/content/LeftTiltedRelationshipMetadataServiceIT.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testGetAuthorRelationshipMetadata() throws Exception {
7272
//request the virtual metadata of the publication only
7373
List<RelationshipMetadataValue> leftList = relationshipMetadataService
7474
.getRelationshipMetadata(leftItem, true);
75-
assertThat(leftList.size(), equalTo(3));
75+
assertThat(leftList.size(), equalTo(4));
7676

7777
assertThat(leftList.get(0).getValue(), equalTo(String.valueOf(rightItem.getID())));
7878
assertThat(leftList.get(0).getMetadataField().getMetadataSchema().getName(),
@@ -87,13 +87,19 @@ public void testGetAuthorRelationshipMetadata() throws Exception {
8787
assertThat(leftList.get(1).getMetadataField().getQualifier(), equalTo("author"));
8888
assertThat(leftList.get(1).getAuthority(), equalTo("virtual::" + relationship.getID()));
8989

90-
assertThat(leftList.get(2).getValue(), equalTo(String.valueOf(rightItem.getID())));
91-
assertThat(leftList.get(2).getMetadataField().getMetadataSchema().getName(),
92-
equalTo(MetadataSchemaEnum.RELATION.getName()));
93-
assertThat(leftList.get(2).getMetadataField().getElement(), equalTo("isAuthorOfPublication"));
94-
assertThat(leftList.get(2).getMetadataField().getQualifier(), nullValue());
90+
assertThat(leftList.get(2).getValue(), equalTo("Author"));
91+
assertThat(leftList.get(2).getMetadataField().getMetadataSchema().getName(), equalTo("dspace"));
92+
assertThat(leftList.get(2).getMetadataField().getElement(), equalTo("relatedentity"));
93+
assertThat(leftList.get(2).getMetadataField().getQualifier(), equalTo("type"));
9594
assertThat(leftList.get(2).getAuthority(), equalTo("virtual::" + relationship.getID()));
9695

96+
assertThat(leftList.get(3).getValue(), equalTo(String.valueOf(rightItem.getID())));
97+
assertThat(leftList.get(3).getMetadataField().getMetadataSchema().getName(),
98+
equalTo(MetadataSchemaEnum.RELATION.getName()));
99+
assertThat(leftList.get(3).getMetadataField().getElement(), equalTo("isAuthorOfPublication"));
100+
assertThat(leftList.get(3).getMetadataField().getQualifier(), nullValue());
101+
assertThat(leftList.get(3).getAuthority(), equalTo("virtual::" + relationship.getID()));
102+
97103
// rightItem is the author
98104
List<MetadataValue> rightRelationshipMetadataList = itemService
99105
.getMetadata(rightItem, MetadataSchemaEnum.RELATION.getName(), "isPublicationOfAuthor", null, Item.ANY);

dspace-api/src/test/java/org/dspace/content/RelationshipMetadataServiceIT.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public void testGetAuthorRelationshipMetadata() throws Exception {
187187
//request the virtual metadata of the publication only
188188
List<RelationshipMetadataValue> leftList = relationshipMetadataService
189189
.getRelationshipMetadata(leftItem, true);
190-
assertThat(leftList.size(), equalTo(3));
190+
assertThat(leftList.size(), equalTo(4));
191191

192192
assertThat(leftList.get(0).getValue(), equalTo(String.valueOf(rightItem.getID())));
193193
assertThat(leftList.get(0).getMetadataField().getMetadataSchema().getName(),
@@ -202,12 +202,12 @@ public void testGetAuthorRelationshipMetadata() throws Exception {
202202
assertThat(leftList.get(1).getMetadataField().getQualifier(), equalTo("author"));
203203
assertThat(leftList.get(1).getAuthority(), equalTo("virtual::" + relationship.getID()));
204204

205-
assertThat(leftList.get(2).getValue(), equalTo(String.valueOf(rightItem.getID())));
206-
assertThat(leftList.get(2).getMetadataField().getMetadataSchema().getName(),
205+
assertThat(leftList.get(3).getValue(), equalTo(String.valueOf(rightItem.getID())));
206+
assertThat(leftList.get(3).getMetadataField().getMetadataSchema().getName(),
207207
equalTo(MetadataSchemaEnum.RELATION.getName()));
208-
assertThat(leftList.get(2).getMetadataField().getElement(), equalTo("isAuthorOfPublication"));
209-
assertThat(leftList.get(2).getMetadataField().getQualifier(), nullValue());
210-
assertThat(leftList.get(2).getAuthority(), equalTo("virtual::" + relationship.getID()));
208+
assertThat(leftList.get(3).getMetadataField().getElement(), equalTo("isAuthorOfPublication"));
209+
assertThat(leftList.get(3).getMetadataField().getQualifier(), nullValue());
210+
assertThat(leftList.get(3).getAuthority(), equalTo("virtual::" + relationship.getID()));
211211

212212
// rightItem is the author
213213
List<MetadataValue> rightRelationshipMetadataList = itemService

dspace-server-webapp/src/test/java/org/dspace/app/rest/RelationshipRestRepositoryIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ public void addRelationshipsAndMetadataToValidatePlaceTest() throws Exception {
10421042
list = itemService.getMetadata(publication1, Item.ANY, Item.ANY, Item.ANY, Item.ANY);
10431043
// also includes type, 3 relation.isAuthorOfPublication and 3 relation.isAuthorOfPublication.latestForDiscovery
10441044
// values
1045-
assertEquals(22, list.size());
1045+
assertEquals(25, list.size());
10461046

10471047
} finally {
10481048
RelationshipBuilder.deleteRelationship(idRef1.get());

dspace/config/crosswalks/DIM2DataCite.xsl

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@
379379
<xsl:variable name="authority" select="@authority"/>
380380
<creator>
381381
<creatorName>
382+
<xsl:call-template name="nameType">
383+
<xsl:with-param name="authority_value" select="$authority"/>
384+
</xsl:call-template>
382385
<xsl:value-of select="." />
383386
</creatorName>
384387
<xsl:call-template name="personOrcid">
@@ -444,6 +447,9 @@
444447
<xsl:element name="contributor">
445448
<xsl:attribute name="contributorType">Editor</xsl:attribute>
446449
<contributorName>
450+
<xsl:call-template name="nameType">
451+
<xsl:with-param name="authority_value" select="$authority"/>
452+
</xsl:call-template>
447453
<xsl:value-of select="." />
448454
</contributorName>
449455
<xsl:call-template name="personOrcid">
@@ -458,6 +464,9 @@
458464
<xsl:element name="contributor">
459465
<xsl:attribute name="contributorType">RelatedPerson</xsl:attribute>
460466
<contributorName>
467+
<xsl:call-template name="nameType">
468+
<xsl:with-param name="authority_value" select="$authority"/>
469+
</xsl:call-template>
461470
<xsl:value-of select="." />
462471
</contributorName>
463472
<xsl:call-template name="personOrcid">
@@ -472,6 +481,9 @@
472481
<xsl:element name="contributor">
473482
<xsl:attribute name="contributorType">Other</xsl:attribute>
474483
<contributorName>
484+
<xsl:call-template name="nameType">
485+
<xsl:with-param name="authority_value" select="$authority"/>
486+
</xsl:call-template>
475487
<xsl:value-of select="." />
476488
</contributorName>
477489
<xsl:call-template name="personOrcid">
@@ -486,6 +498,9 @@
486498
<xsl:element name="contributor">
487499
<xsl:attribute name="contributorType">Other</xsl:attribute>
488500
<contributorName>
501+
<xsl:call-template name="nameType">
502+
<xsl:with-param name="authority_value" select="$authority"/>
503+
</xsl:call-template>
489504
<xsl:value-of select="." />
490505
</contributorName>
491506
<xsl:call-template name="personOrcid">
@@ -500,6 +515,9 @@
500515
<xsl:element name="contributor">
501516
<xsl:attribute name="contributorType">Other</xsl:attribute>
502517
<contributorName>
518+
<xsl:call-template name="nameType">
519+
<xsl:with-param name="authority_value" select="$authority"/>
520+
</xsl:call-template>
503521
<xsl:value-of select="." />
504522
</contributorName>
505523
<xsl:call-template name="personOrcid">
@@ -726,4 +744,25 @@
726744
</xsl:if>
727745
</xsl:template>
728746

747+
<!--
748+
This template is used to add a nameType attribute to a
749+
contributorName element when a dspace.entity.type virtual
750+
metadata is available to be able to tell whether the
751+
contributor is a Person or an OrgUnit, or when it comes in
752+
through the isOrgUnitOfPublication relationship.
753+
-->
754+
<xsl:template name="nameType">
755+
<xsl:param name="authority_value"/>
756+
<xsl:variable name="entity_type" select= "//dspace:field[@mdschema='dspace' and @element='relatedentity' and @qualifier='type' and @authority=$authority_value]" />
757+
<xsl:if test="starts-with($authority_value, 'virtual::')">
758+
<xsl:choose>
759+
<xsl:when test="$entity_type = 'OrgUnit' or //dspace:field[@mdschema='relation' and @element='isOrgUnitOfPublication' and @authority=$authority_value]">
760+
<xsl:attribute name="nameType">Organizational</xsl:attribute>
761+
</xsl:when>
762+
<xsl:when test="$entity_type = 'Person'">
763+
<xsl:attribute name="nameType">Personal</xsl:attribute>
764+
</xsl:when>
765+
</xsl:choose>
766+
</xsl:if>
767+
</xsl:template>
729768
</xsl:stylesheet>

dspace/config/registries/dspace-types.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
<scope_note>Stores the type of Entity that a specific Item represents</scope_note>
3838
</dc-type>
3939

40+
<dc-type>
41+
<schema>dspace</schema>
42+
<element>relatedentity</element>
43+
<qualifier>type</qualifier>
44+
<scope_note>Stores the type of Entity that a specific Item represents when it is linked to another item</scope_note>
45+
</dc-type>
46+
4047
<dc-type>
4148
<schema>dspace</schema>
4249
<element>iiif</element>

dspace/config/spring/api/virtual-metadata.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
<entry key="dc.contributor.author" value-ref="publicationAuthor_author"/>
4949
<entry key="person.identifier.orcid" value-ref="publicationAuthor_identifierOrcid"/>
5050
<entry key="organization.identifier.ror" value-ref="publicationAuthor_identifierRor"/>
51+
<entry key="dspace.relatedentity.type" value-ref="publicationAuthor_entityType"/>
5152
</util:map>
5253
<!--
5354
If the related item has:
@@ -84,6 +85,14 @@
8485
</property>
8586
</bean>
8687

88+
<bean class="org.dspace.content.virtual.Collected" id="publicationAuthor_entityType">
89+
<property name="fields">
90+
<util:list>
91+
<value>dspace.entity.type</value>
92+
</util:list>
93+
</property>
94+
</bean>
95+
8796
<!-- Config like this will tell our VirtualMetadataPopulator to include the virtual metadata field
8897
'dc.contributor.editor' on the appropriate item with the values defined in the value-ref.
8998
This value-ref should be a bean of type VirtualMetadataConfiguration -->

0 commit comments

Comments
 (0)