From 306669209fa58206635ab094f2f3ef28963b34f1 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Tue, 16 Jun 2020 16:54:44 +0200 Subject: [PATCH] code formatting --- .../eu/dnetlib/dhp/schema/oaf/Measure.java | 79 ++++++++++--------- .../eu/dnetlib/dhp/schema/oaf/Programme.java | 1 - .../eu/dnetlib/dhp/schema/oaf/Relation.java | 14 ++-- .../eu/dnetlib/dhp/schema/oaf/Result.java | 2 +- .../dnetlib/dhp/schema/oaf/MeasureTest.java | 67 +++++++++------- .../actionmanager/project/ProjectSubset.java | 15 ++-- .../project/SparkUpdateProjectTest.java | 1 - 7 files changed, 96 insertions(+), 83 deletions(-) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Measure.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Measure.java index c37e760618..c0c14d10de 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Measure.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Measure.java @@ -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 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 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 getUnit() { - return unit; - } + public List getUnit() { + return unit; + } - public void setUnit(List unit) { - this.unit = unit; - } + public void setUnit(List 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); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Programme.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Programme.java index c5259d07e5..00dc32fbca 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Programme.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Programme.java @@ -35,5 +35,4 @@ public class Programme implements Serializable { return Objects.equals(code, programme.code); } - } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java index d77bd7d733..17a50d7aca 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java @@ -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 properties = new ArrayList<>(); diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java index 44737d46eb..0dc76fd435 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java @@ -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()); diff --git a/dhp-schemas/src/test/java/eu/dnetlib/dhp/schema/oaf/MeasureTest.java b/dhp-schemas/src/test/java/eu/dnetlib/dhp/schema/oaf/MeasureTest.java index 4275e2c56e..26b4407c9b 100644 --- a/dhp-schemas/src/test/java/eu/dnetlib/dhp/schema/oaf/MeasureTest.java +++ b/dhp-schemas/src/test/java/eu/dnetlib/dhp/schema/oaf/MeasureTest.java @@ -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 m = Lists.newArrayList(popularity, influence); + List 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 mm = OBJECT_MAPPER.readValue(s, new TypeReference>() { }); + List mm = OBJECT_MAPPER.readValue(s, new TypeReference>() { + }); - 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; + } } diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/ProjectSubset.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/ProjectSubset.java index cfbb62f219..2fccbc5165 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/ProjectSubset.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/project/ProjectSubset.java @@ -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; + } } diff --git a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/SparkUpdateProjectTest.java b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/SparkUpdateProjectTest.java index 4d3ec140be..718cd8ebe0 100644 --- a/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/SparkUpdateProjectTest.java +++ b/dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/project/SparkUpdateProjectTest.java @@ -90,6 +90,5 @@ public class SparkUpdateProjectTest { Assertions.assertEquals(14, tmp.count()); - } }