2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
|
2018-03-13 17:02:22 +01:00
|
|
|
import {Router, ActivatedRoute} from '@angular/router';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {ClaimsService} from '../../claim-utils/service/claims.service';
|
|
|
|
import {ModalLoading} from '../../../utils/modal/loading.component';
|
|
|
|
import {AlertModal} from '../../../utils/modal/alert';
|
|
|
|
import {Md5} from 'ts-md5/dist/md5';
|
|
|
|
import {Session} from '../../../login/utils/helper.class';
|
2018-11-01 18:20:05 +01:00
|
|
|
import {LoginErrorCodes} from '../../../login/utils/guardHelper.class';
|
2019-07-23 14:23:12 +02:00
|
|
|
import {EnvProperties} from '../../../utils/properties/env-properties';
|
|
|
|
import {
|
|
|
|
ClaimEntity,
|
|
|
|
ClaimRecord2Insert,
|
|
|
|
ClaimsErrorMessage,
|
|
|
|
DirectIndexRecord,
|
|
|
|
Message
|
|
|
|
} from "../../claim-utils/claimHelper.class";
|
2019-09-13 09:01:19 +02:00
|
|
|
import {UserManagementService} from "../../../services/user-management.service";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2019-07-23 14:23:12 +02:00
|
|
|
selector: 'claim-insert',
|
|
|
|
template: `
|
|
|
|
|
|
|
|
|
|
|
|
<div class="uk-width-1-1">
|
|
|
|
<modal-loading [message]="'Please wait...'"></modal-loading>
|
|
|
|
<modal-alert (alertOutput)="confirmClose()">
|
|
|
|
<h4 class="modal-title uk-text-bold " id="myModalLabel">Confirmation notice</h4>
|
|
|
|
<p>All the links you provided will be published in the OpenAIRE platform. <br>
|
|
|
|
Please make sure that the information is valid.<br>
|
|
|
|
<span class="uk-text-bold">In some cases, links take some time to be published.</span><br>
|
|
|
|
For more information please check the linking status in My-Links page.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Do you confirm the information you provide is valid?
|
|
|
|
</p>
|
|
|
|
</modal-alert>
|
|
|
|
<div class="uk-clearfix">
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div *ngIf="!claiming " (click)="insert()" style="width: 350px;"
|
2019-08-27 15:19:58 +02:00
|
|
|
[class]="getButtonClass()">CONFIRM LINKING
|
|
|
|
<span [class]="(defaultColors?'':' uk-margin-small-top ')+'uk-icon uk-float-right uk-text-bold uk-margin-small-right'">
|
2019-07-23 14:23:12 +02:00
|
|
|
<svg width="30" height="30" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"
|
|
|
|
icon="chevron-right" ratio="1.5"><polyline fill="none" stroke="#000" stroke-width="1.03"
|
|
|
|
points="7 4 13 10 7 16"></polyline></svg>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
2018-07-25 15:56:02 +02:00
|
|
|
</div>
|
2019-07-23 14:23:12 +02:00
|
|
|
</div>
|
|
|
|
`
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
|
|
|
export class ClaimInsertComponent {
|
2019-09-13 09:01:19 +02:00
|
|
|
constructor(private claimService: ClaimsService, private _router: Router, private route: ActivatedRoute,
|
|
|
|
private userManagementService: UserManagementService) {
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
ngOnInit() {
|
2018-03-13 17:02:22 +01:00
|
|
|
this.route.queryParams.subscribe(params => {
|
|
|
|
this.params = params;
|
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
params = {};
|
|
|
|
|
|
|
|
@Input() public results: ClaimEntity[];
|
|
|
|
@Input() inlineEntity: ClaimEntity = null;
|
|
|
|
@Input() sources: ClaimEntity[] = null;
|
|
|
|
@Input() public properties: EnvProperties;
|
|
|
|
@Input() localStoragePrefix: string;
|
|
|
|
@ViewChild(ModalLoading) loading: ModalLoading;
|
2017-12-19 13:53:46 +01:00
|
|
|
@ViewChild(AlertModal) alert;
|
2019-07-23 14:23:12 +02:00
|
|
|
@Input() errors: ClaimsErrorMessage[];
|
|
|
|
@Output() insertFinished = new EventEmitter();
|
2019-08-27 15:19:58 +02:00
|
|
|
@Input() defaultColors:boolean;
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
public claiming = false;
|
|
|
|
|
|
|
|
public claims: number = 0;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private servicesRespond: number = 0;
|
|
|
|
private insertedClaims = [];
|
|
|
|
private errorInClaims: ClaimRecord2Insert[] = [];
|
|
|
|
private insertedRecords = [];
|
|
|
|
private errorInRecords = [];
|
|
|
|
|
|
|
|
public insert() {
|
|
|
|
this.confirmOpen();
|
|
|
|
}
|
|
|
|
|
|
|
|
private insertActions() {
|
|
|
|
this.servicesRespond = 0;
|
|
|
|
this.insertedClaims = [];
|
|
|
|
this.errorInClaims = [];
|
|
|
|
this.insertedRecords = [];
|
|
|
|
this.errorInRecords = [];
|
2019-09-13 09:01:19 +02:00
|
|
|
this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => {
|
|
|
|
if (!user) {
|
|
|
|
localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
|
|
|
|
if (this.sources != null) {
|
|
|
|
localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
this._router.navigate(['/user-info'], {
|
|
|
|
queryParams: {
|
|
|
|
"errorCode": LoginErrorCodes.NOT_VALID,
|
|
|
|
"redirectUrl": this._router.url
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
this.claiming = true;
|
|
|
|
this.loading.open();
|
|
|
|
let claims: ClaimRecord2Insert[] = [];
|
|
|
|
let directclaims: DirectIndexRecord[] = [];
|
2019-10-16 12:40:19 +02:00
|
|
|
let dashboard = this.properties.environment+"_"+this.properties.dashboard;
|
2019-09-13 09:01:19 +02:00
|
|
|
for (let j = 0; j < this.sources.length; j++) { // if an external result -> direct insert in the index
|
|
|
|
const result: ClaimEntity = this.sources[j];
|
|
|
|
if (result.result && ["crossref", "datacite", "orcid"].indexOf(result.result.source) != -1) {
|
2019-07-23 14:23:12 +02:00
|
|
|
directclaims.push({
|
2019-09-13 09:01:19 +02:00
|
|
|
"id": result.id,
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(result, this.results)
|
2019-07-23 14:23:12 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2019-09-13 09:01:19 +02:00
|
|
|
for (let i = 0; i < this.results.length; i++) {
|
|
|
|
const entity: ClaimEntity = this.results[i]; // this is a research result, a project or a context
|
|
|
|
|
|
|
|
if (entity.result && ["crossref", "datacite", "orcid"].indexOf(entity.result.source) != -1) { // if an external result -> direct insert in the index
|
|
|
|
if (this.sources.length > 0) {
|
|
|
|
directclaims.push({
|
|
|
|
"id": entity.id,
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(entity, this.sources)
|
|
|
|
});
|
|
|
|
} else if (this.inlineEntity) {
|
|
|
|
directclaims.push({
|
|
|
|
"id": entity.id,
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(entity, [this.inlineEntity])
|
|
|
|
});
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
for (let j = 0; j < this.sources.length; j++) {
|
|
|
|
const result: ClaimEntity = this.sources[j]; // this is a research result
|
2019-07-23 14:23:12 +02:00
|
|
|
if (entity.result) {
|
2019-10-16 12:40:19 +02:00
|
|
|
claims.push(ClaimInsertComponent.createResultClaim(result, entity, user.email, dashboard));
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (entity.context) {
|
2019-10-16 12:40:19 +02:00
|
|
|
claims.push(ClaimInsertComponent.createContextClaim(result, entity, user.email, dashboard));
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (entity.project) {
|
2019-10-16 12:40:19 +02:00
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(result, entity, user.email, dashboard));
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2019-09-13 09:01:19 +02:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
if (this.inlineEntity) {
|
|
|
|
if (this.inlineEntity.result) {
|
|
|
|
if (entity.result) {
|
2019-10-16 12:40:19 +02:00
|
|
|
|
|
|
|
claims.push(ClaimInsertComponent.createResultClaim(this.inlineEntity, entity, user.email, dashboard));
|
2019-09-13 09:01:19 +02:00
|
|
|
} else if (entity.context) {
|
2019-10-16 12:40:19 +02:00
|
|
|
claims.push(ClaimInsertComponent.createContextClaim(this.inlineEntity, entity, user.email, dashboard));
|
2019-09-13 09:01:19 +02:00
|
|
|
} else if (entity.project) {
|
2019-10-16 12:40:19 +02:00
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(this.inlineEntity, entity, user.email, dashboard));
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
|
|
|
} else if (this.inlineEntity.project) {
|
|
|
|
if (entity.result) {
|
2019-10-16 12:40:19 +02:00
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(entity, this.inlineEntity, user.email, dashboard));
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2018-03-13 17:02:22 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
2019-09-13 09:01:19 +02:00
|
|
|
//first call direct index service - when call is done (success or error) call isertBulkClaims method to insert claims in DB
|
|
|
|
console.log("directclaims");
|
|
|
|
console.log(directclaims);
|
|
|
|
if (directclaims.length > 0) {
|
|
|
|
this.claimService.insertDirectRecords(directclaims, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
this.insertedRecords = data.insertedIds;
|
|
|
|
|
|
|
|
this.errorInRecords = data.errorInClaims;
|
|
|
|
this.isertBulkClaims(claims);
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
try {
|
|
|
|
err = err.json();
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
if (err.insertedIds && err.insertedIds.length > 0) {
|
|
|
|
this.insertedRecords = err.insertedIds;
|
|
|
|
}
|
|
|
|
if (err.errorInClaims && err.errorInClaims.length > 0) {
|
|
|
|
this.errorInRecords = err.errorInClaims;
|
|
|
|
}
|
|
|
|
this.isertBulkClaims(claims);
|
|
|
|
|
|
|
|
ClaimInsertComponent.handleError("Error inserting direct records: " + JSON.stringify(directclaims), err);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-09-13 09:01:19 +02:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.isertBulkClaims(claims);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-09-13 09:01:19 +02:00
|
|
|
});
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private isertBulkClaims(claims: ClaimRecord2Insert[]) {
|
|
|
|
console.log("claims");
|
|
|
|
console.log(claims);
|
|
|
|
this.errors.splice(0, this.errors.length);
|
|
|
|
this.claimService.insertBulkClaims(claims, this.properties.claimsAPIURL).subscribe(
|
|
|
|
data => {
|
|
|
|
this.insertedClaims = data.insertedIds;
|
|
|
|
this.errorInClaims = data.errorInClaims;
|
|
|
|
//TODO remove - testing having errors in claims
|
|
|
|
// this.insertedClaims.pop();
|
|
|
|
// this.insertedClaims.pop();
|
|
|
|
// this.errorInClaims.push(claims[1]);
|
|
|
|
// this.insertedClaims.splice(0,this.insertedClaims.length);
|
|
|
|
// this.errorInClaims = claims;
|
|
|
|
//remove till here
|
|
|
|
|
|
|
|
if (claims.length != this.insertedClaims.length) {
|
|
|
|
let error: ClaimsErrorMessage = new ClaimsErrorMessage();
|
|
|
|
error.type = "claimServiceFail2Insert";
|
|
|
|
error.inserted = this.insertedClaims.length;
|
|
|
|
error.failed = this.errorInClaims.length;
|
|
|
|
this.createErrorMessagesPerEntity((this.insertedClaims.length == 0));
|
|
|
|
this.errors.push(error);
|
|
|
|
}
|
|
|
|
this.afterclaimsInsertion();
|
|
|
|
},
|
|
|
|
err => {
|
|
|
|
try {
|
|
|
|
err = err.json();
|
|
|
|
} catch (e) {
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
let error: ClaimsErrorMessage = new ClaimsErrorMessage();
|
|
|
|
error.type = "claimServiceFail";
|
|
|
|
if (err.insertedIds && err.insertedIds.length > 0) {
|
|
|
|
this.insertedClaims = err.insertedIds;
|
|
|
|
error.inserted = err.insertedIds.length;
|
|
|
|
}
|
|
|
|
if (err.errorInClaims && err.errorInClaims.length > 0) {
|
|
|
|
this.errorInClaims = err.errorInClaims;
|
|
|
|
error.failed = err.errorInClaims.length;
|
|
|
|
} else {
|
|
|
|
error.failed = claims.length;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.results != null) {
|
|
|
|
localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
|
|
|
|
}
|
|
|
|
if (this.sources != null) {
|
|
|
|
localStorage.setItem(this.localStoragePrefix + "sources", JSON.stringify(this.sources));
|
|
|
|
}
|
|
|
|
console.log(error);
|
|
|
|
this.createErrorMessagesPerEntity((this.insertedClaims.length == 0));
|
|
|
|
this.errors.push(error);
|
|
|
|
this.afterclaimsInsertion();
|
|
|
|
|
|
|
|
ClaimInsertComponent.handleError("Error inserting bulk claims: " + JSON.stringify(claims), err);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
createErrorMessagesPerEntity(applyToAll: boolean) {
|
|
|
|
let errorsInIds: string[] = [];
|
|
|
|
let savedIds: string[] = [];
|
|
|
|
if (!applyToAll) {
|
|
|
|
for (let claim of this.errorInClaims) {
|
|
|
|
errorsInIds.push(claim.sourceId);
|
|
|
|
errorsInIds.push(claim.targetId);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
for (let i = 0; i < this.sources.length; i++) {
|
|
|
|
let entity: ClaimEntity = this.sources[i];
|
|
|
|
if (errorsInIds.indexOf(entity.id) != -1 || applyToAll) {
|
|
|
|
let error: Message = new Message();
|
|
|
|
error.type = "fail2Insert";
|
|
|
|
entity.errorMessages.push(error);
|
|
|
|
} else {
|
|
|
|
savedIds.push(entity.id);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
for (let entity of this.results) {
|
|
|
|
if (errorsInIds.indexOf(entity.id) != -1 || applyToAll) {
|
|
|
|
let error: Message = new Message();
|
|
|
|
error.type = "fail2Insert";
|
|
|
|
entity.errorMessages.push(error);
|
|
|
|
} else {
|
|
|
|
savedIds.push(entity.id);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
if (this.inlineEntity && (errorsInIds.indexOf(this.inlineEntity.id) != -1 || applyToAll)) {
|
|
|
|
let error: Message = new Message();
|
|
|
|
error.type = "fail2Insert";
|
|
|
|
this.inlineEntity.errorMessages.push(error);
|
|
|
|
}
|
|
|
|
//remove entities that have been saved
|
|
|
|
for (let id of savedIds) {
|
|
|
|
|
|
|
|
//remove sources
|
|
|
|
let sourceIndex = -1;
|
|
|
|
for (let i = 0; i < this.sources.length; i++) {
|
|
|
|
if (this.sources[i].id == id) {
|
|
|
|
sourceIndex = i;
|
|
|
|
break;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
if (sourceIndex != -1) {
|
|
|
|
this.sources.splice(sourceIndex, 1);
|
|
|
|
} else {
|
|
|
|
//remove results
|
|
|
|
let resutsIndex = -1;
|
|
|
|
for (let i = 0; i < this.results.length; i++) {
|
|
|
|
if (this.results[i].id == id) {
|
|
|
|
resutsIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (resutsIndex != -1) {
|
|
|
|
this.results.splice(resutsIndex, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
this.insertFinished.emit();
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private afterclaimsInsertion() {
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
this.loading.close();
|
|
|
|
this.claiming = false;
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
if (this.errorInClaims.length == 0 && this.insertedClaims.length > 0) {
|
|
|
|
localStorage.removeItem(this.localStoragePrefix + "sources");
|
2018-07-25 15:56:02 +02:00
|
|
|
localStorage.removeItem(this.localStoragePrefix + "results");
|
2019-07-23 14:23:12 +02:00
|
|
|
this._router.navigate(['/myclaims'], {queryParams: this.params});
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-10-16 12:40:19 +02:00
|
|
|
private static createContextClaim(resultEntity: ClaimEntity, contextEntity: ClaimEntity, user: any, dashboard:string): ClaimRecord2Insert {
|
2019-07-23 14:23:12 +02:00
|
|
|
return {
|
|
|
|
claimedBy: user,
|
|
|
|
sourceId: contextEntity.context.concept.id,
|
|
|
|
sourceType: "context",
|
|
|
|
sourceCollectedFrom: "openaire",
|
|
|
|
sourceAccessRights: "OPEN",
|
|
|
|
sourceEmbargoEndDate: "",
|
|
|
|
targetId: resultEntity.id,
|
|
|
|
targetType: resultEntity.type,
|
|
|
|
targetCollectedFrom: resultEntity.result.source,
|
|
|
|
targetAccessRights: resultEntity.result.accessRights,
|
2019-10-16 12:40:19 +02:00
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(resultEntity),
|
|
|
|
claimedInDashboard : dashboard
|
2019-07-23 14:23:12 +02:00
|
|
|
};
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-10-16 12:40:19 +02:00
|
|
|
private static createProjectClaim(resultEntity: ClaimEntity, projectEntity: ClaimEntity, user: any, dashboard:string): ClaimRecord2Insert {
|
2019-07-23 14:23:12 +02:00
|
|
|
return {
|
|
|
|
claimedBy: user,
|
|
|
|
sourceId: projectEntity.id,
|
|
|
|
sourceType: "project",
|
|
|
|
sourceCollectedFrom: "openaire",
|
|
|
|
sourceAccessRights: "OPEN",
|
|
|
|
sourceEmbargoEndDate: "",
|
|
|
|
targetId: resultEntity.id,
|
|
|
|
targetType: resultEntity.type,
|
|
|
|
targetCollectedFrom: resultEntity.result.source,
|
|
|
|
targetAccessRights: resultEntity.result.accessRights,
|
2019-10-16 12:40:19 +02:00
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(resultEntity),
|
|
|
|
claimedInDashboard : dashboard
|
2019-07-23 14:23:12 +02:00
|
|
|
};
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-10-16 12:40:19 +02:00
|
|
|
private static createResultClaim(inlineResult: ClaimEntity, resultEntity: ClaimEntity, user: string, dashboard:string): ClaimRecord2Insert {
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
claimedBy: user,
|
|
|
|
sourceId: resultEntity.id,
|
|
|
|
sourceType: resultEntity.type,
|
|
|
|
sourceCollectedFrom: resultEntity.result.source,
|
|
|
|
sourceAccessRights: resultEntity.result.accessRights,
|
|
|
|
sourceEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(resultEntity),
|
|
|
|
targetId: inlineResult.id,
|
|
|
|
targetType: inlineResult.type,
|
|
|
|
targetCollectedFrom: inlineResult.result.source,
|
|
|
|
targetAccessRights: inlineResult.result.accessRights,
|
2019-10-16 12:40:19 +02:00
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(inlineResult),
|
|
|
|
claimedInDashboard : dashboard
|
2019-07-23 14:23:12 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
static getEmbargoEndDate(resultEntity: ClaimEntity): string {
|
|
|
|
if (resultEntity.result && resultEntity.result.accessRights == "EMBARGO" && resultEntity.result.embargoEndDate != null) {
|
|
|
|
return resultEntity.result.embargoEndDate;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
return ""
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
static createDirectClaim(resultEntity: ClaimEntity, results: ClaimEntity[]) {
|
|
|
|
let entity = {};
|
|
|
|
const md5_id = Md5.hashStr(resultEntity.id);
|
|
|
|
entity["originalId"] = "userclaim___::" + md5_id;
|
|
|
|
entity["openaireId"] = "userclaim___::" + md5_id;
|
|
|
|
entity["title"] = resultEntity.title;
|
|
|
|
entity["title"] = (Array.isArray(resultEntity.title) && resultEntity.title.length > 0) ? resultEntity.title[0] : resultEntity.title;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
if (resultEntity.result.authors && resultEntity.result.authors.length > 0) {
|
|
|
|
entity["authors"] = resultEntity.result.authors;
|
|
|
|
}
|
|
|
|
if (resultEntity.result.publisher) {
|
|
|
|
entity["publisher"] = resultEntity.result.publisher;
|
|
|
|
}
|
|
|
|
if (resultEntity.result.description) {
|
|
|
|
entity["description"] = resultEntity.result.description;
|
|
|
|
}
|
|
|
|
// entity["language"]=""; no info
|
|
|
|
entity["type"] = resultEntity.type;
|
|
|
|
if (resultEntity.result.source == "crossref" || resultEntity.result.source == "datacite") {
|
|
|
|
entity["pids"] = [];//{type:string, value:string}[];
|
|
|
|
entity["pids"].push({type: "doi", value: resultEntity.id})
|
|
|
|
}
|
|
|
|
entity["licenseCode"] = resultEntity.result.accessRights;
|
|
|
|
if (resultEntity.result.accessRights == "EMBARGO") {
|
|
|
|
entity["embargoEndDate"] = resultEntity.result.embargoEndDate;
|
|
|
|
}
|
|
|
|
if (resultEntity.type == "publication") {
|
|
|
|
entity["resourceType"] = "0001";
|
|
|
|
} else if (resultEntity.type == "dataset") {
|
|
|
|
entity["resourceType"] = "0021";
|
|
|
|
} else if (resultEntity.type == "software") {
|
|
|
|
entity["resourceType"] = "0029";
|
|
|
|
} else if (resultEntity.type == "other") {
|
|
|
|
entity["resourceType"] = "0020";
|
|
|
|
}
|
|
|
|
entity["url"] = resultEntity.result.url;
|
|
|
|
entity["hostedById"] = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
|
|
|
|
if (resultEntity.result.source == "crossref") {
|
|
|
|
entity["collectedFromId"] = "openaire____::crossref";
|
|
|
|
} else if (resultEntity.result.source == "datacite") {
|
|
|
|
entity["collectedFromId"] = "openaire____::datacite";
|
|
|
|
} else if (resultEntity.result.source == "orcid") {
|
|
|
|
entity["collectedFromId"] = "openaire____::orcid";
|
|
|
|
} else if (resultEntity.result.source == "orpenaire") {
|
|
|
|
entity["collectedFromId"] = "openaire____::driver";
|
|
|
|
}
|
|
|
|
for (let i = 0; i < results.length; i++) {
|
|
|
|
if (results[i].project) {
|
|
|
|
if (!entity["linksToProjects"]) {
|
|
|
|
entity["linksToProjects"] = [];
|
|
|
|
}
|
|
|
|
let project: ClaimEntity = results[i];
|
|
|
|
entity["linksToProjects"].push("info:eu-repo/grantAgreement/" + project.project.funderName + "/" + project.project.fundingLevel0 + "/" + project.project.code + "/" + project.project.jurisdiction + "/" + project.title + "/" + project.project.acronym);
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
} else if (results[i].context) {
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
if (!entity["contexts"]) {
|
|
|
|
entity["contexts"] = [];
|
|
|
|
}
|
|
|
|
let context: ClaimEntity = results[i];
|
|
|
|
entity["contexts"].push(context.context.concept.id);
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
// var json = JSON.stringify(entity);
|
|
|
|
//console.log("\nJSON:\n"+json);
|
|
|
|
return entity;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
confirmOpen() {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.alert.cancelButton = true;
|
|
|
|
this.alert.okButton = true;
|
2019-07-23 14:23:12 +02:00
|
|
|
this.alert.alertTitle = "";//"Final Confirmation notice";
|
|
|
|
this.alert.okButtonLeft = false;
|
|
|
|
// this.alert.message = "<div>All the links you provided will be published in the OpenAIRE platform. " +
|
|
|
|
// "<br>Make sure you have checked all the information you provided. In some cases some links take more time to be published. " +
|
|
|
|
// "<br>For more information please check the linking status in My-Links page. " +
|
|
|
|
// "<br><br>Do you confirm the information you provide are valid?</div>";
|
|
|
|
this.alert.okButtonText = "CONFIRM";
|
|
|
|
this.alert.cancelButtonText = "CANCEL";
|
2017-12-19 13:53:46 +01:00
|
|
|
this.alert.open();
|
|
|
|
}
|
2019-07-23 14:23:12 +02:00
|
|
|
|
|
|
|
confirmClose() {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.insertActions();
|
|
|
|
}
|
2019-02-18 15:00:43 +01:00
|
|
|
|
2019-07-23 14:23:12 +02:00
|
|
|
private static handleError(message: string, error) {
|
|
|
|
|
|
|
|
console.error("Insert Claim (component): " + message, error);
|
2019-02-18 15:00:43 +01:00
|
|
|
}
|
2019-08-27 15:19:58 +02:00
|
|
|
|
|
|
|
getButtonClass(){
|
|
|
|
// [class]="(((sources.length>0||inlineEntity) && results.length > 0 && (!claiming && errors.length == 0))?' ':'uk-disabled')+ ' uk-button uk-button-large uk-text-center'+((defaultColors)?'':'')">CONFIRM LINKING
|
|
|
|
// <span class=" uk-margin-small-top uk-icon uk-float-right uk-text-bold uk-margin-small-right"> }
|
|
|
|
// [class]="(((sources.length>0||inlineEntity) && results.length > 0 && (!claiming && errors.length == 0))?'linksbaskettitlesPortalColor ':'uk-disabled')+ ' linksbaskettitles uk-padding-small uk-text-center'">CONFIRM LINKING
|
|
|
|
// <span class="uk-icon uk-float-right uk-text-bold uk-margin-small-right">
|
|
|
|
let buttonClass= "";
|
|
|
|
if((this.sources.length>0||this.inlineEntity) && this.results.length > 0 && (!this.claiming && this.errors.length == 0)){
|
|
|
|
if(this.defaultColors){
|
|
|
|
buttonClass+=" linksbaskettitlesPortalColor ";
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
buttonClass+=" uk-disabled ";
|
|
|
|
|
|
|
|
}
|
|
|
|
if(this.defaultColors){
|
|
|
|
buttonClass+=" linksbaskettitles uk-padding-small ";
|
|
|
|
}else{
|
|
|
|
buttonClass+=" uk-button uk-button-large ";
|
|
|
|
}
|
|
|
|
return buttonClass + "uk-text-center ";
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2019-08-27 15:19:58 +02:00
|
|
|
|