Merge pull request 'added field oafEntity.eoscifguidelines' (#17) from eoscifguidelines into master

Reviewed-on: #17
This commit is contained in:
Claudio Atzori 2022-07-13 11:18:29 +02:00
commit 5dc3270908
4 changed files with 180 additions and 0 deletions

View File

@ -137,6 +137,11 @@ public class Datasource extends OafEntity implements Serializable {
private String lastconsenttermsofusedate;
/**
* EOSC Interoperability Framework Guidelines
*/
private List<EoscIfGuidelines> eoscifguidelines;
public Qualifier getDatasourcetype() {
return datasourcetype;
}
@ -553,6 +558,14 @@ public class Datasource extends OafEntity implements Serializable {
this.consenttermsofusedate = consenttermsofusedate;
}
public List<EoscIfGuidelines> getEoscifguidelines() {
return eoscifguidelines;
}
public void setEoscifguidelines(List<EoscIfGuidelines> eoscifguidelines) {
this.eoscifguidelines = eoscifguidelines;
}
@Override
public void mergeFrom(final OafEntity e) {
super.mergeFrom(e);

View File

@ -0,0 +1,97 @@
package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
/**
* Describes a reference to the EOSC Interoperability Framework (IF) Guidelines
*/
public class EoscIfGuidelines implements Serializable {
/**
* EOSC-IF local code. Later on it could be populated with a PID (e.g. DOI), but for the time being we stick to
* a more loose definition.
*/
private String code;
/**
* EOSC-IF label
*/
private String label;
/**
* EOSC-IF url
*/
private String url;
/**
* EOSC-IF semantic relation (e.g. compliesWith). Values shall be controlled by a dedicated vocabulary.
*/
private String semanticRelation;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getSemanticRelation() {
return semanticRelation;
}
public void setSemanticRelation(String semanticRelation) {
this.semanticRelation = semanticRelation;
}
private String toComparableString() {
return Stream
.of(
Optional.ofNullable(getCode()).orElse(""),
Optional.ofNullable(getLabel()).orElse(""),
Optional.ofNullable(getUrl()).orElse(""),
Optional.ofNullable(getSemanticRelation()).orElse(""))
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining("||"));
}
@Override
public int hashCode() {
return toComparableString().hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EoscIfGuidelines other = (EoscIfGuidelines) obj;
return toComparableString().equals(other.toComparableString());
}
}

View File

@ -142,6 +142,11 @@ public class Result extends OafEntity implements Serializable {
*/
private List<Instance> instance;
/**
* EOSC Interoperability Framework Guidelines
*/
private List<EoscIfGuidelines> eoscifguidelines;
/**
* Gets measures.
*
@ -554,6 +559,13 @@ public class Result extends OafEntity implements Serializable {
this.instance = instance;
}
public List<EoscIfGuidelines> getEoscifguidelines() {
return eoscifguidelines;
}
public void setEoscifguidelines(List<EoscIfGuidelines> eoscifguidelines) {
this.eoscifguidelines = eoscifguidelines;
}
/**
* Is an enrichment boolean.
@ -749,6 +761,8 @@ public class Result extends OafEntity implements Serializable {
measures = mergeLists(measures, r.getMeasures());
eoscifguidelines = mergeLists(eoscifguidelines, r.getEoscifguidelines());
if( !isAnEnrichment(this) && !isAnEnrichment(e))
instance = mergeLists(instance, r.getInstance());
else {

View File

@ -17,6 +17,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
/**
* The type Merge test.
@ -451,6 +452,61 @@ class MergeTest {
assertEquals(3, a.getSubject().size());
}
/**
* Merge publication EoscIfGuidelines test.
*/
@Test
void mergePublicationEoscIfGuidelinesTest() {
Publication a = publication();
Publication b = publication();
a.setEoscifguidelines(Lists.newArrayList(eoscifg("a", "label a", "https://aaa.aa", "semRelA")));
b.setEoscifguidelines(Lists.newArrayList(eoscifg("a", "label a", "https://aaa.aa", "semRelA")));
a.mergeFrom(b);
assertNotNull(a.getEoscifguidelines());
assertEquals(1, a.getEoscifguidelines().size());
a.getEoscifguidelines().clear();
b.getEoscifguidelines().clear();
a.setEoscifguidelines(Lists.newArrayList(eoscifg("a", "label a", "https://aaa.aa", "semRelA")));
b.setEoscifguidelines(Lists.newArrayList(eoscifg("a", "label a", "https://aaa.aa", "semRelA")));
b.mergeFrom(a);
assertNotNull(a.getEoscifguidelines());
assertEquals(1, a.getEoscifguidelines().size());
EoscIfGuidelines e = b.getEoscifguidelines().get(0);
assertEquals("a", e.getCode());
assertEquals("label a", e.getLabel());
assertEquals("https://aaa.aa", e.getUrl());
assertEquals("semRelA", e.getSemanticRelation());
a.getEoscifguidelines().clear();
b.getEoscifguidelines().clear();
a.setEoscifguidelines(Lists.newArrayList(eoscifg("a", "label a", "https://aaa.aa", "semRelA")));
b.setEoscifguidelines(Lists.newArrayList(eoscifg("b", "label b", "https://bbb.bb", "semRelB")));
a.mergeFrom(b);
assertNotNull(a.getEoscifguidelines());
assertEquals(2, a.getEoscifguidelines().size());
}
private EoscIfGuidelines eoscifg(String code, String label, String url, String semrel) {
EoscIfGuidelines e = new EoscIfGuidelines();
e.setCode(code);
e.setLabel(label);
e.setUrl(url);
e.setSemanticRelation(semrel);
return e;
}
/**
* Merge relation test.
*/