Change Orcid API, parsing and display
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51902 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
39d92e32f6
commit
8167f5411c
|
@ -93,13 +93,13 @@
|
|||
<span>Results for
|
||||
<a target="_blank" href="http://orcid.org/{{authorId}}"> <span class="custom-external"></span> {{authorGivenName}} {{authorFamilyName}} - {{authorId}} </a> :
|
||||
</span>
|
||||
<div class = "uk-alert uk-alert-warning " > Not the author you are looking for?
|
||||
<div *ngIf="authors.length > 1" class = "uk-alert uk-alert-warning " > Not the author you are looking for?
|
||||
|
||||
<span class="dropdown">
|
||||
|
||||
<select [(ngModel)]="selectAuthorId" name="select_author" (ngModelChange)="getOrcidResultsById(selectAuthorId)" >
|
||||
<option [value]="0">Choose another one: </option>
|
||||
<option *ngFor=" let item of authorIds let i = index" [value]="authorIds[i]">{{authorGivenNames[i]}} {{authorFamilyNames[i]}} : {{item}} </option>
|
||||
<option *ngFor=" let item of authors let i = index" [value]="authors[i].id">{{authors[i].authorGivenName}} {{authors[i].authorFamilyName}} : {{authors[i].id}} </option>
|
||||
</select>
|
||||
</span>
|
||||
|
||||
|
@ -115,13 +115,14 @@
|
|||
</div>
|
||||
<div >
|
||||
<ul *ngIf="orcidResultsNum >0 && orcidResultsToShow.length > 0 " class="uk-list uk-list-divider">
|
||||
<li *ngFor=" let item of orcidResultsToShow " [class]="(isSelected(authorId+'-'+item['put-code']))?'uk-block-muted':''">
|
||||
<li *ngFor=" let item of orcidResultsToShow " [class]="(isSelected(authorId+'-'+item['work-summary'][0]['put-code']))?'uk-block-muted':''">
|
||||
<div>
|
||||
<span *ngIf="!item.URL" >{{item['work-title']['title'].value}}</span>
|
||||
<a class="uk-button-default uk-align-right" *ngIf="!isSelected(authorId+item['put-code'])" (click)="add(item,authorId+'-'+item['put-code'],'orcid', 'publication', '', item['work-title']['title'].value, item['publication-date']?item['publication-date'].year.value :null,'OPEN')" class="uk-icon-button"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="1"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg></a>
|
||||
<span *ngIf="!item.URL" >{{item['work-summary'][0]['title']['title'].value}}</span>
|
||||
<a class="uk-button-default uk-align-right" *ngIf="!isSelected(authorId+'-'+item['work-summary'][0]['put-code'])" (click)="add(item,authorId+'-'+item['work-summary'][0]['put-code'],'orcid', 'publication', null, item['work-summary'][0]['title']['title'].value, item['work-summary'][0]['publication-date']?item['work-summary'][0]['publication-date'].year.value :null,'OPEN')" class="uk-icon-button"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="1"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg></a>
|
||||
</div>
|
||||
<span *ngIf="item['journal-title'] && item['journal-title'].value " class="uk-article-meta">Journal: {{item['journal-title'].value}}</span><span class="uk-article-meta" *ngIf="(item['publication-date']&&item['publication-date'].year&&item['publication-date'].year.value)"> ({{item['publication-date'].year.value}})</span>
|
||||
<div *ngIf="item.contributors && item.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of item.contributors.slice(0,10) let i = index">{{author}}{{(i < (item.contributors.slice(0,10).length-1))?"; ":""}}{{(i == item.contributors.slice(0,10).length-1 && item.contributors.length > 10)?"...":""}}</span></div>
|
||||
<span *ngIf="item['work-summary'][0]['journal-title'] && item['work-summary'][0]['journal-title'].value " class="uk-article-meta">Journal: {{item['work-summary'][0]['journal-title'].value}}</span><span class="uk-article-meta" *ngIf="(item['work-summary'][0]['publication-date']&&item['work-summary'][0]['publication-date'].year&&item['work-summary'][0]['publication-date'].year.value)"> ({{item['work-summary'][0]['publication-date'].year.value}})</span>
|
||||
<div *ngIf="item['work-summary'][0].source && item['work-summary'][0].source['source-name'] && item['work-summary'][0].source['source-name']" class="uk-article-meta">Authors: {{ item['work-summary'][0].source['source-name'].value}}
|
||||
<!--span *ngFor="let author of item.contributors.slice(0,10) l.valueet i = index">{{author}}{{(i < (item.contributors.slice(0,10).length-1))?"; ":""}}{{(i == item.contributors.slice(0,10).length-1 && item.contributors.length > 10)?"...":""}}</span--></div>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -104,8 +104,7 @@ export class ClaimResultSearchFormComponent {
|
|||
authorFamilyName: string;
|
||||
|
||||
authorIds: string[];
|
||||
authorGivenNames: string[];
|
||||
authorFamilyNames: string[];
|
||||
authors=[];
|
||||
|
||||
authorsNum : number ;
|
||||
|
||||
|
@ -183,7 +182,6 @@ private getCrossrefResults (term: string, size : number, page : number) {
|
|||
}
|
||||
},
|
||||
err => {
|
||||
//console.log(err);
|
||||
this._searchCrossrefService.searchCrossrefResults(term, size, page, this.properties.searchCrossrefAPIURL).subscribe(
|
||||
data => {
|
||||
this.crossrefResults = data.items;
|
||||
|
@ -278,38 +276,38 @@ private getCrossrefResults (term: string, size : number, page : number) {
|
|||
}
|
||||
this.orcidStatus = this.errorCodes.LOADING;
|
||||
this.authorIds = new Array<string>();
|
||||
this.authorGivenNames = new Array<string>();
|
||||
this.authorFamilyNames = new Array<string>();
|
||||
this.authors =[]
|
||||
|
||||
this.getOrcidAuthor(term);
|
||||
this.getOrcidAuthor(term,true);
|
||||
|
||||
console.info('searchOrcid in searchOrcid file');
|
||||
}
|
||||
|
||||
private readData(data: any) {
|
||||
this.authorIds.push(data[2].path);
|
||||
|
||||
var author ={};
|
||||
author['id']=data[2].path;
|
||||
if(data[0] != null) {
|
||||
this.authorGivenNames.push(data[0].value);
|
||||
} else {
|
||||
this.authorGivenNames.push("");
|
||||
author['authorGivenName']=data[0].value;
|
||||
} else {
|
||||
author['authorGivenName']="";
|
||||
}
|
||||
if(data[1] != null) {
|
||||
this.authorFamilyNames.push(data[1].value);
|
||||
author['authorFamilyName']=data[1].value;
|
||||
} else {
|
||||
this.authorFamilyNames.push("");
|
||||
author['authorFamilyName']="";
|
||||
}
|
||||
this.authors.push(author);
|
||||
}
|
||||
|
||||
private getOrcidAuthor (term: string) {
|
||||
private getOrcidAuthor (term: string, addId) {
|
||||
this.orcidResultsNum = null;
|
||||
|
||||
//passing structures in order to fill them in service
|
||||
this._searchOrcidService.searchOrcidAuthor(term, this.authorIds,
|
||||
this.authorGivenNames, this.authorFamilyNames, this.properties).subscribe(
|
||||
this.authors, this.properties, addId).subscribe(
|
||||
data => {
|
||||
if(data != null && data == true) {
|
||||
this.getOrcidResultsByIndex(0);
|
||||
if(data != null && data == true && addId) {
|
||||
this.getOrcidResults(0);
|
||||
}
|
||||
|
||||
this.orcidStatus = this.errorCodes.NONE;
|
||||
|
@ -335,11 +333,12 @@ private getCrossrefResults (term: string, size : number, page : number) {
|
|||
this.selectAuthorId = "0";
|
||||
this.orcidStatus = this.errorCodes.LOADING;
|
||||
//passing structures in order to fill them in service
|
||||
this._searchOrcidService.searchOrcidAuthors(term, this.authorIds,
|
||||
this.authorGivenNames, this.authorFamilyNames, this.properties).subscribe(
|
||||
this._searchOrcidService.searchOrcidAuthors(term, this.authorIds, this.properties).subscribe(
|
||||
data => {
|
||||
if(data != null && data == true) {
|
||||
this.getOrcidResultsByIndex(0);
|
||||
for(var i=0;i<this.authorIds.length;i++){
|
||||
this.getOrcidAuthor(this.authorIds[i], (i==0?true:false));
|
||||
}
|
||||
}else{
|
||||
this.orcidStatus = this.errorCodes.ERROR;
|
||||
}
|
||||
|
@ -353,30 +352,23 @@ private getCrossrefResults (term: string, size : number, page : number) {
|
|||
}
|
||||
|
||||
|
||||
private getOrcidResultsByIndex (index:number) {
|
||||
if(this.authorIds.length > index) {
|
||||
this.orcidStatus = this.errorCodes.LOADING;
|
||||
let id = this.authorIds[index];
|
||||
this.authorGivenName = this.authorGivenNames[index];
|
||||
this.authorFamilyName = this.authorFamilyNames[index];
|
||||
this.getOrcidResultsById(id);
|
||||
private getOrcidResultsById (id) {
|
||||
for(var i=0; i<this.authors.length;i++){
|
||||
if(this.authors[i].id == id){
|
||||
this.getOrcidResults(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
private getOrcidResultsById (id:string) {
|
||||
if(id=="0"){
|
||||
return;
|
||||
}
|
||||
var index = this.authorIds.indexOf(id);
|
||||
this.authorGivenName = this.authorGivenNames[index];
|
||||
this.authorFamilyName = this.authorFamilyNames[index];
|
||||
this.authorId = id;
|
||||
console.info("getOrcidResultsById: "+id);
|
||||
private getOrcidResults (index) {
|
||||
this.authorGivenName =this.authors[index].authorGivenName;
|
||||
this.authorFamilyName = this.authors[index].authorFamilyName;
|
||||
this.authorId = this.authors[index].id;
|
||||
this.orcidStatus = this.errorCodes.LOADING;
|
||||
this._searchOrcidService.searchOrcidPublications(id, this.properties).subscribe(
|
||||
this._searchOrcidService.searchOrcidPublications(this.authors[index].id, this.properties).subscribe(
|
||||
data => {
|
||||
if(data != null) {
|
||||
this.orcidResults=data['orcid-work'];
|
||||
this.orcidResultsNum = data['orcid-work'].length;
|
||||
this.orcidResults=data;
|
||||
this.orcidResultsNum = data.length;
|
||||
this.orcidPage = 1;
|
||||
if((this.orcidResultsNum % this.size) == 0){
|
||||
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size));
|
||||
|
|
|
@ -13,37 +13,38 @@ export class SearchOrcidService {
|
|||
constructor( private http: Http ) {}
|
||||
|
||||
|
||||
searchOrcidAuthor (term: string, authorIds: string[],
|
||||
authorGivenNames: string[], authorFamilyNames: string[], properties:EnvProperties):any {
|
||||
searchOrcidAuthor (term: string, authorIds: string[], authors, properties:EnvProperties, addId):any {
|
||||
console.info("In searchOrcidAuthor: "+term);
|
||||
|
||||
var headers = new Headers();
|
||||
headers.append('Accept', 'application/orcid+json');
|
||||
|
||||
let url = properties.searchOrcidURL + term+'/orcid-bio';
|
||||
let url = properties.searchOrcidURL + term+'/record';
|
||||
let key = url;
|
||||
|
||||
return this.http.get(url, { headers: headers })
|
||||
.map(res => res.json()['orcid-profile'])
|
||||
.map(res => [res['orcid-bio']['personal-details']['given-names'],
|
||||
res['orcid-bio']['personal-details']['family-name'],
|
||||
res['orcid-identifier']])
|
||||
.map(res => this.parseOrcidAuthor(res, authorIds, authorGivenNames, authorFamilyNames));
|
||||
.map(res => res.json()['person'])
|
||||
.do(res => console.log(res))
|
||||
.map(res => [res['name']['given-names'],
|
||||
res['name']['family-name'],
|
||||
res['name']])
|
||||
.do(res => console.log(res))
|
||||
.map(res => this.parseOrcidAuthor(res, authorIds, authors, addId));
|
||||
}
|
||||
|
||||
searchOrcidAuthors (term: string, authorIds: string[],
|
||||
authorGivenNames: string[], authorFamilyNames: string[], properties:EnvProperties):any {
|
||||
properties:EnvProperties):any {
|
||||
console.info("In search Orcid authors for keyword: "+term);
|
||||
|
||||
var headers = new Headers();
|
||||
headers.append('Accept', 'application/orcid+json');
|
||||
|
||||
let url = properties.searchOrcidURL+'search/orcid-bio?defType=edismax&q='+term+'&qf=given-name^1.0+family-name^2.0+other-names^1.0+credit-name^1.0&start=0&rows=10';
|
||||
let url = properties.searchOrcidURL+'search?defType=edismax&q='+term+'&qf=given-name^1.0+family-name^2.0+other-names^1.0+credit-name^1.0&start=0&rows=10';
|
||||
let key = url;
|
||||
|
||||
return this.http.get(url, { headers: headers })
|
||||
.map(res => res.json()['orcid-search-results']['orcid-search-result'])
|
||||
.map(res => this.parseOrcidAuthors(res, authorIds, authorGivenNames, authorFamilyNames));
|
||||
.map(res => res.json()['result'])
|
||||
.map(res => this.parseOrcidAuthors(res, authorIds));
|
||||
|
||||
}
|
||||
|
||||
|
@ -53,31 +54,34 @@ export class SearchOrcidService {
|
|||
var headers = new Headers();
|
||||
headers.append('Accept', 'application/orcid+json');
|
||||
|
||||
let url =properties.searchOrcidURL+id+'/orcid-works';
|
||||
let url =properties.searchOrcidURL+id+'/works';
|
||||
let key = url;
|
||||
|
||||
return this.http.get(url, { headers: headers })
|
||||
.map(res => res.json()['orcid-profile']['orcid-activities']['orcid-works']);
|
||||
.map(res => res.json()['group']);
|
||||
//.map(res => res['orcid-work']);
|
||||
}
|
||||
|
||||
|
||||
parseOrcidAuthor (data: any, authorIds: string[],
|
||||
authorGivenNames: string[], authorFamilyNames: string[]):any {
|
||||
parseOrcidAuthor (data: any, authorIds: string[],authors, addId):any {
|
||||
|
||||
if(data[2] != null) {
|
||||
authorIds.push(data[2].path);
|
||||
|
||||
if(addId){
|
||||
authorIds.push(data[2].path);
|
||||
}
|
||||
var author ={};
|
||||
author['id']=data[2].path;
|
||||
if(data[0] != null) {
|
||||
authorGivenNames.push(data[0].value);
|
||||
} else {
|
||||
authorGivenNames.push("");
|
||||
author['authorGivenName']=data[0].value;
|
||||
} else {
|
||||
author['authorGivenName']="";
|
||||
}
|
||||
if(data[1] != null) {
|
||||
authorFamilyNames.push(data[1].value);
|
||||
author['authorFamilyName']=data[1].value;
|
||||
} else {
|
||||
authorFamilyNames.push("");
|
||||
author['authorFamilyName']="";
|
||||
}
|
||||
authors.push(author);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -85,8 +89,7 @@ export class SearchOrcidService {
|
|||
return false;
|
||||
}
|
||||
|
||||
parseOrcidAuthors (data: any, authorIds: string[],
|
||||
authorGivenNames: string[], authorFamilyNames: string[]):any {
|
||||
parseOrcidAuthors (data: any, authorIds: string[]):any {
|
||||
let ret: boolean = false;
|
||||
let mydata: any;
|
||||
let length: number;
|
||||
|
@ -97,28 +100,27 @@ export class SearchOrcidService {
|
|||
for(let i=0; i<length; i++) {
|
||||
mydata = data.length!=undefined ? data[i] : data;
|
||||
|
||||
if(mydata.hasOwnProperty("orcid-profile")) {
|
||||
if(mydata['orcid-profile'].hasOwnProperty("orcid-identifier")) {
|
||||
authorIds.push(mydata['orcid-profile']['orcid-identifier'].path);
|
||||
if(mydata.hasOwnProperty("orcid-identifier")) {
|
||||
authorIds.push(mydata['orcid-identifier'].path);
|
||||
|
||||
if(mydata['orcid-profile'].hasOwnProperty("orcid-bio")) {
|
||||
if(mydata['orcid-profile']['orcid-bio'].hasOwnProperty("personal-details")) {
|
||||
if(mydata['orcid-profile']['orcid-bio']['personal-details'].hasOwnProperty("given-names")) {
|
||||
authorGivenNames.push(mydata['orcid-profile']['orcid-bio']['personal-details']['given-names'].value);
|
||||
} else {
|
||||
authorGivenNames.push("");
|
||||
}
|
||||
|
||||
if(mydata['orcid-profile']['orcid-bio']['personal-details'].hasOwnProperty("family-name")) {
|
||||
authorFamilyNames.push(mydata['orcid-profile']['orcid-bio']['personal-details']['family-name'].value);
|
||||
} else {
|
||||
authorFamilyNames.push("");
|
||||
}
|
||||
}
|
||||
}
|
||||
// if(mydata.hasOwnProperty("orcid-bio")) {
|
||||
// if(mydata['orcid-bio'].hasOwnProperty("personal-details")) {
|
||||
// if(mydata['orcid-bio']['personal-details'].hasOwnProperty("given-names")) {
|
||||
// authorGivenNames.push(mydata['orcid-bio']['personal-details']['given-names'].value);
|
||||
// } else {
|
||||
// authorGivenNames.push("");
|
||||
// }
|
||||
//
|
||||
// if(mydata['orcid-bio']['personal-details'].hasOwnProperty("family-name")) {
|
||||
// authorFamilyNames.push(mydata['orcid-bio']['personal-details']['family-name'].value);
|
||||
// } else {
|
||||
// authorFamilyNames.push("");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -98,8 +98,8 @@ export class BulkClaimComponent {
|
|||
this.noValidIds = [];
|
||||
this.results.slice(0,this.results.length);
|
||||
this.notFoundIds = [];
|
||||
|
||||
for(i=0;i<rows.length;i++){
|
||||
var limit = 100;
|
||||
for(i=0;i<((rows.length>limit)?limit:rows.length);i++){
|
||||
if(rows[i] && rows[i] != null ){
|
||||
console.log("Row is:" + rows[i]);
|
||||
var values = rows[i].split(',');
|
||||
|
|
|
@ -15,7 +15,7 @@ import{EnvProperties} from '../../../utils/properties/env-properties';
|
|||
template: `
|
||||
<div *ngIf="errorMessage.length > 0">
|
||||
<div class="uk-alert uk-alert-danger" role="alert" [innerHTML]="errorMessage"></div>
|
||||
<div *ngIf="insertedClaims.length>0">There are {{insertedClaims.length}} claims, follow <a routerLinkActive="router-link-active" routerLink="/myclaims">the link</a> to manage your claims</div>
|
||||
<div *ngIf="insertedClaims.length>0">{{insertedClaims.length}} claims created, follow <a routerLinkActive="router-link-active" routerLink="/myclaims">the link</a> to manage your claims</div>
|
||||
</div>
|
||||
<div *ngIf="warningMessage.length > 0">
|
||||
<div class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
||||
|
|
Loading…
Reference in New Issue