added serialization for alternateIdentifiers and pids within each record instance

This commit is contained in:
Claudio Atzori 2021-05-28 16:57:30 +02:00
parent 83722ebc47
commit 96238152cb
3 changed files with 74 additions and 0 deletions

View File

@ -1160,6 +1160,27 @@ public class XmlRecordFactory implements Serializable {
.asXmlElement(
"distributionlocation", instance.getDistributionlocation()));
}
if (instance.getPid() != null) {
fields
.addAll(
instance
.getPid()
.stream()
.filter(Objects::nonNull)
.map(p -> XmlSerializationUtils.mapStructuredProperty("pid", p))
.collect(Collectors.toList()));
}
if (instance.getAlternateIdentifier() != null) {
fields
.addAll(
instance
.getAlternateIdentifier()
.stream()
.filter(Objects::nonNull)
.map(p -> XmlSerializationUtils.mapStructuredProperty("alternateidentifier", p))
.collect(Collectors.toList()));
}
if (instance.getRefereed() != null && !instance.getRefereed().isBlank()) {
fields
.add(

View File

@ -61,6 +61,11 @@ public class XmlRecordFactoryTest {
Assertions.assertEquals("0000-0001-9613-9956", doc.valueOf("//creator[@rank = '2']/@orcid"));
Assertions.assertEquals("", doc.valueOf("//creator[@rank = '2']/@orcid_pending"));
Assertions.assertEquals("doi", doc.valueOf("//instance/pid/@classid"));
Assertions.assertEquals("10.1109/TED.2018.2853550", doc.valueOf("//instance/pid/text()"));
Assertions.assertEquals("doi", doc.valueOf("//instance/alternateidentifier/@classid"));
Assertions.assertEquals("10.5689/LIB.2018.2853550", doc.valueOf("//instance/alternateidentifier/text()"));
// TODO add assertions based of values extracted from the XML record
}

View File

@ -284,6 +284,54 @@
"id": "50|CSC_________::0000ec4dd9df012feaafa77e71a0fb4c",
"instance": [
{
"pid": [
{
"dataInfo": {
"deletedbyinference": false,
"inferenceprovenance": "",
"inferred": false,
"invisible": false,
"provenanceaction": {
"classid": "",
"classname": "",
"schemeid": "",
"schemename": ""
},
"trust": ""
},
"qualifier": {
"classid": "doi",
"classname": "doi",
"schemeid": "dnet:pid_types",
"schemename": "dnet:pid_types"
},
"value": "10.1109/TED.2018.2853550"
}
],
"alternateIdentifier": [
{
"dataInfo": {
"deletedbyinference": false,
"inferenceprovenance": "",
"inferred": false,
"invisible": false,
"provenanceaction": {
"classid": "",
"classname": "",
"schemeid": "",
"schemename": ""
},
"trust": ""
},
"qualifier": {
"classid": "doi",
"classname": "doi",
"schemeid": "dnet:pid_types",
"schemename": "dnet:pid_types"
},
"value": "10.5689/LIB.2018.2853550"
}
],
"accessright": {
"classid": "OPEN",
"classname": "Open Access",