Skip to content

Commit

Permalink
Updated ROR Loader to use V2 of the ROR schema, the additional fields…
Browse files Browse the repository at this point in the history
… not stored yet
  • Loading branch information
Camelia-Orcid committed May 10, 2024
1 parent f57f9c6 commit 00bc0d3
Show file tree
Hide file tree
Showing 7 changed files with 1,178 additions and 513 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void execute_Stats_Test_1() throws URISyntaxException {
assertNotEquals(OrganizationStatus.DEPRECATED.name(), persisted.getStatus());
assertNotEquals(OrganizationStatus.OBSOLETE.name(), persisted.getStatus());

verify(orgDisambiguatedManager, times(5)).createOrgDisambiguatedExternalIdentifier(any(OrgDisambiguatedExternalIdentifierEntity.class));
verify(orgDisambiguatedManager, times(4)).createOrgDisambiguatedExternalIdentifier(any(OrgDisambiguatedExternalIdentifierEntity.class));
verify(orgDisambiguatedManager, never()).updateOrgDisambiguated(any(OrgDisambiguatedEntity.class));
verify(orgDisambiguatedExternalIdentifierDao, never()).merge(any(OrgDisambiguatedExternalIdentifierEntity.class));
}
Expand All @@ -149,7 +149,7 @@ public void execute_Stats_Test_2() throws URISyntaxException {
assertNotEquals(OrganizationStatus.OBSOLETE.name(), persisted.getStatus());
}

verify(orgDisambiguatedManager, times(27)).createOrgDisambiguatedExternalIdentifier(any(OrgDisambiguatedExternalIdentifierEntity.class));
verify(orgDisambiguatedManager, times(24)).createOrgDisambiguatedExternalIdentifier(any(OrgDisambiguatedExternalIdentifierEntity.class));
verify(orgDisambiguatedManager, never()).updateOrgDisambiguated(any(OrgDisambiguatedEntity.class));
verify(orgDisambiguatedExternalIdentifierDao, never()).merge(any(OrgDisambiguatedExternalIdentifierEntity.class));
}
Expand Down Expand Up @@ -238,10 +238,9 @@ public OrgDisambiguatedEntity answer(InvocationOnMock invocation) throws Throwab
entity.setId(1L);
entity.setName("org_1");
entity.setSourceId("ror.1");
entity.setCity("City One");
entity.setCountry(Iso3166Country.US.name());
entity.setCity("Adelaide");
entity.setCountry(Iso3166Country.AU.name());
entity.setOrgType("type_1");
entity.setRegion("Alabama");
entity.setSourceType(OrgDisambiguatedSourceType.ROR.name());
entity.setStatus("active");
entity.setUrl("http://link1.com");
Expand All @@ -256,8 +255,7 @@ public OrgDisambiguatedEntity answer(InvocationOnMock invocation) throws Throwab
when(orgDisambiguatedExternalIdentifierDao.findByDetails(1L, "FUNDREF1", OrgDisambiguatedSourceType.FUNDREF.name())).thenReturn(extIdPreferred);
when(orgDisambiguatedExternalIdentifierDao.findByDetails(1L, "ORGREF1", "ORGREF")).thenReturn(extId);
when(orgDisambiguatedExternalIdentifierDao.findByDetails(1L, "WIKIDATA1", "WIKIDATA")).thenReturn(extId);
when(orgDisambiguatedExternalIdentifierDao.findByDetails(1L, "http://en.wikipedia.org/wiki/org_1", "WIKIPEDIA_URL")).thenReturn(extId);


Path path = Paths.get(getClass().getClassLoader().getResource("ror/ror_1_org_updated_5_external_identifiers.json").toURI());
File testFile = path.toFile();
ReflectionTestUtils.setField(rorOrgLoadSource, "localDataPath", testFile.getAbsolutePath());
Expand All @@ -275,11 +273,9 @@ public OrgDisambiguatedEntity answer(InvocationOnMock invocation) throws Throwab
assertNotEquals(OrganizationStatus.OBSOLETE.name(), orgToBeUpdated.getStatus());
assertEquals(Iso3166Country.AU.name(), orgToBeUpdated.getCountry());
assertEquals(Long.valueOf(1), orgToBeUpdated.getId());
assertEquals("City One Updated", orgToBeUpdated.getCity());
assertEquals("Adelaide Updated", orgToBeUpdated.getCity());
assertEquals(IndexingStatus.PENDING, orgToBeUpdated.getIndexingStatus());
assertEquals("org_1_updated", orgToBeUpdated.getName());
assertEquals("type_1,type_2", orgToBeUpdated.getOrgType());
assertEquals("San Jose", orgToBeUpdated.getRegion());
assertEquals("ror.1", orgToBeUpdated.getSourceId());
assertEquals(OrgDisambiguatedSourceType.ROR.name(), orgToBeUpdated.getSourceType());
assertEquals("active", orgToBeUpdated.getStatus());
Expand Down Expand Up @@ -439,56 +435,6 @@ public void execute_DeprecatedObsoleteInstitutes_2_Test() throws URISyntaxExcept
assertEquals(2, obsoleteCount);
}

