forked from antonis.lempesis/dnet-hadoop
this commit adds: validated/validationDate to relationships; measure type and simple unit test to indicate the relative serialization
This commit is contained in:
parent
24d8d097b6
commit
11938dac5e
|
@ -1,4 +1,56 @@
|
||||||
package eu.dnetlib.dhp.schema.oaf;
|
package eu.dnetlib.dhp.schema.oaf;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represent a measure, must be further described by a system available resource providing name and descriptions.
|
||||||
|
*/
|
||||||
public class Measure {
|
public class Measure {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unique measure identifier.
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of units associated with this measure. KeyValue provides a pair to store the laber (key) and the value,
|
||||||
|
* plus common provenance information.
|
||||||
|
*/
|
||||||
|
private List<KeyValue> unit;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<KeyValue> getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnit(List<KeyValue> unit) {
|
||||||
|
this.unit = unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mergeFrom(Measure m) {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
Measure measure = (Measure) o;
|
||||||
|
return Objects.equal(id, measure.id) &&
|
||||||
|
Objects.equal(unit, measure.unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(id, unit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,21 @@ public class Relation extends Oaf {
|
||||||
*/
|
*/
|
||||||
private String target;
|
private String target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Was this relationship authoritatively validated?
|
||||||
|
*/
|
||||||
|
private Boolean validated;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When was this relationship authoritatively validated.
|
||||||
|
*/
|
||||||
|
private String validationDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of relation specific properties. Values include 'similarityLevel', indicating the similarity score between a pair of publications.
|
||||||
|
*/
|
||||||
|
private List<KeyValue> properties = new ArrayList<>();
|
||||||
|
|
||||||
public String getRelType() {
|
public String getRelType() {
|
||||||
return relType;
|
return relType;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +95,30 @@ public class Relation extends Oaf {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<KeyValue> getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(List<KeyValue> properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getValidated() {
|
||||||
|
return validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidated(Boolean validated) {
|
||||||
|
this.validated = validated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValidationDate() {
|
||||||
|
return validationDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidationDate(String validationDate) {
|
||||||
|
this.validationDate = validationDate;
|
||||||
|
}
|
||||||
|
|
||||||
public void mergeFrom(final Relation r) {
|
public void mergeFrom(final Relation r) {
|
||||||
|
|
||||||
checkArgument(Objects.equals(getSource(), r.getSource()), "source ids must be equal");
|
checkArgument(Objects.equals(getSource(), r.getSource()), "source ids must be equal");
|
||||||
|
@ -122,4 +161,5 @@ public class Relation extends Oaf {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(relType, subRelType, relClass, source, target, collectedfrom);
|
return Objects.hash(relType, subRelType, relClass, source, target, collectedfrom);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class Result extends OafEntity implements Serializable {
|
public class Result extends OafEntity implements Serializable {
|
||||||
|
|
||||||
|
private List<Measure> measures;
|
||||||
|
|
||||||
private List<Author> author;
|
private List<Author> author;
|
||||||
|
|
||||||
// resulttype allows subclassing results into publications | datasets | software
|
// resulttype allows subclassing results into publications | datasets | software
|
||||||
|
@ -51,6 +53,14 @@ public class Result extends OafEntity implements Serializable {
|
||||||
|
|
||||||
private List<Instance> instance;
|
private List<Instance> instance;
|
||||||
|
|
||||||
|
public List<Measure> getMeasures() {
|
||||||
|
return measures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMeasures(List<Measure> measures) {
|
||||||
|
this.measures = measures;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Author> getAuthor() {
|
public List<Author> getAuthor() {
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
@ -229,6 +239,8 @@ public class Result extends OafEntity implements Serializable {
|
||||||
|
|
||||||
Result r = (Result) e;
|
Result r = (Result) e;
|
||||||
|
|
||||||
|
//TODO consider merging also Measures
|
||||||
|
|
||||||
instance = mergeLists(instance, r.getInstance());
|
instance = mergeLists(instance, r.getInstance());
|
||||||
|
|
||||||
if (r.getBestaccessright() != null && compareTrust(this, r) < 0)
|
if (r.getBestaccessright() != null && compareTrust(this, r) < 0)
|
||||||
|
|
|
@ -1,4 +1,41 @@
|
||||||
package eu.dnetlib.dhp.schema.oaf;
|
package eu.dnetlib.dhp.schema.oaf;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class MeasureTest {
|
public class MeasureTest {
|
||||||
|
|
||||||
|
public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
|
||||||
|
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMeasureSerialization() throws IOException {
|
||||||
|
|
||||||
|
Measure m = new Measure();
|
||||||
|
|
||||||
|
m.setId("popularity");
|
||||||
|
m.setUnit(Lists.newArrayList(
|
||||||
|
unit("score", "0.5")));
|
||||||
|
|
||||||
|
String s = OBJECT_MAPPER.writeValueAsString(m);
|
||||||
|
System.out.println(s);
|
||||||
|
|
||||||
|
Measure mm = OBJECT_MAPPER.readValue(s, Measure.class);
|
||||||
|
|
||||||
|
Assertions.assertNotNull(mm);
|
||||||
|
}
|
||||||
|
|
||||||
|
private KeyValue unit(String key, String value) {
|
||||||
|
KeyValue unit = new KeyValue();
|
||||||
|
unit.setKey(key);
|
||||||
|
unit.setValue(value);
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue