openaire-library/landingPages/result/resultLanding.component.ts

682 lines
29 KiB
TypeScript

import {ChangeDetectorRef, Component, Input, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Meta, Title} from '@angular/platform-browser';
import {EnvProperties} from '../../utils/properties/env-properties';
import {Id, ResultLandingInfo} from '../../utils/entities/resultLandingInfo';
import {RouterHelper} from '../../utils/routerHelper.class';
import {PiwikService} from '../../utils/piwik/piwik.service';
import {ResultLandingService} from './resultLanding.service';
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 {MetricsService} from "../../services/metrics.service";
import {RelationResult, ResultPreview} from "../../utils/result-preview/result-preview";
import {IndexInfoService} from "../../utils/indexInfo.service";
import {Identifier, StringUtils} from "../../utils/string-utils.class";
import {properties} from "../../../../environments/environment";
import {ISVocabulariesService} from "../../utils/staticAutoComplete/ISVocabularies.service";
import {Subscriber} from "rxjs";
import {Session} from "../../login/utils/helper.class";
import {AnnotationComponent} from "../annotation/annotation.component";
import {ParsingFunctions} from "../landing-utils/parsingFunctions.class";
@Component({
selector: 'result-landing',
templateUrl: 'resultLanding.component.html',
})
export class ResultLandingComponent {
@Input() type: string = "publication";
@Input() piwikSiteId = properties.piwikSiteId;
@Input() communityId = null;
enermapsId;
@ViewChild('linkModal') linkModal;
@ViewChild('citeModal') citeModal;
@ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
@ViewChild('relationModal') relationModal;
@ViewChild('organizationModal') organizationModal;
public deleteByInferenceOpened: boolean = false;
public resultLandingInfo: ResultLandingInfo;
public supplementaryResults: RelationResult[];
public relation: string = 'trust';
public id: string;
public title: string;
/*Show all organizations*/
public showAll: boolean = false;
// Links for SEO
public linkToLandingPage: string = null;
public linkToSearchPage: string = null;
public thresholdDescription: number = 670;
public showNumDescription: number = 670;
public citeThisClicked: boolean;
// Metrics tab variables
public metricsClicked: boolean;
public hasAltMetrics: boolean = false;
public viewsFrameUrl: string;
public downloadsFrameUrl: string;
public totalViews: number;
public totalDownloads: number;
public pageViews: number;
// Custom tab paging variables
public referencesPage: number = 1;
public bioentitiesPage: number = 1;
public relatedPage: number = 1;
public similarPage: number = 1;
public supplementaryPage: number = 1;
public supplementedByPage: number = 1;
public organizationsPage: number = 1;
public openCitationsPage: number = 1;
public pageSize: number = 10;
// Map counting variables
public bioentitiesNum: number = 0;
public relatedResultsNum: number = 0;
// Message variables
public warningMessage = "";
public errorMessage = "";
public showLoading: boolean = true;
public dashboard = properties.isDashboard;
public routerHelper: RouterHelper = new RouterHelper();
public activeTab: string = null;
private doi: string;
subscriptions = [];
properties: EnvProperties = properties;
public indexUpdateDate: Date;
public pageContents = null;
public divContents = null;
public showFeedback: boolean = false;
public feedbackFields: string [] = [
'Title', 'Authors', 'Access rights',
'Publisher information', 'Funding Information',
'Persistent identifiers', 'Other'];
public pidsArrayString: string = "";
public identifier: Identifier;
public isLoggedIn: boolean = Session.isLoggedIn();
public pid: string;
@ViewChild("annotation") annotation: AnnotationComponent;
constructor(private _resultLandingService: ResultLandingService,
private _vocabulariesService: ISVocabulariesService,
private _piwikService: PiwikService,
private route: ActivatedRoute,
private router: Router,
private _meta: Meta,
private _title: Title,
private _router: Router,
private helper: HelperService,
private seoService: SEOService,
private metricsService: MetricsService,
private cdr: ChangeDetectorRef,
private _location: Location,
private indexInfoService: IndexInfoService) {
}
ngOnInit() {
if (typeof document !== 'undefined') {
this.subscriptions.push(this.indexInfoService.getLastIndexDate(this.properties).subscribe(lastIndexUpdate => {
if (lastIndexUpdate) {
this.indexUpdateDate = new Date(lastIndexUpdate);
}
}));
}
//this.getDivContents();
this.getPageContents();
this.updateUrl(this.properties.domain +this.properties.baseLink + this._router.url);
this.subscriptions.push(this.route.queryParams.subscribe(data => {
this.resultLandingInfo = null;
if (data['articleId']) {
this.id = data['articleId'];
this.initMetaAndLinks("publication");
} else if (data['datasetId']) {
this.id = data['datasetId'];
this.initMetaAndLinks("dataset");
} else if (data['softwareId']) {
this.id = data['softwareId'];
this.initMetaAndLinks("software");
} else if (data['orpId']) {
this.id = data['orpId'];
this.initMetaAndLinks("orp");
} else if (data["id"]) {
this.id = data["id"];
this.initMetaAndLinks("result");
} else if (data["pid"]) {
this.identifier = Identifier.getIdentifierFromString(decodeURIComponent(data["pid"]));
if(!this.type) {
this.type = "result";
}
this.initMetaAndLinks(this.type);
}
this.updateDescription("");
this.metricsClicked = false;
if ((this.id && StringUtils.isOpenAIREID(this.id)) || (this.identifier)) {
this.getProvenanceVocabularyAndResultLandingInfo();
} else {
this.showLoading = false;
this._router.navigate(['/error'], {
queryParams: {
"page": this._location.path(true),
"page_type": this.type
}
});
}
this.scroll();
}));
}
private initMetaAndLinks(type: string) {
if (type == "publication") {
this.type = "publication";
this.updateTitle("Publication");
this.linkToLandingPage = this.properties.searchLinkToPublication;
this.linkToSearchPage = this.properties.searchLinkToPublications;
this.title = "Publication";
} else if (type == "dataset") {
this.updateTitle("Dataset");
this.type = "dataset";
this.linkToLandingPage = this.properties.searchLinkToDataset;
this.linkToSearchPage = this.properties.searchLinkToDatasets;
this.title = "Research Data";
} else if (type == "software") {
this.updateTitle("Software");
this.type = "software";
this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
this.linkToSearchPage = this.properties.searchLinkToSoftware;
this.title = "Software";
} else if (type == "orp") {
this.type = "orp";
this.updateTitle("Other Research Product");
this.linkToLandingPage = this.properties.searchLinkToOrp;
this.linkToSearchPage = this.properties.searchLinkToOrps;
this.title = "Other Research Product";
} else if (type == "result") {
this.type = "result";
this.updateTitle("Research Result");
this.linkToLandingPage = this.properties.searchLinkToResult;
this.linkToSearchPage = this.properties.searchLinkToResults;
this.title = "Research Result";
}
}
private getPageContents() {
if (this.communityId) {
this.subscriptions.push(this.helper.getPageHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.pageContents = contents;
}));
}
}
private getDivContents() {
if (this.communityId) {
this.subscriptions.push(this.helper.getDivHelpContents(this.properties, this.communityId, this._router.url).subscribe(contents => {
this.divContents = contents;
}));
}
}
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
this._vocabulariesService.clearSubscriptions();
}
public pidInit(event) {
this.pid = event;
this.cdr.detectChanges();
}
public getTypeName(): string {
if (this.type === "dataset") {
return "research data";
} else if (this.type === "orp" || this.type === "other") {
return "research product";
} else {
return this.type;
}
}
public removeUnknown(array: string[], type: boolean = false): string[] {
if (type) {
return this.removeDuplicates(array).filter(value => value.toLowerCase() !== 'unknown');
} else {
return array.filter(value => value.toLowerCase() !== 'unknown');
}
}
public removeDuplicates(array: string[]): string[] {
let type = this.getTypeName();
return array.filter(value => value.toLowerCase() !== type);
}
private getOpenCitations() {
this.subscriptions.push(this._resultLandingService.getOpenCitations(this.id, this.properties).subscribe(
data => {
this.resultLandingInfo.openCitations = data[1];
},
err => {
this.handleError("Error getting open citation for " + this.type + " with id: " + this.id, err);
}
));
}
private getProvenanceVocabularyAndResultLandingInfo() {
this.warningMessage = '';
this.errorMessage = '';
this.showLoading = true;
this.resultLandingInfo = null;
if (typeof document !== 'undefined') {
this.subscriptions.push(this._vocabulariesService.getProvenanceActionVocabulary(this.properties).subscribe(
provenanceActionVocabulary => {
this.getResultLandingInfo(provenanceActionVocabulary);
}, err => {
this.getResultLandingInfo(null);
this.handleError("Error getting provenance action vocabulary for " + this.type, err);
}
));
} else {
this.getResultLandingInfo(null);
}
}
private setActiveTab() {
if (this.hasPrimaryInfo || this.hasSecondaryInfo) {
this.activeTab = 'summary';
} else if (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0) {
this.activeTab = 'references';
} else if ((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) ||
(this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) {
this.activeTab = 'supplementary';
} else if ((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) ||
(this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) {
this.activeTab = 'related';
} else if (this.resultLandingInfo.bioentities && this.bioentitiesNum > 0) {
this.activeTab = 'bioentities';
}
}
// private get numberOfTabs(): number {
// let numberOfTabs = 0;
// if(this.hasPrimaryInfo || this.hasSecondaryInfo) {
// numberOfTabs++;
// }
// if(this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0) {
// numberOfTabs++;
// }
// if((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) ||
// (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) {
// numberOfTabs++;
// }
// if((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) ||
// (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) {
// numberOfTabs++;
// }
// if(this.resultLandingInfo.bioentities && this.bioentitiesNum > 0) {
// numberOfTabs++;
// }
// return numberOfTabs;
// }
private getResultLandingInfo(provenanceActionVocabulary: any) {
this.subscriptions.push(this._resultLandingService.getResultLandingInfo(this.id, this.identifier, this.type, provenanceActionVocabulary, this.properties).subscribe(
data => {
this.resultLandingInfo = data;
this.id = this.resultLandingInfo.objIdentifier;
this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false';
let pid:Identifier = Identifier.getResultPIDFromIdentifiers(this.resultLandingInfo.identifiers);
if (this.type == "result") { // no type was specified - update URL based this.resultLandingInfo.resultType
this.updateUrlWithType(pid);
}
this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + ( pid ? (this.linkToLandingPage.split("?")[0] + "?pid=" + encodeURIComponent(pid.id)):
(this.linkToLandingPage + this.resultLandingInfo.relcanId)));
if ((this.type == "publication") && (this.properties.environment == "beta" || this.properties.environment == "development") && (typeof document !== 'undefined')) {
this.getOpenCitations();
}
this.addNoIndexFilter();
if (this.resultLandingInfo.title) {
this.updateTitle(this.resultLandingInfo.title);
this.updateDescription((this.resultLandingInfo.description ? (this.resultLandingInfo.description) : ("," + this.resultLandingInfo.title)));
}
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.subscriptions.push(this._piwikService.trackViewForCustomUrl(this.properties, this.resultLandingInfo.title, this.linkToLandingPage.split("?")[1] + this.id ,this.piwikSiteId).subscribe());
}
let bioentitiesNum = 0;
if (this.resultLandingInfo.bioentities != undefined) {
this.resultLandingInfo.bioentities.forEach(function (value, key, map) {
bioentitiesNum += value.size;
});
}
this.bioentitiesNum = bioentitiesNum;
if (typeof document !== 'undefined') {
if(this.resultLandingInfo.identifiers) {
let pidsArray: string[] = [];
for(let key of Array.from(this.resultLandingInfo.identifiers.keys())) {
pidsArray = pidsArray.concat(this.resultLandingInfo.identifiers.get(key));
this.pidsArrayString = pidsArray.join();
}
if (this.resultLandingInfo.identifiers.has('doi')) {
this.doi = this.resultLandingInfo.identifiers.get('doi')[0];
this.subscriptions.push(this.metricsService.hasAltMetrics(this.properties.altMetricsAPIURL, this.doi).subscribe(hasAltMetrics => {
this.hasAltMetrics = hasAltMetrics;
}, error => {
this.hasAltMetrics = false;
}));
}
}
}
if(this.communityId && this.communityId == "enermaps" && properties.enermapsURL){
this.enermapsId = ParsingFunctions.getEnermapsConceptId(this.resultLandingInfo.contexts);
}
this.showLoading = false;
this.setActiveTab();
},
err => {
this.handleError("Error getting " + this.type + " for " + (this.id ? ("id: " + this.id) : ("pid: " + this.identifier.id + " ("+this.identifier.class+")")), err);
if (err.status == 404) {
this._router.navigate(['/error'], {queryParams: {"page": this._location.path(true), "page_type": this.type}});
}
if (this.type == "publication" || this.type == "software") {
this.errorMessage = 'No ' + this.type + ' found';
} else if (this.type == "dataset") {
this.errorMessage += "No research data found";
} else if (this.type == "orp") {
this.errorMessage += "No research product found";
}
this.showLoading = false;
this.seoService.createLinkForCanonicalURL(this.properties.domain+ properties.baseLink + this.linkToSearchPage);
}
));
}
public metricsResults($event) {
this.totalViews = $event.totalViews;
this.totalDownloads = $event.totalDownloads;
this.pageViews = $event.pageViews;
}
public get hasPrimaryInfo(): boolean {
return !!this.resultLandingInfo && (!!this.resultLandingInfo.description || !!this.resultLandingInfo.identifiers || !!this.resultLandingInfo.subjects);
}
public get hasSecondaryInfo(): boolean {
return (this.resultLandingInfo.fundedByProjects && this.resultLandingInfo.fundedByProjects.length > 0) ||
(this.resultLandingInfo.contexts && this.resultLandingInfo.contexts.length > 0) ||
(this.resultLandingInfo.hostedBy_collectedFrom && this.resultLandingInfo.hostedBy_collectedFrom.length > 0);
}
public get hasMetrics(): boolean {
return !(this.totalViews && this.totalDownloads && this.pageViews) || this.totalViews > 0 || this.totalDownloads > 0 || this.pageViews > 0;
}
private updateDescription(description: string) {
this._meta.updateTag({content: description.substring(0, 160)}, "name='description'");
this._meta.updateTag({content: description.substring(0, 160)}, "property='og:description'");
}
private updateTitle(title: string) {
var _prefix = "";
// if(!this.communityId) {
// _prefix = "OpenAIRE | ";
// }
// var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(title);
this._meta.updateTag({content: title}, "property='og:title'");
}
private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'");
}
public totalPages(totalResults: number): number {
let totalPages: any = totalResults / this.pageSize;
if (!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, this.pageSize) + 1);
}
return totalPages;
}
public updateReferencesPage($event) {
this.referencesPage = $event.value;
}
public updateBioentitiesPage($event) {
this.bioentitiesPage = $event.value;
}
public updateRelatedPage($event) {
this.relatedPage = $event.value;
}
public updateSimilarPage($event) {
this.similarPage = $event.value;
}
public updateSupplementaryPage($event) {
this.supplementaryPage = $event.value;
}
public updateSupplementedByPage($event) {
this.supplementedByPage = $event.value;
}
public updateOrganizationsPage($event) {
this.organizationsPage = $event.value;
}
public updateOpenCitationsPage($event) {
this.openCitationsPage = $event.value;
}
public accessClass(accessMode: string): string {
if (accessMode.toLowerCase().indexOf('open') !== -1) {
return 'open';
} else if (accessMode.toLowerCase() === 'not available') {
return 'unknown';
} else {
return 'closed';
}
}
public keysToArray(bioentities: Map<string, string>): string[] {
let keys: string[] = [];
bioentities.forEach(function (value, key, map) {
keys.push(key);
});
return keys;
}
public getKeys(map) {
return Array.from(map.keys());
}
public scroll() {
HelperFunctions.scroll();
}
private handleError(message: string, error) {
if (this.type == "publication") {
console.error("Publication Landing Page: " + message, error);
} else if (this.type == "dataset") {
console.error("Research Data Landing Page: " + message, error);
} else if (this.type == "software") {
console.error("Software Landing Page: " + message, error);
} else if (this.type == "orp") {
console.error("Other Research Product Landing Page: " + message, error);
} else {
console.error("Landing Page: " + message, error);
}
}
isRouteAvailable(routeToCheck: string) {
for (let i = 0; i < this.router.config.length; i++) {
let routePath: string = this.router.config[i].path;
if (routePath == routeToCheck) {
return true;
}
}
return false;
}
openDeletedByInference() {
this.deleteByInferenceOpened = true;
this.alertModalDeletedByInference.cancelButton = false;
this.alertModalDeletedByInference.okButton = false;
this.alertModalDeletedByInference.alertTitle = "Other versions of";
this.alertModalDeletedByInference.open();
}
public getResultPreview(result: RelationResult): ResultPreview {
return ResultPreview.relationResultConvert(result, this.relation);
}
updateUrlWithType(pid) {
this.type = this.resultLandingInfo.resultType;
if (this.type == "publication") {
this.linkToLandingPage = this.properties.searchLinkToPublication;
this.linkToSearchPage = this.properties.searchLinkToPublications;
} else if (this.type == "dataset") {
this.linkToLandingPage = this.properties.searchLinkToDataset;
this.linkToSearchPage = this.properties.searchLinkToDatasets;
} else if (this.type == "software") {
this.linkToLandingPage = this.properties.searchLinkToSoftwareLanding;
this.linkToSearchPage = this.properties.searchLinkToSoftware;
} else if (this.type == "other") {
this.type = "orp";
this.linkToLandingPage = this.properties.searchLinkToOrp;
this.linkToSearchPage = this.properties.searchLinkToOrps;
}
if(!this.identifier) {
this._location.go(( pid ? (this.linkToLandingPage.split("?")[0] + "?pid=" + pid.id):
(this.linkToLandingPage + this.id)));
}
// else {
// this._location.go(this.linkToLandingPage.split("?")[0] + "?pid=" + this.identifier.id);
// }
}
public getReferenceUrl(id: Id): string {
if (id.type === "doi") {
return this.properties.doiURL + id.value;
} else if (id.type === "pmc") {
return this.properties.pmcURL + id.value;
} else if (id.type === "pmid") {
return this.properties.pmidURL + id.value;
} else if (id.type === "handle") {
return this.properties.handleURL + id.value;
} else {
return null;
}
}
public getReferenceIdName(id: Id): string {
if (id.type === "doi") {
return 'DOI'
} else if (id.type === "pmc") {
return 'Europe PMC'
} else if (id.type === "pmid") {
return 'PubMed';
} else if (id.type === "handle") {
return 'Handle.NET';
} else {
return null;
}
}
public openLinkModal() {
this.linkModal.cancelButton = false;
this.linkModal.okButton = false;
this.linkModal.alertTitle = "Link this " + this.getTypeName() + " to";
this.linkModal.open();
}
public openCiteModal() {
this.citeThisClicked = true;
this.citeModal.cancelButton = false;
this.citeModal.okButton = false;
this.citeModal.alertTitle = "Cite this " + this.getTypeName();
this.citeModal.open();
}
private addNoIndexFilter() {
try {
if(!(this.properties.environment == "production" || this.properties.environment == "development") ) {
return ;
}else {
let allow = !!(!this.resultLandingInfo.underCurationMessage &&
((this.resultLandingInfo.fundedByProjects && this.resultLandingInfo.fundedByProjects.length > 0)
|| this.resultLandingInfo.journal
|| (this.resultLandingInfo.classifiedSubjects && this.resultLandingInfo.classifiedSubjects.size > 0)
//allow free text keywords
|| (this.resultLandingInfo.otherSubjects && this.resultLandingInfo.otherSubjects.size > 0)
|| (this.resultLandingInfo.subjects && this.resultLandingInfo.subjects.length > 0)
|| (this.resultLandingInfo.organizations && this.resultLandingInfo.organizations.length > 0)
|| this.resultLandingInfo.bioentities || (this.resultLandingInfo.references && this.resultLandingInfo.references.length > 0)
|| (this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0)
|| (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)
|| (this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0)
|| (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)
)
);
//spam words to exclude
let title_authors_words = ["movie","hd","film","kimetsu", "1080p","4k","call of duty", "mobile hack", "TUBYDI"];
let abstract_words = ["operacao-feliz-natal.blogspot.com", "moviedouban.site", "hack-expert-solution.link"];
allow = allow && !(
(this.hasKeyword(this.resultLandingInfo.title,title_authors_words) || (this.resultLandingInfo.authors && this.hasKeyword(this.resultLandingInfo.authors.map(o => o.fullName).join(" "),title_authors_words))
|| (this.resultLandingInfo.description && this.hasKeyword(this.resultLandingInfo.description,abstract_words))
) &&
(this.resultLandingInfo.publisher == "Zenodo" ||
this.resultLandingInfo.hostedBy_collectedFrom.filter( value => {return value.downloadName && value.downloadName.indexOf("zenodo")!=-1}).length > 0));
//common titles/ description / authors
let common_titles = ["introduction", "editorial", "book reviews", "preface", "reviews", "none", "book review", "foreword", "conclusion", "review", "reply","einleitung","short notices","erratum","discussion", "letters to the editor","letter to the editor","reviews of books",":{unav)","editorial board"];
let common_abstract = ["international audience","n/a","peer reviewed","national audience","info:eu-repo/semantics/published","-",".","graphical abstract","met lit. opg","international audience; no abstract",'<jats:p>.</jats:p>',"politics","info:eu-repo/semantics/publishedversion","copia digital. madrid : ministerio de educación, cultura y deporte, 2016",'<jats:p />',"peer-reviewed","copia digital. madrid : ministerio de educación, cultura y deporte. subdirección general de coordinación bibliotecaria, 2015","<jats:p>-</jats:p>","imperial users only","yüksek lisans"];
let common_authors = ["[s.n.]","null &na;","nn","(:unap)","(:null)","null anonymous","anonymous"];
allow = allow && !(
this.isKeyword(this.resultLandingInfo.title,common_titles) || this.isKeyword(this.resultLandingInfo.description,common_abstract) ||
(this.resultLandingInfo.authors && this.hasKeyword(this.resultLandingInfo.authors.map(o => o.fullName).join(" "),common_authors))
);
if(!allow) {
this._meta.updateTag({content: 'noindex'}, "name='robots'");
}
}
} catch (e) {
console.error("Error in passNoIndexFilter()", this.resultLandingInfo.relcanId, e);
return false;
}
}
private hasKeyword(value:string, words:string[]){
return value?words.filter( word => { return value.toLowerCase().indexOf(word)!=-1}).length > 0:0;
}
private isKeyword(value:string, words:string[]){
return value?words.filter( word => { return value.toLowerCase() == word}).length > 0:0;
}
}