[Library | new-theme]: Allow also ?pid url parameter in datasource landing | Fixes in newSearchPage for service filters.

1. dataProvider.component.ts: [Bug fix] Allow also ?pid url parameter, query accordingly and set canonicalUrl to use it in seoService and scema2jsonld.
2. dataProvider.component.html: Set canonicalUrl into URL of <schema2jsonld> | Use <landing-header> instead of <showTitle>.
3. dataProvider.service.ts: Set url for querying a datasource by pid (if ?pid in landing url param) and parse also the whole record, the objIdentifier and the relcanId.
4. landing-header.component.ts: Added @Input() isSticky: boolean = false; to set less margins when sticky.
5. resultLanding.component.html: Use <landing-header> instead of <showTitle>.
6. resultLanding.component.ts: Use renamed Identifier.getResultPIDFromIdentifiers --> Identifier.getPIDFromIdentifiers.
7. metrics.service.ts: Removed console.log.
8. searchDataproviders.service.ts: Added parsing for relcanId.
9. dataProviderInfo.ts: Added relcanId, objIdentifier, record.
10. result-preview.component.ts: Use renamed Identifier.getResultPIDFromIdentifiers --> Identifier.getPIDFromIdentifiers.
11. string-utils.class.ts: Renamed Identifier.getResultPIDFromIdentifiers --> Identifier.getPIDFromIdentifiers.
12. [SITEMAPS] extractUrlsFromSearch.ts: Use renamed Identifier.getResultPIDFromIdentifiers --> Identifier.getPIDFromIdentifiers.
13. newSearchPage.component.ts: [Bug fix]
   a. entityType for datasources is "dataprovider".
   b. Added service filter options only when entityType == "service".
This commit is contained in:
Konstantina Galouni 2022-05-30 10:39:10 +03:00
parent 135638ad63
commit 95549185d9
12 changed files with 98 additions and 35 deletions

View File

@ -75,7 +75,7 @@
<div [attr.style]="'margin-top: '+(graph_height? 'calc(40px + 20px - '+graph_height+'px)': '40px')">
<!-- schema.org-->
<schema2jsonld [data]=dataProviderInfo
[URL]="properties.domain+ properties.baseLink + linkToLandingPage +datasourceId"
[URL]="canonicalUrl"
type="datasource"
[otherURL]="(dataProviderInfo.provenance)?provenanceUrls:null"></schema2jsonld>
<helper *ngIf="pageContents && pageContents['top'] && pageContents['top'].length > 0"
@ -139,7 +139,14 @@
uk-sticky="bottom: true; media: @m" [attr.offset]="offset"
cls-active="active">
<div class="uk-padding uk-padding-remove-horizontal uk-padding-remove-bottom">
<showTitle *ngIf="stickyHeader" [titleName]="dataProviderInfo.title.name" classNames="uk-margin-remove-bottom" class="uk-visible@m"></showTitle>
<landing-header *ngIf="stickyHeader" class="uk-visible@m"
[properties]="properties" [title]="dataProviderInfo.title.name"
[subTitle]="(dataProviderInfo.officialName
&& dataProviderInfo.title.name !== dataProviderInfo.officialName)?dataProviderInfo.officialName:null"
[types]="dataProviderInfo.type ? [dataProviderInfo.type] : null"
isSticky="true">
</landing-header>
<!-- <showTitle *ngIf="stickyHeader" [titleName]="dataProviderInfo.title.name" classNames="uk-margin-remove-bottom" class="uk-visible@m"></showTitle>-->
<my-tabs (selectedActiveTab)="onSelectActiveTab($event)" [offsetForSticky]="offset" [(isSticky)]="stickyHeader">
<my-tab [tabTitle]="'Summary'" [tabId]="'summary'" [active]="true"></my-tab>
<my-tab *ngIf="fetchProjects.searchUtils.totalResults > 0"

View File

@ -20,7 +20,7 @@ import {SEOService} from '../../sharedComponents/SEO/SEO.service';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {HelperService} from "../../utils/helper/helper.service";
import {Location} from "@angular/common";
import {StringUtils} from "../../utils/string-utils.class";
import {Identifier, StringUtils} from "../../utils/string-utils.class";
import {SearchResult} from "../../utils/entities/searchResult";
import {ResultPreview} from "../../utils/result-preview/result-preview";
import {IndexInfoService} from "../../utils/indexInfo.service";
@ -44,11 +44,13 @@ export class DataProviderComponent {
@Input() communityId = null;
public dataProviderInfo: DataProviderInfo;
public datasourceId: string;
public identifier: Identifier = null;
public provenanceUrls: string[] = null;
// Links for SEO
public linkToLandingPage: string = null;
public linkToSearchPage: string = null;
public canonicalUrl: string = null;
// Message variables
public warningMessage = "";
@ -186,8 +188,11 @@ export class DataProviderComponent {
this.datasourceId = data['serviceId'];
this.typeQueryPathParam = "services";
this.initMetaAndLinks("service");
} else if (data["pid"]) {
this.identifier = Identifier.getIdentifierFromString(decodeURIComponent(data["pid"]), false);
this.initMetaAndLinks(this.type);
}
if (this.datasourceId && StringUtils.isOpenAIREID(this.datasourceId)) {
if (this.datasourceId && StringUtils.isOpenAIREID(this.datasourceId) || (this.identifier)) {
this.initializeValues();
this.getDataProviderInfo(this.datasourceId);
} else {
@ -319,14 +324,20 @@ export class DataProviderComponent {
this.provenanceUrls = null;
this.showTabs = false;
if (this.datasourceId == null || this.datasourceId == '') {
if ((this.datasourceId == null || this.datasourceId == '') && this.identifier == null) {
this.showLoading = false;
this.warningMessage = "No valid "+this.getTypeName()+" id";
} else {
this.subscriptions.push(this._dataproviderService.getDataproviderInfo(this.datasourceId, this.properties, this.typeQueryPathParam).subscribe(
this.subscriptions.push(this._dataproviderService.getDataproviderInfo(this.datasourceId, this.identifier, this.properties, this.typeQueryPathParam).subscribe(
data => {
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: {

View File

@ -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 => <any> 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;

View File

@ -6,7 +6,7 @@ import {AlertModal} from "../../../utils/modal/alert";
@Component({
selector: 'landing-header',
template: `
<div class="title-section uk-margin-bottom" [ngClass]="titleClass">
<div class="title-section" [class.uk-margin-bottom]="!isSticky" [ngClass]="titleClass">
<div class="uk-text-small">
<span *ngIf="entityType" class="uk-text-capitalize uk-text-small">
{{entityType}}
@ -49,7 +49,7 @@ import {AlertModal} from "../../../utils/modal/alert";
class="uk-text-primary">Under curation</span>
</span>
</div>
<div class="uk-margin-medium-bottom">
<div [class]="isSticky ? 'uk-margon-bottom' : 'uk-margin-medium-bottom'">
<showTitle [titleName]="title" classNames="uk-margin-remove-bottom"></showTitle>
<div *ngIf="subTitle">
<span class="uk-text-meta uk-text-small" [innerHTML]="subTitle"></span>
@ -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');

View File

@ -173,7 +173,16 @@
uk-sticky="bottom: true; media: @m" [attr.offset]="offset"
cls-active="active">
<div class="uk-padding uk-padding-remove-horizontal uk-padding-remove-bottom">
<showTitle *ngIf="stickyHeader" [titleName]="resultLandingInfo.title" classNames="uk-margin-remove-bottom" class="uk-visible@m"></showTitle>
<landing-header *ngIf="stickyHeader" class="uk-visible@m"
[properties]="properties" [title]="resultLandingInfo.title"
[subTitle]="resultLandingInfo.subtitle"
[authors]="resultLandingInfo.authors"
[underCuration]="resultLandingInfo.underCurationMessage"
[entityType]="getTypeName()" [types]="resultLandingInfo.types"
[year]="resultLandingInfo.date" [embargoEndDate]="resultLandingInfo.embargoEndDate"
isSticky="true">
</landing-header>
<!-- <showTitle *ngIf="stickyHeader" [titleName]="resultLandingInfo.title" classNames="uk-margin-remove-bottom" class="uk-visible@m"></showTitle>-->
<my-tabs (selectedActiveTab)="onSelectActiveTab($event)" [offsetForSticky]="offset" [(isSticky)]="stickyHeader">
<my-tab tabTitle="Summary" [tabId]="'summary'" [active]="true"></my-tab>
<my-tab *ngIf="resultLandingInfo.references && resultLandingInfo.references.length > 0"

View File

@ -450,7 +450,7 @@ export class ResultLandingComponent {
this.viewsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' + encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly views","type":"column","query":{"name":"usagestats.results.views.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly views"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
this.downloadsFrameUrl = this.properties.statisticsFrameNewAPIURL + 'chart?json=' +
encodeURIComponent('{"library":"HighCharts","chartDescription":{"queries":[{"name":"Monthly downloads","type":"column","query":{"name":"usagestats.results.downloads.monthly", "parameters":["' + this.id + '"], "profile":"OpenAIRE All-inclusive" }}],"chart":{"backgroundColor":"#FFFFFFFF","borderColor":"#335cadff","borderRadius":0,"borderWidth":0,"plotBorderColor":"#ccccccff","plotBorderWidth":0},"title":{"text":"Monthly downloads"},"subtitle":{},"yAxis":{"title":{"text":""}},"xAxis":{"title":{}},"lang":{"noData":"No Data available for the Query"},"exporting":{"enabled":false},"plotOptions":{"series":{"dataLabels":{"enabled":false}}},"legend":{"enabled":false},"credits":{"href":null,"enabled":true,"text":""}}}');
let pid:Identifier = Identifier.getResultPIDFromIdentifiers(this.resultLandingInfo.identifiers);
let pid:Identifier = Identifier.getPIDFromIdentifiers(this.resultLandingInfo.identifiers);
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
this.updateUrlWithType(pid);
}

View File

@ -957,7 +957,7 @@ export class NewSearchPageComponent {
let params = "";
let doisParams = "";
var DOIs: Identifier[] = Identifier.getIdentifiersFromString(value);
if ((entityType == 'publication' || entityType == 'dataset' || entityType == 'software' || entityType == 'other' || entityType == "result" || entityType == "datasource" || entityType == "service")) {
if ((entityType == 'publication' || entityType == 'dataset' || entityType == 'software' || entityType == 'other' || entityType == "result" || entityType == "dataprovider" || entityType == "service")) {
for (let identifier of DOIs) {
// console.log(identifier)
// pidclassid exact \"doi\" and pid exact \"10.1016/j.nima.2015.11.134\"
@ -1374,7 +1374,7 @@ export class NewSearchPageComponent {
(
(this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result")
||
(this.entityType == "datasource" || this.entityType == "service")
(this.entityType == "service")
)
) {
let values = [];
@ -1504,7 +1504,7 @@ export class NewSearchPageComponent {
let options = null;
if ((this.entityType == 'publication' || this.entityType == 'dataset' || this.entityType == 'software' || this.entityType == 'other' || this.entityType == "result")) {
options = this.resultTypeOptions;
} else if (this.entityType == "datasource" || this.entityType == "service") {
} else if (this.entityType == "service") {
options = this.serviceTypeOptions;
}
if (options) {

View File

@ -78,7 +78,6 @@ export class MetricsService {
}catch(e){
console.error(e)
}
console.log(map)
return map;
}

View File

@ -301,6 +301,11 @@ export class SearchDataprovidersService {
//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']) {

View File

@ -13,6 +13,9 @@ export class DataproviderProvenance {
}
export class DataProviderInfo {
relcanId;
objIdentifier: string;
record;
title: { "name": string, "url": string };
officialName: string;
type: string;

View File

@ -99,7 +99,7 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
}
}
getPID() {
return Identifier.getResultPIDFromIdentifiers(this.result.identifiers);
return Identifier.getPIDFromIdentifiers(this.result.identifiers);
}
public initBeforeTitle() {

View File

@ -207,8 +207,8 @@ export class Identifier {
return (strict?null:{"class": "doi", "id": pid});
}
public static getResultPIDFromIdentifiers(identifiers: Map<string, string[]>): Identifier {
let classes:string [] = ["doi", "handle", "pmc", "pmid"];
public static getPIDFromIdentifiers(identifiers: Map<string, string[]>): Identifier {
let classes:string [] = ["doi", "handle", "pmc", "pmid", "re3data"];
if(identifiers) {
for (let cl of classes){
if(identifiers.get(cl)){