Skip to content

Commit 60bebb6

Browse files
vins01-4scienceAdamF42
authored andcommitted
Merged in task/dspace-cris-2024_02_x/DSC-2456 (pull request DSpace#4325)
DSC-2456 Approved-by: Fapohunda, Adamo
2 parents dd11bf8 + e1d60c5 commit 60bebb6

5 files changed

Lines changed: 40 additions & 18 deletions

File tree

dspace-api/src/main/java/org/dspace/importer/external/metadatamapping/transform/StringJsonValueMappingMetadataProcessorService.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
*/
88
package org.dspace.importer.external.metadatamapping.transform;
99

10-
import static java.util.Optional.ofNullable;
11-
1210
import java.util.ArrayList;
1311
import java.util.Collection;
1412
import java.util.Optional;
@@ -45,13 +43,13 @@ public class StringJsonValueMappingMetadataProcessorService implements JsonPathM
4543
@Override
4644
public Collection<String> processMetadata(String json) {
4745
JsonNode rootNode = convertStringJsonToJsonNode(json);
48-
Optional<JsonNode> abstractNode = Optional.of(rootNode.at(path));
49-
Collection<String> values = new ArrayList<>();
46+
Optional<JsonNode> abstractNode = Optional.ofNullable(rootNode.at(path));
47+
Collection<String> values = new ArrayList<>(1);
5048

5149
if (abstractNode.isPresent() && abstractNode.get().getNodeType().equals(JsonNodeType.STRING)) {
5250

5351
String stringValue = abstractNode.get().asText();
54-
values.add(ofNullable(stringValue)
52+
values.add(Optional.ofNullable(stringValue)
5553
.map(value -> valueMapConverter != null ? valueMapConverter.getValue(value) : value)
5654
.orElse(valueMapConverter.getValue(null)));
5755
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ private ArrayList<ImportRecord> getRecords() {
162162
"State of Awareness of Freshers’ Groups Chortkiv State"
163163
+ " Medical College of Prevention of Iodine Deficiency Diseases");
164164
MetadatumDTO author = createMetadatumDTO("dc", "contributor", "author", "Senyuk, L.V.");
165-
// is expected the dc.type to be mapped from journal-article to Article
166-
MetadatumDTO type = createMetadatumDTO("dc", "type", null, "Article");
165+
// is expected the dc.type to be mapped from journal-article to text::journal::journal article
166+
MetadatumDTO type = createMetadatumDTO("dc", "type", null, "text::journal::journal article");
167167
MetadatumDTO date = createMetadatumDTO("dc", "date", "issued", "2016-05-19");
168168
MetadatumDTO ispartof = createMetadatumDTO("dc", "relation", "ispartof",
169169
"Ukraïnsʹkij žurnal medicini, bìologìï ta sportu");
@@ -192,8 +192,8 @@ private ArrayList<ImportRecord> getRecords() {
192192
MetadatumDTO title2 = createMetadatumDTO("dc", "title", null,
193193
"Ischemic Heart Disease and Role of Nurse of Cardiology Department");
194194
MetadatumDTO author2 = createMetadatumDTO("dc", "contributor", "author", "Kozak, K. І.");
195-
// is expected the dc.type to be mapped from journal-article to Article
196-
MetadatumDTO type2 = createMetadatumDTO("dc", "type", null, "Article");
195+
// is expected the dc.type to be mapped from journal-article to text::journal::journal article
196+
MetadatumDTO type2 = createMetadatumDTO("dc", "type", null, "text::journal::journal article");
197197
MetadatumDTO date2 = createMetadatumDTO("dc", "date", "issued", "2016-05-19");
198198
MetadatumDTO ispartof2 = createMetadatumDTO("dc", "relation", "ispartof",
199199
"Ukraïnsʹkij žurnal medicini, bìologìï ta sportu");

dspace-server-webapp/src/test/java/org/dspace/authority/CrisConsumerIT.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ public void testItemWithWillBeGeneratedAuthority() throws Exception {
685685
.build();
686686

687687
Item publication = ItemBuilder.createItem(context, publicationCollection)
688-
.withEntityType("Publication")
689688
.withAuthor("Walter White", AuthorityValueService.GENERATE + "ORCID::0000-0002-9079-593X")
690689
.build();
691690

@@ -714,7 +713,6 @@ public void testItemWithWillBeGeneratedAuthorityAndNoRelatedItemFound() throws E
714713
createCollection("Collection of persons", "Person", subCommunity);
715714

716715
Item publication = ItemBuilder.createItem(context, publicationCollection)
717-
.withEntityType("Publication")
718716
.withAuthor("Walter White", AuthorityValueService.GENERATE + "ORCID::0000-0002-9079-593X")
719717
.build();
720718

@@ -745,7 +743,6 @@ public void testItemWithWillBeReferencedAuthority() throws Exception {
745743
.build();
746744

747745
Item publication = ItemBuilder.createItem(context, publicationCollection)
748-
.withEntityType("Publication")
749746
.withAuthor("Walter White", AuthorityValueService.REFERENCE + "ORCID::0000-0002-9079-593X")
750747
.build();
751748

@@ -776,7 +773,6 @@ public void testItemWithWillBeReferencedAuthorityAndNoRelatedItemFound() throws
776773
createCollection("Collection of persons", "Person", subCommunity);
777774

778775
Item publication = ItemBuilder.createItem(context, publicationCollection)
779-
.withEntityType("Publication")
780776
.withAuthor("Walter White", AuthorityValueService.REFERENCE + "ORCID::0000-0002-9079-593X")
781777
.build();
782778

@@ -1040,7 +1036,6 @@ public void testItemWithWillBeReferencedAuthorityAndValueOverwriting() throws Ex
10401036
.build();
10411037

10421038
Item publication = ItemBuilder.createItem(context, publicationCollection)
1043-
.withEntityType("Publication")
10441039
.withAuthor("Walter White", AuthorityValueService.REFERENCE + "ORCID::0000-0002-9079-593X")
10451040
.build();
10461041

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# based on Crossref content type at https://crossref.gitlab.io/knowledge_base/docs/topics/content-types/#types-in-cayenne-rest-api
2+
# Mapping between work type supported by Crossref and the COAR common publication's types
3+
journal-article = text::journal::journal article
4+
journal-issue = text::journal::other periodical
5+
journal-volume = text::journal::other periodical
6+
journal = text::journal
7+
proceedings-article = text::conference output::conference paper
8+
proceedings = text::conference output
9+
dataset = other
10+
component = other
11+
report = text::report
12+
report-series = other
13+
standard = other
14+
standard-series = other
15+
edited-book = other
16+
monograph = other
17+
reference-book = other
18+
book = text::book
19+
book-series = other
20+
book-set = other
21+
book-chapter = text::book::book part
22+
book-section = text::book::book part
23+
book-part = text::book::book part
24+
book-track = other
25+
reference-entry = other
26+
dissertation = text::thesis
27+
posted-content = other
28+
peer-review = text::review::peer review
29+
other = other

dspace/config/spring/api/crossref-integration.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
<constructor-arg value="dc.relation.ispartof"/>
5050
</bean>
5151

52-
<bean name="mapConverterCrossRefToDSpacePublicationType" class="org.dspace.util.SimpleMapConverter" init-method="init">
53-
<property name="converterNameFile" value="mapConverter-crossref-to-dspace-publication-type.properties" />
52+
<bean name="mapConverterCrossRefToCoarPublicationType" class="org.dspace.util.SimpleMapConverter" init-method="init">
53+
<property name="converterNameFile" value="mapConverter-crossref-to-coar-publication-type.properties" />
5454
<property name="configurationService" ref="org.dspace.services.ConfigurationService" />
55-
<property name="defaultValue" value="Other"/>
55+
<property name="defaultValue" value="other"/>
5656
</bean>
5757
<bean id="crossrefTypeValueMapping" class="org.dspace.importer.external.metadatamapping.transform.StringJsonValueMappingMetadataProcessorService">
58-
<property name="valueMapConverter" ref="mapConverterCrossRefToDSpacePublicationType"/>
58+
<property name="valueMapConverter" ref="mapConverterCrossRefToCoarPublicationType"/>
5959
<property name="path" value="/type"/>
6060
</bean>
6161
<bean id="crossrefDoiTypeContrib" class="org.dspace.importer.external.metadatamapping.contributor.SimpleJsonPathMetadataContributor">

0 commit comments

Comments
 (0)