diff --git a/services/searchDataproviders.service.ts b/services/searchDataproviders.service.ts index 3e7235bb..d4a98fcb 100644 --- a/services/searchDataproviders.service.ts +++ b/services/searchDataproviders.service.ts @@ -8,10 +8,12 @@ import {RefineResultsUtils} from './servicesUtils/refineResults.class'; import {StringUtils} from '../utils/string-utils.class'; import{EnvProperties} from '../utils/properties/env-properties'; import {map} from "rxjs/operators"; +import {ParsingFunctions} from "../landingPages/landing-utils/parsingFunctions.class"; @Injectable() export class SearchDataprovidersService { private sizeOfDescription: number = 270; + public parsingFunctions: ParsingFunctions = new ParsingFunctions(); constructor(private http: HttpClient ) {} @@ -302,12 +304,8 @@ export class SearchDataprovidersService { result['type'] = this.getDataproviderType(resData); - if(!Array.isArray(resData['description'])) { - result.description = (resData['description']) ? String(resData['description']) : ""; - } else { - result.description = (resData['description'][0]) ? String(resData['description'][0]) : ""; - } - + let abstracts = this.parsingFunctions.parseDescription(resData.description); + result.description = abstracts.length > 0 ? abstracts[0] : ""; if (result.description && result.description.length > this.sizeOfDescription) { result.description = result.description.substring(0, this.sizeOfDescription) + "..."; } diff --git a/services/searchProjects.service.ts b/services/searchProjects.service.ts index 5697e29b..6992ec36 100644 --- a/services/searchProjects.service.ts +++ b/services/searchProjects.service.ts @@ -8,11 +8,13 @@ import {RefineResultsUtils} from './servicesUtils/refineResults.class'; import{EnvProperties} from '../utils/properties/env-properties'; import {StringUtils} from '../utils/string-utils.class'; import {map} from "rxjs/operators"; +import {ParsingFunctions} from "../landingPages/landing-utils/parsingFunctions.class"; @Injectable() export class SearchProjectsService { private sizeOfDescription: number = 270; + public parsingFunctions: ParsingFunctions = new ParsingFunctions(); - constructor(private http: HttpClient ) {} + constructor(private http: HttpClient ) {} searchProjects (params: string, refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any { @@ -152,12 +154,8 @@ export class SearchProjectsService { result.id = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; - if(!Array.isArray(resData['summary'])) { - result.description = (resData['summary']) ? String(resData['summary']) : ""; - } else { - result.description = (resData['summary'][0]) ? String(resData['summary'][0]) : ""; - } - + let abstracts = this.parsingFunctions.parseDescription(resData.summary); + result.description = abstracts.length > 0 ? abstracts[0] : ""; if (result.description && result.description.length > this.sizeOfDescription) { result.description = result.description.substring(0, this.sizeOfDescription) + "..."; } diff --git a/sharedComponents/schema2jsonld/schema2jsonld.component.ts b/sharedComponents/schema2jsonld/schema2jsonld.component.ts index a008f9cd..6729c522 100644 --- a/sharedComponents/schema2jsonld/schema2jsonld.component.ts +++ b/sharedComponents/schema2jsonld/schema2jsonld.component.ts @@ -13,7 +13,7 @@ export class Schema2jsonldComponent implements OnInit, OnChanges { @Input() data; // for project, organization, datasource @Input() URL; @Input() logoURL; // for home, search - @Input() otherURL; //for project, datasource + @Input() otherURL; //for datasource @Input() name; @Input() searchAction = false; @Input() type = 'result'; diff --git a/sharedComponents/schema2jsonld/service/jsonld-document-serializer.service.ts b/sharedComponents/schema2jsonld/service/jsonld-document-serializer.service.ts index 69114f1a..81f5c241 100644 --- a/sharedComponents/schema2jsonld/service/jsonld-document-serializer.service.ts +++ b/sharedComponents/schema2jsonld/service/jsonld-document-serializer.service.ts @@ -115,7 +115,9 @@ export class JsonldDocumentSerializerService { } serializeDescription(doc, buffer){ - buffer["description"] = doc.description[0]; + if(doc.description && doc.description[0]) { + buffer["description"] = doc.description[0]; + } } serializeIdentifier(doc, buffer){ if (doc.identifier && doc.identifier.length == 1) { diff --git a/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts b/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts index d68a3613..e53c5183 100644 --- a/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts +++ b/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts @@ -124,10 +124,18 @@ export class OpenAireJsonldConverterService { funder.title = project.funding.funderName; doc.funder = funder; doc.url = URL; - doc.id = URL; - doc["description"] = []; - doc["description"].push(project.description?project.description: ("project" + (project.title?"," + project.title:"") + (project.funding && project.funding.funderName?", funder: " + project.funding.funderName:"") + (project.acronym?"," + project.acronym:""))); - doc.sameAs =[project.url]; + doc.id = URL; + + doc["description"] = []; + if(project.description) { + let parsing = new ParsingFunctions(); + let abstracts = parsing.parseDescription(project.description); + doc["description"] = [abstracts && abstracts[0] ?(abstracts[0].substring(0,4997)+(abstracts[0].substring(0,4997).length == 4997?'...':'')):"" ]; + } else { + doc["description"].push(("project" + (project.title ? "," + project.title : "") + (project.funding && project.funding.funderName ? ", funder: " + project.funding.funderName : "") + (project.acronym ? "," + project.acronym : ""))); + } + + doc.sameAs =[project.url]; return doc; } @@ -155,13 +163,20 @@ convertDatasource(datasource: any, URL, otherUrl): Organization { } doc.url = URL; doc.id = URL; - doc["description"] = []; - doc["description"].push(datasource.description?datasource.description:datasource.title.name?datasource.title.name:datasource.officialName); + + doc["description"] = []; + if(datasource.description) { + let parsing = new ParsingFunctions(); + let abstracts = parsing.parseDescription(datasource.description); + doc["description"] = [abstracts && abstracts[0] ?(abstracts[0].substring(0,4997)+(abstracts[0].substring(0,4997).length == 4997?'...':'')):"" ]; + } else { + doc["description"].push(datasource.title.name?datasource.title.name:datasource.officialName); + } if(datasource.oaiPmhURL || otherUrl || datasource.title.url){ doc.sameAs = []; if(otherUrl){ - doc.sameAs.push(otherUrl); + doc.sameAs = otherUrl; } if(datasource.oaiPmhURL){ doc.sameAs.push(datasource.oaiPmhURL); diff --git a/utils/properties/searchFields.ts b/utils/properties/searchFields.ts index 50af1ce1..ebcbdfa7 100644 --- a/utils/properties/searchFields.ts +++ b/utils/properties/searchFields.ts @@ -786,5 +786,14 @@ export enum OpenaireEntities { PROJECT = "Project", ORGANIZATION = "Organization", DATASOURCE = "Datasource", - COMMUNITY = "Research community" + COMMUNITY = "Research community", + + RESULTS_FILE = "research-products", + PUBLICATIONS_FILE = "publications", + DATASETS_FILE = "research-data", + SOFTWARE_FILE = "research-software", + OTHER_FILE = "other-research-products", + PROJECTS_FILE = "projects", + ORGANIZATIONS_FILE = "organizations", + DATASOURCES_FILE = "datasources", }