From 072f19285387fa3df2a8fcd0dfd2acbf448bdcb5 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Fri, 1 Jul 2022 09:54:56 +0200 Subject: [PATCH] include the class information in the measure XML serialization --- .../oa/provision/utils/XmlRecordFactory.java | 16 +- .../oa/provision/XmlRecordFactoryTest.java | 15 +- .../dnetlib/dhp/oa/provision/publication.json | 174 +++++++++++++++++- 3 files changed, 188 insertions(+), 17 deletions(-) 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 27128138c..b34ec9693 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 @@ -999,17 +999,11 @@ public class XmlRecordFactory implements Serializable { private List measuresAsXml(List measures) { return measures .stream() - .flatMap( - m -> m - .getUnit() - .stream() - .map( - u -> Lists - .newArrayList( - new Tuple2<>("id", m.getId()), - new Tuple2<>("key", u.getKey()), - new Tuple2<>("value", u.getValue()))) - .map(l -> XmlSerializationUtils.asXmlElement("measure", l))) + .map(m -> { + List> l = Lists.newArrayList(new Tuple2<>("id", m.getId())); + m.getUnit().forEach(kv -> l.add(new Tuple2<>(kv.getKey(), kv.getValue()))); + return XmlSerializationUtils.asXmlElement("measure", l); + }) .collect(Collectors.toList()); } 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 f4763618b..92d9f497f 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 @@ -73,11 +73,20 @@ public class XmlRecordFactoryTest { assertEquals("EUR", doc.valueOf("//processingchargecurrency/text()")); assertEquals( - "1.00889953098e-08", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'influence']/@value")); + "5.06690394631e-09", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'influence']/@score")); assertEquals( - "30.6576853333", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity_alt']/@value")); + "C", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'influence']/@class")); + assertEquals( - "4.62970429725e-08", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity']/@value")); + "0.0", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity_alt']/@score")); + assertEquals( + "C", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity_alt']/@class")); + + assertEquals( + "3.11855618382e-09", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity']/@score")); + assertEquals( + "C", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity']/@class")); + } @Test 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 2c52ce269..41ced45ae 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 @@ -5,7 +5,37 @@ "unit": [ { "key": "score", - "value": "1.00889953098e-08" + "value": "5.06690394631e-09", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } + }, + { + "key": "class", + "value": "C", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } } ] }, @@ -14,7 +44,37 @@ "unit": [ { "key": "score", - "value": "30.6576853333" + "value": "0.0", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } + }, + { + "key": "class", + "value": "C", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } } ] }, @@ -23,7 +83,115 @@ "unit": [ { "key": "score", - "value": "4.62970429725e-08" + "value": "3.11855618382e-09", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } + }, + { + "key": "class", + "value": "C", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } + } + ] + }, + { + "id": "influence_alt", + "unit": [ + { + "key": "score", + "value": "0.0", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } + }, + { + "key": "class", + "value": "C", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } + } + ] + }, + { + "id": "impulse", + "unit": [ + { + "key": "score", + "value": "0.0", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } + }, + { + "key": "class", + "value": "C", + "dataInfo": { + "invisible": false, + "inferred": true, + "deletedbyinference": false, + "trust": "", + "inferenceprovenance": "update", + "provenanceaction": { + "classid": "measure:bip", + "classname": "Inferred by OpenAIRE", + "schemeid": "dnet:provenanceActions", + "schemename": "dnet:provenanceActions" + } + } } ] }