From a72b9e96ac9d1d6ec588370e8d8a374a865c9928 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Thu, 27 Jul 2023 14:57:38 +0200 Subject: [PATCH] expand the instance level fulltext in the XML records --- .../eu/dnetlib/dhp/oa/provision/model/XmlInstance.java | 10 ++++++++++ .../dhp/oa/provision/utils/XmlRecordFactory.java | 6 ++++++ .../dnetlib/dhp/oa/provision/XmlRecordFactoryTest.java | 8 ++++++-- .../eu/dnetlib/dhp/oa/provision/publication.json | 6 +++++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/model/XmlInstance.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/model/XmlInstance.java index 930eab4c3..22e1df9ce 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/model/XmlInstance.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/oa/provision/model/XmlInstance.java @@ -57,6 +57,8 @@ public class XmlInstance implements Serializable { // typed results private String processingchargecurrency; + private String fulltext; + private Qualifier refereed; // peer-review status public String getUrl() { @@ -162,4 +164,12 @@ public class XmlInstance implements Serializable { public void setRefereed(Qualifier refereed) { this.refereed = refereed; } + + public String getFulltext() { + return fulltext; + } + + public void setFulltext(String fulltext) { + this.fulltext = fulltext; + } } 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 19d889d90..3b810ba8c 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 @@ -1309,6 +1309,9 @@ public class XmlRecordFactory implements Serializable { .map(d -> XmlSerializationUtils.asXmlElement("license", d)) .collect(Collectors.toList())); } + if (StringUtils.isNotBlank(instance.getFulltext())) { + fields.add(XmlSerializationUtils.asXmlElement("fulltext", instance.getFulltext())); + } children .add( @@ -1459,6 +1462,9 @@ public class XmlRecordFactory implements Serializable { Optional .ofNullable(i.getDistributionlocation()) .ifPresent(dl -> instance.getDistributionlocation().add(dl)); + Optional + .ofNullable(i.getFulltext()) + .ifPresent(instance::setFulltext); }); if (instance.getHostedby().size() > 1 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 8802b546d..761539780 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 @@ -47,8 +47,6 @@ public class XmlRecordFactoryTest { final String xml = xmlRecordFactory.build(new JoinedEntity<>(p)); - System.out.println(xml); - assertNotNull(xml); final Document doc = new SAXReader().read(new StringReader(xml)); @@ -92,6 +90,12 @@ public class XmlRecordFactoryTest { assertEquals("EOSC::Jupyter Notebook", doc.valueOf("//*[local-name() = 'result']/eoscifguidelines/@code")); + assertEquals(2, Integer.parseInt(doc.valueOf("count(//*[local-name() = 'result']/fulltext)"))); + + assertEquals( + "https://osf.io/preprints/socarxiv/7vgtu/download", + doc.valueOf("//*[local-name() = 'result']/fulltext[1]")); + } @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 901e6d579..4ba20292c 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 @@ -485,10 +485,14 @@ }, "extraInfo": [], "format": [], - "fulltext": [], + "fulltext": [ + { "value" : "https://osf.io/preprints/socarxiv/7vgtu/download" }, + { "value" : "https://osf.io/preprints/socarxiv/7vgtu/download2" } + ], "id": "50|CSC_________::0000ec4dd9df012feaafa77e71a0fb4c", "instance": [ { + "fulltext" : "https://osf.io/preprints/socarxiv/7vgtu/download", "measures": [ { "id": "influence",