import {Injectable} from '@angular/core'; import {HttpClient} from "@angular/common/http"; import {DeletedByInferenceResult} from '../../../utils/entities/deletedByInferenceResult'; import {EnvProperties} from '../../../utils/properties/env-properties'; import {ParsingFunctions} from '../parsingFunctions.class'; import {map} from "rxjs/operators"; @Injectable() export class DeletedByInferenceService { private sizeOfDescription: number = 270; constructor(private http: HttpClient ) { this.parsingFunctions = new ParsingFunctions(); } public parsingFunctions: ParsingFunctions; getDeletedByInferencePublications (id: string, properties:EnvProperties):any { let url = properties.searchAPIURLLAst + 'deletedByInferencePublications/' +id+"?format=json"; let key = url; return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) //.map(res => res.json()) .pipe(map(res => res['result']['metadata']['oaf:entity'])) .pipe(map(res => this.parseDeletedByInferencePublications(res, properties))); } parseDeletedByInferencePublications (result: any, properties: EnvProperties): DeletedByInferenceResult { /*title, authors, abstract, List of projects, PIDs, collectedfrom (link pointing to the download url), access rights*/ //let publications: DeletedByInferenceResult[] = []; //if(results) { let publication : DeletedByInferenceResult; //let length = Array.isArray(results) ? results.length : 1; //for(let i=0; i this.sizeOfDescription) { publication.description = publication.description.substring(0, this.sizeOfDescription) + "..."; } if(data['bestaccessright'] && data['bestaccessright'].hasOwnProperty("classid")) { publication.accessMode = data['bestaccessright'].classid; } } if(result['oaf:result'] && result['oaf:result']['title']) { let title = result['oaf:result']['title']; if(Array.isArray(title)) { publication.title = title[0].content; } else { publication.title = title.content; } } if(result['oaf:result'] && result['oaf:result']['language']) { publication.languages = this.parsingFunctions.parseLanguages(result['oaf:result']['language']); } if(result['oaf:result'] && result['oaf:result']['country']) { publication.countries = this.parsingFunctions.parseCountries(result['oaf:result']['country']); } if(result['oaf:result'] && result['oaf:result']['rels'] && result['oaf:result']['rels']['rel']) { let relation; let length = Array.isArray(result['oaf:result']['rels']['rel']) ? result['oaf:result']['rels']['rel'].length : 1; for(let i=0; i(); let types = new Set(); publication.hostedBy_collectedFrom = new Array<{"downloadName": string, "downloadUrl": string[], "collectedName": string, "collectedId": string, "accessMode": string[], "bestAccessMode": string, "type": string, "year":string}>(); let counter = 0; let instance; let length = Array.isArray(children['instance']) ? children['instance'].length : 1; for(let i=0; i(); } let authors = result['oaf:result']['creator']; let length = Array.isArray(authors) ? authors.length : 1; for(let i=0; i