2020-03-30 16:24:56 +02:00
import { ChangeDetectorRef , Component , Input , ViewChild } from '@angular/core' ;
2020-02-19 16:35:48 +01:00
import { ActivatedRoute , Router } from '@angular/router' ;
import { Location } from '@angular/common' ;
2022-09-21 09:29:11 +02:00
import { Meta , Title } from '@angular/platform-browser' ;
2020-02-19 16:35:48 +01:00
import { FetchResearchResults } from '../../utils/fetchEntitiesClasses/fetchResearchResults.class' ;
import { FetchDataproviders } from '../../utils/fetchEntitiesClasses/fetchDataproviders.class' ;
import { FetchProjects } from '../../utils/fetchEntitiesClasses/fetchProjects.class' ;
import { FetchOrganizations } from '../../utils/fetchEntitiesClasses/fetchOrganizations.class' ;
import { SearchResearchResultsService } from '../../services/searchResearchResults.service' ;
import { SearchDataprovidersService } from '../../services/searchDataproviders.service' ;
import { SearchProjectsService } from '../../services/searchProjects.service' ;
import { SearchOrganizationsService } from '../../services/searchOrganizations.service' ;
2022-04-15 23:49:35 +02:00
import { OpenaireEntities , SearchFields } from '../../utils/properties/searchFields' ;
2020-02-19 16:35:48 +01:00
import { ErrorCodes } from '../../utils/properties/errorCodes' ;
import { RouterHelper } from '../../utils/routerHelper.class' ;
import { RefineFieldResultsService } from '../../services/refineFieldResults.service' ;
import { PiwikService } from '../../utils/piwik/piwik.service' ;
import { ConfigurationService } from '../../utils/configuration/configuration.service' ;
import { EnvProperties } from '../../utils/properties/env-properties' ;
import { SEOService } from '../../sharedComponents/SEO/SEO.service' ;
import { StringUtils } from '../../utils/string-utils.class' ;
import { SearchCustomFilter } from "../searchUtils/searchUtils.class" ;
2020-11-11 15:43:13 +01:00
import { Subscription } from "rxjs" ;
2020-02-19 16:35:48 +01:00
import { AdvancedField , Filter } from "../searchUtils/searchHelperClasses.class" ;
2020-03-30 16:24:56 +02:00
import { SearchResearchResultsComponent } from "../searchResearchResults.component" ;
import { SearchProjectsComponent } from "../searchProjects.component" ;
import { SearchOrganizationsComponent } from "../searchOrganizations.component" ;
import { SearchDataProvidersComponent } from "../searchDataProviders.component" ;
2022-04-15 23:49:35 +02:00
import { NewSearchPageComponent , SearchForm } from "../searchUtils/newSearchPage.component" ;
2020-11-18 17:06:27 +01:00
import { properties } from "../../../../environments/environment" ;
2022-04-15 23:49:35 +02:00
import { Breadcrumb } from "../../utils/breadcrumbs/breadcrumbs.component" ;
2020-02-19 16:35:48 +01:00
@Component ( {
selector : 'search-all' ,
templateUrl : 'searchAll.component.html'
} )
export class SearchAllComponent {
2022-05-13 14:57:31 +02:00
reload : { result :boolean , projects :boolean , datasources : boolean , services : boolean , organizations :boolean } =
{ result :true , projects :true , datasources : true , services : true , organizations :true } ;
2020-02-19 16:35:48 +01:00
public pageTitle = "Search in OpenAIRE"
public keyword : string = "" ;
public publications : string [ ] ;
public datasets : string [ ] ;
public software : string [ ] ;
public orps : string [ ] ;
public projectsTab : string [ ] ;
public dataproviders : string [ ] ;
public organizations : string [ ] ;
public activeEntity = null ;
public linkToSearchPublications = "" ;
public linkToSearchProjects = "" ;
public linkToSearchDataproviders = "" ;
public linkToSearchOrganizations = "" ;
public fetchPublications : FetchResearchResults ;
public fetchDataproviders : FetchDataproviders ;
2022-05-13 14:57:31 +02:00
public fetchServices : FetchDataproviders ;
2020-02-19 16:35:48 +01:00
public fetchProjects : FetchProjects ;
public fetchDatasets : FetchResearchResults ;
public fetchSoftware : FetchResearchResults ;
public fetchOrps : FetchResearchResults ;
public fetchOrganizations : FetchOrganizations ;
public searchFields : SearchFields = new SearchFields ( ) ;
public errorCodes : ErrorCodes = new ErrorCodes ( ) ;
public routerHelper : RouterHelper = new RouterHelper ( ) ;
2022-04-15 23:49:35 +02:00
public resultsName = OpenaireEntities . RESULTS ;
public projectName = OpenaireEntities . PROJECTS ;
public organizationsName = OpenaireEntities . ORGANIZATIONS ;
public dataSourcesName = OpenaireEntities . DATASOURCES ;
2022-05-13 14:57:31 +02:00
public servicesName = OpenaireEntities . SERVICES ;
2020-02-19 16:35:48 +01:00
showPublications : boolean = false ;
showDatasets : boolean = false ;
showSoftware : boolean = false ;
showOrps : boolean = false ;
showProjects : boolean = false ;
showDataProviders : boolean = false ;
2022-05-13 14:57:31 +02:00
showServices : boolean = false ;
2020-02-19 16:35:48 +01:00
showOrganizations : boolean = false ;
advancedSearchLink : string = "/search/advanced/publications" ;
properties : EnvProperties ;
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
public openaireEntities = OpenaireEntities ;
2020-02-19 16:35:48 +01:00
@Input ( ) logoURL ;
@Input ( ) name ;
2020-04-22 15:00:13 +02:00
@Input ( ) customFilter : SearchCustomFilter = null ;
2020-02-19 16:35:48 +01:00
@Input ( ) piwikSiteId = null ;
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
@Input ( ) formPlaceholderText = "Search for " + OpenaireEntities . RESULTS + ", " + OpenaireEntities . PROJECTS + ", " + OpenaireEntities . DATASOURCES + " & " + OpenaireEntities . ORGANIZATIONS + " in OpenAIRE" ;
2022-04-15 23:49:35 +02:00
@Input ( ) searchForm : SearchForm = { class : 'search-form' , dark : true }
@Input ( ) breadcrumbs : Breadcrumb [ ] = [ ] ;
2020-07-13 00:19:30 +02:00
subs : Subscription [ ] = [ ] ;
2020-02-19 16:35:48 +01:00
quickFilter : { filter : Filter , selected : boolean , filterId : string , value : string } = {
filter : null ,
selected : true ,
filterId : "resultbestaccessright" ,
value : "Open Access"
} ;
resultTypes = { publication : true , dataset : true , software : true , other : true } ;
//adv Search Form
2022-09-08 23:46:44 +02:00
public fieldIds : string [ ] = this . searchFields . getResultAdvancedFields ( ) ;
2020-02-19 16:35:48 +01:00
public fieldIdsMap = this . searchFields . RESULT_FIELDS ;
public selectedFields : AdvancedField [ ] = [ ] ;
//new
parameters = { } ;
disableForms : boolean = true ;
2021-07-14 13:19:57 +02:00
@ViewChild ( SearchResearchResultsComponent ) searchResearchResultsComponent : SearchResearchResultsComponent ;
@ViewChild ( SearchProjectsComponent ) searchProjectsComponent : SearchProjectsComponent ;
@ViewChild ( SearchDataProvidersComponent ) searchDataprovidersComponent : SearchDataProvidersComponent ;
2022-05-13 14:57:31 +02:00
@ViewChild ( SearchDataProvidersComponent ) searchServicesComponent : SearchDataProvidersComponent ;
2021-07-14 13:19:57 +02:00
@ViewChild ( SearchOrganizationsComponent ) searchOrganizationsComponent : SearchOrganizationsComponent ;
2020-02-19 16:35:48 +01:00
constructor ( private route : ActivatedRoute ,
private _router : Router ,
private _searchResearchResultsService : SearchResearchResultsService ,
private _searchDataprovidersService : SearchDataprovidersService ,
private _searchProjectsService : SearchProjectsService ,
private _searchOrganizationsService : SearchOrganizationsService ,
private _refineFieldResultsService : RefineFieldResultsService ,
private location : Location ,
private _meta : Meta ,
private _title : Title ,
private _piwikService : PiwikService ,
private config : ConfigurationService ,
private seoService : SEOService , private router : Router , private cdr :ChangeDetectorRef ) {
this . fetchPublications = new FetchResearchResults ( this . _searchResearchResultsService ) ;
this . fetchDataproviders = new FetchDataproviders ( this . _searchDataprovidersService ) ;
2022-05-13 14:57:31 +02:00
this . fetchServices = new FetchDataproviders ( this . _searchDataprovidersService ) ;
2020-02-19 16:35:48 +01:00
this . fetchProjects = new FetchProjects ( this . _searchProjectsService ) ;
this . fetchDatasets = new FetchResearchResults ( this . _searchResearchResultsService ) ;
this . fetchSoftware = new FetchResearchResults ( this . _searchResearchResultsService ) ;
this . fetchOrps = new FetchResearchResults ( this . _searchResearchResultsService ) ;
this . fetchOrganizations = new FetchOrganizations ( this . _searchOrganizationsService ) ;
2022-06-23 16:30:45 +02:00
this . searchFields . sortFieldsByName ( this . fieldIds , this . fieldIdsMap ) ;
2020-02-19 16:35:48 +01:00
this . selectedFields . push ( new AdvancedField ( this . fieldIds [ 0 ] , this . fieldIdsMap [ this . fieldIds [ 0 ] ] . param , this . fieldIdsMap [ this . fieldIds [ 0 ] ] . name , this . fieldIdsMap [ this . fieldIds [ 0 ] ] . type , '' , "and" ) ) ;
}
public ngOnInit() {
2020-11-18 17:06:27 +01:00
2020-02-19 16:35:48 +01:00
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
var description = "Search for " + OpenaireEntities . RESULTS + " (" + OpenaireEntities . PUBLICATIONS + ", " + OpenaireEntities . DATASETS + ", " + OpenaireEntities . SOFTWARE + ", " + OpenaireEntities . OTHER + "), " + OpenaireEntities . PROJECTS + ", " + OpenaireEntities . ORGANIZATIONS + ", " + OpenaireEntities . DATASOURCES + " in the OpenAIRE Research Graph. " ;
var title = "OpenAIRE |Search for " + OpenaireEntities . RESULTS + ", " + OpenaireEntities . PROJECTS + ", " + OpenaireEntities . DATASOURCES + " & " + OpenaireEntities . ORGANIZATIONS ;
2020-11-18 17:06:27 +01:00
this . properties = properties ;
2020-09-18 12:10:18 +02:00
var url = this . properties . domain + this . properties . baseLink + this . _router . url ;
2020-02-19 16:35:48 +01:00
this . _title . setTitle ( title ) ;
this . _meta . updateTag ( { content : description } , "name='description'" ) ;
this . _meta . updateTag ( { content : description } , "property='og:description'" ) ;
this . _meta . updateTag ( { content : title } , "property='og:title'" ) ;
this . _meta . updateTag ( { content : url } , "property='og:url'" ) ;
2020-09-18 09:57:42 +02:00
this . seoService . createLinkForCanonicalURL ( this . properties . domain + this . properties . baseLink + this . _router . url , false ) ;
2020-02-19 16:35:48 +01:00
if ( this . properties . enablePiwikTrack && ( typeof document !== 'undefined' ) ) {
2020-08-19 12:16:43 +02:00
this . subs . push ( this . _piwikService . trackView ( this . properties , title , this . piwikSiteId ) . subscribe ( ) ) ;
2020-02-19 16:35:48 +01:00
}
2020-04-03 18:00:19 +02:00
if ( ( this . customFilter && this . customFilter . queryFieldName == "communityId" ) || this . properties . adminToolsCommunity ) {
2020-07-13 00:19:30 +02:00
//this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
this . subs . push ( this . config . communityInformationState . subscribe ( data = > {
2020-12-07 11:22:24 +01:00
if ( data && data [ 'entities' ] ) {
2020-07-13 00:19:30 +02:00
var showEntity = { } ;
for ( var i = 0 ; i < data [ 'entities' ] . length ; i ++ ) {
showEntity [ "" + data [ 'entities' ] [ i ] [ "pid" ] + "" ] = data [ 'entities' ] [ i ] [ "isEnabled" ] ;
}
this . showPublications = showEntity [ "publication" ] ;
this . showDatasets = showEntity [ "dataset" ] ;
this . showProjects = showEntity [ "project" ] ;
this . showOrganizations = showEntity [ "organization" ] ;
this . showDataProviders = showEntity [ "datasource" ] ;
2022-05-13 14:57:31 +02:00
this . showServices = showEntity [ "service" ] ;
2020-07-13 00:19:30 +02:00
this . showSoftware = showEntity [ "software" ] ;
this . showOrps = showEntity [ "orp" ] ;
if ( this . customFilter && this . customFilter . queryFieldName == "communityId" ) {
this . showProjects = false ;
this . showOrganizations = false ;
this . showDataProviders = false ;
2022-05-13 14:57:31 +02:00
this . showServices = false ;
2020-07-13 00:19:30 +02:00
}
this . loadAll ( ) ;
2020-02-19 16:35:48 +01:00
}
2020-07-13 00:19:30 +02:00
} ) ) ;
2020-02-19 16:35:48 +01:00
} else {
if ( ( this . customFilter && this . customFilter . queryFieldName == "country" ) ) {
this . showPublications = true ;
this . showDatasets = true ;
this . showSoftware = true ;
this . showOrps = true ;
this . showProjects = true ;
this . showOrganizations = true ;
this . showDataProviders = true ;
2022-05-13 14:57:31 +02:00
this . showServices = false ;
2020-02-19 16:35:48 +01:00
}
}
this . loadAll ( ) ;
2020-11-18 17:06:27 +01:00
2020-02-19 16:35:48 +01:00
}
loadAll() {
this . reloadTabs ( ) ;
2020-07-13 00:19:30 +02:00
this . subs . push ( this . route . queryParams . subscribe ( params = > {
2020-02-19 16:35:48 +01:00
this . parameters = Object . assign ( { } , params ) ;
2020-03-27 13:39:18 +01:00
this . keyword = ( params [ 'keyword' ] ) ? params [ 'keyword' ] : ( params [ "q" ] ? params [ "q" ] : ( params [ "f0" ] && params [ "f0" ] == "q" && params [ "fv0" ] ? params [ "fv0" ] : "" ) ) ;
2020-04-15 20:54:56 +02:00
this . selectedFields [ 0 ] . value = StringUtils . URIDecode ( this . keyword ) ;
2020-02-19 16:35:48 +01:00
this . quickFilter . selected = ( ( params [ 'qf' ] == undefined || params [ "qf" ] == "true" ) == true ) ;
if ( params [ "type" ] && params [ "type" ] . length > 0 ) {
this . resultTypes [ 'publication' ] = ( params [ "type" ] . split ( "," ) . indexOf ( "publications" ) != - 1 ) ;
this . resultTypes [ 'dataset' ] = ( params [ "type" ] . split ( "," ) . indexOf ( "datasets" ) != - 1 ) ;
this . resultTypes [ 'software' ] = ( params [ "type" ] . split ( "," ) . indexOf ( "software" ) != - 1 ) ;
this . resultTypes [ 'other' ] = ( params [ "type" ] . split ( "," ) . indexOf ( "other" ) != - 1 ) ;
}
if ( this . activeEntity == null && ( ! params [ "active" ] || params [ "active" ] . length == 0 ) ) {
this . activeEntity = this . getDefaultEntityToShow ( ) ;
} else if ( params [ "active" ] && params [ "active" ] . length > 0 ) {
2022-05-13 14:57:31 +02:00
this . activeEntity = ( ( [ "result" , "projects" , "organizations" , "datasources" , "services" ] ) . indexOf ( params [ "active" ] ) != - 1 ) ? params [ "active" ] : this . getDefaultEntityToShow ( ) ;
2020-02-19 16:35:48 +01:00
} else if ( this . activeEntity != null && ( ! params [ "active" ] || params [ "active" ] . length == 0 ) ) {
this . parameters [ "active" ] = this . activeEntity ;
if ( location . search && location . search . indexOf ( "active=" ) == - 1 ) {
this . location . go ( location . pathname , ( ( location . search ) ? ( location . search + "&" ) : ( "?" ) ) + "active=" + this . activeEntity ) ;
}
}
if ( this . activeEntity == "result" ) {
this . searchResults ( ) ;
} else if ( this . activeEntity == "projects" ) {
this . searchProjects ( ) ;
} else if ( this . activeEntity == "datasources" ) {
this . searchDataProviders ( ) ;
2022-05-13 14:57:31 +02:00
} else if ( this . activeEntity == "services" ) {
this . searchServices ( ) ;
2020-02-19 16:35:48 +01:00
} else if ( this . activeEntity == "organizations" ) {
this . searchOrganizations ( ) ;
}
this . count ( ) ;
2020-07-13 00:19:30 +02:00
} ) ) ;
2020-02-19 16:35:48 +01:00
}
getDefaultEntityToShow ( ) {
if ( this . showPublications || this . showDatasets || this . showSoftware || this . showOrps ) {
return "result" ;
} else if ( this . showProjects ) {
return "projects" ;
} else if ( this . showDataProviders ) {
2022-09-21 09:29:11 +02:00
return "datasources" ;
2020-02-19 16:35:48 +01:00
} else if ( this . showOrganizations ) {
return "organizations" ;
}
}
public ngOnDestroy() {
2020-07-13 00:19:30 +02:00
for ( let sub of this . subs ) {
sub . unsubscribe ( ) ;
2020-02-19 16:35:48 +01:00
}
2020-11-11 15:43:13 +01:00
this . fetchDatasets . clearSubscriptions ( ) ;
this . fetchPublications . clearSubscriptions ( ) ;
this . fetchSoftware . clearSubscriptions ( ) ;
this . fetchPublications . clearSubscriptions ( ) ;
this . fetchOrganizations . clearSubscriptions ( ) ;
this . fetchDataproviders . clearSubscriptions ( ) ;
2022-05-13 14:57:31 +02:00
this . fetchServices . clearSubscriptions ( ) ;
2020-11-11 15:43:13 +01:00
this . fetchProjects . clearSubscriptions ( ) ;
2020-02-19 16:35:48 +01:00
}
public searchResults() {
this . advancedSearchLink = this . properties . searchLinkToAdvancedPublications ; //"/search/advanced/publications";
if ( this . reload [ this . activeEntity ] &&
this . fetchPublications . searchUtils . status != this . errorCodes . NONE ) {
this . reload [ this . activeEntity ] = false ;
this . linkToSearchPublications = this . properties . searchLinkToPublications ; // + "?keyword=" + this.keyword;
}
}
public searchProjects() {
this . advancedSearchLink = this . properties . searchLinkToAdvancedProjects ; //"/search/advanced/projects";
if ( this . reload [ this . activeEntity ] &&
this . fetchProjects . searchUtils . status != this . errorCodes . NONE ) {
this . reload [ this . activeEntity ] = false ;
this . linkToSearchProjects = this . properties . searchLinkToProjects ; // + "?keyword=" + this.keyword;
}
}
public searchDataProviders() {
this . advancedSearchLink = this . properties . searchLinkToAdvancedDataProviders ; //"/search/advanced/dataproviders";
if ( this . reload [ this . activeEntity ] &&
this . fetchDataproviders . searchUtils . status != this . errorCodes . NONE ) {
this . reload [ this . activeEntity ] = false ;
this . linkToSearchDataproviders = this . properties . searchLinkToDataProviders ; // + "?keyword=" + this.keyword;
}
}
2022-05-13 14:57:31 +02:00
public searchServices() {
this . advancedSearchLink = this . properties . searchLinkToAdvancedServices ; //"/search/advanced/services";
if ( this . reload [ this . activeEntity ] &&
this . fetchServices . searchUtils . status != this . errorCodes . NONE ) {
this . reload [ this . activeEntity ] = false ;
this . linkToSearchDataproviders = this . properties . searchLinkToServices ; // + "?keyword=" + this.keyword;
}
}
2020-02-19 16:35:48 +01:00
public searchOrganizations() {
this . advancedSearchLink = this . properties . searchLinkToAdvancedOrganizations ; //"/search/advanced/organizations";
if ( this . reload [ this . activeEntity ] &&
this . fetchOrganizations . searchUtils . status != this . errorCodes . NONE ) {
this . reload [ this . activeEntity ] = false ;
this . linkToSearchOrganizations = this . properties . searchLinkToOrganizations ; // + "?keyword=" + this.keyword;
}
}
private prepareKeywordParam ( keyword ) {
2020-04-07 13:11:31 +02:00
if ( this . parameters [ "q" ] ) {
2020-02-19 16:35:48 +01:00
delete this . parameters [ 'q' ] ;
delete this . parameters [ 'op' ] ;
2020-04-07 13:11:31 +02:00
}
if ( keyword . length > 0 ) {
2020-03-27 13:39:18 +01:00
this . parameters [ "fv0" ] = keyword ;
this . parameters [ "f0" ] = "q" ;
2020-04-07 13:11:31 +02:00
} else if ( keyword . length == 0 && this . parameters [ "f0" ] == "q" ) {
delete this . parameters [ 'f0' ] ;
delete this . parameters [ 'fv0' ] ;
}
2020-02-19 16:35:48 +01:00
}
2020-04-23 09:33:23 +02:00
/ *
//quickSelection moved inside the searchpage
2020-02-19 16:35:48 +01:00
private prepareResultParameters() {
//quickSelections
if ( this . resultTypes && this . activeEntity == "result" ) {
let values = [ ] ;
if ( this . resultTypes . publication ) {
values . push ( "publications" ) ;
}
if ( this . resultTypes . dataset ) {
values . push ( "datasets" ) ;
}
if ( this . resultTypes . software ) {
values . push ( "software" ) ;
}
if ( this . resultTypes . other ) {
values . push ( "other" ) ;
}
if ( values . length > 0 ) {
this . parameters [ "type" ] = values . join ( "," ) ;
}
}
if ( this . quickFilter && this . activeEntity == "result" ) {
this . parameters [ "qf" ] = this . quickFilter . selected ;
}
}
public quickSelectionsChanged() {
this . prepareResultParameters ( ) ;
2020-04-07 13:11:31 +02:00
this . parameters [ "page" ] = 1 ;
2020-02-19 16:35:48 +01:00
this . reload [ this . activeEntity ] = true ;
this . router . navigate ( [ location . pathname ] , { queryParams : this.parameters } ) ;
2020-04-23 09:33:23 +02:00
} * /
2020-02-19 16:35:48 +01:00
public keywordChanged ( $event ) {
this . prepareKeywordParam ( this . selectedFields [ 0 ] . value ) ;
2020-04-07 13:11:31 +02:00
this . parameters [ "page" ] = 1 ;
2020-02-19 16:35:48 +01:00
this . reloadTabs ( ) ;
this . router . navigate ( [ location . pathname ] , { queryParams : this.parameters } ) ;
}
private count() {
var refineParams = null ;
if ( this . customFilter ) {
refineParams = ( refineParams ? ( refineParams + '&' ) : '' ) + "&fq=" + StringUtils . URIEncode ( this . customFilter . queryFieldName + " exact " + StringUtils . quote ( ( this . customFilter . valueId ) ) ) ;
}
if ( this . activeEntity != "result" && this . reload [ "result" ] && ( this . showPublications || this . showSoftware || this . datasets || this . showOrps ) ) {
this . fetchPublications . searchUtils . status = this . errorCodes . LOADING ;
this . reload [ "result" ] = false ;
this . fetchPublications . results = [ ] ;
2020-04-07 13:11:31 +02:00
//Add Open Access Filter
2020-07-13 00:19:30 +02:00
this . subs . push ( this . numOfSearchResults ( this . fetchPublications , ( refineParams ? ( refineParams + '&' ) : '' ) + "&fq=resultbestaccessright%20exact%20%22Open%20Access%22" ) ) ;
2020-02-19 16:35:48 +01:00
}
if ( this . activeEntity != "projects" && this . reload [ "projects" ] && this . showProjects ) {
this . fetchProjects . searchUtils . status = this . errorCodes . LOADING ;
this . fetchProjects . results = [ ] ;
this . reload [ "projects" ] = false ;
2020-07-13 00:19:30 +02:00
this . subs . push ( this . _searchProjectsService . numOfSearchProjects2 ( this . keyword . length > 0 ? NewSearchPageComponent . createKeywordQuery ( "project" , this . keyword , "q" , "=" ) : "" , this . properties , refineParams ) . subscribe (
2020-02-19 16:35:48 +01:00
data = > {
this . fetchProjects . searchUtils . totalResults = data ;
this . fetchProjects . searchUtils . status = this . errorCodes . DONE ;
if ( this . fetchProjects . searchUtils . totalResults == 0 ) {
this . fetchProjects . searchUtils . status = this . errorCodes . NONE ;
}
} ,
err = > {
//console.log(err);
2022-05-13 14:57:31 +02:00
this . handleError ( "Error getting number of " + OpenaireEntities . PROJECTS , err ) ;
2020-02-19 16:35:48 +01:00
this . fetchProjects . searchUtils . status = this . errorCodes . ERROR ;
2020-06-29 13:10:32 +02:00
this . fetchProjects . searchUtils . totalResults = null ;
2020-02-19 16:35:48 +01:00
}
2020-07-13 00:19:30 +02:00
) ) ;
2020-02-19 16:35:48 +01:00
}
if ( this . activeEntity != "datasources" && this . reload [ "datasources" ] && this . showDataProviders ) {
this . fetchDataproviders . results = [ ] ;
this . reload [ "datasources" ] = false ;
2020-04-07 13:11:31 +02:00
// this.fetchDataproviders.getNumForSearch(this.keyword, this.properties, refineParams);
2020-07-13 00:19:30 +02:00
this . subs . push ( this . _searchDataprovidersService . numOfSearchDataproviders2 ( this . keyword . length > 0 ? NewSearchPageComponent . createKeywordQuery ( "datasources" , this . keyword , "q" , "=" ) : "" , this . properties , refineParams ) . subscribe (
2020-04-07 13:11:31 +02:00
data = > {
this . fetchDataproviders . searchUtils . totalResults = data ;
this . fetchDataproviders . searchUtils . status = this . errorCodes . DONE ;
if ( this . fetchDataproviders . searchUtils . totalResults == 0 ) {
this . fetchDataproviders . searchUtils . status = this . errorCodes . NONE ;
}
} ,
err = > {
//console.log(err);
2022-05-13 14:57:31 +02:00
this . handleError ( "Error getting number of " + OpenaireEntities . DATASOURCES , err ) ;
2020-04-07 13:11:31 +02:00
this . fetchDataproviders . searchUtils . status = this . errorCodes . ERROR ;
2020-06-29 13:10:32 +02:00
this . fetchDataproviders . searchUtils . totalResults = null ;
2020-04-07 13:11:31 +02:00
}
2020-07-13 00:19:30 +02:00
) ) ;
2020-02-19 16:35:48 +01:00
}
2022-05-13 14:57:31 +02:00
if ( this . activeEntity != "services" && this . reload [ "services" ] && this . showServices ) {
this . fetchServices . results = [ ] ;
this . reload [ "services" ] = false ;
this . subs . push ( this . _searchDataprovidersService . numOfSearchDataproviders2 ( this . keyword . length > 0 ? NewSearchPageComponent . createKeywordQuery ( "datasources" , this . keyword , "q" , "=" ) : "" , this . properties , refineParams , "services" ) . subscribe (
data = > {
this . fetchServices . searchUtils . totalResults = data ;
this . fetchServices . searchUtils . status = this . errorCodes . DONE ;
if ( this . fetchServices . searchUtils . totalResults == 0 ) {
this . fetchServices . searchUtils . status = this . errorCodes . NONE ;
}
} ,
err = > {
//console.log(err);
this . handleError ( "Error getting number of " + OpenaireEntities . SERVICES , err ) ;
this . fetchServices . searchUtils . status = this . errorCodes . ERROR ;
this . fetchServices . searchUtils . totalResults = null ;
}
) ) ;
}
2020-02-19 16:35:48 +01:00
if ( this . activeEntity != "organizations" && this . reload [ "organizations" ] && this . showOrganizations ) {
this . fetchOrganizations . searchUtils . status = this . errorCodes . LOADING ;
this . fetchOrganizations . results = [ ] ;
this . reload [ "organizations" ] = false ;
2020-07-13 00:19:30 +02:00
this . subs . push ( this . _searchOrganizationsService . numOfSearchOrganizations2 ( this . keyword . length > 0 ? NewSearchPageComponent . createKeywordQuery ( "organizations" , this . keyword , "q" , "=" ) : "" , this . properties , refineParams ) . subscribe (
2020-02-19 16:35:48 +01:00
data = > {
this . fetchOrganizations . searchUtils . totalResults = data ;
this . fetchOrganizations . searchUtils . status = this . errorCodes . DONE ;
if ( this . fetchOrganizations . searchUtils . totalResults == 0 ) {
this . fetchOrganizations . searchUtils . status = this . errorCodes . NONE ;
}
} ,
err = > {
//console.log(err);
2022-05-13 14:57:31 +02:00
this . handleError ( "Error getting number of " + OpenaireEntities . ORGANIZATIONS , err ) ;
2020-02-19 16:35:48 +01:00
this . fetchOrganizations . searchUtils . status = this . errorCodes . ERROR ;
2020-06-29 13:10:32 +02:00
this . fetchOrganizations . searchUtils . totalResults = null ;
2020-02-19 16:35:48 +01:00
}
2020-07-13 00:19:30 +02:00
) ) ;
2020-02-19 16:35:48 +01:00
}
}
2020-07-13 00:19:30 +02:00
private numOfSearchResults ( fetchClass : FetchResearchResults , refineParams ) : Subscription {
2020-04-07 13:11:31 +02:00
return this . _searchResearchResultsService . numOfResearchOutcomes ( this . keyword . length > 0 ? NewSearchPageComponent . createKeywordQuery ( "result" , this . keyword , "q" , "=" ) : "" , this . properties , refineParams ) . subscribe (
2020-02-19 16:35:48 +01:00
data = > {
fetchClass . searchUtils . totalResults = data ;
fetchClass . searchUtils . status = this . errorCodes . DONE ;
if ( fetchClass . searchUtils . totalResults == 0 ) {
fetchClass . searchUtils . status = this . errorCodes . NONE ;
}
} ,
err = > {
this . handleError ( "Error getting number of research results" , err ) ;
fetchClass . searchUtils . status = this . errorCodes . ERROR ;
2020-06-29 13:10:32 +02:00
fetchClass . searchUtils . totalResults = null ;
2020-02-19 16:35:48 +01:00
}
) ;
}
private reloadTabs() {
2022-05-13 14:57:31 +02:00
this . reload = { result :true , projects :true , datasources : true , services : true , organizations :true } ;
2020-02-19 16:35:48 +01:00
this . fetchOrganizations . searchUtils . status = this . errorCodes . LOADING ;
this . fetchDataproviders . searchUtils . status = this . errorCodes . LOADING ;
2022-05-13 14:57:31 +02:00
this . fetchServices . searchUtils . status = this . errorCodes . LOADING ;
2020-02-19 16:35:48 +01:00
this . fetchProjects . searchUtils . status = this . errorCodes . LOADING ;
this . fetchPublications . searchUtils . status = this . errorCodes . LOADING ;
this . fetchDatasets . searchUtils . status = this . errorCodes . LOADING ;
this . fetchSoftware . searchUtils . status = this . errorCodes . LOADING ;
this . fetchOrps . searchUtils . status = this . errorCodes . LOADING ;
}
private handleError ( message : string , error ) {
console . error ( "General Search Page: " + message , error ) ;
}
activeEntityUpdate ( $event ) {
2020-12-15 13:45:02 +01:00
if ( $event . searchUtils . status != this . errorCodes . LOADING ) {
this . disableForms = $event . disableForms ;
}
let updated = true ;
2020-02-19 16:35:48 +01:00
if ( this . activeEntity == "result" ) {
if ( $event . searchUtils . status != this . errorCodes . LOADING ) {
this . fetchPublications . searchUtils . totalResults = $event . searchUtils . totalResults ;
}
this . fetchPublications . searchUtils . status = $event . searchUtils . status ;
} else if ( this . activeEntity == "projects" ) {
if ( $event . searchUtils . status != this . errorCodes . LOADING ) {
this . fetchProjects . searchUtils . totalResults = $event . searchUtils . totalResults ;
}
this . fetchProjects . searchUtils . status = $event . searchUtils . status ;
} else if ( this . activeEntity == "datasources" ) {
if ( $event . searchUtils . status != this . errorCodes . LOADING ) {
this . fetchDataproviders . searchUtils . totalResults = $event . searchUtils . totalResults ;
}
this . fetchDataproviders . searchUtils . status = $event . searchUtils . status ;
2022-05-13 14:57:31 +02:00
} else if ( this . activeEntity == "services" ) {
if ( $event . searchUtils . status != this . errorCodes . LOADING ) {
this . fetchServices . searchUtils . totalResults = $event . searchUtils . totalResults ;
}
this . fetchServices . searchUtils . status = $event . searchUtils . status ;
2020-02-19 16:35:48 +01:00
} else if ( this . activeEntity == "organizations" ) {
if ( $event . searchUtils . status != this . errorCodes . LOADING ) {
this . fetchOrganizations . searchUtils . totalResults = $event . searchUtils . totalResults ;
}
this . fetchOrganizations . searchUtils . status = $event . searchUtils . status ;
} else {
updated = false ;
}
if ( updated ) {
this . cdr . detectChanges ( ) ;
}
}
entityChanged ( entity ) {
2020-03-30 16:24:56 +02:00
if ( this . activeEntity == "result" ) {
this . resultTypes = { publication : true , dataset : true , software : true , other : true } ;
}
if ( this . activeEntity == "result" && this . searchResearchResultsComponent ) {
this . searchResearchResultsComponent . ngOnDestroy ( ) ;
} else if ( this . activeEntity == "projects" && this . searchProjectsComponent ) {
this . searchProjectsComponent . ngOnDestroy ( ) ;
} else if ( this . activeEntity == "datasources" && this . searchDataprovidersComponent ) {
this . searchDataprovidersComponent . ngOnDestroy ( ) ;
2022-05-13 14:57:31 +02:00
} else if ( this . activeEntity == "services" && this . searchDataprovidersComponent ) {
this . searchDataprovidersComponent . ngOnDestroy ( ) ;
2020-03-30 16:24:56 +02:00
} else if ( this . activeEntity == "organizations" && this . searchOrganizationsComponent ) {
this . searchOrganizationsComponent . ngOnDestroy ( ) ;
}
2020-02-19 16:35:48 +01:00
this . activeEntity = entity ;
this . parameters = { } ;
this . reload [ entity ] = true ;
this . parameters [ "active" ] = entity ;
if ( this . keyword . length > 0 ) {
2020-04-07 13:11:31 +02:00
this . parameters [ "fv0" ] = this . keyword ;
this . parameters [ "f0" ] = "q" ;
2020-11-23 17:08:36 +01:00
}
if ( this . customFilter ) {
this . parameters = this . customFilter . getParameters ( this . parameters ) ;
2020-02-19 16:35:48 +01:00
}
2020-03-17 17:16:21 +01:00
this . router . navigate ( [ "/search/find" ] , { queryParams : this.parameters } ) ;
2020-02-19 16:35:48 +01:00
}
}