@Test
public void execute_AddMissingWikipediaExtId_Test() throws URISyntaxException {
when(orgDisambiguatedDao.findBySourceIdAndSourceType("ror.1", OrgDisambiguatedSourceType.ROR.name())).thenAnswer(new Answer<OrgDisambiguatedEntity>() {
@Override
public OrgDisambiguatedEntity answer(InvocationOnMock invocation) throws Throwable {
OrgDisambiguatedEntity entity = new OrgDisambiguatedEntity();
entity.setId(1L);
entity.setName("org_1");
entity.setSourceId("ror.1");
entity.setCity("City One");
entity.setCountry(Iso3166Country.US.name());
entity.setOrgType("type_1");
entity.setRegion("Alabama");
entity.setSourceType(OrgDisambiguatedSourceType.ROR.name());
entity.setStatus("active");
entity.setUrl("http://link1.com");
return entity;
}
});
OrgDisambiguatedExternalIdentifierEntity extId = new OrgDisambiguatedExternalIdentifierEntity();
extId.setPreferred(false);

OrgDisambiguatedExternalIdentifierEntity extIdPreferred = new OrgDisambiguatedExternalIdentifierEntity();
extIdPreferred.setPreferred(true);

when(orgDisambiguatedExternalIdentifierDao.findByDetails(1L, "ISNI1", "ISNI")).thenReturn(extId);
when(orgDisambiguatedExternalIdentifierDao.findByDetails(1L, "FUNDREF1", OrgDisambiguatedSourceType.FUNDREF.name())).thenReturn(extIdPreferred);
when(orgDisambiguatedExternalIdentifierDao.findByDetails(1L, "ORGREF1", "ORGREF")).thenReturn(extId);
when(orgDisambiguatedExternalIdentifierDao.findByDetails(1L, "WIKIDATA1", "WIKIDATA")).thenReturn(extId);

Path path = Paths.get(getClass().getClassLoader().getResource("ror/ror_1_org_5_external_identifiers.json").toURI());
File testFile = path.toFile();
ReflectionTestUtils.setField(rorOrgLoadSource, "localDataPath", testFile.getAbsolutePath());
rorOrgLoadSource.loadOrgData();

verify(orgDisambiguatedDao, never()).persist(Mockito.any(OrgDisambiguatedEntity.class));
verify(orgDisambiguatedManager, times(1)).createOrgDisambiguatedExternalIdentifier(any(OrgDisambiguatedExternalIdentifierEntity.class));
verify(orgDisambiguatedDao, never()).merge(any(OrgDisambiguatedEntity.class));
verify(orgDisambiguatedExternalIdentifierDao, never()).merge(any(OrgDisambiguatedExternalIdentifierEntity.class));

ArgumentCaptor<OrgDisambiguatedExternalIdentifierEntity> captor = ArgumentCaptor.forClass(OrgDisambiguatedExternalIdentifierEntity.class);

verify(orgDisambiguatedManager).createOrgDisambiguatedExternalIdentifier(captor.capture());

OrgDisambiguatedExternalIdentifierEntity orgToBeUpdated = captor.getValue();
assertEquals("http://en.wikipedia.org/wiki/org_1", orgToBeUpdated.getIdentifier());
assertEquals("WIKIPEDIA_URL", orgToBeUpdated.getIdentifierType());
assertEquals(Boolean.TRUE, orgToBeUpdated.getPreferred());
}

