forked from D-Net/dnet-hadoop
Merge pull request 'score class in the XML serialization' (#225) from measure_serialization into beta
Reviewed-on: D-Net/dnet-hadoop#225
This commit is contained in:
commit
138d1dfbf8
|
@ -999,17 +999,11 @@ public class XmlRecordFactory implements Serializable {
|
||||||
private List<String> measuresAsXml(List<Measure> measures) {
|
private List<String> measuresAsXml(List<Measure> measures) {
|
||||||
return measures
|
return measures
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(
|
.map(m -> {
|
||||||
m -> m
|
List<Tuple2<String, String>> l = Lists.newArrayList(new Tuple2<>("id", m.getId()));
|
||||||
.getUnit()
|
m.getUnit().forEach(kv -> l.add(new Tuple2<>(kv.getKey(), kv.getValue())));
|
||||||
.stream()
|
return XmlSerializationUtils.asXmlElement("measure", l);
|
||||||
.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)))
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,11 +73,20 @@ public class XmlRecordFactoryTest {
|
||||||
assertEquals("EUR", doc.valueOf("//processingchargecurrency/text()"));
|
assertEquals("EUR", doc.valueOf("//processingchargecurrency/text()"));
|
||||||
|
|
||||||
assertEquals(
|
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(
|
assertEquals(
|
||||||
"30.6576853333", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity_alt']/@value"));
|
"C", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'influence']/@class"));
|
||||||
|
|
||||||
assertEquals(
|
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
|
@Test
|
||||||
|
|
|
@ -5,7 +5,37 @@
|
||||||
"unit": [
|
"unit": [
|
||||||
{
|
{
|
||||||
"key": "score",
|
"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": [
|
"unit": [
|
||||||
{
|
{
|
||||||
"key": "score",
|
"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": [
|
"unit": [
|
||||||
{
|
{
|
||||||
"key": "score",
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue