Skip to content

Commit

Permalink
modifying code to run with ROR V2
Browse files Browse the repository at this point in the history
  • Loading branch information
ramGranell committed Nov 26, 2024
1 parent 193328d commit 7fa56eb
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 35 deletions.
45 changes: 30 additions & 15 deletions src/components/Editor/Organisations/LinkOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,15 @@
this.enterName = false
this.importROR = true
this.validName = true
data.items.forEach( it => {
it.names.every(e => {
if (e.types.includes('ror_display')){
it.name = e.value
return false
} else {
return true
}})
})
this.organisationsList = data.items
this.organisationsNameList = data.items.map(item => item.name)
} else {
Expand All @@ -702,21 +711,24 @@
/************ Organisation Name ************/
this.menus.newOrganisation.data.name = this.menus.newOrganisation.selectOrganisation.name
/************** Homepage Link **************/
this.menus.newOrganisation.data.homepage = this.menus.newOrganisation.selectOrganisation.links[0]
this.menus.newOrganisation.data.homepage = this.menus.newOrganisation.selectOrganisation.links.filter(link => link.type === 'website')[0].value
//his.menus.newOrganisation.data.homepage = this.menus.newOrganisation.selectOrganisation.links[0]
/*************** ROR Link ***************/
this.menus.newOrganisation.data.ror_link = this.menus.newOrganisation.selectOrganisation.id
/*************** Alternative Names ***************/
this.menus.newOrganisation.data.alternative_names =
this.menus.newOrganisation.selectOrganisation.aliases.concat(
this.menus.newOrganisation.selectOrganisation.acronyms
)
this.menus.newOrganisation.data.alternative_names = []
this.menus.newOrganisation.selectOrganisation.names.forEach( it =>{
if (!it.types.includes('ror_display')){
this.menus.newOrganisation.data.alternative_names.push(it.value)
}
})
/*************** Type Select ***************/
this.selectTypes()
/************* Country Select *************/
this.menus.newOrganisation.data.country_ids = this.countries.filter(country => country.name === this.menus.newOrganisation.selectOrganisation.country["country_name"])
this.menus.newOrganisation.data.country_ids = this.countries.filter(country => country.name === this.menus.newOrganisation.selectOrganisation.locations[0].geonames_details["country_name"])
/************* Parent ror relationship *************/
this.menus.newOrganisation.data.parent_ror_links = this.menus.newOrganisation.selectOrganisation.relationships.filter(obj => obj.type === "Parent")
this.menus.newOrganisation.data.child_ror_links = this.menus.newOrganisation.selectOrganisation.relationships.filter(obj => obj.type === "Child")
this.menus.newOrganisation.data.parent_ror_links = this.menus.newOrganisation.selectOrganisation.relationships.filter(obj => obj.type === "parent")
this.menus.newOrganisation.data.child_ror_links = this.menus.newOrganisation.selectOrganisation.relationships.filter(obj => obj.type === "child")
}
},
Expand All @@ -727,19 +739,22 @@
this.menus.newOrganisation.data.organisation_type_ids = matchedType
} else{
switch (selectedType) {
case 'Government':
case 'government':
this.menus.newOrganisation.data.organisation_type_ids = [this.organisationsTypes[0]]
break
case 'Nonprofit':
case 'nonprofit':
this.menus.newOrganisation.data.organisation_type_ids = [this.organisationsTypes[1]]
break
case 'Education':
case 'education':
this.menus.newOrganisation.data.organisation_type_ids = [this.organisationsTypes[2]]
break
case 'Healthcare':
case 'Archive':
case 'Facility':
case 'Other':
case 'company':
this.menus.newOrganisation.data.organisation_type_ids = [this.organisationsTypes[5]]
break
case 'healthcare':
case 'archive':
case 'facility':
case 'other':
default:
this.menus.newOrganisation.data.organisation_type_ids = [this.organisationsTypes[8]]
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/Client/ExternalClients.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class ExternalRESTClients {
this.pmidBaseURL = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&retmode=json&id=";
this.tessBaseURL = "https://tess.elixir-europe.org/materials.json?q=";
this.orcidBaseURL = "https://pub.orcid.org/v2.0/";
this.rorOrganisationsBaseURL = "https://api.ror.org/organizations?query=";
//this.rorOrganisationsBaseURL = "https://api.ror.org/organizations?query=";
this.rorOrganisationsBaseURL = "https://api.ror.org/v2/organizations?query=";
}

async getDOI(doi){
Expand Down
55 changes: 36 additions & 19 deletions tests/unit/components/Editor/Organisations/LinkOverlay.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,26 @@ const formValidation = {
};

const organisation = {
"items":[{
"country":{
"country_code": "GB",
"country_name": "Great Britain"
},
"links":["http://www.obsmedical.com/"],
"name":"OBS Medical (United Kingdom)",
"types":["Company"],
"ror_link": "https:rororere.rere",
"parent_ror_links": ["https:rororere.rere1", "https:rororere.rere2"],
"child_ror_links": ["https:rororere.rere3", "https:rororere.rere4"]
}],
"items": [{
"locations":[{
"geonames_details": {
"country_code": "GB",
"country_name": "Great Britain"
}
}],
"links":[{
"type": "website",
"value": "http://www.obsmedical.com/"
}],
"names":[{
"types": ["ror_display"],
"value": "OBS Medical (United Kingdom)"
}],
"ror_link": "https:rororere.rere",
"types":["company"],
"parent_ror_links": ["https:rororere.rere1", "https:rororere.rere2"],
"child_ror_links": ["https:rororere.rere3", "https:rororere.rere4"]
}],
};

describe("Edit -> LinkOverlay.vue", function() {
Expand Down Expand Up @@ -237,14 +245,23 @@ describe("Edit -> LinkOverlay.vue", function() {
fetchStub = sinon.stub(ExternalClient.prototype, "executeQuery");
fetchStub.returns({data:organisation});
const expectedOrganisation = [{
"country":{
"country_code": "GB",
"country_name": "Great Britain"
},
"links":["http://www.obsmedical.com/"],
"name":"OBS Medical (United Kingdom)",
"locations":[{
"geonames_details": {
"country_code": "GB",
"country_name": "Great Britain"
}
}],
"links":[{
"type": "website",
"value": "http://www.obsmedical.com/"
}],
"names":[{
"types": ["ror_display"],
"value": "OBS Medical (United Kingdom)"
}],
"name": "OBS Medical (United Kingdom)",
"ror_link": "https:rororere.rere",
"types":["Company"],
"types":["company"],
"parent_ror_links": ["https:rororere.rere1", "https:rororere.rere2"],
"child_ror_links": ["https:rororere.rere3", "https:rororere.rere4"]
}]
Expand Down

0 comments on commit 7fa56eb

Please sign in to comment.