From 7c5cd86927cd449b96bd131834658a094f5d52de Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Thu, 29 Apr 2021 09:29:19 +0200 Subject: [PATCH] annotations and tests --- .../ror/GenerateRorActionSetJob.java | 3 +- .../dhp/actionmanager/ror/model/Address.java | 22 ++++ .../dhp/actionmanager/ror/model/Country.java | 6 + .../ror/model/ExternalIdType.java | 6 + .../actionmanager/ror/model/ExternalIds.java | 12 ++ .../ror/model/GeonamesAdmin.java | 10 ++ .../actionmanager/ror/model/GeonamesCity.java | 18 +++ .../dhp/actionmanager/ror/model/GridType.java | 5 + .../dhp/actionmanager/ror/model/Label.java | 6 + .../dhp/actionmanager/ror/model/License.java | 6 + .../actionmanager/ror/model/NameAndCode.java | 6 + .../actionmanager/ror/model/Relationship.java | 8 ++ .../ror/model/RorOrganization.java | 34 +++++ .../ror/GenerateRorActionSetJobTest.java | 40 ++++++ .../dhp/actionmanager/ror/ror_org.json | 123 ++++++++++++++++++ 15 files changed, 304 insertions(+), 1 deletion(-) create mode 100644 dhp-workflows/dhp-aggregation/src/test/java/eu/dnetlib/dhp/actionmanager/ror/GenerateRorActionSetJobTest.java create mode 100644 dhp-workflows/dhp-aggregation/src/test/resources/eu/dnetlib/dhp/actionmanager/ror/ror_org.json diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/GenerateRorActionSetJob.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/GenerateRorActionSetJob.java index 81f0c55f8..78ce56f03 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/GenerateRorActionSetJob.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/GenerateRorActionSetJob.java @@ -114,7 +114,7 @@ public class GenerateRorActionSetJob { } - private static Organization convertRorOrg(final RorOrganization r) { + protected static Organization convertRorOrg(final RorOrganization r) { final Date now = new Date(); @@ -178,6 +178,7 @@ public class GenerateRorActionSetJob { final Set names = new LinkedHashSet<>(); names.addAll(r.getAliases()); names.addAll(r.getAcronyms()); + r.getLabels().forEach(l -> names.add(l.getLabel())); return names.stream().filter(StringUtils::isNotBlank).map(s -> field(s, ROR_DATA_INFO)).collect(Collectors.toList()); } diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Address.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Address.java index 68dc62e26..b566a5501 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Address.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Address.java @@ -3,18 +3,40 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class Address implements Serializable { + @JsonProperty("lat") private Float lat; + + @JsonProperty("state_code") private String stateCode; + + @JsonProperty("country_geonames_id") private Integer countryGeonamesId; + + @JsonProperty("lng") private Float lng; + + @JsonProperty("state") private String state; + + @JsonProperty("city") private String city; + + @JsonProperty("geonames_city") private GeonamesCity geonamesCity; + + @JsonProperty("postcode") private String postcode; + + @JsonProperty("primary") private Boolean primary; + + @JsonProperty("line") private String line; + private final static long serialVersionUID = 2444635485253443195L; public Float getLat() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Country.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Country.java index 08ca939f2..3dab60a9f 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Country.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Country.java @@ -3,10 +3,16 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class Country implements Serializable { + @JsonProperty("country_code") private String countryCode; + + @JsonProperty("country_name") private String countryName; + private final static long serialVersionUID = 4357848706229493627L; public String getCountryCode() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/ExternalIdType.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/ExternalIdType.java index 42406f097..f36c25ef0 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/ExternalIdType.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/ExternalIdType.java @@ -5,10 +5,16 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + public class ExternalIdType implements Serializable { + @JsonProperty("all") private List all = new ArrayList<>(); + + @JsonProperty("preferred") private String preferred; + private final static long serialVersionUID = 2616688352998387611L; public List getAll() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/ExternalIds.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/ExternalIds.java index 9ea1ccdb8..bbf92f6ab 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/ExternalIds.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/ExternalIds.java @@ -3,13 +3,25 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class ExternalIds implements Serializable { + @JsonProperty("Wikidata") private ExternalIdType wikidata; + + @JsonProperty("OrgRef") private ExternalIdType orgRef; + + @JsonProperty("ISNI") private ExternalIdType isni; + + @JsonProperty("FundRef") private ExternalIdType fundRef; + + @JsonProperty("GRID") private GridType grid; + private final static long serialVersionUID = 686536347353680869L; public ExternalIdType getWikidata() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GeonamesAdmin.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GeonamesAdmin.java index a446c092f..9616db447 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GeonamesAdmin.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GeonamesAdmin.java @@ -3,12 +3,22 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class GeonamesAdmin implements Serializable { + @JsonProperty("ascii_name") private String asciiName; + + @JsonProperty("id") private Integer id; + + @JsonProperty("name") private String name; + + @JsonProperty("code") private String code; + private final static long serialVersionUID = 7294958526269195673L; public String getAsciiName() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GeonamesCity.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GeonamesCity.java index 9c98bebd1..3fd539066 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GeonamesCity.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GeonamesCity.java @@ -3,16 +3,34 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class GeonamesCity implements Serializable { + @JsonProperty("geonames_admin1") private GeonamesAdmin geonamesAdmin1; + + @JsonProperty("geonames_admin2") private GeonamesAdmin geonamesAdmin2; + + @JsonProperty("city") private String city; + + @JsonProperty("id") private Integer id; + + @JsonProperty("nuts_level1") private NameAndCode nutsLevel1; + + @JsonProperty("nuts_level2") private NameAndCode nutsLevel2; + + @JsonProperty("nuts_level3") private NameAndCode nutsLevel3; + + @JsonProperty("") private License license; + private final static long serialVersionUID = -8389480201526252955L; public NameAndCode getNutsLevel2() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GridType.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GridType.java index 739ea22e0..4a7f7ca77 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GridType.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/GridType.java @@ -3,6 +3,8 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class GridType implements Serializable { /** @@ -10,7 +12,10 @@ public class GridType implements Serializable { */ private static final long serialVersionUID = -5605887658267581353L; + @JsonProperty("all") private String all; + + @JsonProperty("preferred") private String preferred; public String getAll() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Label.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Label.java index 39816da6b..61eb0339d 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Label.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Label.java @@ -3,10 +3,16 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class Label implements Serializable { + @JsonProperty("iso639") private String iso639; + + @JsonProperty("label") private String label; + private final static long serialVersionUID = -6576156103297850809L; public String getIso639() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/License.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/License.java index 1c07bbc2b..bdc8f4c42 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/License.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/License.java @@ -3,10 +3,16 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class License implements Serializable { + @JsonProperty("attribution") private String attribution; + + @JsonProperty("license") private String license; + private final static long serialVersionUID = -194308261058176439L; public String getAttribution() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/NameAndCode.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/NameAndCode.java index b2d728f7d..61d7eb8e6 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/NameAndCode.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/NameAndCode.java @@ -3,10 +3,16 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class NameAndCode implements Serializable { + @JsonProperty("name") private String name; + + @JsonProperty("code") private String code; + private final static long serialVersionUID = 5459836979206140843L; public String getName() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Relationship.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Relationship.java index 1d0e03f42..8b73db98f 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Relationship.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/Relationship.java @@ -3,11 +3,19 @@ package eu.dnetlib.dhp.actionmanager.ror.model; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; + public class Relationship implements Serializable { + @JsonProperty("type") private String type; + + @JsonProperty("id") private String id; + + @JsonProperty("label") private String label; + private final static long serialVersionUID = 7847399503395576960L; public String getType() { diff --git a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/RorOrganization.java b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/RorOrganization.java index fae8b3ead..7712ef4f2 100644 --- a/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/RorOrganization.java +++ b/dhp-workflows/dhp-aggregation/src/main/java/eu/dnetlib/dhp/actionmanager/ror/model/RorOrganization.java @@ -5,24 +5,58 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + public class RorOrganization implements Serializable { + @JsonProperty("ip_addresses") private List ipAddresses = new ArrayList<>(); + + @JsonProperty("aliases") private List aliases = new ArrayList<>(); + + @JsonProperty("acronyms") private List acronyms = new ArrayList<>(); + + @JsonProperty("links") private List links = new ArrayList<>(); + + @JsonProperty("country") private Country country; + + @JsonProperty("name") private String name; + + @JsonProperty("wikipedia_url") private String wikipediaUrl; + + @JsonProperty("addresses") private List
addresses = new ArrayList<>(); + + @JsonProperty("types") private List types = new ArrayList<>(); + + @JsonProperty("established") private Integer established; + + @JsonProperty("relationships") private List relationships = new ArrayList<>(); + + @JsonProperty("email_address") private String emailAddress; + + @JsonProperty("external_ids") private ExternalIds externalIds; + + @JsonProperty("id") private String id; + + @JsonProperty("labels") private List