From 499826ead1934f1dbe3f880cdcaa82200ea5f470 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Thu, 4 Aug 2022 12:40:48 +0200 Subject: [PATCH] serialising field eoscifguidelines field in the Solr XML records --- .../dhp/oa/provision/utils/XmlRecordFactory.java | 11 +++++++++++ .../oa/provision/utils/XmlSerializationUtils.java | 13 +++++++++++++ .../dhp/oa/provision/XmlRecordFactoryTest.java | 2 ++ .../eu/dnetlib/dhp/oa/provision/publication.json | 8 ++++++++ 4 files changed, 34 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 b34ec9693..45ba840c9 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 @@ -214,6 +214,17 @@ public class XmlRecordFactory implements Serializable { metadata.addAll(measuresAsXml(r.getMeasures())); } + if (r.getEoscifguidelines() != null) { + metadata + .addAll( + r + .getEoscifguidelines() + .stream() + .filter(Objects::nonNull) + .map(e -> XmlSerializationUtils.mapEoscIf(e)) + .collect(Collectors.toList())); + } + if (r.getContext() != null) { contexts.addAll(r.getContext().stream().map(c -> c.getId()).collect(Collectors.toList())); /* FIXME: Workaround for CLARIN mining issue: #3670#note-29 */ diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/utils/XmlSerializationUtils.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/utils/XmlSerializationUtils.java index 73667e056..adf7090d2 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/utils/XmlSerializationUtils.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/utils/XmlSerializationUtils.java @@ -7,6 +7,8 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.util.List; +import com.google.common.collect.Lists; + import eu.dnetlib.dhp.schema.oaf.*; import scala.Tuple2; @@ -161,4 +163,15 @@ public class XmlSerializationUtils { sb.append("/>"); return sb.toString(); } + + public static String mapEoscIf(EoscIfGuidelines e) { + return asXmlElement( + "eoscifguidelines", Lists + .newArrayList( + new Tuple2<>("code", e.getCode()), + new Tuple2<>("label", e.getLabel()), + new Tuple2<>("url", e.getUrl()), + new Tuple2<>("semanticrelation", e.getSemanticRelation()))); + } + } 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 92d9f497f..77d1f9fdb 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 @@ -87,6 +87,8 @@ public class XmlRecordFactoryTest { assertEquals( "C", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity']/@class")); + assertEquals("EOSC::Jupyter Notebook", doc.valueOf("//*[local-name() = 'result']/eoscifguidelines/@code")); + } @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 41ced45ae..5e3f19bd7 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 @@ -1,4 +1,12 @@ { + "eoscifguidelines": [ + { + "code" : "EOSC::Jupyter Notebook", + "label" : "EOSC::Jupyter Notebook", + "url" : "", + "semanticRelation" : "compliesWith" + } + ], "measures": [ { "id": "influence",