2019-10-24 11:39:41 +02:00
|
|
|
package eu.dnetlib.dhp.schema.oaf;
|
|
|
|
|
2020-02-19 17:29:05 +01:00
|
|
|
import java.util.ArrayList;
|
2019-10-24 11:39:41 +02:00
|
|
|
import java.util.List;
|
2020-02-19 17:29:05 +01:00
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Stream;
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
import org.junit.Assert;
|
|
|
|
|
2019-10-25 18:10:30 +02:00
|
|
|
public class Relation extends Oaf {
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
private String relType;
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
private String subRelType;
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
private String relClass;
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
private String source;
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
private String target;
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
private List<KeyValue> collectedFrom = new ArrayList<>();
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public String getRelType() {
|
|
|
|
return relType;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public void setRelType(final String relType) {
|
|
|
|
this.relType = relType;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public String getSubRelType() {
|
|
|
|
return subRelType;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public void setSubRelType(final String subRelType) {
|
|
|
|
this.subRelType = subRelType;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public String getRelClass() {
|
|
|
|
return relClass;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public void setRelClass(final String relClass) {
|
|
|
|
this.relClass = relClass;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public String getSource() {
|
|
|
|
return source;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public void setSource(final String source) {
|
|
|
|
this.source = source;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public String getTarget() {
|
|
|
|
return target;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public void setTarget(final String target) {
|
|
|
|
this.target = target;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public List<KeyValue> getCollectedFrom() {
|
|
|
|
return collectedFrom;
|
|
|
|
}
|
2019-10-24 11:39:41 +02:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public void setCollectedFrom(final List<KeyValue> collectedFrom) {
|
|
|
|
this.collectedFrom = collectedFrom;
|
|
|
|
}
|
2020-02-19 17:29:05 +01:00
|
|
|
|
2020-02-20 11:43:32 +01:00
|
|
|
public void mergeFrom(final Relation r) {
|
|
|
|
Assert.assertEquals("source ids must be equal", getSource(), r.getSource());
|
|
|
|
Assert.assertEquals("target ids must be equal", getTarget(), r.getTarget());
|
|
|
|
Assert.assertEquals("relType(s) must be equal", getRelType(), r.getRelType());
|
|
|
|
Assert.assertEquals("subRelType(s) must be equal", getSubRelType(), r.getSubRelType());
|
|
|
|
Assert.assertEquals("relClass(es) must be equal", getRelClass(), r.getRelClass());
|
|
|
|
setCollectedFrom(Stream.concat(getCollectedFrom().stream(), r.getCollectedFrom().stream())
|
|
|
|
.distinct() // relies on KeyValue.equals
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
}
|
2020-02-19 17:29:05 +01:00
|
|
|
|
2019-10-24 11:39:41 +02:00
|
|
|
}
|