Skip to content

Commit

Permalink
extend datacite import mapping with additional required or optional f…
Browse files Browse the repository at this point in the history
…ields
  • Loading branch information
floriangantner committed Oct 31, 2024
1 parent 995e8e5 commit b149d97
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,29 @@ public void dataCiteImportMetadataGetRecordsTest() throws Exception {
}
}

@Test
public void dataCiteImportMetadataGetRecordsTest2() throws Exception {
context.turnOffAuthorisationSystem();
CloseableHttpClient originalHttpClient = liveImportClientImpl.getHttpClient();
CloseableHttpClient httpClient = Mockito.mock(CloseableHttpClient.class);
try (InputStream dataCiteResp = getClass().getResourceAsStream("dataCite-test1.json")) {
String dataCiteRespXmlResp = IOUtils.toString(dataCiteResp, Charset.defaultCharset());

liveImportClientImpl.setHttpClient(httpClient);
CloseableHttpResponse response = mockResponse(dataCiteRespXmlResp, 200, "OK");
when(httpClient.execute(ArgumentMatchers.any())).thenReturn(response);

context.restoreAuthSystemState();
ArrayList<ImportRecord> collection2match = getRecords2();
Collection<ImportRecord> recordsImported = dataCiteServiceImpl.getRecords("10.5446/57552",
0, -1);
assertEquals(1, recordsImported.size());
matchRecords(new ArrayList<>(recordsImported), collection2match);
} finally {
liveImportClientImpl.setHttpClient(originalHttpClient);
}
}

@Test
public void dataCiteImportMetadataGetRecordsCountTest() throws Exception {
context.turnOffAuthorisationSystem();
Expand Down Expand Up @@ -130,6 +153,21 @@ private ArrayList<ImportRecord> getRecords() {
MetadatumDTO dateissued = createMetadatumDTO("dc", "date", "issued", "2022");
MetadatumDTO publisher = createMetadatumDTO("dc", "publisher", null, "arXiv");
MetadatumDTO type = createMetadatumDTO("dc", "type", null, "Working Paper");
MetadatumDTO abstrct = createMetadatumDTO("dc", "description", "abstract", "A proof is one of the most" +
" important concepts of mathematics. However, there is a striking difference between how a proof " +
"is defined in theory and how it " +
"is used in practice. This puts the unique status of mathematics as exact science into peril. " +
"Now may be the time to reconcile theory and practice, i.e. precision and intuition, through the" +
" advent of computer proof assistants. For the most time this has been a topic for experts in specialized" +
" communities. However, mathematical proofs have become increasingly sophisticated, stretching the" +
" boundaries of what is humanly comprehensible, so that leading mathematicians have asked for formal" +
" verification of their proofs. At the same time, major theorems in mathematics have recently been" +
" computer-verified by people from outside of these communities, even by beginning students. This" +
" article investigates the gap between the different definitions of a proof and possibilities to" +
" build bridges. It is written as a polemic or a collage by different members of the communities in" +
" mathematics and computer science at different stages of their careers, challenging well-known" +
" preconceptions and exploring new perspectives.");
MetadatumDTO description = createMetadatumDTO("dc", "description", null, "17 pages, 1 figure");
metadatums.add(title);
metadatums.add(doi);
metadatums.add(author1);
Expand All @@ -145,6 +183,40 @@ private ArrayList<ImportRecord> getRecords() {
metadatums.add(dateissued);
metadatums.add(publisher);
metadatums.add(type);
metadatums.add(abstrct);
metadatums.add(description);

ImportRecord firstRecord = new ImportRecord(metadatums);

records.add(firstRecord);
return records;
}

private ArrayList<ImportRecord> getRecords2() {
ArrayList<ImportRecord> records = new ArrayList<>();
//define first record
List<MetadatumDTO> metadatums = new ArrayList<>();
MetadatumDTO title = createMetadatumDTO("dc", "title", null,
"Der Professorinnen- und Professorenkatalog der Universität Bamberg");
MetadatumDTO doi = createMetadatumDTO("dc", "identifier", "doi", "10.5446/57552");
MetadatumDTO author1 = createMetadatumDTO("dc", "contributor", "author", "Prussat, Margrit");
MetadatumDTO author2 = createMetadatumDTO("dc", "contributor", "author", "Gantner, Florian");
MetadatumDTO dateissued = createMetadatumDTO("dc", "date", "issued", "2022");
MetadatumDTO publisher = createMetadatumDTO("dc", "publisher", null, "The Library Code GmbH");
MetadatumDTO type = createMetadatumDTO("dc", "type", null, "Video");
MetadatumDTO language = createMetadatumDTO("dc", "language", "iso", "de");
MetadatumDTO abstrct = createMetadatumDTO("dc", "description", "abstract", "Dr. Margrit Prussat" +
" und Florian Gantner stellen auf dem DSpace Anwendertreffen 2021 den mit DSpace betriebenen" +
" Professorinnen- und Professorenkatalog der Universität Bamberg vor.");
metadatums.add(title);
metadatums.add(doi);
metadatums.add(author1);
metadatums.add(author2);
metadatums.add(dateissued);
metadatums.add(publisher);
metadatums.add(type);
metadatums.add(abstrct);
metadatums.add(language);

ImportRecord firstRecord = new ImportRecord(metadatums);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"data":{"id":"10.5446/57552","type":"dois","attributes":{"doi":"10.5446/57552","prefix":"10.5446","suffix":"57552","identifiers":[],"alternateIdentifiers":[],"creators":[{"name":"Prussat, Margrit","nameType":"Personal","givenName":"Margrit","familyName":"Prussat","affiliation":[],"nameIdentifiers":[]},{"name":"Gantner, Florian","nameType":"Personal","givenName":"Florian","familyName":"Gantner","affiliation":[],"nameIdentifiers":[]}],"titles":[{"title":"Der Professorinnen- und Professorenkatalog der Universität Bamberg"}],"publisher":"The Library Code GmbH","container":{},"publicationYear":2022,"subjects":[{"subject":"Information Science"},{"subject":"DSpace"}],"contributors":[{"name":"Becker, Pascal (Moderation)","nameType":"Personal","affiliation":[],"contributorType":"RelatedPerson","nameIdentifiers":[]}],"dates":[{"date":"2022","dateType":"Issued"}],"language":"de","types":{"ris":"MPCT","bibtex":"misc","citeproc":"article","schemaOrg":"MediaObject","resourceType":"Conference/Talk","resourceTypeGeneral":"Audiovisual"},"relatedIdentifiers":[],"relatedItems":[],"sizes":[],"formats":[],"version":null,"rightsList":[],"descriptions":[{"description":"Dr. Margrit Prussat und Florian Gantner stellen auf dem DSpace Anwendertreffen 2021 den mit DSpace betriebenen Professorinnen- und Professorenkatalog der Universität Bamberg vor.","descriptionType":"Abstract"}],"geoLocations":[],"fundingReferences":[],"xml":"PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHJlc291cmNlIHhtbG5zPSJodHRwOi8vZGF0YWNpdGUub3JnL3NjaGVtYS9rZXJuZWwtMyIgeG1sbnM6eHNpPSJodHRwOi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYS1pbnN0YW5jZ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ck5hbWU+CiAgICA8L2NvbnRyaWJ1dG9yPgogIDwvY29udHJpYnV0b3JzPgogIDxzdWJqZWN0cz4KICAgIDxzdWJqZWN0PkluZm9ybWF0aW9uIFNjaWVuY2U8L3N1YmplY3Q+CiAgICA8c3ViamVjdD5EU3BhY2U8L3N1YmplY3Q+CiAgPC9zdWJqZWN0cz4KICA8ZGVzY3JpcHRpb25zPgogICAgPGRlc2NyaXB0aW9uIGRlc2NyaXB0aW9uVHlwZT0iQWJzdHJhY3QiPkRyLiBNYXJncml0IFBydXNzYXQgdW5kIEZsb3JpYW4gR2FudG5lciBzdGVsbGVuIGF1ZiBkZW0gRFNwYWNlIEFud2VuZGVydHJlZmZlbiAyMDIxIGRlbiBtaXQgRFNwYWNlIGJldHJpZWJlbmVuIFByb2Zlc3NvcmlubmVuLSB1bmQgUHJvZmVzc29yZW5rYXRhbG9nIGRlciBVbml2ZXJzaXTDpHQgQmFtYmVyZyB2b3IuPC9kZXNjcmlwdGlvbj4KICA8L2Rlc2NyaXB0aW9ucz4KPC9yZXNvdXJjZT4=","url":"https://av.tib.eu/media/57552","contentUrl":null,"metadataVersion":0,"schemaVersion":"http://datacite.org/schema/kernel-3","source":"mds","isActive":true,"state":"findable","reason":null,"viewCount":0,"viewsOverTime":[],"downloadCount":0,"downloadsOverTime":[],"referenceCount":0,"citationCount":0,"citationsOverTime":[],"partCount":0,"partOfCount":0,"versionCount":0,"versionOfCount":0,"created":"2022-06-02T13:35:17.000Z","registered":"2022-06-02T13:35:18.000Z","published":"2022","updated":"2022-06-02T13:35:18.000Z"},"relationships":{"client":{"data":{"id":"tib.kmo","type":"clients"}},"provider":{"data":{"id":"wuua","type":"providers"}},"media":{"data":{"id":"10.5446/57552","type":"media"}},"references":{"data":[]},"citations":{"data":[]},"parts":{"data":[]},"partOf":{"data":[]},"versions":{"data":[]},"versionOf":{"data":[]}}}}
32 changes: 32 additions & 0 deletions dspace/config/spring/api/datacite-integration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
only matters here for postprocessing of the value. The mapped MetadatumContributor has full control over
what metadatafield is generated.
</description>
<!-- Mandatory Fields -->
<entry key-ref="datacite.title" value-ref="dataciteTitleContrib"/>
<entry key-ref="datacite.id" value-ref="dataciteIDContrib"/>
<entry key-ref="datacite.author" value-ref="dataciteAuthorContrib"/>
<entry key-ref="datacite.publicationyear" value-ref="datacitePublicationYearContrib"/>
<entry key-ref="datacite.publisher" value-ref="datacitePublisherContrib"/>
<entry key-ref="datacite.resourcetype" value-ref="dataciteResourceTypeContrib"/>
<!-- Optional Fields -->
<entry key-ref="datacite.abstract" value-ref="dataciteAbstractContrib"/>
<entry key-ref="datacite.description" value-ref="dataciteDescriptionContrib"/>
<entry key-ref="datacite.language" value-ref="dataciteLanguageContrib"/>
<!-- TODO: Further Mappings here! querys are applied among the data.attributes object containing the informations -->

</util:map>
Expand Down Expand Up @@ -95,5 +100,32 @@
<property name="defaultValue" value="Other"/>
</bean>

<bean id="dataciteAbstractContrib" class="org.dspace.importer.external.metadatamapping.contributor.EnhancedJsonPathAttributeConditionMetadataContributor">
<property name="field" ref="datacite.abstract"/>
<property name="query" value="/descriptions"/>
<property name="elementAttribute" value="description"/>
<property name="conditionKey" value="descriptionType" />
<property name="conditionValue" value=".*Abstract.*" />
</bean>
<bean id="datacite.abstract" class="org.dspace.importer.external.metadatamapping.MetadataFieldConfig">
<constructor-arg value="dc.description.abstract"/>
</bean>
<bean id="dataciteDescriptionContrib" class="org.dspace.importer.external.metadatamapping.contributor.EnhancedJsonPathAttributeConditionMetadataContributor">
<property name="field" ref="datacite.description"/>
<property name="query" value="/descriptions"/>
<property name="elementAttribute" value="description"/>
<property name="conditionKey" value="descriptionType" />
<property name="conditionValue" value="^((?!Abstract).)*$" />
</bean>
<bean id="datacite.description" class="org.dspace.importer.external.metadatamapping.MetadataFieldConfig">
<constructor-arg value="dc.description"/>
</bean>
<bean id="dataciteLanguageContrib" class="org.dspace.importer.external.metadatamapping.contributor.SimpleJsonPathMetadataContributor">
<property name="field" ref="datacite.language"/>
<property name="query" value="/language"/>
</bean>
<bean id="datacite.language" class="org.dspace.importer.external.metadatamapping.MetadataFieldConfig">
<constructor-arg value="dc.language.iso"/>
</bean>

</beans>

0 comments on commit b149d97

Please sign in to comment.