[new-search-json | WIP | CHANGED]: Updated parsing of organizations, projects (landing & search) and search data sources according to new JSON response schema.
This commit is contained in:
parent
bef6dda2c2
commit
82e8551129
|
@ -101,7 +101,7 @@ export class ParsingFunctions {
|
|||
if (fundingData.hasOwnProperty("funder")) {
|
||||
funding.funderShortname = fundingData['funder'].shortname;
|
||||
funding.funderName = fundingData['funder'].name;
|
||||
funding.funderJurisdiction = fundingData['funder'].jurisdiction;
|
||||
funding.funderJurisdiction = fundingData['funder'].jurisdiction?.code;
|
||||
}
|
||||
|
||||
funding.stream = this.addFundingLevel0(fundingData, funding.stream);
|
||||
|
@ -114,9 +114,8 @@ export class ParsingFunctions {
|
|||
}
|
||||
|
||||
addFundingLevel0(parent: string, fundingStream: string): string {
|
||||
if (parent.hasOwnProperty("funding_level_0")) {
|
||||
let level0 = parent['funding_level_0'];
|
||||
|
||||
if (parent.hasOwnProperty("level0") && parent['level0'].name) {
|
||||
let level0 = parent['level0'];
|
||||
fundingStream += (fundingStream) ? " ; " : "";
|
||||
fundingStream += level0.name;
|
||||
}
|
||||
|
@ -124,8 +123,8 @@ export class ParsingFunctions {
|
|||
}
|
||||
|
||||
addFundingLevel1(parent: string, fundingStream: string): string {
|
||||
if (parent.hasOwnProperty("funding_level_1")) {
|
||||
let level1 = parent['funding_level_1'];
|
||||
if (parent.hasOwnProperty("level1") && parent['level1'].name) {
|
||||
let level1 = parent['level1'];
|
||||
|
||||
// For projects' parsing
|
||||
if (level1.hasOwnProperty("parent")) {
|
||||
|
@ -139,8 +138,8 @@ export class ParsingFunctions {
|
|||
}
|
||||
|
||||
addFundingLevel2(parent: string, fundingStream: string): string {
|
||||
if (parent.hasOwnProperty("funding_level_2")) {
|
||||
let level2 = parent['funding_level_2'];
|
||||
if (parent.hasOwnProperty("level2") && parent['level2'].name) {
|
||||
let level2 = parent['level2'];
|
||||
|
||||
// For projects' parsing
|
||||
if (level2.hasOwnProperty("parent")) {
|
||||
|
@ -924,16 +923,23 @@ export class ParsingFunctions {
|
|||
|
||||
static parseRelCanonicalId(record, type) {
|
||||
try {
|
||||
if (record["result"]["metadata"]["oaf:entity"][("oaf:" + type)]["children"] && record["result"]["metadata"]["oaf:entity"][("oaf:" + type)]["children"][type]) {
|
||||
for (let child of record["result"]["metadata"]["oaf:entity"][("oaf:" + type)]["children"][type]) {
|
||||
return child["objidentifier"];
|
||||
if (record && record['links']) {
|
||||
let links = record['links'];
|
||||
let relLength = Array.isArray(links) ? links.length : 1;
|
||||
|
||||
for(let i=0; i<relLength; i++) {
|
||||
let relation = Array.isArray(links) ? links[i] : links;
|
||||
if (relation.hasOwnProperty("header")) {
|
||||
if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "merges" && relation['header'].relatedRecordType == type) {
|
||||
return relation['header'].relatedIdentifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// console.error(e);
|
||||
}
|
||||
return record["result"]["header"]["dri:objIdentifier"];
|
||||
|
||||
return record["header"]["id"];
|
||||
}
|
||||
|
||||
parseDescription(description, stripHTML: boolean = false): string {
|
||||
|
|
|
@ -102,7 +102,7 @@ export class OrganizationsDeletedByInferenceComponent {
|
|||
}
|
||||
|
||||
if(result.hasOwnProperty("country")) {
|
||||
preview.countries = [result['country'].classname];
|
||||
preview.countries = [result['country'].label];
|
||||
}
|
||||
|
||||
preview.resultType = 'organization';
|
||||
|
|
|
@ -27,11 +27,12 @@ export class ProjectService {
|
|||
|
||||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['result']['metadata']['oaf:entity']['oaf:project']))
|
||||
.pipe(map(res => [res,
|
||||
res['fundingtree'],
|
||||
res['rels']['rel']]))
|
||||
.pipe(map(res => this.parseProjectInfo(res, properties)));
|
||||
// .pipe(map(res => res))
|
||||
.pipe(map(res => [res['project'],
|
||||
res['project']['funding'],
|
||||
res['links'],
|
||||
res['header']['id']]))
|
||||
.pipe(map(res => this.parseProjectInfo(res, properties)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,7 @@ export class ProjectService {
|
|||
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
||||
//.map(res => <any> res.json())
|
||||
.pipe(map(res => res['results'][0]))
|
||||
.pipe(map(res => [res['result']['metadata']['oaf:entity']['oaf:project'], res['result']['header']['dri:objIdentifier']]))
|
||||
.pipe(map(res => [res['result']['metadata']['oaf:entity']['oaf:project'], res['header']['id']]))
|
||||
.pipe(map(res => [res[0],
|
||||
res[0]['fundingtree'],
|
||||
res[0]['rels']['rel'], res[1]]))
|
||||
|
@ -189,13 +190,12 @@ export class ProjectService {
|
|||
this.projectInfo.organizations = [];
|
||||
|
||||
if (!Array.isArray(data[2])) {
|
||||
if (data[2].hasOwnProperty("to") && data[2]['to'].class && data[2]['to'].class.toLowerCase() == "hasparticipant") {
|
||||
let country: string = "";
|
||||
if (data[2].hasOwnProperty("header") && data[2]['header'].relationClass && data[2]['header'].relationClass.toLowerCase() == "hasparticipant") { let country: string = "";
|
||||
let acronym: string = "";
|
||||
let name: string = "";
|
||||
let id: string = "";
|
||||
if(data[2].hasOwnProperty("country")) {
|
||||
country = data[2].country.classname;
|
||||
country = data[2].country.label;
|
||||
}
|
||||
if (data[2].hasOwnProperty("legalshortname")) {
|
||||
acronym = data[2].legalshortname;
|
||||
|
@ -208,8 +208,8 @@ export class ProjectService {
|
|||
acronym = "[no title available]";
|
||||
}
|
||||
|
||||
if (data[2].hasOwnProperty("to")) {
|
||||
id = data[2]['to'].content;
|
||||
if (data[2].hasOwnProperty("header")) {
|
||||
id = data[2]['header'].relatedIdentifier;
|
||||
}
|
||||
|
||||
this.projectInfo.organizations.push({"country": country, "acronym": acronym, "name": name, "id": id});
|
||||
|
@ -220,9 +220,8 @@ export class ProjectService {
|
|||
let acronym: string = "";
|
||||
let name: string = "";
|
||||
let id: string = "";
|
||||
if (data[2][i].hasOwnProperty("to") && data[2][i]['to'].class && data[2][i]['to'].class.toLowerCase() == "hasparticipant") {
|
||||
if(data[2][i].hasOwnProperty("country")) {
|
||||
country = data[2][i].country.classname;
|
||||
if (data[2][i].hasOwnProperty("header") && data[2][i]['header'].relationClass && data[2][i]['header'].relationClass.toLowerCase() == "hasparticipant") { if(data[2][i].hasOwnProperty("country")) {
|
||||
country = data[2][i].country.label;
|
||||
}
|
||||
if (data[2][i].hasOwnProperty("legalshortname")) {
|
||||
acronym = data[2][i].legalshortname;
|
||||
|
@ -234,8 +233,8 @@ export class ProjectService {
|
|||
acronym = "[no title available]";
|
||||
}
|
||||
|
||||
if (data[2][i].hasOwnProperty("to")) {
|
||||
id = data[2][i]['to'].content;
|
||||
if (data[2][i].hasOwnProperty("header")) {
|
||||
id = data[2][i]['header'].relatedIdentifier;
|
||||
}
|
||||
|
||||
this.projectInfo.organizations.push({"country": country, "acronym": acronym, "name": name, "id": id});
|
||||
|
|
|
@ -48,170 +48,84 @@ export class OrganizationService {
|
|||
return throwError(error || 'Server error');
|
||||
}
|
||||
|
||||
parseOrganizationInfo (data: any):any {
|
||||
this.organizationInfo = new OrganizationInfo();
|
||||
this.organizationInfo.relcanId = ParsingFunctions.parseRelCanonicalId(data,"organization");
|
||||
let organization;
|
||||
let relations;
|
||||
if(data != null) {
|
||||
organization = data['result']['metadata']['oaf:entity']['oaf:organization'];
|
||||
this.organizationInfo.objIdentifier = data["result"]["header"]["dri:objIdentifier"];
|
||||
if(this.organizationInfo.objIdentifier.startsWith("openorgs____::")) {
|
||||
this.organizationInfo.relcanId = this.organizationInfo.objIdentifier;
|
||||
}
|
||||
relations = data['result']['metadata']['oaf:entity']['oaf:organization']['rels']['rel'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(organization != null) {
|
||||
|
||||
if(organization.hasOwnProperty("websiteurl")) {
|
||||
this.organizationInfo.title = {"name": organization.legalshortname, "url": organization.websiteurl};
|
||||
} else {
|
||||
this.organizationInfo.title = {"name": organization.legalshortname, "url": ''};
|
||||
}
|
||||
|
||||
this.organizationInfo.name = organization.legalname;
|
||||
|
||||
if(!this.organizationInfo.title.name || this.organizationInfo.title.name == '') {
|
||||
this.organizationInfo.title.name = this.organizationInfo.name;
|
||||
}
|
||||
|
||||
if(organization.hasOwnProperty("country")) {
|
||||
this.organizationInfo.country = organization['country'].classname;
|
||||
}
|
||||
|
||||
if (organization.hasOwnProperty("children")) {
|
||||
let children = organization['children'];
|
||||
if( children.hasOwnProperty("organization")) {
|
||||
this.organizationInfo.deletedByInferenceIds = [];
|
||||
let length = Array.isArray(children['organization']) ? children['organization'].length : 1;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
let result = Array.isArray(children['organization']) ? children['organization'][i] : children['organization'];
|
||||
this.organizationInfo.deletedByInferenceIds.push(result.objidentifier);
|
||||
}
|
||||
}
|
||||
this.organizationInfo.children = children['organization'];
|
||||
}
|
||||
|
||||
if(organization['pid']) {
|
||||
this.organizationInfo.identifiers = this.parsingFunctions.parseIdentifiers(organization['pid']);
|
||||
}
|
||||
}
|
||||
|
||||
//Comment Parsing Projects info
|
||||
/*
|
||||
if(data[1] != null) {
|
||||
|
||||
let counter;
|
||||
let length = relations.length!=undefined ? relations.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let relation = relations.length!=undefined ? relations[i] : relations;
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
if(relation['to'].class == "isParticipant") {
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
if(relation['funding'].hasOwnProperty("funder")) {
|
||||
if(this.organizationInfo.projects == undefined) {
|
||||
this.organizationInfo.projects = new Map<string,
|
||||
{ "name": string, "id": string, "code": string,
|
||||
"acronym": string, "funder": string, "funderId": string,
|
||||
"fundingStream": string, "fundingLevel1": string, "fundingLevel2": string,
|
||||
"sc39": string, "startDate": string, "endDate": string }[]>();
|
||||
}
|
||||
|
||||
if(!this.organizationInfo.projects.has(relation['funding']['funder'].name)) {
|
||||
this.organizationInfo.projects.setValues(relation['funding']['funder'].name,
|
||||
new Array<{ "name": string, "id": string, "code": string,
|
||||
"acronym": string, "funder": string, "funderId": string,
|
||||
"fundingStream": string, "fundingLevel1": string, "fundingLevel2": string,
|
||||
"sc39": string, "startDate": string, "endDate": string }>());
|
||||
}
|
||||
|
||||
counter = this.organizationInfo.projects.get(relation['funding']['funder'].name).length;
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter] =
|
||||
{ "name": "", "id": "", "code": "",
|
||||
"acronym": "", "funder": "", "funderId": "",
|
||||
"fundingStream": "", "fundingLevel1": "", "fundingLevel2": "",
|
||||
"sc39": "", "startDate": "", "endDate": "" };
|
||||
|
||||
//let url = "";
|
||||
if(relation['to'].content != null && relation['to'].content != "") {
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['id'] = relation['to'].content;
|
||||
//url = OpenaireProperties.getsearchLinkToProject()+relation['to'].content;
|
||||
}
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['name'] = relation.title;
|
||||
//this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['url'] = url;
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['code'] = relation.code;
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['acronym'] = relation.acronym;
|
||||
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['funder'] = relation['funding']['funder'].shortname;
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['funderId'] = relation['funding']['funder'].id;
|
||||
if(relation['funding'].hasOwnProperty("funding_level_0")) {
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['fundingStream'] = relation['funding']['funding_level_0'].name;
|
||||
}
|
||||
if(relation['funding'].hasOwnProperty("funding_level_1")) {
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['fundingLevel1'] = relation['funding']['funding_level_1'].name;
|
||||
}
|
||||
if(relation['funding'].hasOwnProperty("funding_level_2")) {
|
||||
this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['fundingLevel2'] = relation['funding']['funding_level_2'].name;
|
||||
}
|
||||
//this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['sc39'] =
|
||||
//this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['startDate'] =
|
||||
//this.organizationInfo.projects.get(relation['funding']['funder'].name)[counter]['endDate'] =
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} /*else if(relation['to'].class == "isProvidedBy") {
|
||||
|
||||
if(this.organizationInfo.dataProviders == undefined) {
|
||||
this.organizationInfo.dataProviders = new Array<{ "name": string, "url": string, "type": string, "websiteUrl": string , "organizations": {"name": string, "url": string}[]}>();
|
||||
}
|
||||
|
||||
counter = this.organizationInfo.dataProviders.length;
|
||||
this.organizationInfo.dataProviders[counter] = { "name": "", "url": "", "type": "", "websiteUrl": "", "organizations": [] }
|
||||
|
||||
let url="";
|
||||
if(relation['to'].content != null && relation['to'].content != "") {
|
||||
url = OpenaireProperties.getsearchLinkToDataProvider()+relation['to'].content;
|
||||
}
|
||||
this.organizationInfo.dataProviders[counter]['name'] = relation.officialname;
|
||||
this.organizationInfo.dataProviders[counter]['url'] = url;
|
||||
if(relation.hasOwnProperty("datasourcetype")) {
|
||||
this.organizationInfo.dataProviders[counter]['type'] = relation['datasourcetype'].classname;
|
||||
}
|
||||
this.organizationInfo.dataProviders[counter]['websiteUrl'] = relation.websiteurl;
|
||||
}*/
|
||||
/* ----->
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
return this.organizationInfo;
|
||||
|
||||
parseOrganizationInfo (data: any):any {
|
||||
if(data == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
parseOrganizationNameAndUrl(organization: any): any {
|
||||
let title: {"name": string, "url": string} = {"name": "", "url": ""};
|
||||
this.organizationInfo = new OrganizationInfo();
|
||||
let organization;
|
||||
|
||||
if(organization != null) {
|
||||
if(organization.hasOwnProperty("websiteurl")) {
|
||||
title = {"name": organization.legalshortname, "url": organization.websiteurl};
|
||||
} else {
|
||||
title = {"name": organization.legalshortname, "url": ''};
|
||||
}
|
||||
if(data.hasOwnProperty("header")) {
|
||||
this.organizationInfo.relcanId = ParsingFunctions.parseRelCanonicalId(data,"organization");
|
||||
|
||||
if(title.name == '') {
|
||||
title.name = organization.legalname;
|
||||
}
|
||||
this.organizationInfo.objIdentifier = data["header"]["id"];
|
||||
if(this.organizationInfo.objIdentifier.startsWith("openorgs____::")) {
|
||||
this.organizationInfo.relcanId = this.organizationInfo.objIdentifier;
|
||||
}
|
||||
}
|
||||
|
||||
if(data.hasOwnProperty("organization")) {
|
||||
organization = data["organization"];
|
||||
if (organization.hasOwnProperty("websiteurl")) {
|
||||
this.organizationInfo.title = {"name": organization.legalshortname, "url": organization.websiteurl};
|
||||
} else {
|
||||
this.organizationInfo.title = {"name": organization.legalshortname, "url": ''};
|
||||
}
|
||||
|
||||
return title;
|
||||
this.organizationInfo.name = organization.legalname;
|
||||
|
||||
if (!this.organizationInfo.title.name || this.organizationInfo.title.name == '') {
|
||||
this.organizationInfo.title.name = this.organizationInfo.name;
|
||||
}
|
||||
|
||||
if (organization.hasOwnProperty("country")) {
|
||||
this.organizationInfo.country = organization['country'].label;
|
||||
}
|
||||
|
||||
if(organization['pid']) {
|
||||
this.organizationInfo.identifiers = this.parsingFunctions.parseIdentifiers(organization['pid']);
|
||||
}
|
||||
}
|
||||
|
||||
if(data.hasOwnProperty("links")) {
|
||||
let links = data['links'];
|
||||
let relLength = Array.isArray(links) ? links.length : 1;
|
||||
|
||||
for(let i=0; i<relLength; i++) {
|
||||
let relation = Array.isArray(links) ? links[i] : links;
|
||||
if (relation.hasOwnProperty("header")) {
|
||||
if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "merges" && relation['header'].relatedRecordType == "organization") {
|
||||
if(!this.organizationInfo.deletedByInferenceIds) {
|
||||
this.organizationInfo.deletedByInferenceIds = [];
|
||||
}
|
||||
this.organizationInfo.deletedByInferenceIds.push(relation['header'].relatedIdentifier);
|
||||
if(!this.organizationInfo.children) {
|
||||
this.organizationInfo.children = [];
|
||||
}
|
||||
this.organizationInfo.children.push(relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.organizationInfo;
|
||||
}
|
||||
|
||||
parseOrganizationNameAndUrl(organization: any): any {
|
||||
let title: {"name": string, "url": string} = {"name": "", "url": ""};
|
||||
|
||||
if(organization != null) {
|
||||
if(organization.hasOwnProperty("websiteurl")) {
|
||||
title = {"name": organization.legalshortname, "url": organization.websiteurl};
|
||||
} else {
|
||||
title = {"name": organization.legalshortname, "url": ''};
|
||||
}
|
||||
|
||||
if(title.name == '') {
|
||||
title.name = organization.legalname;
|
||||
}
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,162 +97,171 @@ export class SearchDataprovidersService {
|
|||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
||||
}
|
||||
|
||||
parseResults(data: any): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
parseResults(data: any): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
|
||||
for(let i=0; i<length; i++) {
|
||||
let resBody = Array.isArray(data) ? data[i] : data;
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
var result: SearchResult = new SearchResult();
|
||||
|
||||
result['title'] = {"name": '', "accessMode": ''};
|
||||
|
||||
if(resData.officialname) {
|
||||
result['title'].name = StringUtils.HTMLToString(String(resData.officialname));
|
||||
}
|
||||
if(resData.englishname) {
|
||||
result['englishname'] = StringUtils.HTMLToString(String(resData.englishname));
|
||||
} else {
|
||||
result['englishname'] = "";
|
||||
}
|
||||
result['originalId'] = resData.originalId;
|
||||
//result['title'].url = OpenaireProperties.getsearchLinkToDataProvider();
|
||||
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "datasource");
|
||||
if (canId) {
|
||||
result['id'] = canId;
|
||||
}
|
||||
result['relcanId'] = result['id'];
|
||||
|
||||
result['type'] = this.getDataproviderType(resData);
|
||||
if (resData['eosctype']) {
|
||||
result.entityType = resData['eosctype'].classname == "Service" ? "service" : "dataprovider";
|
||||
}
|
||||
|
||||
let abstracts = this.parsingFunctions.parseDescription(resData.description, true);
|
||||
result.description = abstracts;
|
||||
// if (result.description && result.description.length > this.sizeOfDescription) {
|
||||
// result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
||||
// }
|
||||
|
||||
let typeid: string = resData['datasourcetype'] && resData['datasourcetype'].classid;
|
||||
if(typeid != "entityregistry" && typeid != "entityregistry::projects" && typeid != "entityregistry::repositories") {
|
||||
|
||||
if(resData.hasOwnProperty('accessinfopackage')) {
|
||||
let OAIPMHURL: string;
|
||||
if(Array.isArray(resData['accessinfopackage'])) {
|
||||
OAIPMHURL = resData['accessinfopackage'][0];
|
||||
} else {
|
||||
OAIPMHURL = resData['accessinfopackage'];
|
||||
}
|
||||
|
||||
if(OAIPMHURL != '' && OAIPMHURL != 'unknown') {
|
||||
result['OAIPMHURL'] = OAIPMHURL;
|
||||
}
|
||||
}
|
||||
let compatibility = this.getDataproviderCompatibility(resData);
|
||||
result['compatibility'] = compatibility.classname;
|
||||
if(compatibility.classid == "UNKNOWN") {
|
||||
result['compatibilityUNKNOWN'] = true;
|
||||
}
|
||||
} else {
|
||||
result['compatibility'] = "";
|
||||
}
|
||||
|
||||
result['websiteURL'] = resData.websiteurl;
|
||||
|
||||
let res:[string[], {"name":string, "id":string}[]] = this.getDataproviderCountriesOrganizations(resData, true, true);
|
||||
result['organizations'] = res[1];
|
||||
result['countries'] = res[0];
|
||||
result['subjects'] = this.getDataproviderSubjects(resData);
|
||||
|
||||
if(resData['pid']) {
|
||||
result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']);
|
||||
}
|
||||
// Measure
|
||||
result.measure = this.parsingFunctions.parseMeasures(resData['measure']);
|
||||
|
||||
results.push(result);
|
||||
if(resBody.hasOwnProperty("header")) {
|
||||
result.id = resBody['header']['id'];
|
||||
let canId = ParsingFunctions.parseRelCanonicalId(resBody, "datasource");
|
||||
if (canId) {
|
||||
result['id'] = canId;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
getDataproviderSubjects(resData: any): string [] {
|
||||
var subjects:string [] = [];
|
||||
|
||||
let length = Array.isArray(resData['subjects']) ? resData['subjects'].length : 1;
|
||||
for(let i=0; i<length; i++) {
|
||||
let subject = Array.isArray(resData['subjects']) ? resData['subjects'][i] :resData['subjects'];
|
||||
if(subject && subject.content) {
|
||||
subjects.push(subject.content);
|
||||
}
|
||||
result['relcanId'] = result['id'];
|
||||
}
|
||||
return subjects;
|
||||
}
|
||||
getDataproviderType(resData: any): string {
|
||||
if(resData.hasOwnProperty('datasourcetype') && resData['datasourcetype'].hasOwnProperty("classname")) {
|
||||
return resData['datasourcetype'].classname;
|
||||
} else {
|
||||
return '';
|
||||
|
||||
if (resBody.hasOwnProperty("datasource")) {
|
||||
let resData = resBody['datasource'];
|
||||
result['title'] = {"name": '', "accessMode": ''};
|
||||
|
||||
if(resData.officialname) {
|
||||
result['title'].name = StringUtils.HTMLToString(String(resData.officialname));
|
||||
}
|
||||
}
|
||||
|
||||
getDataproviderCompatibility(resData: any): {"classid": string, "classname": string} {
|
||||
if(resData.hasOwnProperty('openairecompatibility')) {
|
||||
return {"classid": resData['openairecompatibility'].classid, "classname": resData['openairecompatibility'].classname};
|
||||
if(resData.englishname) {
|
||||
result['englishname'] = StringUtils.HTMLToString(String(resData.englishname));
|
||||
} else {
|
||||
return {"classid": "", "classname": ""};
|
||||
result['englishname'] = "";
|
||||
}
|
||||
}
|
||||
result['originalId'] = resData.originalId;
|
||||
|
||||
getDataproviderCountriesOrganizations(resData: any, getCountries: boolean, getOrganizations: boolean): [string[], {"name": string, "id": string}[]] {
|
||||
let countries: string[] = [];
|
||||
let organizations: {"name": string, "id": string}[] = [];
|
||||
result['type'] = this.getDataproviderType(resData);
|
||||
if (resData['eosctype']) {
|
||||
result.entityType = resData['eosctype'].classname == "Service" ? "service" : "dataprovider";
|
||||
}
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let countriesSet: Set<string> = new Set<string>();
|
||||
let abstracts = this.parsingFunctions.parseDescription(resData.description, true);
|
||||
result.description = abstracts;
|
||||
// if (result.description && result.description.length > this.sizeOfDescription) {
|
||||
// result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
||||
// }
|
||||
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
let typeid: string = resData['datasourcetype'] && resData['datasourcetype'].code;
|
||||
if(typeid != "entityregistry" && typeid != "entityregistry::projects" && typeid != "entityregistry::repositories") {
|
||||
|
||||
for(let i=0; i<relLength; i++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][i] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
if(relation['to'].class && relation['to'].class.toLowerCase() == "isprovidedby" && relation['to'].type == "organization") {
|
||||
if(getOrganizations) {
|
||||
let item: {"name":string, "id":string} = {"name": "", "id": ""};
|
||||
//item['name'] = relation.legalname;
|
||||
if(relation.legalshortname) {
|
||||
item['name'] = relation.legalshortname;
|
||||
} else {
|
||||
item['name'] = relation.legalname;
|
||||
}
|
||||
if(!item['name']) {
|
||||
item['name'] = "[no title available]";
|
||||
}
|
||||
item['id'] = /*OpenaireProperties.getsearchLinkToOrganization()+*/relation['to'].content;
|
||||
organizations.push(item);
|
||||
}
|
||||
|
||||
if(getCountries) {
|
||||
if(relation.hasOwnProperty('country') &&
|
||||
relation.country.hasOwnProperty('classname')) {
|
||||
if(!countriesSet.has(relation.country.classname)) {
|
||||
countriesSet.add(relation.country.classname);
|
||||
countries.push(relation.country.classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(resData.hasOwnProperty('accessinfopackage')) {
|
||||
let OAIPMHURL: string;
|
||||
if(Array.isArray(resData['accessinfopackage'])) {
|
||||
OAIPMHURL = resData['accessinfopackage'][0];
|
||||
} else {
|
||||
OAIPMHURL = resData['accessinfopackage'];
|
||||
}
|
||||
|
||||
if(OAIPMHURL != '' && OAIPMHURL != 'unknown') {
|
||||
result['OAIPMHURL'] = OAIPMHURL;
|
||||
}
|
||||
}
|
||||
let compatibility = this.getDataproviderCompatibility(resData);
|
||||
result['compatibility'] = compatibility.classname;
|
||||
if(compatibility.classid == "UNKNOWN") {
|
||||
result['compatibilityUNKNOWN'] = true;
|
||||
}
|
||||
} else {
|
||||
result['compatibility'] = "";
|
||||
}
|
||||
return [countries, organizations];
|
||||
|
||||
result['websiteURL'] = resData.websiteurl;
|
||||
|
||||
result['subjects'] = this.getDataproviderSubjects(resData);
|
||||
|
||||
// TODO: now pid.type & pid.value, but Claudio said that pid.type would be replaced by pid.typeCode and pid.typeLabel
|
||||
// if(resData['pid']) {
|
||||
// result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']);
|
||||
// }
|
||||
|
||||
// TODO: example?
|
||||
// Measure
|
||||
//result.measure = this.parsingFunctions.parseMeasures(resData['measure']);
|
||||
}
|
||||
|
||||
if(resBody.hasOwnProperty("links")) {
|
||||
let res:[string[], {"name":string, "id":string}[]] = this.getDataproviderCountriesOrganizations(resBody['links'], true, true);
|
||||
result['organizations'] = res[1];
|
||||
result['countries'] = res[0];
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
getDataproviderSubjects(resData: any): string [] {
|
||||
var subjects:string [] = [];
|
||||
|
||||
let length = Array.isArray(resData['subjects']) ? resData['subjects'].length : 1;
|
||||
for(let i=0; i<length; i++) {
|
||||
let subject = Array.isArray(resData['subjects']) ? resData['subjects'][i] :resData['subjects'];
|
||||
if(subject && subject.value) {
|
||||
subjects.push(subject.value);
|
||||
}
|
||||
}
|
||||
return subjects;
|
||||
}
|
||||
getDataproviderType(resData: any): string {
|
||||
if(resData.hasOwnProperty('datasourcetype') && resData['datasourcetype'].hasOwnProperty("label")) {
|
||||
return resData['datasourcetype'].label;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
getDataproviderCompatibility(resData: any): {"classid": string, "classname": string} {
|
||||
if(resData.hasOwnProperty('openairecompatibility')) {
|
||||
return {"classid": resData['openairecompatibility'].code, "classname": resData['openairecompatibility'].label};
|
||||
} else {
|
||||
return {"classid": "", "classname": ""};
|
||||
}
|
||||
}
|
||||
|
||||
getDataproviderCountriesOrganizations(links: any, getCountries: boolean, getOrganizations: boolean): [string[], {"name": string, "id": string}[]] {
|
||||
let countries: string[] = [];
|
||||
let organizations: {"name": string, "id": string}[] = [];
|
||||
|
||||
let countriesSet: Set<string> = new Set<string>();
|
||||
|
||||
let relLength = Array.isArray(links) ? links.length : 1;
|
||||
|
||||
for(let i=0; i<relLength; i++) {
|
||||
let relation = Array.isArray(links) ? links[i] : links;
|
||||
|
||||
if(relation.hasOwnProperty("header")) {
|
||||
if(relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "isprovidedby" && relation['header'].relatedRecordType == "organization") {
|
||||
if(getOrganizations) {
|
||||
let item: {"name":string, "id":string} = {"name": "", "id": ""};
|
||||
//item['name'] = relation.legalname;
|
||||
if(relation.legalshortname) {
|
||||
item['name'] = relation.legalshortname;
|
||||
} else {
|
||||
item['name'] = relation.legalname;
|
||||
}
|
||||
if(!item['name']) {
|
||||
item['name'] = "[no title available]";
|
||||
}
|
||||
item['id'] = /*OpenaireProperties.getsearchLinkToOrganization()+*/relation['header'].relatedIdentifier;
|
||||
organizations.push(item);
|
||||
}
|
||||
|
||||
if(getCountries) {
|
||||
if(relation.hasOwnProperty('country') &&
|
||||
relation.country.hasOwnProperty('label')) {
|
||||
if(!countriesSet.has(relation.country.label)) {
|
||||
countriesSet.add(relation.country.label);
|
||||
countries.push(relation.country.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return [countries, organizations];
|
||||
}
|
||||
|
||||
numOfDataproviders(url: string, properties:EnvProperties):any {
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
.pipe(map(res => res['total']));
|
||||
|
|
|
@ -88,107 +88,113 @@ export class SearchOrganizationsService {
|
|||
|
||||
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "organization")]));
|
||||
}
|
||||
parseResults(data: any): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
parseResults(data: any): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:organization'] : data['result']['metadata']['oaf:entity']['oaf:organization'];
|
||||
for(let i=0; i<length; i++) {
|
||||
let resBody = Array.isArray(data) ? data[i] : data;
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
var result: SearchResult = new SearchResult();
|
||||
|
||||
result['title'] = {"name": '', "accessMode": ''};
|
||||
|
||||
if(resData.legalname) {
|
||||
result['title'].name = StringUtils.HTMLToString(String(resData.legalname));
|
||||
} else {
|
||||
result['title'].name = "";
|
||||
}
|
||||
|
||||
if(resData.legalshortname) {
|
||||
result['acronym'] = StringUtils.HTMLToString(String(resData.legalshortname));
|
||||
if(resBody.hasOwnProperty("header")) {
|
||||
result.id = resBody['header']['id'];
|
||||
if(!result['id'].startsWith("openorgs____::")) {
|
||||
let canId = ParsingFunctions.parseRelCanonicalId(resBody, "organization");
|
||||
if(canId){
|
||||
result['id'] = canId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//result['title'].url = OpenaireProperties.getsearchLinkToOrganization();
|
||||
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
if(!result['id'].startsWith("openorgs____::")) {
|
||||
let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "organization");
|
||||
if(canId){
|
||||
result['id'] = canId;
|
||||
}
|
||||
}
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
if (resBody.hasOwnProperty("organization")) {
|
||||
let resData = resBody['organization'];
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
result['title'] = {"name": '', "accessMode": ''};
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
if(relation['to'].class && relation['to'].class.toLowerCase() == "isparticipant") {
|
||||
if(result['projects'] == undefined) {
|
||||
result['projects'] = new Array<
|
||||
{ "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = result['projects'].length;
|
||||
|
||||
result['projects'][countProjects] = {
|
||||
"id": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
if(relation.title != 'unidentified') {
|
||||
result['projects'][countProjects]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToProject() + */relation['to'].content;
|
||||
result['projects'][countProjects]['acronym'] = relation.acronym;
|
||||
result['projects'][countProjects]['title'] = relation.title;
|
||||
result['projects'][countProjects]['code'] = relation.code;
|
||||
} else {
|
||||
result['projects'][countProjects]['id'] = "";
|
||||
result['projects'][countProjects]['acronym'] = "";
|
||||
result['projects'][countProjects]['title'] = "";
|
||||
result['projects'][countProjects]['code'] = "";
|
||||
}
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
result['projects'][countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
result['projects'][countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(resData.country.hasOwnProperty("classname")) {
|
||||
result.country = resData.country.classname;
|
||||
}
|
||||
|
||||
if(resData['pid']) {
|
||||
result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']);
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
if(resData.legalname) {
|
||||
result['title'].name = StringUtils.HTMLToString(String(resData.legalname));
|
||||
} else {
|
||||
result['title'].name = "";
|
||||
}
|
||||
|
||||
return results;
|
||||
if(resData.legalshortname) {
|
||||
result['acronym'] = StringUtils.HTMLToString(String(resData.legalshortname));
|
||||
}
|
||||
|
||||
if(resData.country.hasOwnProperty("label")) {
|
||||
result.country = resData.country.label;
|
||||
}
|
||||
|
||||
// TODO: now pid.type & pid.value, but Claudio said that pid.type would be replaced by pid.typeCode and pid.typeLabel
|
||||
// if(resData['pid']) {
|
||||
// result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']);
|
||||
// }
|
||||
}
|
||||
|
||||
if (resBody.hasOwnProperty("links")) {
|
||||
let relLength = Array.isArray(resBody['links']) ? resBody['links'].length : 1;
|
||||
|
||||
for (let j = 0; j < relLength; j++) {
|
||||
let relation = Array.isArray(resBody['links']) ? resBody['links'][j] : resBody['links'];
|
||||
|
||||
if(relation.hasOwnProperty("header")) {
|
||||
if(relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "isparticipant") {
|
||||
if(result['projects'] == undefined) {
|
||||
result['projects'] = new Array<
|
||||
{ "id": string, "acronym": string, "title": string,
|
||||
"funderShortname": string, "funderName": string,
|
||||
"code": string
|
||||
}>();
|
||||
}
|
||||
|
||||
let countProjects = result['projects'].length;
|
||||
|
||||
result['projects'][countProjects] = {
|
||||
"id": "", "acronym": "", "title": "",
|
||||
"funderShortname": "", "funderName": "",
|
||||
"code": ""
|
||||
}
|
||||
|
||||
if(relation.title != 'unidentified') {
|
||||
result['projects'][countProjects]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToProject() + */relation['header'].relatedIdentifier;
|
||||
result['projects'][countProjects]['acronym'] = relation.acronym;
|
||||
result['projects'][countProjects]['title'] = relation.title; // TODO: Could not find any examples with this field
|
||||
result['projects'][countProjects]['code'] = relation.code;
|
||||
} else {
|
||||
result['projects'][countProjects]['id'] = "";
|
||||
result['projects'][countProjects]['acronym'] = "";
|
||||
result['projects'][countProjects]['title'] = "";
|
||||
result['projects'][countProjects]['code'] = "";
|
||||
}
|
||||
|
||||
if(relation.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
|
||||
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
result['projects'][countProjects]['funderShortname'] = fundingData['funder'].shortname;
|
||||
result['projects'][countProjects]['funderName'] = fundingData['funder'].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
numOfOrganizations(url: string, properties:EnvProperties ): any {
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
numOfOrganizations(url: string, properties:EnvProperties ): any {
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
//.map(res => <any> res.json())
|
||||
|
|
|
@ -127,154 +127,139 @@ export class SearchProjectsService {
|
|||
|
||||
}) ;
|
||||
}
|
||||
parseResults(data: any): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
parseResults(data: any): SearchResult[] {
|
||||
let results: SearchResult[] = [];
|
||||
|
||||
for(let i=0; i<length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:project'] : data['result']['metadata']['oaf:entity']['oaf:project'];
|
||||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
result.openAccessMandatePublications = (resData['oamandatepublications'])?true:false;
|
||||
if(resData.hasOwnProperty("oamandatedata")) {
|
||||
result.openAccessMandateDatasets = (resData['oamandatedata'])?true:false;
|
||||
} else {
|
||||
result.openAccessMandateDatasets = (resData['ecarticle29_3'])?true:false;
|
||||
}
|
||||
result['title'] = {"name": '', "accessMode": ''};
|
||||
// if(resData['acronym'] != undefined && resData['acronym'] != "") {
|
||||
// result['title'].name = resData['acronym'] + " - ";
|
||||
// }
|
||||
if(resData['title']) {
|
||||
if (Array.isArray(resData['title'])) {
|
||||
result['title'].name += StringUtils.HTMLToString(String(resData['title'][0]));
|
||||
} else {
|
||||
result['title'].name += StringUtils.HTMLToString(String(resData['title']));
|
||||
}
|
||||
for (let i = 0; i < length; i++) {
|
||||
let resBody = Array.isArray(data) ? data[i] : data;
|
||||
|
||||
var result: SearchResult = new SearchResult();
|
||||
|
||||
if (resBody.hasOwnProperty("header")) {
|
||||
result.id = resBody['header']['id'];
|
||||
}
|
||||
|
||||
if (resBody.hasOwnProperty("project")) {
|
||||
let resData = resBody['project'];
|
||||
result.openAccessMandatePublications = (resData['oamandatepublications']) ? true : false;
|
||||
if (resData.hasOwnProperty("oamandatedata")) {
|
||||
result.openAccessMandateDatasets = (resData['oamandatedata']) ? true : false;
|
||||
} else {
|
||||
result.openAccessMandateDatasets = (resData['ecarticle29_3']) ? true : false;
|
||||
}
|
||||
result['title'] = {"name": '', "accessMode": ''};
|
||||
// if(resData['acronym'] != undefined && resData['acronym'] != "") {
|
||||
// result['title'].name = resData['acronym'] + " - ";
|
||||
// }
|
||||
if (resData['title']) {
|
||||
if (Array.isArray(resData['title'])) {
|
||||
result['title'].name += StringUtils.HTMLToString(String(resData['title'][0]));
|
||||
} else {
|
||||
result['title'].name = "";
|
||||
result['title'].name += StringUtils.HTMLToString(String(resData['title']));
|
||||
}
|
||||
|
||||
// if(result['title'].name != '') {
|
||||
// result['title'].name += " ("+resData['code']+")"
|
||||
// }
|
||||
|
||||
// if(resData['ecsc39'] == true) {
|
||||
// result['title'].sc39 = "sc39";
|
||||
// }
|
||||
|
||||
result.acronym = resData['acronym'];
|
||||
result.code = resData['code'];
|
||||
|
||||
result.budget = resData.totalcost;//"10000";
|
||||
result.contribution = resData.fundedamount;//"200100";
|
||||
result.currency = resData.currency;//"EUR";
|
||||
|
||||
result.id = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
|
||||
let abstracts = this.parsingFunctions.parseDescription(resData.summary, true);
|
||||
result.description = abstracts;
|
||||
// if (result.description && result.description.length > this.sizeOfDescription) {
|
||||
// result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
||||
// }
|
||||
|
||||
if(resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for(let j=0; j<relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if(relation.hasOwnProperty("to")) {
|
||||
if(relation['to'].class && relation['to'].class.toLowerCase() == "hasparticipant") {
|
||||
if(result['organizations'] == undefined) {
|
||||
result['organizations'] = new Array<
|
||||
{ "name": string, "id": string}>();
|
||||
}
|
||||
|
||||
let countOrganizations = result['organizations'].length;
|
||||
|
||||
result['organizations'][countOrganizations] = { "name": "", "id": "" }
|
||||
|
||||
result['organizations'][countOrganizations]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToOrganization() + */relation['to'].content;
|
||||
if(relation.legalshortname) {
|
||||
result['organizations'][countOrganizations]['name'] = relation.legalshortname;
|
||||
} else {
|
||||
result['organizations'][countOrganizations]['name'] = relation.legalname;
|
||||
}
|
||||
if(!result['organizations'][countOrganizations]['name']) {
|
||||
result['organizations'][countOrganizations]['name'] = "[no title available]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(resData.hasOwnProperty("fundingtree")) {
|
||||
/*let funderSet: Set<string>;
|
||||
if(result['funders'] == undefined) {
|
||||
result['funders'] = new Array<
|
||||
{"funderShortname": string, "funderName": string}>();
|
||||
funderSet = new Set<string>();
|
||||
}
|
||||
|
||||
let fundingLength = Array.isArray(resData['fundingtree']) ? resData['fundingtree'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(resData['fundingtree']) ? resData['fundingtree'][z] : resData['fundingtree'];
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
if(!funderSet.has(fundingData['funder'].shortname)) {
|
||||
let countFunders = result['funders'].length;
|
||||
|
||||
result['funders'][countFunders] = {"funderShortname": "", "funderName": ""};
|
||||
result['funders'][countFunders]['funderShortname'] = fundingData['funder'].shortname;
|
||||
result['funders'][countFunders]['funderName'] = fundingData['funder'].name;
|
||||
funderSet.add(fundingData['funder'].shortname);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
let fundingLength = Array.isArray(resData['fundingtree']) ? resData['fundingtree'].length : 1;
|
||||
|
||||
for(let z=0; z<fundingLength; z++) {
|
||||
let fundingData = Array.isArray(resData['fundingtree']) ? resData['fundingtree'][z] : resData['fundingtree'];
|
||||
if(fundingData.hasOwnProperty("funder")) {
|
||||
result['funderShortname'] = fundingData['funder'].shortname;
|
||||
result['funderName'] = fundingData['funder'].name;
|
||||
result['funderId'] = fundingData['funder'].id;
|
||||
result['jurisdiction'] = (fundingData['funder']['id']['jurisdiction'] )?fundingData['funder']['id']['jurisdiction']:"";
|
||||
|
||||
if(fundingData['funding_level_2']){
|
||||
result['fundingLevel0'] = (fundingData['funding_level_2'] && fundingData['funding_level_2']['parent'] &&
|
||||
fundingData['funding_level_2']['parent']['funding_level_1'] && fundingData['funding_level_2']['parent']['funding_level_1']['parent']
|
||||
&& fundingData['funding_level_2']['parent']['funding_level_1']['parent']['funding_level_0'])?
|
||||
fundingData['funding_level_2']['parent']['funding_level_1']['parent']['funding_level_0']['name']:"";
|
||||
}else if(fundingData['funding_level_1']){
|
||||
result['fundingLevel0'] = (fundingData['funding_level_1'] && fundingData['funding_level_1']['parent'] && fundingData['funding_level_1']['parent']['funding_level_0'])?
|
||||
fundingData['funding_level_1']['parent']['funding_level_0']['name']:"";
|
||||
}else if(fundingData['funding_level_0']){
|
||||
result['fundingLevel0'] = (fundingData['funding_level_0'] )?fundingData['funding_level_0']['name']:"";
|
||||
}else {
|
||||
result['fundingLevel0']="";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(resData.hasOwnProperty("startdate") && resData['startdate']) {
|
||||
result.startYear = resData.startdate.split('-')[0];
|
||||
}
|
||||
if(resData.hasOwnProperty("enddate") && resData['enddate']) {
|
||||
result.endYear = resData.enddate.split('-')[0];
|
||||
}
|
||||
// Measure
|
||||
result.measure = this.parsingFunctions.parseMeasures(resData['measure']);
|
||||
|
||||
results.push(result);
|
||||
} else {
|
||||
result['title'].name = "";
|
||||
}
|
||||
|
||||
return results;
|
||||
// if(result['title'].name != '') {
|
||||
// result['title'].name += " ("+resData['code']+")"
|
||||
// }
|
||||
|
||||
// if(resData['ecsc39'] == true) {
|
||||
// result['title'].sc39 = "sc39";
|
||||
// }
|
||||
|
||||
result.acronym = resData['acronym'];
|
||||
result.code = resData['code'];
|
||||
|
||||
result.budget = resData.totalcost;//"10000";
|
||||
result.contribution = resData.fundedamount;//"200100";
|
||||
result.currency = resData.currency;//"EUR";
|
||||
|
||||
let abstracts = this.parsingFunctions.parseDescription(resData.summary, true);
|
||||
result.description = abstracts;
|
||||
// if (result.description && result.description.length > this.sizeOfDescription) {
|
||||
// result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
||||
// }
|
||||
|
||||
if (resData.hasOwnProperty("funding")) {
|
||||
let fundingLength = Array.isArray(resData['funding']) ? resData['funding'].length : 1;
|
||||
|
||||
for (let z = 0; z < fundingLength; z++) {
|
||||
let fundingData = Array.isArray(resData['funding']) ? resData['funding'][z] : resData['funding'];
|
||||
if (fundingData.hasOwnProperty("funder")) {
|
||||
result['funderShortname'] = fundingData['funder'].shortname;
|
||||
result['funderName'] = fundingData['funder'].name;
|
||||
result['funderId'] = fundingData['funder'].id;
|
||||
result['jurisdiction'] = fundingData['funder']['jurisdiction']?.code;
|
||||
|
||||
if (fundingData['level2']) {
|
||||
result['fundingLevel0'] = (fundingData['level2'] && fundingData['level2']['parent'] &&
|
||||
fundingData['level2']['parent']['level1'] && fundingData['level2']['parent']['level1']['parent']
|
||||
&& fundingData['level2']['parent']['level1']['parent']['level0']) ?
|
||||
fundingData['level2']['parent']['level1']['parent']['level0']['name'] : "";
|
||||
} else if (fundingData['level1']) {
|
||||
result['level0'] = (fundingData['level1'] && fundingData['level1']['parent'] && fundingData['level1']['parent']['level0']) ?
|
||||
fundingData['level1']['parent']['level0']['name'] : "";
|
||||
} else if (fundingData['level0']) {
|
||||
result['fundingLevel0'] = (fundingData['level0']) ? fundingData['level0']['name'] : "";
|
||||
} else {
|
||||
result['fundingLevel0'] = "";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resData.hasOwnProperty("startdate") && resData['startdate']) {
|
||||
result.startYear = resData.startdate.split('-')[0];
|
||||
}
|
||||
if (resData.hasOwnProperty("enddate") && resData['enddate']) {
|
||||
result.endYear = resData.enddate.split('-')[0];
|
||||
}
|
||||
// Measure
|
||||
result.measure = this.parsingFunctions.parseMeasures(resData['measure']);
|
||||
}
|
||||
|
||||
if (resBody.hasOwnProperty("links")) {
|
||||
let relLength = Array.isArray(resBody['links']) ? resBody['links'].length : 1;
|
||||
|
||||
for (let j = 0; j < relLength; j++) {
|
||||
let relation = Array.isArray(resBody['links']) ? resBody['links'][j] : resBody['links'];
|
||||
|
||||
if (relation.hasOwnProperty("header")) {
|
||||
if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "hasparticipant") {
|
||||
if (result['organizations'] == undefined) {
|
||||
result['organizations'] = new Array<
|
||||
{ "name": string, "id": string }>();
|
||||
}
|
||||
|
||||
let countOrganizations = result['organizations'].length;
|
||||
|
||||
result['organizations'][countOrganizations] = {"name": "", "id": ""}
|
||||
|
||||
result['organizations'][countOrganizations]['id'] =
|
||||
/*OpenaireProperties.getsearchLinkToOrganization() + */relation['header'].relatedIdentifier;
|
||||
if (relation.legalshortname) {
|
||||
result['organizations'][countOrganizations]['name'] = relation.legalshortname;
|
||||
} else {
|
||||
result['organizations'][countOrganizations]['name'] = relation.legalname;
|
||||
}
|
||||
if (!result['organizations'][countOrganizations]['name']) {
|
||||
result['organizations'][countOrganizations]['name'] = "[no title available]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
results.push(result);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
numOfProjects(url: string, properties:EnvProperties ):any {
|
||||
|
||||
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
||||
|
|
|
@ -102,8 +102,8 @@ export let commonDev: EnvProperties = {
|
|||
statisticsFrameAPIURL: "https://beta.openaire.eu/stats/",
|
||||
statisticsFrameNewAPIURL: "https://beta.services.openaire.eu/stats-tool/",
|
||||
claimsAPIURL: "http://scoobydoo.di.uoa.gr:8880/dnet-claims-service-2.0.0-SNAPSHOT/rest/claimsService/",
|
||||
searchAPIURLLAst: "http://beta.services.openaire.eu/search/v2/api/",
|
||||
searchResourcesAPIURL: "https://beta.services.openaire.eu/search/v2/api/resources",
|
||||
searchAPIURLLAst: "http://rudie.di.uoa.gr:8280/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/",
|
||||
searchResourcesAPIURL: "http://rudie.di.uoa.gr:8280/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2/api/resources",
|
||||
|
||||
openCitationsAPIURL: "https://services.openaire.eu/opencitations/getCitations?id=",
|
||||
csvAPIURL: "https://beta.services.openaire.eu/search/v2/api/reports",
|
||||
|
|
Loading…
Reference in New Issue