From 96238152cb050440d1e08e119f54e84ab45cb98d Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Fri, 28 May 2021 16:57:30 +0200 Subject: [PATCH] added serialization for alternateIdentifiers and pids within each record instance --- .../oa/provision/utils/XmlRecordFactory.java | 21 ++++++++ .../oa/provision/XmlRecordFactoryTest.java | 5 ++ .../dnetlib/dhp/oa/provision/publication.json | 48 +++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/utils/XmlRecordFactory.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/utils/XmlRecordFactory.java index 526c1b5f4..86bbae99e 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/utils/XmlRecordFactory.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/utils/XmlRecordFactory.java @@ -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( diff --git a/dhp-workflows/dhp-graph-provision/src/test/java/eu/dnetlib/dhp/oa/provision/XmlRecordFactoryTest.java b/dhp-workflows/dhp-graph-provision/src/test/java/eu/dnetlib/dhp/oa/provision/XmlRecordFactoryTest.java index 75805f66c..6631cb4da 100644 --- a/dhp-workflows/dhp-graph-provision/src/test/java/eu/dnetlib/dhp/oa/provision/XmlRecordFactoryTest.java +++ b/dhp-workflows/dhp-graph-provision/src/test/java/eu/dnetlib/dhp/oa/provision/XmlRecordFactoryTest.java @@ -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 } diff --git a/dhp-workflows/dhp-graph-provision/src/test/resources/eu/dnetlib/dhp/oa/provision/publication.json b/dhp-workflows/dhp-graph-provision/src/test/resources/eu/dnetlib/dhp/oa/provision/publication.json index ea7a30051..91f159853 100644 --- a/dhp-workflows/dhp-graph-provision/src/test/resources/eu/dnetlib/dhp/oa/provision/publication.json +++ b/dhp-workflows/dhp-graph-provision/src/test/resources/eu/dnetlib/dhp/oa/provision/publication.json @@ -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",