[Trunk|Library]:

1. env-properties: Add 'openCitationsAPIURL' property.
2. publication.service: Do not use cache for opencitations request.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@54898 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-02-25 15:14:17 +00:00
parent bb24192b47
commit 7205f2e34c
2 changed files with 27 additions and 24 deletions

View File

@ -356,10 +356,11 @@ export class PublicationService {
getOpenCitations(id: string, properties:EnvProperties) {
//https://services.openaire.eu/opencitations/getCitations?id=doajarticles::2634200c24772ee8f10232d3e184ec65
let url = /*properties.searchAPIURLLAst*/ "https://services.openaire.eu/opencitations/getCitations?id=" + id;
let url = properties.openCitationsAPIURL+id;// "https://services.openaire.eu/opencitations/getCitations?id=" + id;
let key = url;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
return this.http.get(url)
.map(res => <any> res.json())
.map(res => [res['total'], this.parseOpenCitations(res['results'])]);
}
@ -376,31 +377,33 @@ export class PublicationService {
let citation: {"url": string, "title": string, "year": string, "doi": string, "authors": string[]} = {"url": "", "title": "", "year": "", "doi": "", "authors": []};
citation.url = openCitation.id;
citation.title = openCitation.title;
//citation.type = openCitation.type;
citation.year = (openCitation.pubDate && (openCitation.pubDate).indexOf('-') !== -1)?openCitation.pubDate.split('-')[0]:openCitation.pubDate;
citation.doi = openCitation.doi;
if(openCitation) {
citation.url = openCitation.id;
citation.title = openCitation.title;
//citation.type = openCitation.type;
citation.year = (openCitation.pubDate && (openCitation.pubDate).indexOf('-') !== -1)?openCitation.pubDate.split('-')[0]:openCitation.pubDate;
citation.doi = openCitation.doi;
let authorsLength = Array.isArray(openCitation.authors) ? openCitation.authors.length : 1;
for(let i=0; i<authorsLength; i++) {
let author = Array.isArray(openCitation.authors) ? openCitation.authors[i] : openCitation.authors;
let lastFirstName: string = "";
if(author.lastName) {
lastFirstName = author.lastName;
}
if(author.lastName && author.firstName) {
lastFirstName += ", ";
}
if(author.firstName) {
lastFirstName += author.firstName;
}
let authorsLength = Array.isArray(openCitation.authors) ? openCitation.authors.length : 1;
for(let i=0; i<authorsLength; i++) {
let author = Array.isArray(openCitation.authors) ? openCitation.authors[i] : openCitation.authors;
let lastFirstName: string = "";
if(author.lastName) {
lastFirstName = author.lastName;
}
if(author.lastName && author.firstName) {
lastFirstName += ", ";
}
if(author.firstName) {
lastFirstName += author.firstName;
}
if(lastFirstName) {
citation.authors.push(lastFirstName);
if(lastFirstName) {
citation.authors.push(lastFirstName);
}
}
citations.push(citation);
}
citations.push(citation);
}
return citations;
}

View File

@ -20,7 +20,7 @@ export class EnvProperties {
searchResourcesAPIURL;
openCitationsAPIURL;
csvAPIURL;