diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index b65516e0..e88eaca6 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -152,7 +152,7 @@ export class ResultLandingComponent { this.id = data["id"]; this.initMetaAndLinks("result"); } else if (data["pid"]) { - this.identifier = Identifier.getIdentifierFromString(data["pid"]); + this.identifier = Identifier.getIdentifierFromString(decodeURIComponent(data["pid"])); if(!this.type) { this.type = "result"; diff --git a/services/searchOrganizations.service.ts b/services/searchOrganizations.service.ts index af8aee90..13fcfa1c 100644 --- a/services/searchOrganizations.service.ts +++ b/services/searchOrganizations.service.ts @@ -8,6 +8,7 @@ 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 SearchOrganizationsService { @@ -101,7 +102,10 @@ export class SearchOrganizationsService { //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']; - + 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; diff --git a/services/searchResearchResults.service.ts b/services/searchResearchResults.service.ts index 932acfa8..4cbfaac7 100644 --- a/services/searchResearchResults.service.ts +++ b/services/searchResearchResults.service.ts @@ -271,6 +271,10 @@ export class SearchResearchResultsService { } 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, "result"); + if(canId){ + result['id'] = canId; + } if(resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classname")) { result['title'].accessMode = resData['bestaccessright'].classname; } diff --git a/utils/result-preview/result-preview.component.ts b/utils/result-preview/result-preview.component.ts index edb23d93..5e60f8e9 100644 --- a/utils/result-preview/result-preview.component.ts +++ b/utils/result-preview/result-preview.component.ts @@ -5,6 +5,7 @@ import {RouterHelper} from "../routerHelper.class"; import {AlertModal} from "../modal/alert"; import {properties} from "../../../../environments/environment"; import {Session} from "../../login/utils/helper.class"; +import {Identifier} from "../string-utils.class"; @Component({ selector: 'result-preview', @@ -55,6 +56,13 @@ export class ResultPreviewComponent implements OnInit{ this.urlParam = "id"; this.url = properties.searchLinkToResult.split('?')[0]; } + // if result has a pid use it as parameter instead of openaireId + let pid:Identifier = Identifier.getResultPIDFromIdentifiers(this.result.identifiers); + if(pid){ + this.urlParam = "pid"; + this.result.id = encodeURIComponent(pid.id); + + } this.initBeforeTitle(); if(this.result.languages) { this.result.languages = this.removeUnknown(this.result.languages); diff --git a/utils/string-utils.class.ts b/utils/string-utils.class.ts index 30c6912c..c660e53c 100644 --- a/utils/string-utils.class.ts +++ b/utils/string-utils.class.ts @@ -157,6 +157,23 @@ export class Identifier { } return null; } + + public static getResultPIDFromIdentifiers(identifiers: Map): Identifier { + let classes:string [] = ["doi", "handle", "pmc", "pmid"]; + if(identifiers) { + for (let cl of classes){ + if(identifiers.get(cl)){ + for (let pid of identifiers.get(cl)) { + let identifier = Identifier.getIdentifierFromString(pid); + if (identifier){ + return identifier; + } + } + } + } + return null; + } + } public static isValidDOI(str: string): boolean { var exp1 = /\b(10[.][0-9]{4,}(?:[.][0-9]+)*\/(?:(?!["&\'<>])\S)+)\b/g