Compare commits

...

4 Commits

4 changed files with 36 additions and 31 deletions

View File

@ -92,6 +92,7 @@ export class ClaimRecord2Insert {
targetAccessRights: string; targetAccessRights: string;
targetEmbargoEndDate: string; targetEmbargoEndDate: string;
claimedInDashboard: string; claimedInDashboard: string;
idSuffix:string;
constructor() { constructor() {

View File

@ -364,7 +364,7 @@ export class DisplayClaimsComponent implements OnInit, OnDestroy {
if (claimDateStr < lastUpdateDateStr) { if (claimDateStr < lastUpdateDateStr) {
return true; return true;
} else { } else {
return claim.target.collectedFrom != "infrastruct_::openaire" && claim.indexed; return claim.target.collectedFrom != "infrastruct_::openaire";
} }
} }

View File

@ -58,22 +58,20 @@ export class SearchDataciteService {
entity.result.journal = null; entity.result.journal = null;
entity.result.DOI = item.attributes.doi; entity.result.DOI = item.attributes.doi;
entity.id = item.attributes.doi; entity.id = item.attributes.doi;
entity.title = item.attributes.title; entity.title = Array.isArray(item.attributes.titles) && item.attributes.titles[0].title?item.attributes.titles[0].title:null;
entity.result.url = properties.doiURL + item.attributes.doi; entity.result.url = properties.doiURL + item.attributes.doi;
entity.result.source = 'datacite'; entity.result.source = 'datacite';
entity.type = 'dataset'; entity.type = 'dataset';
entity.result.date = item.attributes.published; entity.result.date = item.attributes.publicationYear;
entity.result.accessRights = "OPEN"; entity.result.accessRights = "OPEN";
entity.result.publisher = item.attributes['container-title']; entity.result.publisher = item.attributes['publisher'];
entity.result.journal = null; entity.result.journal = null;
entity.result.record = item; entity.result.record = item;
if (item.attributes.author) { if (item.attributes.creators) {
entity.result.authors = []; entity.result.authors = [];
for (let j = 0; j < item.attributes.author.length; j++) { for (let j = 0; j < item.attributes.creators.length; j++) {
const author = item.attributes.author[j]; const author = item.attributes.creators[j].name;
if(author.family || author.literal) { entity.result.authors.push(author);
entity.result.authors.push((author.family) ? author.family + (author.given ? ', ' + author.given : '') : author.literal);
}
} }
} }
results.push(entity); results.push(entity);

View File

@ -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;