|
|
@ -156,13 +156,14 @@ export class ClaimInsertComponent {
|
|
|
|
this.loading.open();
|
|
|
|
this.loading.open();
|
|
|
|
let claims: ClaimRecord2Insert[] = [];
|
|
|
|
let claims: ClaimRecord2Insert[] = [];
|
|
|
|
let directclaims: DirectIndexRecord[] = [];
|
|
|
|
let directclaims: DirectIndexRecord[] = [];
|
|
|
|
|
|
|
|
let idSuffix = (new Date()).getTime() + "";
|
|
|
|
let dashboard = this.properties.environment+"_"+this.properties.dashboard + (this.communityId?("_"+this.communityId):'');
|
|
|
|
let dashboard = this.properties.environment+"_"+this.properties.dashboard + (this.communityId?("_"+this.communityId):'');
|
|
|
|
for (let j = 0; j < this.sources.length; j++) { // if an external result -> direct insert in the index
|
|
|
|
for (let j = 0; j < this.sources.length; j++) { // if an external result -> direct insert in the index
|
|
|
|
const result: ClaimEntity = this.sources[j];
|
|
|
|
const result: ClaimEntity = this.sources[j];
|
|
|
|
if (result.result && ["crossref", "datacite", "orcid"].indexOf(result.result.source) != -1) {
|
|
|
|
if (result.result && ["crossref", "datacite", "orcid"].indexOf(result.result.source) != -1) {
|
|
|
|
directclaims.push({
|
|
|
|
directclaims.push({
|
|
|
|
"id": result.id,
|
|
|
|
"id": result.id,
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(result, this.results)
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(result, this.results, idSuffix)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -173,12 +174,12 @@ export class ClaimInsertComponent {
|
|
|
|
if (this.sources.length > 0) {
|
|
|
|
if (this.sources.length > 0) {
|
|
|
|
directclaims.push({
|
|
|
|
directclaims.push({
|
|
|
|
"id": entity.id,
|
|
|
|
"id": entity.id,
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(entity, this.sources)
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(entity, this.sources, idSuffix)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else if (this.inlineEntity) {
|
|
|
|
} else if (this.inlineEntity) {
|
|
|
|
directclaims.push({
|
|
|
|
directclaims.push({
|
|
|
|
"id": entity.id,
|
|
|
|
"id": entity.id,
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(entity, [this.inlineEntity])
|
|
|
|
"record": ClaimInsertComponent.createDirectClaim(entity, [this.inlineEntity], idSuffix)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -187,11 +188,11 @@ export class ClaimInsertComponent {
|
|
|
|
for (let j = 0; j < this.sources.length; j++) {
|
|
|
|
for (let j = 0; j < this.sources.length; j++) {
|
|
|
|
const result: ClaimEntity = this.sources[j]; // this is a research result
|
|
|
|
const result: ClaimEntity = this.sources[j]; // this is a research result
|
|
|
|
if (entity.result) {
|
|
|
|
if (entity.result) {
|
|
|
|
claims.push(ClaimInsertComponent.createResultClaim(result, entity, user.email, dashboard));
|
|
|
|
claims.push(ClaimInsertComponent.createResultClaim(result, entity, user.email, dashboard, idSuffix));
|
|
|
|
} else if (entity.context) {
|
|
|
|
} else if (entity.context) {
|
|
|
|
claims.push(ClaimInsertComponent.createContextClaim(result, entity, user.email, dashboard));
|
|
|
|
claims.push(ClaimInsertComponent.createContextClaim(result, entity, user.email, dashboard, idSuffix));
|
|
|
|
} else if (entity.project) {
|
|
|
|
} else if (entity.project) {
|
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(result, entity, user.email, dashboard));
|
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(result, entity, user.email, dashboard, idSuffix));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.infoToLog.push([ result.title?result.title: result.id, entity.title?entity.title:entity.id]);
|
|
|
|
this.infoToLog.push([ result.title?result.title: result.id, entity.title?entity.title:entity.id]);
|
|
|
|
|
|
|
|
|
|
|
@ -201,15 +202,15 @@ export class ClaimInsertComponent {
|
|
|
|
if (this.inlineEntity.result) {
|
|
|
|
if (this.inlineEntity.result) {
|
|
|
|
if (entity.result) {
|
|
|
|
if (entity.result) {
|
|
|
|
|
|
|
|
|
|
|
|
claims.push(ClaimInsertComponent.createResultClaim(this.inlineEntity, entity, user.email, dashboard));
|
|
|
|
claims.push(ClaimInsertComponent.createResultClaim(this.inlineEntity, entity, user.email, dashboard, idSuffix));
|
|
|
|
} else if (entity.context) {
|
|
|
|
} else if (entity.context) {
|
|
|
|
claims.push(ClaimInsertComponent.createContextClaim(this.inlineEntity, entity, user.email, dashboard));
|
|
|
|
claims.push(ClaimInsertComponent.createContextClaim(this.inlineEntity, entity, user.email, dashboard, idSuffix));
|
|
|
|
} else if (entity.project) {
|
|
|
|
} else if (entity.project) {
|
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(this.inlineEntity, entity, user.email, dashboard));
|
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(this.inlineEntity, entity, user.email, dashboard, idSuffix));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (this.inlineEntity.project) {
|
|
|
|
} else if (this.inlineEntity.project) {
|
|
|
|
if (entity.result) {
|
|
|
|
if (entity.result) {
|
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(entity, this.inlineEntity, user.email, dashboard));
|
|
|
|
claims.push(ClaimInsertComponent.createProjectClaim(entity, this.inlineEntity, user.email, dashboard, idSuffix));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -390,7 +391,7 @@ export class ClaimInsertComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static createContextClaim(resultEntity: ClaimEntity, contextEntity: ClaimEntity, user: any, dashboard:string): ClaimRecord2Insert {
|
|
|
|
private static createContextClaim(resultEntity: ClaimEntity, contextEntity: ClaimEntity, user: any, dashboard:string, idSuffix:string): ClaimRecord2Insert {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
claimedBy: user,
|
|
|
|
claimedBy: user,
|
|
|
|
sourceId: contextEntity.context.concept.id,
|
|
|
|
sourceId: contextEntity.context.concept.id,
|
|
|
@ -403,11 +404,12 @@ export class ClaimInsertComponent {
|
|
|
|
targetCollectedFrom: resultEntity.result.source,
|
|
|
|
targetCollectedFrom: resultEntity.result.source,
|
|
|
|
targetAccessRights: resultEntity.result.accessRights,
|
|
|
|
targetAccessRights: resultEntity.result.accessRights,
|
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(resultEntity),
|
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(resultEntity),
|
|
|
|
claimedInDashboard : dashboard
|
|
|
|
claimedInDashboard : dashboard,
|
|
|
|
|
|
|
|
idSuffix : idSuffix
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static createProjectClaim(resultEntity: ClaimEntity, projectEntity: ClaimEntity, user: any, dashboard:string): ClaimRecord2Insert {
|
|
|
|
private static createProjectClaim(resultEntity: ClaimEntity, projectEntity: ClaimEntity, user: any, dashboard:string, idSuffix:string): ClaimRecord2Insert {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
claimedBy: user,
|
|
|
|
claimedBy: user,
|
|
|
|
sourceId: projectEntity.id,
|
|
|
|
sourceId: projectEntity.id,
|
|
|
@ -420,11 +422,12 @@ export class ClaimInsertComponent {
|
|
|
|
targetCollectedFrom: resultEntity.result.source,
|
|
|
|
targetCollectedFrom: resultEntity.result.source,
|
|
|
|
targetAccessRights: resultEntity.result.accessRights,
|
|
|
|
targetAccessRights: resultEntity.result.accessRights,
|
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(resultEntity),
|
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(resultEntity),
|
|
|
|
claimedInDashboard : dashboard
|
|
|
|
claimedInDashboard : dashboard,
|
|
|
|
|
|
|
|
idSuffix : idSuffix
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static createResultClaim(inlineResult: ClaimEntity, resultEntity: ClaimEntity, user: string, dashboard:string): ClaimRecord2Insert {
|
|
|
|
private static createResultClaim(inlineResult: ClaimEntity, resultEntity: ClaimEntity, user: string, dashboard:string, idSuffix:string): ClaimRecord2Insert {
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
claimedBy: user,
|
|
|
|
claimedBy: user,
|
|
|
@ -438,7 +441,9 @@ export class ClaimInsertComponent {
|
|
|
|
targetCollectedFrom: inlineResult.result.source,
|
|
|
|
targetCollectedFrom: inlineResult.result.source,
|
|
|
|
targetAccessRights: inlineResult.result.accessRights,
|
|
|
|
targetAccessRights: inlineResult.result.accessRights,
|
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(inlineResult),
|
|
|
|
targetEmbargoEndDate: ClaimInsertComponent.getEmbargoEndDate(inlineResult),
|
|
|
|
claimedInDashboard : dashboard
|
|
|
|
claimedInDashboard : dashboard,
|
|
|
|
|
|
|
|
idSuffix : idSuffix
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -448,12 +453,13 @@ export class ClaimInsertComponent {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static createOpenAIREId(id, idSuffix:string):string {
|
|
|
|
static createDirectClaim(resultEntity: ClaimEntity, results: ClaimEntity[]) {
|
|
|
|
return id.indexOf( "::" ) == -1 ? ("userclaim___::" + Md5.hashStr(id + idSuffix)):id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static createDirectClaim(resultEntity: ClaimEntity, results: ClaimEntity[], idSuffix:string) {
|
|
|
|
let entity = {};
|
|
|
|
let entity = {};
|
|
|
|
const md5_id = Md5.hashStr(resultEntity.id);
|
|
|
|
entity["originalId"] = this.createOpenAIREId(resultEntity.id, idSuffix);
|
|
|
|
entity["originalId"] = "userclaim___::" + md5_id;
|
|
|
|
entity["openaireId"] = this.createOpenAIREId(resultEntity.id, idSuffix);
|
|
|
|
entity["openaireId"] = "userclaim___::" + md5_id;
|
|
|
|
|
|
|
|
entity["title"] = resultEntity.title;
|
|
|
|
entity["title"] = resultEntity.title;
|
|
|
|
entity["title"] = (Array.isArray(resultEntity.title) && resultEntity.title.length > 0) ? resultEntity.title[0] : resultEntity.title;
|
|
|
|
entity["title"] = (Array.isArray(resultEntity.title) && resultEntity.title.length > 0) ? resultEntity.title[0] : resultEntity.title;
|
|
|
|
|
|
|
|
|
|
|
|