added field oafEntity.eoscifguidelines
This commit is contained in:
parent
ccf9f6ef34
commit
6facd0ec18
|
@ -0,0 +1,96 @@
|
|||
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 code
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* EOSC-IF label
|
||||
*/
|
||||
private String label;
|
||||
|
||||
/**
|
||||
* EOSC-IF url
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* EOSC-IF semantic relation
|
||||
*/
|
||||
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());
|
||||
}
|
||||
}
|
|
@ -21,6 +21,8 @@ public abstract class OafEntity extends Oaf implements Serializable {
|
|||
|
||||
private OAIProvenance oaiprovenance;
|
||||
|
||||
private List<EoscIfGuidelines> eoscifguidelines;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -77,6 +79,14 @@ public abstract class OafEntity extends Oaf implements Serializable {
|
|||
this.oaiprovenance = oaiprovenance;
|
||||
}
|
||||
|
||||
public List<EoscIfGuidelines> getEoscifguidelines() {
|
||||
return eoscifguidelines;
|
||||
}
|
||||
|
||||
public void setEoscifguidelines(List<EoscIfGuidelines> eoscifguidelines) {
|
||||
this.eoscifguidelines = eoscifguidelines;
|
||||
}
|
||||
|
||||
public void mergeFrom(OafEntity e) {
|
||||
super.mergeFrom(e);
|
||||
|
||||
|
@ -84,6 +94,8 @@ public abstract class OafEntity extends Oaf implements Serializable {
|
|||
|
||||
pid = mergeLists(pid, e.getPid());
|
||||
|
||||
eoscifguidelines = mergeLists(eoscifguidelines, e.getEoscifguidelines());
|
||||
|
||||
if (e.getDateofcollection() != null && compareTrust(this, e) < 0)
|
||||
dateofcollection = e.getDateofcollection();
|
||||
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue