1
0
Fork 0

code formatting

This commit is contained in:
Claudio Atzori 2020-06-16 16:54:44 +02:00
parent 1bc1d15eaf
commit 306669209f
7 changed files with 96 additions and 83 deletions

View File

@ -1,56 +1,59 @@
package eu.dnetlib.dhp.schema.oaf; package eu.dnetlib.dhp.schema.oaf;
import com.google.common.base.Objects;
import java.util.List; 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. * 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. * Unique measure identifier.
*/ */
private String id; private String id;
/** /**
* List of units associated with this measure. KeyValue provides a pair to store the laber (key) and the value, * List of units associated with this measure. KeyValue provides a pair to store the laber (key) and the value, plus
* plus common provenance information. * common provenance information.
*/ */
private List<KeyValue> unit; private List<KeyValue> unit;
public String getId() { public String getId() {
return id; return id;
} }
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
public List<KeyValue> getUnit() { public List<KeyValue> getUnit() {
return unit; return unit;
} }
public void setUnit(List<KeyValue> unit) { public void setUnit(List<KeyValue> unit) {
this.unit = unit; this.unit = unit;
} }
public void mergeFrom(Measure m) { public void mergeFrom(Measure m) {
//TODO // TODO
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o)
if (o == null || getClass() != o.getClass()) return false; return true;
Measure measure = (Measure) o; if (o == null || getClass() != o.getClass())
return Objects.equal(id, measure.id) && return false;
Objects.equal(unit, measure.unit); Measure measure = (Measure) o;
} return Objects.equal(id, measure.id) &&
Objects.equal(unit, measure.unit);
}
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(id, unit); return Objects.hashCode(id, unit);
} }
} }

View File

@ -35,5 +35,4 @@ public class Programme implements Serializable {
return Objects.equals(code, programme.code); return Objects.equals(code, programme.code);
} }
} }

View File

@ -8,10 +8,10 @@ import java.util.stream.Collectors;
import java.util.stream.Stream; 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 * Relation models any edge between two nodes in the OpenAIRE graph. It has a source id and a target id pointing to
* pointing to graph node identifiers and it is further characterised by the semantic of the link through the fields * graph node identifiers and it is further characterised by the semantic of the link through the fields relType,
* relType, subRelType and relClass. Provenance information is modeled according to the dataInfo element and collectedFrom, * subRelType and relClass. Provenance information is modeled according to the dataInfo element and collectedFrom, while
* while individual relationship types can provide extra information via the properties field. * individual relationship types can provide extra information via the properties field.
*/ */
public class Relation extends Oaf { public class Relation extends Oaf {
@ -26,7 +26,8 @@ public class Relation extends Oaf {
private String subRelType; 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; private String relClass;
@ -51,7 +52,8 @@ public class Relation extends Oaf {
private String validationDate; 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<>(); private List<KeyValue> properties = new ArrayList<>();

View File

@ -241,7 +241,7 @@ public class Result extends OafEntity implements Serializable {
Result r = (Result) e; Result r = (Result) e;
//TODO consider merging also Measures // TODO consider merging also Measures
instance = mergeLists(instance, r.getInstance()); instance = mergeLists(instance, r.getInstance());

View File

@ -1,48 +1,57 @@
package eu.dnetlib.dhp.schema.oaf; 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.annotation.JsonInclude;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists; 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 class MeasureTest {
public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
.setSerializationInclusion(JsonInclude.Include.NON_NULL); .setSerializationInclusion(JsonInclude.Include.NON_NULL);
@Test @Test
public void testMeasureSerialization() throws IOException { public void testMeasureSerialization() throws IOException {
Measure popularity = new Measure(); Measure popularity = new Measure();
popularity.setId("popularity"); popularity.setId("popularity");
popularity.setUnit(Lists.newArrayList( popularity
unit("score", "0.5"))); .setUnit(
Lists
.newArrayList(
unit("score", "0.5")));
Measure influence = new Measure(); Measure influence = new Measure();
influence.setId("influence"); influence.setId("influence");
influence.setUnit(Lists.newArrayList( influence
unit("score", "0.3"))); .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); String s = OBJECT_MAPPER.writeValueAsString(m);
System.out.println(s); 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) { private KeyValue unit(String key, String value) {
KeyValue unit = new KeyValue(); KeyValue unit = new KeyValue();
unit.setKey(key); unit.setKey(key);
unit.setValue(value); unit.setValue(value);
return unit; return unit;
} }
} }

View File

@ -1,16 +1,17 @@
package eu.dnetlib.dhp.actionmanager.project; package eu.dnetlib.dhp.actionmanager.project;
import java.io.Serializable; import java.io.Serializable;
public class ProjectSubset implements Serializable { public class ProjectSubset implements Serializable {
private String code; private String code;
public String getCode() { public String getCode() {
return code; return code;
} }
public void setCode(String code) { public void setCode(String code) {
this.code = code; this.code = code;
} }
} }

View File

@ -90,6 +90,5 @@ public class SparkUpdateProjectTest {
Assertions.assertEquals(14, tmp.count()); Assertions.assertEquals(14, tmp.count());
} }
} }