Merge pull request 'serialising field eoscifguidelines field in the Solr XML records' (#234) from tagEosc into beta

Reviewed-on: D-Net/dnet-hadoop#234
This commit is contained in:
Claudio Atzori 2022-08-08 10:28:41 +02:00
commit d85ba3c1a9
4 changed files with 34 additions and 0 deletions

View File

@ -214,6 +214,17 @@ public class XmlRecordFactory implements Serializable {
metadata.addAll(measuresAsXml(r.getMeasures())); 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) { if (r.getContext() != null) {
contexts.addAll(r.getContext().stream().map(c -> c.getId()).collect(Collectors.toList())); contexts.addAll(r.getContext().stream().map(c -> c.getId()).collect(Collectors.toList()));
/* FIXME: Workaround for CLARIN mining issue: #3670#note-29 */ /* FIXME: Workaround for CLARIN mining issue: #3670#note-29 */

View File

@ -7,6 +7,8 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.List; import java.util.List;
import com.google.common.collect.Lists;
import eu.dnetlib.dhp.schema.oaf.*; import eu.dnetlib.dhp.schema.oaf.*;
import scala.Tuple2; import scala.Tuple2;
@ -161,4 +163,15 @@ public class XmlSerializationUtils {
sb.append("/>"); sb.append("/>");
return sb.toString(); 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())));
}
} }

View File

@ -87,6 +87,8 @@ public class XmlRecordFactoryTest {
assertEquals( assertEquals(
"C", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity']/@class")); "C", doc.valueOf("//*[local-name() = 'result']/measure[./@id = 'popularity']/@class"));
assertEquals("EOSC::Jupyter Notebook", doc.valueOf("//*[local-name() = 'result']/eoscifguidelines/@code"));
} }
@Test @Test

View File

@ -1,4 +1,12 @@
{ {
"eoscifguidelines": [
{
"code" : "EOSC::Jupyter Notebook",
"label" : "EOSC::Jupyter Notebook",
"url" : "",
"semanticRelation" : "compliesWith"
}
],
"measures": [ "measures": [
{ {
"id": "influence", "id": "influence",