forked from D-Net/dnet-hadoop
code formatting
This commit is contained in:
parent
1bc1d15eaf
commit
306669209f
|
@ -1,56 +1,59 @@
|
|||
|
||||
package eu.dnetlib.dhp.schema.oaf;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
|
||||
/**
|
||||
* Represent a measure, must be further described by a system available resource providing name and descriptions.
|
||||
*/
|
||||
public class Measure {
|
||||
|
||||
/**
|
||||
* Unique measure identifier.
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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 String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<KeyValue> getUnit() {
|
||||
return unit;
|
||||
}
|
||||
public List<KeyValue> getUnit() {
|
||||
return unit;
|
||||
}
|
||||
|
||||
public void setUnit(List<KeyValue> unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
public void setUnit(List<KeyValue> unit) {
|
||||
this.unit = unit;
|
||||
}
|
||||
|
||||
public void mergeFrom(Measure m) {
|
||||
//TODO
|
||||
}
|
||||
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 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);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(id, unit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,5 +35,4 @@ public class Programme implements Serializable {
|
|||
return Objects.equals(code, programme.code);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Relation models any edge between two nodes in the OpenAIRE graph. It has a source id and a target id
|
||||
* pointing to graph node identifiers and it is further characterised by the semantic of the link through the fields
|
||||
* relType, subRelType and relClass. Provenance information is modeled according to the dataInfo element and collectedFrom,
|
||||
* while individual relationship types can provide extra information via the properties field.
|
||||
* Relation models any edge between two nodes in the OpenAIRE graph. It has a source id and a target id pointing to
|
||||
* graph node identifiers and it is further characterised by the semantic of the link through the fields relType,
|
||||
* subRelType and relClass. Provenance information is modeled according to the dataInfo element and collectedFrom, while
|
||||
* individual relationship types can provide extra information via the properties field.
|
||||
*/
|
||||
public class Relation extends Oaf {
|
||||
|
||||
|
@ -26,7 +26,8 @@ public class Relation extends Oaf {
|
|||
private String subRelType;
|
||||
|
||||
/**
|
||||
* Indicates the direction of the relationship, values include 'isSupplementTo', 'isSupplementedBy', 'merges, 'isMergedIn'.
|
||||
* Indicates the direction of the relationship, values include 'isSupplementTo', 'isSupplementedBy', 'merges,
|
||||
* 'isMergedIn'.
|
||||
*/
|
||||
private String relClass;
|
||||
|
||||
|
@ -51,7 +52,8 @@ public class Relation extends Oaf {
|
|||
private String validationDate;
|
||||
|
||||
/**
|
||||
* List of relation specific properties. Values include 'similarityLevel', indicating the similarity score between a pair of publications.
|
||||
* List of relation specific properties. Values include 'similarityLevel', indicating the similarity score between a
|
||||
* pair of publications.
|
||||
*/
|
||||
private List<KeyValue> properties = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -241,7 +241,7 @@ public class Result extends OafEntity implements Serializable {
|
|||
|
||||
Result r = (Result) e;
|
||||
|
||||
//TODO consider merging also Measures
|
||||
// TODO consider merging also Measures
|
||||
|
||||
instance = mergeLists(instance, r.getInstance());
|
||||
|
||||
|
|
|
@ -1,48 +1,57 @@
|
|||
|
||||
package eu.dnetlib.dhp.schema.oaf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
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;
|
||||
import java.util.List;
|
||||
|
||||
public class MeasureTest {
|
||||
|
||||
public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
@Test
|
||||
public void testMeasureSerialization() throws IOException {
|
||||
@Test
|
||||
public void testMeasureSerialization() throws IOException {
|
||||
|
||||
Measure popularity = new Measure();
|
||||
popularity.setId("popularity");
|
||||
popularity.setUnit(Lists.newArrayList(
|
||||
unit("score", "0.5")));
|
||||
Measure popularity = new Measure();
|
||||
popularity.setId("popularity");
|
||||
popularity
|
||||
.setUnit(
|
||||
Lists
|
||||
.newArrayList(
|
||||
unit("score", "0.5")));
|
||||
|
||||
Measure influence = new Measure();
|
||||
influence.setId("influence");
|
||||
influence.setUnit(Lists.newArrayList(
|
||||
unit("score", "0.3")));
|
||||
Measure influence = new Measure();
|
||||
influence.setId("influence");
|
||||
influence
|
||||
.setUnit(
|
||||
Lists
|
||||
.newArrayList(
|
||||
unit("score", "0.3")));
|
||||
|
||||
List<Measure> m = Lists.newArrayList(popularity, influence);
|
||||
List<Measure> m = Lists.newArrayList(popularity, influence);
|
||||
|
||||
String s = OBJECT_MAPPER.writeValueAsString(m);
|
||||
System.out.println(s);
|
||||
String s = OBJECT_MAPPER.writeValueAsString(m);
|
||||
System.out.println(s);
|
||||
|
||||
List<Measure> mm = OBJECT_MAPPER.readValue(s, new TypeReference<List<Measure>>() { });
|
||||
List<Measure> mm = OBJECT_MAPPER.readValue(s, new TypeReference<List<Measure>>() {
|
||||
});
|
||||
|
||||
Assertions.assertNotNull(mm);
|
||||
}
|
||||
Assertions.assertNotNull(mm);
|
||||
}
|
||||
|
||||
private KeyValue unit(String key, String value) {
|
||||
KeyValue unit = new KeyValue();
|
||||
unit.setKey(key);
|
||||
unit.setValue(value);
|
||||
return unit;
|
||||
}
|
||||
private KeyValue unit(String key, String value) {
|
||||
KeyValue unit = new KeyValue();
|
||||
unit.setKey(key);
|
||||
unit.setValue(value);
|
||||
return unit;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
|
||||
package eu.dnetlib.dhp.actionmanager.project;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ProjectSubset implements Serializable {
|
||||
|
||||
private String code;
|
||||
private String code;
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,6 +90,5 @@ public class SparkUpdateProjectTest {
|
|||
|
||||
Assertions.assertEquals(14, tmp.count());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue