diff --git a/landingPages/dataProvider/dataProvider.component.html b/landingPages/dataProvider/dataProvider.component.html index 416fe498..146e2207 100644 --- a/landingPages/dataProvider/dataProvider.component.html +++ b/landingPages/dataProvider/dataProvider.component.html @@ -75,7 +75,7 @@
- + + + { this.dataProviderInfo = data; this.getProvenanceUrls(); + this.datasourceId = this.dataProviderInfo.objIdentifier; + let pid:Identifier = Identifier.getPIDFromIdentifiers(this.dataProviderInfo.identifiers); + this.canonicalUrl = this.properties.domain+ properties.baseLink + ( pid ? (this.linkToLandingPage.split("?")[0] + "?pid=" + encodeURIComponent(pid.id)): + (this.linkToLandingPage + this.dataProviderInfo.relcanId)); + this.seoService.createLinkForCanonicalURL(this.canonicalUrl); + this.updateUrl(this.canonicalUrl); this.seoService.createLinkForCanonicalURL(this.properties.domain +this.properties.baseLink + this._router.url); if (typeof document !== 'undefined') { this.getDataProviderAggregationStatus(this.dataProviderInfo.originalId); @@ -352,7 +363,7 @@ export class DataProviderComponent { }, err => { //console.log(err); - this.handleError("Error getting "+this.openaireEntities.DATASOURCE+" for id: " + this.datasourceId, err); + this.handleError("Error getting " + this.type + " for " + (this.datasourceId ? ("id: " + this.datasourceId) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err); if (err.status == 404) { this._router.navigate([this.properties.errorLink], { queryParams: { diff --git a/landingPages/dataProvider/dataProvider.service.ts b/landingPages/dataProvider/dataProvider.service.ts index ab6f237e..f1c8598a 100644 --- a/landingPages/dataProvider/dataProvider.service.ts +++ b/landingPages/dataProvider/dataProvider.service.ts @@ -6,6 +6,8 @@ import{EnvProperties} from '../../utils/properties/env-properties'; import {map} from "rxjs/operators"; import {ParsingFunctions} from "../landing-utils/parsingFunctions.class"; import {OpenaireEntities} from "../../utils/properties/searchFields"; +import {Identifier} from "../../utils/string-utils.class"; +import {properties} from "../../../../environments/environment"; @Injectable() @@ -18,24 +20,46 @@ export class DataProviderService { dataProviderInfo: DataProviderInfo; public parsingFunctions: ParsingFunctions; - getDataproviderInfo (id: string, properties:EnvProperties, typePathParam: string):any { - let url = properties.searchAPIURLLAst + typePathParam+ '/' +id +"?format=json"; - let key = url; - - return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) - //.map(res => res.json()) - .pipe(map(res => res['result']['metadata']['oaf:entity'])) - .pipe(map(res => [res['oaf:datasource'], - res['oaf:datasource']['datasourcetype'], - res['oaf:datasource']['openairecompatibility'], - res['oaf:datasource']['collectedfrom'], - res['oaf:datasource']['accessinfopackage'], - res['oaf:datasource']['rels']['rel'], - res['oaf:datasource']['journal'] //6 - ])) - .pipe(map(res => this.parseDataProviderInfo(res))); - + private buildDatasourceLandingInfoUrl(id: string, identifier: Identifier, typePathParam: string): string { + if (id) { + return properties.searchAPIURLLAst + typePathParam + "/" + id + '?format=json'; + } else if (identifier) { + return properties.searchAPIURLLAst + "resources2?pid="+encodeURIComponent(identifier.id) + "&pidtype=" + identifier.class + "&type="+typePathParam+"&format=json"; } + } + + getDataproviderInfo (id: string, identifier: Identifier, properties: EnvProperties, typePathParam: string): any { + let url: string = this.buildDatasourceLandingInfoUrl(id, identifier, typePathParam); + let finalUrl: string = (properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url; + return this.http.get(finalUrl) + .pipe(map(res => { + if(!id && identifier) { + if(!res['results'] || res['results'].length == 0) { + throw new HttpErrorResponse({ + status: 404, + statusText: "Not found", + url: finalUrl, + error: "Http failure response for "+finalUrl+": 404 Not Found" + }); + } + return res['results'][0]; + } else { + return res; + } + })) + .pipe(map(res => [res['result']['metadata']['oaf:entity'], res])) + .pipe(map(res => [ + res[0]['oaf:datasource'], // 0 + res[0]['oaf:datasource']['datasourcetype'], // 1 + res[0]['oaf:datasource']['openairecompatibility'], // 2 + res[0]['oaf:datasource']['collectedfrom'], // 3 + res[0]['oaf:datasource']['accessinfopackage'], // 4 + res[0]['oaf:datasource']['rels']['rel'], // 5 + res[0]['oaf:datasource']['journal'], // 6 + res[1] // 7 + ])) + .pipe(map(res => this.parseDataProviderInfo(res))); + } getDataproviderAggregationStatus(original_id: string, properties:EnvProperties):any { //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); @@ -109,6 +133,10 @@ export class DataProviderService { parseDataProviderInfo (data: any):any { this.dataProviderInfo = new DataProviderInfo(); + this.dataProviderInfo.record = data[7]; + this.dataProviderInfo.objIdentifier = data[7]["result"]["header"]["dri:objIdentifier"]; + this.dataProviderInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.dataProviderInfo.record, "datasource"); + if(data[0] != null) { this.dataProviderInfo.title = {"name": (data[0].englishname)?data[0].englishname: data[0].officialname, "url": data[0].websiteurl}; this.dataProviderInfo.officialName = data[0].officialname; diff --git a/landingPages/landing-utils/landing-header/landing-header.component.ts b/landingPages/landing-utils/landing-header/landing-header.component.ts index a64ebf59..805ded09 100644 --- a/landingPages/landing-utils/landing-header/landing-header.component.ts +++ b/landingPages/landing-utils/landing-header/landing-header.component.ts @@ -6,7 +6,7 @@ import {AlertModal} from "../../../utils/modal/alert"; @Component({ selector: 'landing-header', template: ` -
+
{{entityType}} @@ -49,7 +49,7 @@ import {AlertModal} from "../../../utils/modal/alert"; class="uk-text-primary">Under curation
-
+
@@ -78,6 +78,7 @@ export class LandingHeaderComponent { @Input() modal: AlertModal; @Input() titleClass: string = null; @Input() isTitleH1:boolean =true; + @Input() isSticky: boolean = false; public removeUnknown(array: string[], type: boolean = false): string[] { if (type) { return this.removeDuplicates(array).filter(value => value.toLowerCase() !== 'unknown'); diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index c7424b7e..f5980b18 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -173,7 +173,16 @@ uk-sticky="bottom: true; media: @m" [attr.offset]="offset" cls-active="active">
- + + + ): Identifier { - let classes:string [] = ["doi", "handle", "pmc", "pmid"]; + public static getPIDFromIdentifiers(identifiers: Map): Identifier { + let classes:string [] = ["doi", "handle", "pmc", "pmid", "re3data"]; if(identifiers) { for (let cl of classes){ if(identifiers.get(cl)){