From 48d32466e4c4ee5b3ef39a23f04073487b2979da Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Wed, 23 Mar 2022 14:52:03 +0100 Subject: [PATCH 1/2] instances grouped by URL expose only one refereed --- .../dhp/oa/provision/model/XmlInstance.java | 13 +++++++--- .../oa/provision/utils/XmlRecordFactory.java | 20 +++++++------- .../oa/provision/XmlRecordFactoryTest.java | 2 +- .../dnetlib/dhp/oa/provision/publication.json | 26 ++++++++++++++++++- pom.xml | 2 +- 5 files changed, 48 insertions(+), 15 deletions(-) diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/model/XmlInstance.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/model/XmlInstance.java index a383297506..930eab4c32 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/model/XmlInstance.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/model/XmlInstance.java @@ -12,6 +12,7 @@ import scala.Serializable; public class XmlInstance implements Serializable { public static final AccessRight UNKNOWN_ACCESS_RIGHT; + public static final Qualifier UNKNOWN_REVIEW_LEVEL; static { UNKNOWN_ACCESS_RIGHT = new AccessRight(); @@ -19,6 +20,12 @@ public class XmlInstance implements Serializable { UNKNOWN_ACCESS_RIGHT.setClassname(ModelConstants.UNKNOWN); UNKNOWN_ACCESS_RIGHT.setSchemeid(ModelConstants.DNET_ACCESS_MODES); UNKNOWN_ACCESS_RIGHT.setSchemename(ModelConstants.DNET_ACCESS_MODES); + + UNKNOWN_REVIEW_LEVEL = new Qualifier(); + UNKNOWN_REVIEW_LEVEL.setClassid("0000"); + UNKNOWN_REVIEW_LEVEL.setClassname(ModelConstants.UNKNOWN); + UNKNOWN_ACCESS_RIGHT.setSchemeid(ModelConstants.DNET_REVIEW_LEVELS); + UNKNOWN_REVIEW_LEVEL.setSchemename(ModelConstants.DNET_REVIEW_LEVELS); } private String url; @@ -50,7 +57,7 @@ public class XmlInstance implements Serializable { // typed results private String processingchargecurrency; - private Set refereed = Sets.newHashSet();; // peer-review status + private Qualifier refereed; // peer-review status public String getUrl() { return url; @@ -148,11 +155,11 @@ public class XmlInstance implements Serializable { this.processingchargecurrency = processingchargecurrency; } - public Set getRefereed() { + public Qualifier getRefereed() { return refereed; } - public void setRefereed(Set refereed) { + public void setRefereed(Qualifier refereed) { this.refereed = refereed; } } 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 cb29dc1216..5d4a831c0d 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 @@ -31,6 +31,7 @@ import org.dom4j.Node; import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; +import org.json4s.Xml; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Joiner; @@ -1208,14 +1209,8 @@ public class XmlRecordFactory implements Serializable { if (instance.getRefereed() != null) { fields - .addAll( - instance - .getRefereed() - .stream() - .filter(Objects::nonNull) - .filter(r -> !r.isBlank()) - .map(r -> XmlSerializationUtils.mapQualifier("refereed", r)) - .collect(Collectors.toList())); + .add( + XmlSerializationUtils.mapQualifier("refereed", instance.getRefereed())); } if (instance.getProcessingchargeamount() != null && isNotBlank(instance.getProcessingchargeamount())) { @@ -1359,13 +1354,20 @@ public class XmlRecordFactory implements Serializable { .map(Instance::getAccessright) .min(new AccessRightComparator()) .orElse(XmlInstance.UNKNOWN_ACCESS_RIGHT)); + instance + .setRefereed( + instances + .stream() + .map(Pair::getValue) + .map(i -> Optional.ofNullable(i.getRefereed()).orElse(XmlInstance.UNKNOWN_REVIEW_LEVEL)) + .min(new RefereedComparator()) + .orElse(XmlInstance.UNKNOWN_REVIEW_LEVEL)); instances.forEach(p -> { final Instance i = p.getRight(); instance.getCollectedfrom().add(i.getCollectedfrom()); instance.getHostedby().add(i.getHostedby()); instance.getInstancetype().add(i.getInstancetype()); - instance.getRefereed().add(i.getRefereed()); instance .setProcessingchargeamount( Optional.ofNullable(i.getProcessingchargeamount()).map(apc -> apc.getValue()).orElse(null)); 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 273132bffe..c32d868e86 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 @@ -66,7 +66,7 @@ public class XmlRecordFactoryTest { assertEquals("doi", doc.valueOf("//instance/alternateidentifier/@classid")); assertEquals("10.5689/LIB.2018.2853550", doc.valueOf("//instance/alternateidentifier/text()")); - assertEquals(3, doc.selectNodes("//instance").size()); + assertEquals(2, doc.selectNodes("//instance").size()); assertEquals("1721.47", doc.valueOf("//processingchargeamount/text()")); assertEquals("EUR", doc.valueOf("//processingchargecurrency/text()")); 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 d0c8ea4edc..2c52ce269f 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 @@ -453,6 +453,12 @@ "schemeid": "dnet:dataCite_resource", "schemename": "dnet:dataCite_resource" }, + "refereed": { + "classid": "0001", + "classname": "peerReviewed", + "schemeid": "dnet:review_levels", + "schemename": "dnet:review_levels" + }, "license": { "dataInfo": { "deletedbyinference": false, @@ -585,6 +591,12 @@ "schemeid": "dnet:dataCite_resource", "schemename": "dnet:dataCite_resource" }, + "refereed": { + "classid": "0000", + "classname": "UNKNOWN", + "schemeid": "dnet:review_levels", + "schemename": "dnet:review_levels" + }, "license": { "dataInfo": { "deletedbyinference": false, @@ -717,6 +729,12 @@ "schemeid": "dnet:dataCite_resource", "schemename": "dnet:dataCite_resource" }, + "refereed": { + "classid": "0002", + "classname": "nonPeerReviewed", + "schemeid": "dnet:review_levels", + "schemename": "dnet:review_levels" + }, "license": { "dataInfo": { "deletedbyinference": false, @@ -849,6 +867,12 @@ "schemeid": "dnet:dataCite_resource", "schemename": "dnet:dataCite_resource" }, + "refereed": { + "classid": "0001", + "classname": "peerReviewed", + "schemeid": "dnet:review_levels", + "schemename": "dnet:review_levels" + }, "license": { "dataInfo": { "deletedbyinference": false, @@ -866,7 +890,7 @@ "value": "" }, "url": [ - "http://dx.doi.org/10.1109/TED.2018.2853552", + "http://dx.doi.org/10.1109/TED.2018.2853551", "http://dx.doi.org/10.1109/TED.2018.2853554" ] }, diff --git a/pom.xml b/pom.xml index 86adee9022..0f0aa711e2 100644 --- a/pom.xml +++ b/pom.xml @@ -797,7 +797,7 @@ 3.3.3 3.4.2 [2.12,3.0) - [2.10.29] + [2.10.30] [4.0.3] [6.0.5] [3.1.6] From 395ac6ececc1ac72947fb9efffd3e49e25708ba6 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Mon, 28 Mar 2022 09:23:42 +0200 Subject: [PATCH 2/2] merged pom.xml from beta branch --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0f0aa711e2..45265d5baf 100644 --- a/pom.xml +++ b/pom.xml @@ -797,7 +797,7 @@ 3.3.3 3.4.2 [2.12,3.0) - [2.10.30] + [2.10.31] [4.0.3] [6.0.5] [3.1.6]