[new-search-json | WIP ] continue parsing research results, start parsing result landing

This commit is contained in:
argirok 2024-10-09 09:54:41 +03:00
parent 187444bb09
commit f675fba83b
4 changed files with 350 additions and 342 deletions

View File

@ -28,7 +28,10 @@ export class ParsingFunctions {
public open = 'open_access'; public open = 'open_access';
public closed = 'closed_access'; public closed = 'closed_access';
public unknown = 'unknown_access'; public unknown = 'unknown_access';
// public identifierTypes = ["doi", "pmc" , "handle", "pmid", "re3data", "swhid", "ROR", "ISNI", "Wikidata", "FundRef"];
//TODO what are the names of Identifiers types e.g doi = Digital Object Identifier
public identifierTypes = ["Digital Object Identifier", "pmc", "Handle", "PubMed ID", "re3data", "swhid",
"ROR", "International Standard Name Identifier", "Wikidata", "FundRef"];
private instanceWithDoiExists: boolean = false; private instanceWithDoiExists: boolean = false;
constructor() { constructor() {
@ -595,9 +598,7 @@ export class ParsingFunctions {
let identifiers = new Map<string, string[]>(); let identifiers = new Map<string, string[]>();
if (pid.hasOwnProperty("type") && pid['type'] != "") { if (pid.hasOwnProperty("type") && pid['type'] != "") {
if (pid.type == "doi" || pid.type == "pmc" || pid.type == "handle" || pid.type == "pmid" || pid.type == "re3data" if (this.identifierTypes.indexOf(pid.type) !=-1) {
|| pid.type == "swhid"
|| pid.type == "ROR" || pid.type == "ISNI" || pid.type == "Wikidata" || pid.type == "FundRef") {
if (!identifiers.has(pid.type)) { if (!identifiers.has(pid.type)) {
identifiers.set(pid.type, new Array<string>()); identifiers.set(pid.type, new Array<string>());
} }
@ -605,9 +606,7 @@ export class ParsingFunctions {
} }
} else { } else {
for (let i = 0; i < pid.length; i++) { for (let i = 0; i < pid.length; i++) {
if (pid[i].type == "doi" || pid[i].type == "pmc" || pid[i].type == "handle" || pid[i].type == "pmid" || pid[i].type == "re3data" if (this.identifierTypes.indexOf(pid[i].type) !=-1) {
|| pid[i].type == "swhid"
|| pid[i].type == "ROR" || pid[i].type == "ISNI" || pid[i].type == "Wikidata" || pid[i].type == "FundRef") {
if (!identifiers.has(pid[i].type)) { if (!identifiers.has(pid[i].type)) {
identifiers.set(pid[i].type, new Array<string>()); identifiers.set(pid[i].type, new Array<string>());
} }

View File

@ -10,6 +10,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import {EnvProperties} from "../../utils/properties/env-properties"; import {EnvProperties} from "../../utils/properties/env-properties";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {ParsingFunctions} from "./parsingFunctions.class";
@Component({ @Component({
selector: 'showIdentifiers', selector: 'showIdentifiers',
@ -26,8 +27,7 @@ import {properties} from "../../../../environments/environment";
<span class="uk-text-meta uk-text-small" [class.uk-text-uppercase]="key != 're3data'">{{key}}: </span> <span class="uk-text-meta uk-text-small" [class.uk-text-uppercase]="key != 're3data'">{{key}}: </span>
<span [class.uk-margin-small-left]="modal"> <span [class.uk-margin-small-left]="modal">
<ng-container *ngFor="let item of identifiers.get(key) let j=index"> <ng-container *ngFor="let item of identifiers.get(key) let j=index">
<a *ngIf="key == 'doi' || key == 'pmc' || key == 'pmid' || key == 'handle' || key == 're3data' || key == 'swhid' <a *ngIf="parsingFunctions.identifierTypes.indexOf(key) != -1"
|| key == 'ROR' || key == 'ISNI' || key == 'Wikidata' || key == 'FundRef'"
[href]="getUrl(key, item) + item" target="_blank" class="uk-display-inline-block custom-external"> [href]="getUrl(key, item) + item" target="_blank" class="uk-display-inline-block custom-external">
{{item}} {{item}}
</a> </a>
@ -69,7 +69,7 @@ export class ShowIdentifiersComponent implements AfterViewInit {
properties: EnvProperties = properties; properties: EnvProperties = properties;
@ViewChildren("content", { read: ElementRef }) types: QueryList<ElementRef>; @ViewChildren("content", { read: ElementRef }) types: QueryList<ElementRef>;
@ViewChild('identifiersModal') identifiersModal; @ViewChild('identifiersModal') identifiersModal;
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
constructor(private cdr: ChangeDetectorRef) { constructor(private cdr: ChangeDetectorRef) {
} }
@ -118,7 +118,7 @@ export class ShowIdentifiersComponent implements AfterViewInit {
if(value.includes("http://") || value.includes("https://")) { if(value.includes("http://") || value.includes("https://")) {
return ""; return "";
} }
if(key == "doi") { if(key == "doi" || key == "Digital Object Identifier") {
return properties.doiURL; return properties.doiURL;
} else if(key == "pmc") { } else if(key == "pmc") {
return properties.pmcURL; return properties.pmcURL;

View File

@ -74,13 +74,14 @@ export class ResultLandingService {
error: "Http failure response for " + finalUrl + ": 404 Not Found" error: "Http failure response for " + finalUrl + ": 404 Not Found"
}); });
} }
//TODO make sure to pass the correct part
return res['results'][0]; return res['results'][0];
} else { } else {
return res; return res;
} }
})) }))
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res])) // .pipe(map(res => [res['meta']['status'], res['result']['metadata']['oaf:entity'], res]))
.pipe(map(res => [ /*.pipe(map(res => [
res[1]['oaf:result'], // 0 res[1]['oaf:result'], // 0
res[1]['oaf:result']['title'], // 1 res[1]['oaf:result']['title'], // 1
res[1]['oaf:result']['rels']['rel'], // 2 res[1]['oaf:result']['rels']['rel'], // 2
@ -99,7 +100,7 @@ export class ResultLandingService {
? res[1]['extraInfo']['references']['reference'] : null, // 13 ? res[1]['extraInfo']['references']['reference'] : null, // 13
res[0], // 14 res[0], // 14
res[2], // 15 res[2], // 15
])) ]))*/
.pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties))); .pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties)));
} }
@ -128,35 +129,38 @@ export class ResultLandingService {
parseResultLandingInfo(data: any, subjectsVocabulary: any, properties: EnvProperties): any { parseResultLandingInfo(data: any, subjectsVocabulary: any, properties: EnvProperties): any {
this.resultLandingInfo = new ResultLandingInfo(); this.resultLandingInfo = new ResultLandingInfo();
try {
// res // res
this.resultLandingInfo.record = data[15]; this.resultLandingInfo.record = data;
this.resultLandingInfo.objIdentifier = data[15]["result"]["header"]["dri:objIdentifier"]; this.resultLandingInfo.objIdentifier = data["header"]["id"];
//TODO relcan ?
this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result"); this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result");
this.resultLandingInfo.resultType = data[0].resulttype.classid; this.resultLandingInfo.resultType = data['header']['recordType'];
let date: string = (data['result']['publicationdate'] ? data['result']['publicationdate'] : '') + ''; // transform to string in case it is an integer
// res['result']['metadata']['oaf:entity']['oaf:result']
if (data[0] != null) {
let date: string = (data[0].dateofacceptance ? data[0].dateofacceptance : '') + ''; // transform to string in case it is an integer
this.resultLandingInfo.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date; this.resultLandingInfo.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
this.resultLandingInfo.dateofacceptance = data[0].dateofacceptance ? Dates.getDate(data[0].dateofacceptance) : null; this.resultLandingInfo.dateofacceptance = data['result']['publicationdate'] ? Dates.getDate(data['result']['publicationdate']) : null;
this.resultLandingInfo.publisher = data[0].publisher; this.resultLandingInfo.publisher = data['result']['publisher'];
this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data[0] && data[0].description ? data[0].description : []); this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data['result']['description'] ? data['result']['description'] : []);
this.resultLandingInfo.embargoEndDate = data[0].embargoenddate ? Dates.getDate(data[0].embargoenddate) : null; this.resultLandingInfo.embargoEndDate = data['result']['embargoenddate'] ? Dates.getDate(data['result']['embargoenddate']) : null;
if(data[0].hasOwnProperty("publiclyfunded") && data[0].publiclyfunded) {
this.resultLandingInfo.publiclyFunded = data[0].publiclyfunded; if (data['result'].hasOwnProperty("publiclyFunded") && data['result'].publiclyFunded) {
this.resultLandingInfo.publiclyFunded = data['result'].publiclyFunded;
} }
if((data[0].hasOwnProperty("isgreen") && data[0].isgreen) //TODO check duplicates - are we going to keep one?
|| (data[0].hasOwnProperty("openaccesscolor") && data[0].openaccesscolor) if ((data['result'].hasOwnProperty("isGreen") && data['result'].isGreen)
|| (data[0].hasOwnProperty("isindiamondjournal") && data[0].isindiamondjournal)) { || (data['result'].hasOwnProperty("openAccessColor") && data['result'].openAccessColor)
|| (data['result'].hasOwnProperty("isInDiamondJournal") && data['result'].isInDiamondJournal)) {
this.resultLandingInfo.oaRoutes = { this.resultLandingInfo.oaRoutes = {
"green": data[0].isgreen, "green": data['result'].isGreen,
"oaColor": data[0].openaccesscolor, "oaColor": data['result'].openAccessColor,
"isInDiamondJournal":data[0].isindiamondjournal "isInDiamondJournal": data['result'].isInDiamondJournal
}; };
} }
}
//TODO continue from here
if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) { if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) {
this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname; this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname;
} }
@ -211,7 +215,7 @@ export class ResultLandingService {
} else if (relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") { } else if (relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") {
this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation); this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation);
} else if (relation['to'].scheme && relation['to'].scheme == "dnet:result_datasource_relations" && } else if (relation['to'].scheme && relation['to'].scheme == "dnet:result_datasource_relations" &&
(relation['datasourcetype']?.classname!== "service" || properties.adminToolsPortalType == "eosc")) { (relation['datasourcetype']?.classname !== "service" || properties.adminToolsPortalType == "eosc")) {
let relationName: string = relation.to.class; let relationName: string = relation.to.class;
if (!this.resultLandingInfo.relatedServicesClassFilters.has(relationName)) { if (!this.resultLandingInfo.relatedServicesClassFilters.has(relationName)) {
this.resultLandingInfo.relatedServicesClassFilters.add(relationName); this.resultLandingInfo.relatedServicesClassFilters.add(relationName);
@ -347,13 +351,13 @@ export class ResultLandingService {
subjectResults[3].forEach(element => { subjectResults[3].forEach(element => {
// hide L3 & L4 FoS // hide L3 & L4 FoS
let add = true; let add = true;
if(element) { if (element) {
let id = element.split(" ")[0]; let id = element.split(" ")[0];
if(id.length > 4 && properties.environment != "development") { if (id.length > 4 && properties.environment != "development") {
add = false; add = false;
} }
} }
if(add) { if (add) {
this.resultLandingInfo.fos.push( this.resultLandingInfo.fos.push(
{ {
id: element, id: element,
@ -366,7 +370,7 @@ export class ResultLandingService {
if (this.resultLandingInfo.fos) { if (this.resultLandingInfo.fos) {
this.resultLandingInfo.fos.sort((a, b) => a.id.localeCompare(b.id)); this.resultLandingInfo.fos.sort((a, b) => a.id.localeCompare(b.id));
} }
if(properties.dashboard != "irish") { if (properties.dashboard != "irish") {
this.resultLandingInfo.sdg = subjectResults[4]; this.resultLandingInfo.sdg = subjectResults[4];
if (this.resultLandingInfo.sdg) { if (this.resultLandingInfo.sdg) {
this.resultLandingInfo.sdg.sort((a, b) => { this.resultLandingInfo.sdg.sort((a, b) => {
@ -425,10 +429,10 @@ export class ResultLandingService {
author.orcid_pending = author.orcid_pending.toUpperCase(); author.orcid_pending = author.orcid_pending.toUpperCase();
} }
if(this.resultLandingInfo['authors'][author.rank] && this.resultLandingInfo['authors'][author.rank].fullName == author.content) { if (this.resultLandingInfo['authors'][author.rank] && this.resultLandingInfo['authors'][author.rank].fullName == author.content) {
if(!author.orcid && this.resultLandingInfo['authors'][author.rank].orcid) { if (!author.orcid && this.resultLandingInfo['authors'][author.rank].orcid) {
author.orcid = this.resultLandingInfo['authors'][author.rank].orcid; author.orcid = this.resultLandingInfo['authors'][author.rank].orcid;
} else if(!author.orcid_pending && this.resultLandingInfo['authors'][author.rank].orcid_pending) { } else if (!author.orcid_pending && this.resultLandingInfo['authors'][author.rank].orcid_pending) {
author.orcid_pending = this.resultLandingInfo['authors'][author.rank].orcid_pending; author.orcid_pending = this.resultLandingInfo['authors'][author.rank].orcid_pending;
} }
} }
@ -451,7 +455,9 @@ export class ResultLandingService {
} }
this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults); this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults);
}catch (e){
}
return this.resultLandingInfo; return this.resultLandingInfo;
} }

View File

@ -234,14 +234,16 @@ export class SearchResearchResultsService {
/////////////////////////// Athena Code /////////////////////////// /////////////////////////// Athena Code ///////////////////////////
if (resData['pid']) { if (resData['pid']) {
if (!Array.isArray(resData['pid'])) { if (!Array.isArray(resData['pid'])) {
if (resData['pid'].type && resData['pid'].type == 'doi') { //TODO change to "doi"
if (resData['pid'].type && resData['pid'].type == 'Digital Object Identifier') {
if (resData['pid'].value != '' && resData['pid'].value != null) { if (resData['pid'].value != '' && resData['pid'].value != null) {
result.DOIs.push((resData['pid'].value + "").replace("https://doi.org/", "")); result.DOIs.push((resData['pid'].value + "").replace("https://doi.org/", ""));
} }
} }
} else { } else {
for (let i = 0; i < resData['pid'].length; i++) { for (let i = 0; i < resData['pid'].length; i++) {
if (resData['pid'][i].type == 'doi') { //TODO change to "doi"
if (resData['pid'][i].type == 'Digital Object Identifier') {
if (resData['pid'][i].value != '' && resData['pid'][i].value != null && resData['pid'][i].value) { if (resData['pid'][i].value != '' && resData['pid'][i].value != null && resData['pid'][i].value) {
result.DOIs.push((resData['pid'][i].value + "").replace("https://doi.org/", "")); result.DOIs.push((resData['pid'][i].value + "").replace("https://doi.org/", ""));
} }
@ -307,7 +309,6 @@ export class SearchResearchResultsService {
result['id'] = canId; result['id'] = canId;
} }
result['relcanId'] = result['id']; result['relcanId'] = result['id'];
if (resData['links']) { if (resData['links']) {
let relLength = Array.isArray(resData['links']) ? resData['links'].length : 1; let relLength = Array.isArray(resData['links']) ? resData['links'].length : 1;
@ -379,27 +380,28 @@ export class SearchResearchResultsService {
if (resData['result'].embargoenddate && resData['result'].embargoenddate != '') { if (resData['result'].embargoenddate && resData['result'].embargoenddate != '') {
result.embargoEndDate = Dates.getDate(resData['result'].embargoenddate); result.embargoEndDate = Dates.getDate(resData['result'].embargoenddate);
} }
// TODO continue from here
if (!Array.isArray(resData.publisher)) { if (!Array.isArray(resData['result'].publisher)) {
result.publisher = resData.publisher; result.publisher = resData['result'].publisher;
} else { } else {
for (let i = 0; i < resData.publisher.length; i++) { for (let i = 0; i < resData.publisher['result'].length; i++) {
if (result.publisher != undefined) { if (result.publisher != undefined) {
result.publisher += ', ' + resData['publisher'][i]; result.publisher += ', ' + resData['result']['publisher'][i];
} else { } else {
result.publisher = resData['publisher'][i]; result.publisher = resData['result']['publisher'][i];
} }
} }
} }
//todo DOUBLEcheck with connect
if (resData['context'] != null) { if (resData['context'] != null) {
result.enermapsId = ParsingFunctions.getEnermapsConceptId(this.parsingFunctions.parseContexts(resData['context'])); result.enermapsId = ParsingFunctions.getEnermapsConceptId(this.parsingFunctions.parseContexts(resData['context']));
} }
if (resData.dateofacceptance && resData.dateofacceptance != null) { if (resData['result'].publicationdate && resData['result'].publicationdate != null) {
let date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // transform to string in case it is an integer let date: string = (resData['result'].publicationdate ? resData['result'].publicationdate : '') + ''; // transform to string in case it is an integer
result.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date; result.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
result.dateofacceptance = resData.dateofacceptance ? Dates.getDate(resData.dateofacceptance) : null; result.dateofacceptance = resData['result'].publicationdate ? Dates.getDate(resData['result'].publicationdate) : null;
} }
if (resData.journal && resData.journal != null) { if (resData['result'].journal && resData['result'].journal != null) {
result.journal = { result.journal = {
"journal": "", "journal": "",
"issn": "", "issn": "",
@ -410,14 +412,14 @@ export class SearchResearchResultsService {
"start_page": "", "start_page": "",
"end_page": "" "end_page": ""
} }
result.journal['journal'] = resData.journal.content; result.journal['journal'] = resData['result'].journal.name;
result.journal['issn'] = resData.journal.issn; result.journal['issn'] = resData['result'].journal.issnPrinted;
result.journal['lissn'] = resData.journal.lissn; result.journal['lissn'] = resData['result'].journal.issnLinking;
result.journal['eissn'] = resData.journal.eissn; result.journal['eissn'] = resData['result'].journal.issnOnline;
result.journal['issue'] = resData.journal.iss; result.journal['issue'] = resData['result'].journal.iss;
result.journal['volume'] = resData.journal.vol; result.journal['volume'] = resData['result'].journal.vol;
result.journal['start_page'] = resData.journal.sp; result.journal['start_page'] = resData['result'].journal.sp;
result.journal['end_page'] = resData.journal.ep; result.journal['end_page'] = resData['result'].journal.ep;
} }
result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
@ -425,16 +427,17 @@ export class SearchResearchResultsService {
result['journal'] ? result['journal'].journal : null, result.identifiers); result['journal'] ? result['journal'].journal : null, result.identifiers);
if (resData.hasOwnProperty("publiclyfunded") && resData.publiclyfunded) { if (resData['result'].hasOwnProperty("publiclyFunded") && resData['result'].publiclyFunded) {
result.publiclyFunded = resData.publiclyfunded; result.publiclyFunded = resData['result'].publiclyFunded;
} }
if ((resData.hasOwnProperty("isgreen") && resData.isgreen) //TODO check duplicates - are we going to keep one?
|| (resData.hasOwnProperty("openaccesscolor") && resData.openaccesscolor) if ((resData['result'].hasOwnProperty("isGreen") && resData['result'].isGreen)
|| (resData.hasOwnProperty("isindiamondjournal") && resData.isindiamondjournal)) { || (resData['result'].hasOwnProperty("openAccessColor") && resData['result'].openAccessColor)
|| (resData['result'].hasOwnProperty("isInDiamondJournal") && resData['result'].isInDiamondJournal)) {
result.oaRoutes = { result.oaRoutes = {
"green": resData.isgreen, "green": resData['result'].isGreen,
"oaColor": resData.openaccesscolor, "oaColor": resData['result'].openAccessColor,
"isInDiamondJournal": resData.isindiamondjournal "isInDiamondJournal": resData['result'].isInDiamondJournal
}; };
} }
}catch (e){ }catch (e){