1
0
Fork 0

instances grouped by URL expose only one refereed

This commit is contained in:
Claudio Atzori 2022-03-23 14:52:03 +01:00
parent f10066547b
commit 48d32466e4
5 changed files with 48 additions and 15 deletions

View File

@ -12,6 +12,7 @@ import scala.Serializable;
public class XmlInstance implements Serializable {
public static final AccessRight UNKNOWN_ACCESS_RIGHT;
public static final Qualifier UNKNOWN_REVIEW_LEVEL;
static {
UNKNOWN_ACCESS_RIGHT = new AccessRight();
@ -19,6 +20,12 @@ public class XmlInstance implements Serializable {
UNKNOWN_ACCESS_RIGHT.setClassname(ModelConstants.UNKNOWN);
UNKNOWN_ACCESS_RIGHT.setSchemeid(ModelConstants.DNET_ACCESS_MODES);
UNKNOWN_ACCESS_RIGHT.setSchemename(ModelConstants.DNET_ACCESS_MODES);
UNKNOWN_REVIEW_LEVEL = new Qualifier();
UNKNOWN_REVIEW_LEVEL.setClassid("0000");
UNKNOWN_REVIEW_LEVEL.setClassname(ModelConstants.UNKNOWN);
UNKNOWN_ACCESS_RIGHT.setSchemeid(ModelConstants.DNET_REVIEW_LEVELS);
UNKNOWN_REVIEW_LEVEL.setSchemename(ModelConstants.DNET_REVIEW_LEVELS);
}
private String url;
@ -50,7 +57,7 @@ public class XmlInstance implements Serializable {
// typed results
private String processingchargecurrency;
private Set<Qualifier> refereed = Sets.newHashSet();; // peer-review status
private Qualifier refereed; // peer-review status
public String getUrl() {
return url;
@ -148,11 +155,11 @@ public class XmlInstance implements Serializable {
this.processingchargecurrency = processingchargecurrency;
}
public Set<Qualifier> getRefereed() {
public Qualifier getRefereed() {
return refereed;
}
public void setRefereed(Set<Qualifier> refereed) {
public void setRefereed(Qualifier refereed) {
this.refereed = refereed;
}
}

View File

@ -31,6 +31,7 @@ import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.json4s.Xml;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Joiner;
@ -1208,14 +1209,8 @@ public class XmlRecordFactory implements Serializable {
if (instance.getRefereed() != null) {
fields
.addAll(
instance
.getRefereed()
.stream()
.filter(Objects::nonNull)
.filter(r -> !r.isBlank())
.map(r -> XmlSerializationUtils.mapQualifier("refereed", r))
.collect(Collectors.toList()));
.add(
XmlSerializationUtils.mapQualifier("refereed", instance.getRefereed()));
}
if (instance.getProcessingchargeamount() != null
&& isNotBlank(instance.getProcessingchargeamount())) {
@ -1359,13 +1354,20 @@ public class XmlRecordFactory implements Serializable {
.map(Instance::getAccessright)
.min(new AccessRightComparator<AccessRight>())
.orElse(XmlInstance.UNKNOWN_ACCESS_RIGHT));
instance
.setRefereed(
instances
.stream()
.map(Pair::getValue)
.map(i -> Optional.ofNullable(i.getRefereed()).orElse(XmlInstance.UNKNOWN_REVIEW_LEVEL))
.min(new RefereedComparator())
.orElse(XmlInstance.UNKNOWN_REVIEW_LEVEL));
instances.forEach(p -> {
final Instance i = p.getRight();
instance.getCollectedfrom().add(i.getCollectedfrom());
instance.getHostedby().add(i.getHostedby());
instance.getInstancetype().add(i.getInstancetype());
instance.getRefereed().add(i.getRefereed());
instance
.setProcessingchargeamount(
Optional.ofNullable(i.getProcessingchargeamount()).map(apc -> apc.getValue()).orElse(null));

View File

@ -66,7 +66,7 @@ public class XmlRecordFactoryTest {
assertEquals("doi", doc.valueOf("//instance/alternateidentifier/@classid"));
assertEquals("10.5689/LIB.2018.2853550", doc.valueOf("//instance/alternateidentifier/text()"));
assertEquals(3, doc.selectNodes("//instance").size());
assertEquals(2, doc.selectNodes("//instance").size());
assertEquals("1721.47", doc.valueOf("//processingchargeamount/text()"));
assertEquals("EUR", doc.valueOf("//processingchargecurrency/text()"));

View File

@ -453,6 +453,12 @@
"schemeid": "dnet:dataCite_resource",
"schemename": "dnet:dataCite_resource"
},
"refereed": {
"classid": "0001",
"classname": "peerReviewed",
"schemeid": "dnet:review_levels",
"schemename": "dnet:review_levels"
},
"license": {
"dataInfo": {
"deletedbyinference": false,
@ -585,6 +591,12 @@
"schemeid": "dnet:dataCite_resource",
"schemename": "dnet:dataCite_resource"
},
"refereed": {
"classid": "0000",
"classname": "UNKNOWN",
"schemeid": "dnet:review_levels",
"schemename": "dnet:review_levels"
},
"license": {
"dataInfo": {
"deletedbyinference": false,
@ -717,6 +729,12 @@
"schemeid": "dnet:dataCite_resource",
"schemename": "dnet:dataCite_resource"
},
"refereed": {
"classid": "0002",
"classname": "nonPeerReviewed",
"schemeid": "dnet:review_levels",
"schemename": "dnet:review_levels"
},
"license": {
"dataInfo": {
"deletedbyinference": false,
@ -849,6 +867,12 @@
"schemeid": "dnet:dataCite_resource",
"schemename": "dnet:dataCite_resource"
},
"refereed": {
"classid": "0001",
"classname": "peerReviewed",
"schemeid": "dnet:review_levels",
"schemename": "dnet:review_levels"
},
"license": {
"dataInfo": {
"deletedbyinference": false,
@ -866,7 +890,7 @@
"value": ""
},
"url": [
"http://dx.doi.org/10.1109/TED.2018.2853552",
"http://dx.doi.org/10.1109/TED.2018.2853551",
"http://dx.doi.org/10.1109/TED.2018.2853554"
]
},

View File

@ -797,7 +797,7 @@
<mockito-core.version>3.3.3</mockito-core.version>
<mongodb.driver.version>3.4.2</mongodb.driver.version>
<vtd.version>[2.12,3.0)</vtd.version>
<dhp-schemas.version>[2.10.29]</dhp-schemas.version>
<dhp-schemas.version>[2.10.30]</dhp-schemas.version>
<dnet-actionmanager-api.version>[4.0.3]</dnet-actionmanager-api.version>
<dnet-actionmanager-common.version>[6.0.5]</dnet-actionmanager-common.version>
<dnet-openaire-broker-common.version>[3.1.6]</dnet-openaire-broker-common.version>