@Test
public void execute_UpdatePreferredIndicator_Test() throws URISyntaxException {
when(orgDisambiguatedDao.findBySourceIdAndSourceType("ror.1", OrgDisambiguatedSourceType.ROR.name())).thenAnswer(new Answer<OrgDisambiguatedEntity>() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,71 @@

[
{ "name": "org_1","country": {"country_code": "AU", "country_name": "Australia" },"wikipedia_url": null, "email_address": null, "links": ["http://link1.com"], "aliases": ["alias 1"], "acronyms": ["ACR_1"], "types": ["type_1"], "ip_addresses": [], "addresses": [{ "line_1": "", "line_2": "", "line_3": null, "lat": 0, "lng": 0, "postcode": "", "primary": false, "city": "City One", "state": "Alabama", "state_code": "AL", "country": "United States", "country_code": "US", "geonames_city": { "id": 2172517, "city": "Canberra", "nuts_level1": null, "nuts_level2": null, "nuts_level3": null, "geonames_admin1": { "name": "ACT", "ascii_name": "ACT", "code": "AU.01" }, "geonames_admin2": null, "license": { "attribution": "Data from geonames.org under a CC-BY 3.0 license", "license": "http://creativecommons.org/licenses/by/3.0/" } } }], "labels": [], "id": "ror.1", "status": "active", "established": 1946, "relationships": [{ "type": "Related", "label": "Calvary Hospital", "id": "grid.460694.9" }, { "type": "Related", "label": "Canberra Hospital", "id": "grid.413314.0" }, { "type": "Related", "label": "Goulburn Base Hospital", "id": "grid.460721.6" }], "external_ids": { "Wikidata": { "preferred": "WIKIDATA2", "all": ["WIKIDATA1", "WIKIDATA2"] } }, "weight": 1 }
]
[
{
"names":[
{
"value":"org_1",
"types":[
"ror_display",
"label"
],
"lang":null
}
],
"locations": [
{
"geonames_id": 2078025,
"geonames_details": {
"country_code": "AU",
"country_name": "Australia",
"lat": -35.024038,
"lng": 138.572615,
"name": "Adelaide"
}
}
],
"email_address": null,
"links": [
"http://link1.com"
],
"aliases": [
"alias 1"
],
"acronyms": [
"ACR_1"
],
"types": [
"type_1"
],
"ip_addresses": [],
"labels": [],
"id": "ror.1",
"status": "active",
"established": 1946,
"relationships": [
{
"type": "Related",
"label": "Calvary Hospital",
"id": "grid.460694.9"
},
{
"type": "Related",
"label": "Canberra Hospital",
"id": "grid.413314.0"
},
{
"type": "Related",
"label": "Goulburn Base Hospital",
"id": "grid.460721.6"
}
],
"external_ids": [
{
"type": "Wikidata",
"preferred": "WIKIDATA2",
"all": [
"WIKIDATA1",
"WIKIDATA2"
]
}
]
}
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,95 @@
[
{ "name": "org_1", "country": {"country_code": "AU", "country_name": "Australia" },"wikipedia_url": "http://en.wikipedia.org/wiki/org_1", "email_address": null, "links": ["http://link1.com"], "aliases": ["alias 1"], "acronyms": ["ACR_1"], "types": ["type_1"], "ip_addresses": [], "addresses": [{ "line_1": "", "line_2": "", "line_3": null, "lat": 0, "lng": 0, "postcode": "", "primary": false, "city": "City One", "state": "Alabama", "state_code": "AL", "country": "United States", "country_code": "US", "geonames_city": { "id": 2172517, "city": "Canberra", "nuts_level1": null, "nuts_level2": null, "nuts_level3": null, "geonames_admin1": { "name": "ACT", "ascii_name": "ACT", "code": "AU.01" }, "geonames_admin2": null, "license": { "attribution": "Data from geonames.org under a CC-BY 3.0 license", "license": "http://creativecommons.org/licenses/by/3.0/" } } }], "labels": [], "id": "ror.1", "status": "active", "established": 1946, "relationships": [{ "type": "Related", "label": "Calvary Hospital", "id": "grid.460694.9" }, { "type": "Related", "label": "Canberra Hospital", "id": "grid.413314.0" }, { "type": "Related", "label": "Goulburn Base Hospital", "id": "grid.460721.6" }], "external_ids": { "ISNI": { "preferred": null, "all": ["ISNI1"] }, "FundRef": { "preferred": "FUNDREF1", "all": ["FUNDREF1"] }, "OrgRef": { "preferred": null, "all": ["ORGREF1"] }, "Wikidata": { "preferred": null, "all": ["WIKIDATA1"] } }, "weight": 1 }
{
"names": [
{
"value": "org_1",
"types": [
"ror_display",
"label"
],
"lang": null
} ],

"locations":[
{
"geonames_id":2078025,
"geonames_details":{
"country_code":"AU",
"country_name":"Australia",
"lat":-35.024038,
"lng":138.572615,
"name":"Adelaide"
}
}
],
"email_address":null,
"links":[
"http://link1.com"
],
"aliases":[
"alias 1"
],
"acronyms":[
"ACR_1"
],
"types":[
"type_1"
],
"ip_addresses":[

],
"labels":[

],
"id":"ror.1",
"status":"active",
"established":1946,
"relationships":[
{
"type":"Related",
"label":"Calvary Hospital",
"id":"grid.460694.9"
},
{
"type":"Related",
"label":"Canberra Hospital",
"id":"grid.413314.0"
},
{
"type":"Related",
"label":"Goulburn Base Hospital",
"id":"grid.460721.6"
}
],
"external_ids":[
{
"type":"ISNI",
"preferred":null,
"all":[
"ISNI1"
]
},
{
"type":"FundRef",
"preferred":"FUNDREF1",
"all":[
"FUNDREF1"
]
},
{
"type":"OrgRef",
"preferred":null,
"all":[
"ORGREF1"
]
},
{
"type":"Wikidata",
"preferred":null,
"all":[
"WIKIDATA1"
]
}
]
}
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,96 @@
[
{ "name": "org_1", "country": {"country_code": "AU", "country_name": "Australia" },"wikipedia_url": "http://en.wikipedia.org/wiki/org_1", "email_address": null, "links": ["http://link1.com"], "aliases": ["alias 1"], "acronyms": ["ACR_1"], "types": ["type_1"], "ip_addresses": [], "addresses": [{ "line_1": "", "line_2": "", "line_3": null, "lat": 0, "lng": 0, "postcode": "", "primary": false, "city": "City One", "state": "Alabama", "state_code": "AL", "country": "United States", "country_code": "US", "geonames_city": { "id": 2172517, "city": "Canberra", "nuts_level1": null, "nuts_level2": null, "nuts_level3": null, "geonames_admin1": { "name": "ACT", "ascii_name": "ACT", "code": "AU.01" }, "geonames_admin2": null, "license": { "attribution": "Data from geonames.org under a CC-BY 3.0 license", "license": "http://creativecommons.org/licenses/by/3.0/" } } }], "labels": [], "id": "ror.1", "status": "active", "established": 1946, "relationships": [{ "type": "Related", "label": "Calvary Hospital", "id": "grid.460694.9" }, { "type": "Related", "label": "Canberra Hospital", "id": "grid.413314.0" }, { "type": "Related", "label": "Goulburn Base Hospital", "id": "grid.460721.6" }], "external_ids": { "ISNI": { "preferred": null, "all": ["ISNI1"] }, "FundRef": { "preferred": "FUNDREF1", "all": ["FUNDREF1", "FUNDREF2"] }, "OrgRef": { "preferred": null, "all": ["ORGREF1"] }, "Wikidata": { "preferred": null, "all": ["WIKIDATA1"] } }, "weight": 1 }
]
[
{
"names":[
{
"value":"org_1",
"types":[
"ror_display",
"label"
],
"lang":null
}
],
"locations":[
{
"geonames_id":2078025,
"geonames_details":{
"country_code":"AU",
"country_name":"Australia",
"lat":-35.024038,
"lng":138.572615,
"name":"Adelaide"
}
}
],
"email_address":null,
"links":[
"http://link1.com"
],
"aliases":[
"alias 1"
],
"acronyms":[
"ACR_1"
],
"types":[
"type_1"
],
"ip_addresses":[

],
"labels":[

],
"id":"ror.1",
"status":"active",
"established":1946,
"relationships":[
{
"type":"Related",
"label":"Calvary Hospital",
"id":"grid.460694.9"
},
{
"type":"Related",
"label":"Canberra Hospital",
"id":"grid.413314.0"
},
{
"type":"Related",
"label":"Goulburn Base Hospital",
"id":"grid.460721.6"
}
],
"external_ids":[
{
"type":"ISNI",
"preferred":null,
"all":[
"ISNI1"
]
},
{
"type":"FundRef",
"preferred":"FUNDREF1",
"all":[
"FUNDREF1",
"FUNDREF2"
]
},
{
"type":"OrgRef",
"preferred":null,
"all":[
"ORGREF1"
]
},
{
"type":"Wikidata",
"preferred":null,
"all":[
"WIKIDATA1"
]
}
]
}
]

0 comments on commit 00bc0d3

Please sign in to comment.