[Library | new-theme]:

1. searchDataproviders.service.ts & searchProjects.service.ts: Updated parsing of description (like in services for landing, use ParsingFunctions.parseDescription()).
2. searchFields.ts: Added in OpenaireEntities enum values for type names in files.
3. open-aire-jsonld-converter.service.ts:
   a. Updated parsing of description in methods convertProject() and convertDatasource() - use ParsingFunctions.parseDescription().
   b. In convertDatasource() method set "otherUrl" (not push it) in sameAs (on next commit, dataprovider landing sents all provenance urls as array).
4. jsonld-document-serializer.service.ts: [Bug fix] Added check in "serializeDescription()" method.
This commit is contained in:
Konstantina Galouni 2022-05-05 20:29:55 +03:00
parent 0168c5e894
commit 0f505c682a
6 changed files with 45 additions and 23 deletions

View File

@ -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) + "...";
}

View File

@ -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) + "...";
}

View File

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

View File

@ -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) {

View File

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

View File

@ -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",
}