[Trunk | Library]:
orcid-work.component.ts: Updates and fixes | Add UI for "pageType=='my_search'" (my orcid links page). orcid.component.ts: a. Update component to get ORCID tokens and redirect back to the appropriate page. b. When called by ORCID UI (no source parameter), call method "orcidService.getPersonalDetails()" to redirect to advanced search research outcomes, filtered by name. c. Remove unused code. orcid.module.ts: import ResultLandingUtilsModule. orcid.service.ts: a. Add methods "getLocalWorksByPids()", "getUserOrcid()" and "getPersonalDetails()". b. Fixes and imporovements in request responses. c. Separate /local from /orcid methods in orcid service (/local query only DB while /orcid query ORCID API). orcidWork.ts: a. Add method "mapType()" to map OpenAIRE result types to ORCID work types. b. [Bug fix] Parse resultLandingInfo.dateofacceptance correctly into year, month, day. c. [Bug fix] Capitalize author.orcid to set "contributor-orcid].path. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60392 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
fed345b244
commit
fb458253d4
File diff suppressed because it is too large
Load Diff
|
@ -2,56 +2,12 @@ import { Component } from '@angular/core';
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {Subscriber, Subscription} from "rxjs";
|
import {Subscriber, Subscription} from "rxjs";
|
||||||
import {OrcidService} from "./orcid.service";
|
import {OrcidService} from "./orcid.service";
|
||||||
import {ResultLandingService} from "../landingPages/result/resultLanding.service";
|
|
||||||
import {ResultLandingInfo} from "../utils/entities/resultLandingInfo";
|
|
||||||
import {properties} from "../../../environments/environment";
|
import {properties} from "../../../environments/environment";
|
||||||
|
import {RouterHelper} from "../utils/routerHelper.class";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'orcid',
|
selector: 'orcid',
|
||||||
template: `
|
template: `
|
||||||
<!-- <div class="uk-section uk-container">-->
|
|
||||||
<!-- <div *ngIf="!testingUserRecord" class="uk-margin-small-top">Testing user ORCID iD: {{testingUserOrcid}}</div>-->
|
|
||||||
|
|
||||||
<!-- <div *ngIf="testingUserToken">-->
|
|
||||||
<!--<!– <div>Testing user token: {{testingUserToken}}</div>–>-->
|
|
||||||
<!-- <button (click)="getRecord()" type="submit"-->
|
|
||||||
<!-- class="uk-button uk-padding uk-padding-remove-vertical uk-margin-left uk-margin-small-top uk-button-primary">-->
|
|
||||||
<!-- <span>Get record</span>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
<!-- <div *ngIf="testingUserRecord" class="uk-margin-small-top">{{testingUserRecord | json}}</div>-->
|
|
||||||
|
|
||||||
<!-- <button *ngIf="!work" (click)="getLanding()" type="submit"-->
|
|
||||||
<!-- class="uk-button uk-padding uk-padding-remove-vertical uk-margin-left uk-margin-small-top uk-button-primary">-->
|
|
||||||
<!-- <span>Get landing and post work</span>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
<!--<!– <div *ngIf="resultLandingInfo" class="uk-margin-small-top">{{resultLandingInfo | json}}</div>–>-->
|
|
||||||
<!-- <button *ngIf="!work" (click)="getWork()" type="submit"-->
|
|
||||||
<!-- class="uk-button uk-padding uk-padding-remove-vertical uk-margin-left uk-margin-small-top uk-button-primary">-->
|
|
||||||
<!-- <span>Get work</span>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
<!-- <div *ngIf="work" class="uk-margin-small-top">{{work | json}}</div>-->
|
|
||||||
|
|
||||||
<!-- <button *ngIf="work" (click)="deleteWork()" type="submit"-->
|
|
||||||
<!-- class="uk-button uk-padding uk-padding-remove-vertical uk-margin-left uk-margin-small-top uk-button-primary">-->
|
|
||||||
<!-- <span>Delete work</span>-->
|
|
||||||
<!-- </button>-->
|
|
||||||
|
|
||||||
<!--<!– <button (click)="getWorks()" type="submit"–>-->
|
|
||||||
<!--<!– class="uk-button uk-padding uk-padding-remove-vertical uk-margin-left uk-margin-small-top uk-button-primary">–>-->
|
|
||||||
<!--<!– <span>Get works</span>–>-->
|
|
||||||
<!--<!– </button>–>-->
|
|
||||||
<!--<!– <div *ngIf="works" class="uk-margin-small-top">{{works | json}}</div>–>-->
|
|
||||||
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- <div *ngIf="!testingUserToken" class="uk-flex uk-flex-middle">-->
|
|
||||||
<!-- No token for testing user found. You need to grant access OpenAIRE.-->
|
|
||||||
<!-- <a href="{{tokenUrl}}" type="submit"-->
|
|
||||||
<!-- class="uk-button uk-padding uk-padding-remove-vertical uk-margin-left uk-button-primary">-->
|
|
||||||
<!-- <span>Get code and token</span>-->
|
|
||||||
<!-- </a>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
|
|
||||||
<div class="uk-section uk-container">
|
<div class="uk-section uk-container">
|
||||||
<div *ngIf="orcidMessage">{{orcidMessage}}</div>
|
<div *ngIf="orcidMessage">{{orcidMessage}}</div>
|
||||||
<div *ngIf="message" [innerHTML]="message"></div>
|
<div *ngIf="message" [innerHTML]="message"></div>
|
||||||
|
@ -63,57 +19,23 @@ import {properties} from "../../../environments/environment";
|
||||||
})
|
})
|
||||||
|
|
||||||
export class OrcidComponent {
|
export class OrcidComponent {
|
||||||
private clientId: string = "APP-A5M3KTX6NCN67L91";
|
|
||||||
//Client secret: 96b20d71-ae06-4286-bb00-9172536c1ad4
|
|
||||||
public tokenUrl: string = "";//"https://sandbox.orcid.org/oauth/authorize?client_id="+this.clientId+"&response_type=code&scope=/authenticate&redirect_uri="+location.href;
|
|
||||||
public testingUserToken: any = "ac2e24e2-cd7e-4874-8cb8-d56395b9f3e2";// = "70a0274a-5b28-49dc-b6fd-2b427727a0da";// = "94634687-f5ea-4a0d-91ab-da8268287f72";
|
|
||||||
public testingUserOrcid: string = "0000-0001-9541-4617";
|
|
||||||
public testingUserRecord: any;
|
|
||||||
public resultId: string = "dedup_wf_001::35c93a04a93b87f3a5954c1387aa7588";
|
|
||||||
public testingPutCode: string = "1167642";
|
|
||||||
|
|
||||||
// invalid:
|
|
||||||
//code: gpq2pG
|
|
||||||
// {"access_token":"c4a81d38-4a32-4160-887d-9b6f39ce2d75","token_type":"bearer","refresh_token":"0ba698e9-f73b-40ca-a0c3-f7b8e1123f3c","expires_in":631138518,"scope":"/authenticate","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"f4d8f230-fe1a-4d4e-af52-6ee67556ad2c","token_type":"bearer","refresh_token":"dc041582-33f4-476a-851d-f8d7e44de84c","expires_in":631138518,"scope":"/authenticate","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"91eced53-0c44-4e5b-b49e-b32cc4548988","token_type":"bearer","refresh_token":"d9c35f21-1f67-4c1a-99af-fc445ead37c4","expires_in":631138518,"scope":"/authenticate","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"c953699e-06bf-41a3-98a2-4ad3241a6592","token_type":"bearer","refresh_token":"75341fe0-26f6-41b8-85b0-3add39d7891e","expires_in":631138518,"scope":"/authenticate /read-limited /activities/update /person/update","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"3ad4cadd-3429-4a6d-acc8-95fecf110917","token_type":"bearer","refresh_token":"ff0d26c1-6f42-4f25-8eae-51b84b83f0cc","expires_in":631138518,"scope":"/authenticate /read-limited /activities/update /person/update","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
|
|
||||||
// {"access_token":"f77deae6-a8cd-4070-b409-eb459ed22cd1","token_type":"bearer","refresh_token":"70c6ae8f-0de6-4ebf-ac0e-409beda5d17f","expires_in":631138518,"scope":"/authenticate","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"d5c7d36e-fdbb-44b4-bb4e-1364286ba73a","token_type":"bearer","refresh_token":"db85dc40-c8dc-4ed5-81de-e98fb8d35228","expires_in":631138518,"scope":"/authenticate /read-limited /activities/update /person/update","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"94634687-f5ea-4a0d-91ab-da8268287f72","token_type":"bearer","refresh_token":"1d4c01f2-a1ef-4f01-8187-3fc26cbc5b78","expires_in":631138518,"scope":"/authenticate /read-limited /activities/update /person/update","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"70a0274a-5b28-49dc-b6fd-2b427727a0da","token_type":"bearer","refresh_token":"b973c6fd-99b3-415e-af0c-6944500f8af3","expires_in":631138518,"scope":"/activities/update","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"d1847264-a7e0-4f26-98e5-f193362ee7e2","token_type":"bearer","refresh_token":"2d1e1bfe-54d0-4e7c-984b-8af16609f6ae","expires_in":631138518,"scope":"/authenticate /read-limited /activities/update /person/update","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
// {"access_token":"77c17e47-bbe7-4a05-a0e6-5c7920a8cc26","token_type":"bearer","refresh_token":"6ae41ee9-ef94-4f8b-bb08-a241e720d3c5","expires_in":631138518,"scope":"/authenticate","name":"OpenAIRE OpenAIRE","orcid":"0000-0001-9541-4617"}
|
|
||||||
|
|
||||||
public subscriptions: Subscription[] = [];
|
public subscriptions: Subscription[] = [];
|
||||||
public resultLandingInfo: ResultLandingInfo;
|
|
||||||
|
|
||||||
public work: any;
|
|
||||||
public works: any;
|
|
||||||
|
|
||||||
public showLoading: boolean = false;
|
public showLoading: boolean = false;
|
||||||
public message: string = "";
|
public message: string = "";
|
||||||
public orcidMessage: string = "";
|
public orcidMessage: string = "";
|
||||||
|
|
||||||
|
public source: string = "";
|
||||||
|
|
||||||
|
public routerHelper:RouterHelper = new RouterHelper();
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private _router: Router,
|
private _router: Router,
|
||||||
private orcidService: OrcidService,
|
private orcidService: OrcidService) {}
|
||||||
private resultLandingService: ResultLandingService) {
|
|
||||||
|
|
||||||
if(typeof location !== undefined) {
|
|
||||||
console.debug(location);
|
|
||||||
this.tokenUrl = "https://sandbox.orcid.org/oauth/authorize?"
|
|
||||||
+ "client_id="+this.clientId
|
|
||||||
// + "&response_type=code&scope=/activities/update"
|
|
||||||
+ "&response_type=code&scope=/authenticate /activities/update /person/update /read-limited"
|
|
||||||
+ "&redirect_uri="+location.origin+"/orcid";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
this.subscriptions.push(this.route.queryParams.subscribe(params => {
|
||||||
|
this.source = params['source'];
|
||||||
if (params['code']) {
|
if (params['code']) {
|
||||||
this.getToken(params['code']);
|
this.getToken(params['code']);
|
||||||
} else if(params['error']) {
|
} else if(params['error']) {
|
||||||
|
@ -130,7 +52,6 @@ export class OrcidComponent {
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.subscriptions.forEach(subscription => {
|
this.subscriptions.forEach(subscription => {
|
||||||
if (subscription instanceof Subscriber) {
|
if (subscription instanceof Subscriber) {
|
||||||
console.debug("subscription closing...");
|
|
||||||
subscription.unsubscribe();
|
subscription.unsubscribe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -141,16 +62,56 @@ export class OrcidComponent {
|
||||||
private getToken(code: string) {
|
private getToken(code: string) {
|
||||||
this.showLoading = true;
|
this.showLoading = true;
|
||||||
this.orcidService.getToken(code).subscribe(
|
this.orcidService.getToken(code).subscribe(
|
||||||
tokens => {
|
gotTokens => {
|
||||||
console.debug(tokens);
|
if(gotTokens == null || gotTokens['value'] == false) {
|
||||||
this.testingUserToken = tokens;
|
|
||||||
if(tokens == null) {
|
|
||||||
this.showLoading = false;
|
this.showLoading = false;
|
||||||
this.message = "An error occured while trying to connect your ORCID iD with OpenAIRE. Please try again!";
|
this.message = "<div>An error occured while trying to connect your ORCID iD with OpenAIRE. Please try again!</div>" +
|
||||||
|
"<div class='uk-margin-small-top'>Need help? <a href='https://www.openaire.eu/support/helpdesk'>Contact us!</a></div>";
|
||||||
} else {
|
} else {
|
||||||
window.opener.postMessage("success");
|
if(this.source == "openaire") {
|
||||||
window.close();
|
this.message = "<div>Thank you for connecting your ORCID iD with OpenAIRE!</div>" +
|
||||||
this.message = "Thank you for connecting your ORCID iD with OpenAIRE! Please close this window and continue!";
|
"<div class='uk-margin-small-top'>This window will automatically close and you will be ready to link OpenAIRE research results with your ORCID iD.</div>";
|
||||||
|
if(window && window.opener) {
|
||||||
|
window.opener.postMessage("success");
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
this.message += "<div class='uk-margin-top'>If this widnow does not close authomatically, please close it and continue!</div>";
|
||||||
|
}, 3000);
|
||||||
|
} else {
|
||||||
|
this.message = "<div>Thank you for connecting your ORCID iD with OpenAIRE!</div>" +
|
||||||
|
"<div class='uk-margin-small-top'>You will automatically be redirected to our advanced search page where you can link OpenAIRE research results with your ORCID iD.</div>";
|
||||||
|
|
||||||
|
//get author name
|
||||||
|
this.subscriptions.push(this.orcidService.getPersonalDetails().subscribe(
|
||||||
|
details => {
|
||||||
|
let author: string = "";
|
||||||
|
|
||||||
|
if(details && details['name']) {
|
||||||
|
let name: string = details['name'];
|
||||||
|
if(name['given-names'] && name['given-names']['value']) {
|
||||||
|
author = name['given-names']['value'];
|
||||||
|
}
|
||||||
|
if(name['family-name'] && name['family-name']['value']) {
|
||||||
|
author += (author ? " " : "") + name['family-name']['value'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let params = this.routerHelper.createQueryParams(['f0', 'fv0'], ['resultauthor', author]);
|
||||||
|
this._router.navigate([properties.searchLinkToAdvancedResults], {queryParams: params});
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.error("Error getting personal details", error);
|
||||||
|
this._router.navigate([properties.searchLinkToAdvancedResults], {});
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.message += "<div class='uk-margin-top'>If you are not authomatically redirected, please navigate to our search pages.</div>";
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
// this.message = "Thank you for connecting your ORCID iD with OpenAIRE! Please close this window and continue!";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
@ -162,106 +123,4 @@ export class OrcidComponent {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRecord() {
|
|
||||||
//this.orcidService.getMyRecord(this.testingUserToken, this.testingUserOrcid).subscribe(
|
|
||||||
this.subscriptions.push(this.orcidService.getRecord().subscribe(
|
|
||||||
record => {
|
|
||||||
this.testingUserRecord = record;
|
|
||||||
console.debug(record);
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
console.error("Error getting record info for ORCID iD: "+this.testingUserOrcid + " with token: "+this.testingUserToken, error);
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
private getLanding() {
|
|
||||||
this.subscriptions.push(this.resultLandingService.getResultLandingInfo(this.resultId, null, "publication", null, properties).subscribe(
|
|
||||||
data => {
|
|
||||||
this.resultLandingInfo = data;
|
|
||||||
|
|
||||||
this.postWork();
|
|
||||||
|
|
||||||
console.debug(this.resultLandingInfo);
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
console.error("Error getting landing info for publication id: "+this.resultId, error);
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
private postWork() {
|
|
||||||
let pids: string[] = [];
|
|
||||||
if(this.resultLandingInfo && this.resultLandingInfo.identifiers) {
|
|
||||||
for (let key of Array.from(this.resultLandingInfo.identifiers.keys())) {
|
|
||||||
pids = pids.concat(this.resultLandingInfo.identifiers.get(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.subscriptions.push(this.orcidService.saveWork(this.resultLandingInfo, pids.join()).subscribe(
|
|
||||||
response => {
|
|
||||||
console.debug(response);
|
|
||||||
//this.work = this.orcidService.parse(this.resultLandingInfo);
|
|
||||||
//this.work['put-code'] = response;
|
|
||||||
this.work = response;
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
console.error("Error posting landing info", error);
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
// private updateWork() {
|
|
||||||
// this.subscriptions.push(this.orcidService.updateWork(this.resultLandingInfo, this.testingUserOrcid, this.testingPutCode).subscribe(
|
|
||||||
// response => {
|
|
||||||
// console.debug(response);
|
|
||||||
// //this.work = this.orcidService.parse(this.resultLandingInfo);
|
|
||||||
// //this.work['put-code'] = response;
|
|
||||||
// this.work = response;
|
|
||||||
// },
|
|
||||||
// error => {
|
|
||||||
// console.error("Error updating landing info", error);
|
|
||||||
// }
|
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private getWorks() {
|
|
||||||
// this.subscriptions.push(this.orcidService.getWorks().subscribe(
|
|
||||||
// response => {
|
|
||||||
// console.debug(response);
|
|
||||||
// this.works = response;
|
|
||||||
// },
|
|
||||||
// error => {
|
|
||||||
// console.error("Error getting works", error);
|
|
||||||
// }
|
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private getWork() {
|
|
||||||
// this.subscriptions.push(this.orcidService.getWork(this.resultId).subscribe(
|
|
||||||
// response => {
|
|
||||||
// console.debug(response);
|
|
||||||
// this.work = response;
|
|
||||||
// },
|
|
||||||
// error => {
|
|
||||||
// console.error("Error getting work", error);
|
|
||||||
// }
|
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
|
|
||||||
private deleteWork() {
|
|
||||||
let put_code = this.testingPutCode;
|
|
||||||
if(this.work && this.work['put-code']) {
|
|
||||||
put_code = this.work['put-code'];
|
|
||||||
}
|
|
||||||
this.subscriptions.push(this.orcidService.deleteWork(put_code).subscribe(
|
|
||||||
response => {
|
|
||||||
console.debug(response);
|
|
||||||
this.work = null;
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
console.error("Error deleting work", error);
|
|
||||||
}
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -11,10 +11,11 @@ import {OrcidWorkComponent} from "./orcid-work.component";
|
||||||
import {AlertModalModule} from "../utils/modal/alertModal.module";
|
import {AlertModalModule} from "../utils/modal/alertModal.module";
|
||||||
import {ResultLandingService} from "../landingPages/result/resultLanding.service";
|
import {ResultLandingService} from "../landingPages/result/resultLanding.service";
|
||||||
import {LoadingModule} from "../utils/loading/loading.module";
|
import {LoadingModule} from "../utils/loading/loading.module";
|
||||||
|
import {ResultLandingUtilsModule} from "../landingPages/landing-utils/resultLandingUtils.module";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule, RouterModule, AlertModalModule, LoadingModule
|
CommonModule, RouterModule, AlertModalModule, LoadingModule, ResultLandingUtilsModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
OrcidComponent,
|
OrcidComponent,
|
||||||
|
|
|
@ -13,12 +13,17 @@ export class OrcidService {
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
getPutCode(pids: string) {
|
getPutCode(pids: string) {
|
||||||
let url: string = properties.orcidAPIURL+"put-code?pids="+pids;
|
let url: string = properties.orcidAPIURL+"local/put-code?pids="+pids;
|
||||||
return this.http.get<string[]>(url, CustomOptions.registryOptions());
|
return this.http.get<string[]>(url, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
getPutCodes(pids: string[][]) {
|
getPutCodes(pids: string[][]) {
|
||||||
let url: string = properties.orcidAPIURL+"put-codes";
|
let url: string = properties.orcidAPIURL+"local/put-codes";
|
||||||
|
return this.http.post<string[][]>(url, JSON.stringify(pids), CustomOptions.registryOptions());
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocalWorksByPids(pids: string[][]) {
|
||||||
|
let url: string = properties.orcidAPIURL+"local/works";
|
||||||
return this.http.post<string[][]>(url, JSON.stringify(pids), CustomOptions.registryOptions());
|
return this.http.post<string[][]>(url, JSON.stringify(pids), CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,13 +38,13 @@ export class OrcidService {
|
||||||
// console.debug(url);
|
// console.debug(url);
|
||||||
// return this.http.post(url, JSON.stringify(body));
|
// return this.http.post(url, JSON.stringify(body));
|
||||||
//.pipe(catchError(this.handleError));
|
//.pipe(catchError(this.handleError));
|
||||||
console.debug(code);
|
// console.debug(code);
|
||||||
let url: string = properties.orcidAPIURL+"token/save?code="+code;
|
let url: string = properties.orcidAPIURL+"orcid/token/save?code="+code;
|
||||||
return this.http.get<string>(url, CustomOptions.registryOptions());
|
return this.http.get(url, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
getRecord() {
|
getRecord() {
|
||||||
let url: string = properties.orcidAPIURL+"record";
|
let url: string = properties.orcidAPIURL+"orcid/record";
|
||||||
return this.http.get(url, CustomOptions.registryOptions());
|
return this.http.get(url, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,48 +54,89 @@ export class OrcidService {
|
||||||
"pids": pids.split(","),
|
"pids": pids.split(","),
|
||||||
"work": work
|
"work": work
|
||||||
};
|
};
|
||||||
let url: string = properties.orcidAPIURL+"work/save";
|
let url: string = properties.orcidAPIURL+"orcid/work/save";
|
||||||
return this.http.post<any>(url, JSON.stringify(result), CustomOptions.registryOptions())
|
return this.http.post<any>(url, JSON.stringify(result), CustomOptions.registryOptions())
|
||||||
.pipe(map(res => {
|
// .pipe(map(res => {
|
||||||
console.debug(res);
|
// console.debug(res);
|
||||||
if(!res) {
|
// if(!res) {
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
work['put-code'] = +res;
|
// work['put-code'] = +res;
|
||||||
return work;
|
// return work;
|
||||||
}));
|
// }));
|
||||||
|
.pipe(map(res => {
|
||||||
|
// console.debug(res);
|
||||||
|
if(!res || !res['putCode']) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
work['put-code'] = +res['putCode'];
|
||||||
|
work['created-date'] = {};
|
||||||
|
work['created-date']['value'] = res['creationDate'];
|
||||||
|
work['last-modified-date'] = {};
|
||||||
|
work['last-modified-date']['value'] = res['updateDate'];
|
||||||
|
return work;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateWork(resultLandingInfo: ResultLandingInfo, /*orcid: string,*/ putCode: string) {
|
// updateWork(resultLandingInfo: ResultLandingInfo, pids: string, putCode: string) {
|
||||||
let work = WorkV3_0.resultLandingInfoConvert(resultLandingInfo, putCode);
|
// let work = WorkV3_0.resultLandingInfoConvert(resultLandingInfo, putCode);
|
||||||
// let url: string = "http://duffy.di.uoa.gr:8080/uoa-orcid-service/orcid/"+orcid+"work/"+putCode;
|
// let url: string = properties.orcidAPIURL+"orcid/work/update/"+putCode;
|
||||||
let url: string = properties.orcidAPIURL+"work/update/"+putCode;
|
//
|
||||||
return this.http.post(url, JSON.stringify(work), CustomOptions.registryOptions())
|
// let result = {
|
||||||
.pipe(map(res => work));
|
// "pids": pids.split(","),
|
||||||
}
|
// "work": work
|
||||||
|
// };
|
||||||
// getWorks() {
|
// console.log(result);
|
||||||
// let url: string = "http://duffy.di.uoa.gr:8080/uoa-orcid-service/orcid/works?orcid=0000-0001-9541-4617";
|
// return this.http.post(url, JSON.stringify(work), CustomOptions.registryOptions())
|
||||||
// return this.http.get(url, CustomOptions.registryOptions());
|
// .pipe(map(res => work));
|
||||||
// }
|
// }
|
||||||
|
updateWork(resultLandingInfo: ResultLandingInfo, pids: string, putCode: string) {
|
||||||
|
let work = WorkV3_0.resultLandingInfoConvert(resultLandingInfo, putCode);
|
||||||
|
let result = {
|
||||||
|
"pids": pids.split(","),
|
||||||
|
"work": work
|
||||||
|
};
|
||||||
|
|
||||||
getWorks(pids: string) {
|
let url: string = properties.orcidAPIURL+"orcid/work/update/"+putCode;
|
||||||
let url: string = "http://duffy.di.uoa.gr:8080/uoa-orcid-service/orcid/work?orcid=0000-0001-9541-4617&pids="+pids;
|
return this.http.post(url, JSON.stringify(result), CustomOptions.registryOptions())
|
||||||
|
.pipe(map(res => {
|
||||||
|
if(!res || !res['putCode']) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
work['last-modified-date'] = {};
|
||||||
|
work['last-modified-date']['value'] = res['updateDate'];
|
||||||
|
return work;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
getOrcidWorks(putCodes: string[]) {
|
||||||
|
let url: string = properties.orcidAPIURL + "orcid/works?put_codes="+putCodes.join(",");
|
||||||
return this.http.get<any[]>(url, CustomOptions.registryOptions());
|
return this.http.get<any[]>(url, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
deleteWork(putCode: string) {
|
deleteWork(putCode: string) {
|
||||||
let url: string = properties.orcidAPIURL+"work/"+putCode+"/delete";
|
let url: string = properties.orcidAPIURL+"orcid/work/"+putCode+"/delete";
|
||||||
return this.http.delete(url, CustomOptions.registryOptions());
|
return this.http.delete(url, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteWorks(putCodes: string[]) {
|
deleteWorks(putCodes: string[]) {
|
||||||
let url: string = properties.orcidAPIURL+"works/delete";
|
let url: string = properties.orcidAPIURL+"orcid/works/delete";
|
||||||
return this.http.post<string[]>(url, JSON.stringify(putCodes), CustomOptions.registryOptions());
|
return this.http.post<string[]>(url, JSON.stringify(putCodes), CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
getLocalWorks() {
|
getLocalWorks() {
|
||||||
let url: string = properties.orcidAPIURL+"works/local";
|
let url: string = properties.orcidAPIURL+"local/works";
|
||||||
return this.http.get<any[]>(url, CustomOptions.registryOptions());
|
return this.http.get<any[]>(url, CustomOptions.registryOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserOrcid() {
|
||||||
|
let url: string = properties.orcidAPIURL+"local/orcidId";
|
||||||
|
return this.http.get(url, CustomOptions.registryOptions()).pipe(map(res => res['value']));
|
||||||
|
}
|
||||||
|
|
||||||
|
getPersonalDetails() {
|
||||||
|
let url: string = properties.orcidAPIURL+"orcid/personal-details";
|
||||||
|
return this.http.get(url, CustomOptions.registryOptions());
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
import {ResultLandingInfo} from "../utils/entities/resultLandingInfo";
|
import {ResultLandingInfo} from "../utils/entities/resultLandingInfo";
|
||||||
|
import {ResultPreview} from "../utils/result-preview/result-preview";
|
||||||
|
|
||||||
export class WorkV3_0 {
|
export class WorkV3_0 {
|
||||||
// automatically filled by orcid?
|
// automatically filled by orcid?
|
||||||
|
@ -21,6 +22,45 @@ export class WorkV3_0 {
|
||||||
country ?: CountryV3_0; // not sent
|
country ?: CountryV3_0; // not sent
|
||||||
visibility ?: string; // always public? // = ['limited', 'registered-only', 'public']
|
visibility ?: string; // always public? // = ['limited', 'registered-only', 'public']
|
||||||
|
|
||||||
|
private static mapType(type: string): string {
|
||||||
|
if(type == "Annotation") {
|
||||||
|
return "annotation";
|
||||||
|
} else if(type == "Article") {
|
||||||
|
return "journal-article";
|
||||||
|
} else if(type == "Book") {
|
||||||
|
return "book";
|
||||||
|
} else if(type == "Clinical Trial") {
|
||||||
|
return "test";
|
||||||
|
} else if(type == "Dataset") {
|
||||||
|
return "data-set";
|
||||||
|
} else if(type == "Doctoral thesis") {
|
||||||
|
return "dissertation-thesis";
|
||||||
|
} else if(type == "Film") {
|
||||||
|
return "artistic-performance";
|
||||||
|
} else if(type == "Lecture") {
|
||||||
|
return "lecture-speech";
|
||||||
|
} else if(type == "Newsletter") {
|
||||||
|
return "newsletter-article";
|
||||||
|
} else if(type == "Part of book or chapter of book") {
|
||||||
|
return "book-chapter";
|
||||||
|
} else if(type == "Patent") {
|
||||||
|
return "patent";
|
||||||
|
} else if(type == "PhysicalObject") {
|
||||||
|
return "physical-object";
|
||||||
|
} else if(type == "Preprint") {
|
||||||
|
return "preprint";
|
||||||
|
} else if(type == "Report") {
|
||||||
|
return "report";
|
||||||
|
} else if(type == "Research") {
|
||||||
|
return "working-paper";
|
||||||
|
} else if(type == "Review") {
|
||||||
|
return "book-review";
|
||||||
|
} else if(type == "Software") {
|
||||||
|
return "software";
|
||||||
|
}
|
||||||
|
return "other";
|
||||||
|
}
|
||||||
|
|
||||||
public static resultLandingInfoConvert(resultLandingInfo: ResultLandingInfo, putCode: string) : WorkV3_0 {
|
public static resultLandingInfoConvert(resultLandingInfo: ResultLandingInfo, putCode: string) : WorkV3_0 {
|
||||||
let work: WorkV3_0 = {};
|
let work: WorkV3_0 = {};
|
||||||
// let work = {};
|
// let work = {};
|
||||||
|
@ -43,7 +83,6 @@ export class WorkV3_0 {
|
||||||
// work["assertion-origin-client-id"] = null;
|
// work["assertion-origin-client-id"] = null;
|
||||||
// work["assertion-origin-name"] = null;
|
// work["assertion-origin-name"] = null;
|
||||||
//
|
//
|
||||||
console.debug("putCode: "+putCode);
|
|
||||||
if(putCode) {
|
if(putCode) {
|
||||||
work['put-code'] = +putCode;
|
work['put-code'] = +putCode;
|
||||||
}
|
}
|
||||||
|
@ -72,15 +111,15 @@ export class WorkV3_0 {
|
||||||
// citation (Citation, optional),
|
// citation (Citation, optional),
|
||||||
|
|
||||||
if(resultLandingInfo.types) {
|
if(resultLandingInfo.types) {
|
||||||
work['type'] = "other";//resultLandingInfo.types[0];
|
work['type'] = this.mapType(resultLandingInfo.types[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(resultLandingInfo.date || resultLandingInfo.dateofacceptance) {
|
if(resultLandingInfo.date || resultLandingInfo.dateofacceptance) {
|
||||||
if(resultLandingInfo.dateofacceptance) {
|
if(resultLandingInfo.dateofacceptance) {
|
||||||
work['publication-date'] = {
|
work['publication-date'] = {
|
||||||
"year": { "value": ('0' + resultLandingInfo.dateofacceptance.getFullYear()).slice(-4) },
|
"year": { "value": ('0' + resultLandingInfo.dateofacceptance.getFullYear()).slice(-4) },
|
||||||
"month": { "value": ('0' + resultLandingInfo.dateofacceptance.getMonth()).slice(-2) },
|
"month": { "value": ('0' + (resultLandingInfo.dateofacceptance.getMonth() + 1)).slice(-2) },
|
||||||
"day": { "value": ('0' + resultLandingInfo.dateofacceptance.getDay()).slice(-2) }
|
"day": { "value": ('0' + resultLandingInfo.dateofacceptance.getDate()).slice(-2) }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
work['publication-date'] = {
|
work['publication-date'] = {
|
||||||
|
@ -114,7 +153,7 @@ export class WorkV3_0 {
|
||||||
contributor["contributor-orcid"] =
|
contributor["contributor-orcid"] =
|
||||||
{
|
{
|
||||||
// "uri": "string",
|
// "uri": "string",
|
||||||
"path": author.orcid
|
"path": author.orcid.toUpperCase()
|
||||||
// "host": "string"
|
// "host": "string"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,8 +187,6 @@ export class WorkV3_0 {
|
||||||
|
|
||||||
// visibility (string, optional) = ['limited', 'registered-only', 'public']
|
// visibility (string, optional) = ['limited', 'registered-only', 'public']
|
||||||
|
|
||||||
console.debug(work);
|
|
||||||
|
|
||||||
return work;
|
return work;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue