forked from D-Net/dnet-hadoop
annotations and tests
This commit is contained in:
parent
b5cf505cc6
commit
7c5cd86927
|
@ -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<String> 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());
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<String> all = new ArrayList<>();
|
||||
|
||||
@JsonProperty("preferred")
|
||||
private String preferred;
|
||||
|
||||
private final static long serialVersionUID = 2616688352998387611L;
|
||||
|
||||
public List<String> getAll() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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<String> ipAddresses = new ArrayList<>();
|
||||
|
||||
@JsonProperty("aliases")
|
||||
private List<String> aliases = new ArrayList<>();
|
||||
|
||||
@JsonProperty("acronyms")
|
||||
private List<String> acronyms = new ArrayList<>();
|
||||
|
||||
@JsonProperty("links")
|
||||
private List<String> links = new ArrayList<>();
|
||||
|
||||
@JsonProperty("country")
|
||||
private Country country;
|
||||
|
||||
@JsonProperty("name")
|
||||
private String name;
|
||||
|
||||
@JsonProperty("wikipedia_url")
|
||||
private String wikipediaUrl;
|
||||
|
||||
@JsonProperty("addresses")
|
||||
private List<Address> addresses = new ArrayList<>();
|
||||
|
||||
@JsonProperty("types")
|
||||
private List<String> types = new ArrayList<>();
|
||||
|
||||
@JsonProperty("established")
|
||||
private Integer established;
|
||||
|
||||
@JsonProperty("relationships")
|
||||
private List<Relationship> relationships = new ArrayList<>();
|
||||
|
||||
@JsonProperty("email_address")
|
||||
private String emailAddress;
|
||||
|
||||
@JsonProperty("external_ids")
|
||||
private ExternalIds externalIds;
|
||||
|
||||
@JsonProperty("id")
|
||||
private String id;
|
||||
|
||||
@JsonProperty("labels")
|
||||
private List<Label> labels = new ArrayList<>();
|
||||
|
||||
@JsonProperty("status")
|
||||
private String status;
|
||||
|
||||
private final static long serialVersionUID = -2658312087616043225L;
|
||||
|
||||
public List<String> getIpAddresses() {
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package eu.dnetlib.dhp.actionmanager.ror;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import eu.dnetlib.dhp.actionmanager.ror.model.RorOrganization;
|
||||
import eu.dnetlib.dhp.schema.oaf.Organization;
|
||||
|
||||
class GenerateRorActionSetJobTest {
|
||||
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
private static final String local_file_path = "/Users/michele/Downloads/ror-data-2021-04-06.json";
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {}
|
||||
|
||||
@Test
|
||||
void testConvertRorOrg() throws Exception {
|
||||
final RorOrganization r = mapper.readValue(IOUtils.toString(getClass().getResourceAsStream("ror_org.json")), RorOrganization.class);
|
||||
final Organization org = GenerateRorActionSetJob.convertRorOrg(r);
|
||||
|
||||
System.out.println(mapper.writeValueAsString(org));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConvertAllRorOrg() throws Exception {
|
||||
final RorOrganization[] arr = mapper.readValue(IOUtils.toString(new FileInputStream(local_file_path)), RorOrganization[].class);
|
||||
|
||||
for (final RorOrganization r : arr) {
|
||||
GenerateRorActionSetJob.convertRorOrg(r);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
{
|
||||
"ip_addresses": [],
|
||||
"aliases": [],
|
||||
"acronyms": [
|
||||
"ANU"
|
||||
],
|
||||
"links": [
|
||||
"http://www.anu.edu.au/"
|
||||
],
|
||||
"country": {
|
||||
"country_code": "AU",
|
||||
"country_name": "Australia"
|
||||
},
|
||||
"name": "Australian National University",
|
||||
"wikipedia_url": "http://en.wikipedia.org/wiki/Australian_National_University",
|
||||
"addresses": [
|
||||
{
|
||||
"lat": -35.2778,
|
||||
"state_code": "AU-ACT",
|
||||
"country_geonames_id": 2077456,
|
||||
"lng": 149.1205,
|
||||
"state": "Australian Capital Territory",
|
||||
"city": "Canberra",
|
||||
"geonames_city": {
|
||||
"nuts_level2": {
|
||||
"name": null,
|
||||
"code": null
|
||||
},
|
||||
"geonames_admin2": {
|
||||
"ascii_name": null,
|
||||
"id": null,
|
||||
"name": null,
|
||||
"code": null
|
||||
},
|
||||
"geonames_admin1": {
|
||||
"ascii_name": "ACT",
|
||||
"id": 2177478,
|
||||
"name": "ACT",
|
||||
"code": "AU.01"
|
||||
},
|
||||
"city": "Canberra",
|
||||
"id": 2172517,
|
||||
"nuts_level1": {
|
||||
"name": null,
|
||||
"code": null
|
||||
},
|
||||
"nuts_level3": {
|
||||
"name": null,
|
||||
"code": null
|
||||
},
|
||||
"license": {
|
||||
"attribution": "Data from geonames.org under a CC-BY 3.0 license",
|
||||
"license": "http://creativecommons.org/licenses/by/3.0/"
|
||||
}
|
||||
},
|
||||
"postcode": null,
|
||||
"primary": false,
|
||||
"line": null
|
||||
}
|
||||
],
|
||||
"types": [
|
||||
"Education"
|
||||
],
|
||||
"established": 1946,
|
||||
"relationships": [
|
||||
{
|
||||
"type": "Related",
|
||||
"id": "https://ror.org/041c7s516",
|
||||
"label": "Calvary Hospital"
|
||||
},
|
||||
{
|
||||
"type": "Related",
|
||||
"id": "https://ror.org/04h7nbn38",
|
||||
"label": "Canberra Hospital"
|
||||
},
|
||||
{
|
||||
"type": "Related",
|
||||
"id": "https://ror.org/030jpqj15",
|
||||
"label": "Goulburn Base Hospital"
|
||||
},
|
||||
{
|
||||
"type": "Child",
|
||||
"id": "https://ror.org/006a4jj40",
|
||||
"label": "Mount Stromlo Observatory"
|
||||
}
|
||||
],
|
||||
"email_address": null,
|
||||
"external_ids": {
|
||||
"Wikidata": {
|
||||
"all": [
|
||||
"Q127990"
|
||||
],
|
||||
"preferred": null
|
||||
},
|
||||
"OrgRef": {
|
||||
"all": [
|
||||
"285106"
|
||||
],
|
||||
"preferred": null
|
||||
},
|
||||
"ISNI": {
|
||||
"all": [
|
||||
"0000 0001 2180 7477"
|
||||
],
|
||||
"preferred": null
|
||||
},
|
||||
"FundRef": {
|
||||
"all": [
|
||||
"501100000995",
|
||||
"501100001151",
|
||||
"100009020"
|
||||
],
|
||||
"preferred": "501100000995"
|
||||
},
|
||||
"GRID": {
|
||||
"all": "grid.1001.0",
|
||||
"preferred": "grid.1001.0"
|
||||
}
|
||||
},
|
||||
"id": "https://ror.org/019wvm592",
|
||||
"labels": [],
|
||||
"status": "active"
|
||||
}
|
Loading…
Reference in New Issue