include the class information in the measure XML serialization

This commit is contained in:
Claudio Atzori 2022-07-01 09:54:56 +02:00
parent a88103bcf9
commit 072f192853
3 changed files with 188 additions and 17 deletions

View File

@ -999,17 +999,11 @@ public class XmlRecordFactory implements Serializable {
private List<String> measuresAsXml(List<Measure> 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<Tuple2<String, String>> 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());
}

View File

@ -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

View File

@ -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"
}
}
}
]
}