[Library|Trunk]

Custom Filter:
		pass custom filter in organizations, content providers and projects search pages
		search/find:
			for aggregators filter show also projects/ datasources/ organizations and pass the parameter for the query


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56091 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2019-06-14 13:06:58 +00:00
parent 1d752d6bd9
commit f32cb4735a
10 changed files with 454 additions and 412 deletions

View File

@ -234,7 +234,8 @@
</search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='projects'" class ="uk-animation-fade">
<browse-entities [(properties)]=properties entityName="project" baseUrl="/search/find/projects" [refineFields]=searchFields.PROJECT_REFINE_FIELDS></browse-entities>
<browse-entities [(properties)]=properties entityName="project"
baseUrl="/search/find/projects" [refineFields]=searchFields.PROJECT_REFINE_FIELDS [customFilter]="customFilter"></browse-entities>
</div>
<!--/li>
<li-->
@ -254,7 +255,8 @@
</search-result>
</div>
<div *ngIf = "keyword.length == 0 && activeTab=='content providers'" class ="uk-animation-fade" >
<browse-entities [(properties)]=properties entityName="dataprovider" baseUrl="/search/find/dataproviders" [refineFields]=searchFields.DATASOURCE_REFINE_FIELDS></browse-entities>
<browse-entities [(properties)]=properties entityName="dataprovider"
baseUrl="/search/find/dataproviders" [refineFields]=searchFields.DATASOURCE_REFINE_FIELDS [customFilter]="customFilter"></browse-entities>
</div>
<!--/li>
<li-->

View File

@ -1,48 +1,49 @@
import {Component, Input, Output} from '@angular/core';
import {EventEmitter, ViewChild} from '@angular/core';
import {ChangeDetectionStrategy} from '@angular/core';
import {ViewEncapsulation} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Title, Meta} from '@angular/platform-browser';
import {Component, Input, Output} from '@angular/core';
import {EventEmitter, ViewChild} from '@angular/core';
import {ChangeDetectionStrategy} from '@angular/core';
import {ViewEncapsulation} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs';
import {Observable} from 'rxjs';
import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class';
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
import {FetchDatasets} from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
import {FetchSoftware} from '../../utils/fetchEntitiesClasses/fetchSoftware.class';
import {FetchOrps} from '../../utils/fetchEntitiesClasses/fetchOrps.class';
import {FetchOrganizations} from '../../utils/fetchEntitiesClasses/fetchOrganizations.class';
import {FetchPublications} from '../../utils/fetchEntitiesClasses/fetchPublications.class';
import {FetchDataproviders} from '../../utils/fetchEntitiesClasses/fetchDataproviders.class';
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
import {FetchDatasets} from '../../utils/fetchEntitiesClasses/fetchDatasets.class';
import {FetchSoftware} from '../../utils/fetchEntitiesClasses/fetchSoftware.class';
import {FetchOrps} from '../../utils/fetchEntitiesClasses/fetchOrps.class';
import {FetchOrganizations} from '../../utils/fetchEntitiesClasses/fetchOrganizations.class';
import {SearchPublicationsService} from '../../services/searchPublications.service';
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
import {SearchProjectsService} from '../../services/searchProjects.service';
import {SearchDatasetsService} from '../../services/searchDatasets.service';
import {SearchSoftwareService} from '../../services/searchSoftware.service';
import {SearchOrpsService} from '../../services/searchOrps.service';
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
import {SearchPublicationsService} from '../../services/searchPublications.service';
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
import {SearchProjectsService} from '../../services/searchProjects.service';
import {SearchDatasetsService} from '../../services/searchDatasets.service';
import {SearchSoftwareService} from '../../services/searchSoftware.service';
import {SearchOrpsService} from '../../services/searchOrps.service';
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
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 {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
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";
@Component({
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated,
selector: 'search-find',
templateUrl: 'search.component.html'
selector: 'search-find',
templateUrl: 'search.component.html'
})
export class SearchComponent {
public sub: any; piwiksub: any;
public sub: any;
piwiksub: any;
public reloadPublications: boolean;
public reloadDatasets: boolean;
public reloadSoftware: boolean;
@ -53,14 +54,14 @@ export class SearchComponent {
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 keyword: string = "";
public publications: string[];
public datasets: string[];
public software: string[];
public orps: string[];
public projectsTab: string[];
public dataproviders: string[];
public organizations: string[];
public activeTab = "publications";
public linkToSearchPublications = "";
@ -71,65 +72,72 @@ export class SearchComponent {
public linkToSearchOrps = "";
public linkToSearchOrganizations = "";
public fetchPublications : FetchPublications;
public fetchDataproviders : FetchDataproviders;
public fetchProjects : FetchProjects;
public fetchPublications: FetchPublications;
public fetchDataproviders: FetchDataproviders;
public fetchProjects: FetchProjects;
public fetchDatasets: FetchDatasets;
public fetchSoftware: FetchSoftware;
public fetchOrps: FetchOrps;
public fetchOrganizations: FetchOrganizations;
public searchFields:SearchFields = new SearchFields();
public errorCodes:ErrorCodes = new ErrorCodes();
public routerHelper:RouterHelper = new RouterHelper();
public searchFields: SearchFields = new SearchFields();
public errorCodes: ErrorCodes = new ErrorCodes();
public routerHelper: RouterHelper = new RouterHelper();
public publicationsSize:any = null;
public datasetsSize:any = null;
public softwareSize:any = null;
public oprsSize:any = null;
public fundersSize:any = null;
public projectsSize:any = null;
public datasourcesSize:any = null;
showPublications:boolean= false;
showDatasets:boolean= false;
showSoftware:boolean=false;
showOrps:boolean=false;
showProjects:boolean= false;
showDataProviders:boolean= false;
showOrganizations:boolean= false;
advancedSearchLink:string ="/search/advanced/publications";
public publicationsSize: any = null;
public datasetsSize: any = null;
public softwareSize: any = null;
public oprsSize: any = null;
public fundersSize: any = null;
public projectsSize: any = null;
public datasourcesSize: any = null;
showPublications: boolean = false;
showDatasets: boolean = false;
showSoftware: boolean = false;
showOrps: boolean = false;
showProjects: boolean = false;
showDataProviders: boolean = false;
showOrganizations: boolean = false;
advancedSearchLink: string = "/search/advanced/publications";
properties: EnvProperties;
@Input() logoURL;
@Input() name;
@Input() customFilter:SearchCustomFilter= null;
@Input() customFilter: SearchCustomFilter = null;
@Input() piwikSiteId = null;
@Input() formPlaceholderText = "Search for research results, projects, content providers & organizations in OpenAIRE";
public subPub;public subData; public subSoftware; public subOrps; public subProjects;public subOrg; public subDataPr;
constructor ( private route: ActivatedRoute,
private _router: Router,
private _searchPublicationsService: SearchPublicationsService,
private _searchDataprovidersService: SearchDataprovidersService,
private _searchProjectsService: SearchProjectsService,
private _searchDatasetsService: SearchDatasetsService,
private _searchSoftwareService: SearchSoftwareService,
private _searchOrpsService: SearchOrpsService,
private _searchOrganizationsService: SearchOrganizationsService,
private _refineFieldResultsService:RefineFieldResultsService,
private location: Location,
private _meta: Meta,
private _title: Title,
private _piwikService:PiwikService,
private config: ConfigurationService,
private seoService: SEOService ) {
this.fetchPublications = new FetchPublications(this._searchPublicationsService);
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
this.fetchProjects = new FetchProjects(this._searchProjectsService);
this.fetchDatasets = new FetchDatasets( this._searchDatasetsService);
this.fetchSoftware = new FetchSoftware(this._searchSoftwareService);
this.fetchOrps = new FetchOrps( this._searchOrpsService);
this.fetchOrganizations = new FetchOrganizations( this._searchOrganizationsService);
public subPub;
public subData;
public subSoftware;
public subOrps;
public subProjects;
public subOrg;
public subDataPr;
constructor(private route: ActivatedRoute,
private _router: Router,
private _searchPublicationsService: SearchPublicationsService,
private _searchDataprovidersService: SearchDataprovidersService,
private _searchProjectsService: SearchProjectsService,
private _searchDatasetsService: SearchDatasetsService,
private _searchSoftwareService: SearchSoftwareService,
private _searchOrpsService: SearchOrpsService,
private _searchOrganizationsService: SearchOrganizationsService,
private _refineFieldResultsService: RefineFieldResultsService,
private location: Location,
private _meta: Meta,
private _title: Title,
private _piwikService: PiwikService,
private config: ConfigurationService,
private seoService: SEOService) {
this.fetchPublications = new FetchPublications(this._searchPublicationsService);
this.fetchDataproviders = new FetchDataproviders(this._searchDataprovidersService);
this.fetchProjects = new FetchProjects(this._searchProjectsService);
this.fetchDatasets = new FetchDatasets(this._searchDatasetsService);
this.fetchSoftware = new FetchSoftware(this._searchSoftwareService);
this.fetchOrps = new FetchOrps(this._searchOrpsService);
this.fetchOrganizations = new FetchOrganizations(this._searchOrganizationsService);
}
@ -140,375 +148,391 @@ public subPub;public subData; public subSoftware; public subOrps; public subProj
var description = "open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ";
var title = "OpenAIRE | Search publications, research data, projects... | OpenAIRE";
this.properties = data.envSpecific;
var url = data.envSpecific.baseLink+this._router.url;
var url = data.envSpecific.baseLink + this._router.url;
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'");
this.seoService.createLinkForCanonicalURL(this.properties.baseLink+this._router.url,false);
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
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'");
this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this._router.url, false);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE |Search publications, research data, projects...", this.piwikSiteId).subscribe();
}
if ((this.customFilter && this.customFilter.queryFieldName == "communitId") || this.properties.adminToolsCommunity) {
this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communitId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
var showEntity = {};
for (var i = 0; i < data['entities'].length; i++) {
this.config.getCommunityInformation(this.properties, (this.customFilter)?this.customFilter.valueId :this.properties.adminToolsCommunity ).subscribe(data => {
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"];
this.showSoftware = showEntity["software"];
this.showOrps = showEntity["orp"];
if (this.customFilter && this.customFilter.queryFieldName == "communityId") {
this.showProjects = false;
this.showOrganizations = false;
this.showDataProviders = false;
}
this.loadAll();
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"];
this.showSoftware = showEntity["software"];
this.showOrps = showEntity["orp"];
console.log(this.customFilter)
if(this.customFilter && this.customFilter.queryFieldName=="communityId"){
this.showProjects = false;
this.showOrganizations = false;
this.showDataProviders = false;
}
if((this.customFilter && this.customFilter.queryFieldName=="country")){
this.showProjects = false;
// this.showOrganizations = false;
this.showDataProviders = false;
}
this.sub = this.route.queryParams.subscribe(params => {
this.reloadTabs();
this.keyword = (params['keyword'])?params['keyword']:"";
if(this.keyword !=null && this.keyword.length > 0){
//if showPublications == false will setValues another entity as the first
if(this.showPublications){
this.activeTab = "publications";
this.searchPublications();
}else if(this.showDatasets){
this.activeTab = "research data";
this.searchDatasets();
}else if(this.showSoftware){
this.activeTab = "software";
this.searchSoftware();
}else if(this.showOrps){
this.activeTab = "other research products";
this.searchOrps();
}else if(this.showProjects){
this.activeTab = "projects";
this.searchProjects();
}else if(this.showDataProviders){
this.activeTab = "content providers";
this.searchDataProviders();
}else if(this.showOrganizations){
this.activeTab = "organizations";
this.searchOrganizations();
}
this.count();
}
});
});
});
} else {
if ((this.customFilter && this.customFilter.queryFieldName == "country")) {
this.showPublications =true;
this.showDatasets = true;
this.showDataProviders = true;
this.showSoftware = true;
this.showOrps = true;
this.showProjects = true;
this.showOrganizations = true;
this.showDataProviders = true;
}
}
this.loadAll();
});
}
loadAll() {
this.sub = this.route.queryParams.subscribe(params => {
this.reloadTabs();
this.keyword = (params['keyword']) ? params['keyword'] : "";
if (this.keyword != null && this.keyword.length > 0) {
//if showPublications == false will setValues another entity as the first
if (this.showPublications) {
this.activeTab = "publications";
this.searchPublications();
} else if (this.showDatasets) {
this.activeTab = "research data";
this.searchDatasets();
} else if (this.showSoftware) {
this.activeTab = "software";
this.searchSoftware();
} else if (this.showOrps) {
this.activeTab = "other research products";
this.searchOrps();
} else if (this.showProjects) {
this.activeTab = "projects";
this.searchProjects();
} else if (this.showDataProviders) {
this.activeTab = "content providers";
this.searchDataProviders();
} else if (this.showOrganizations) {
this.activeTab = "organizations";
this.searchOrganizations();
}
this.count();
}
});
}
public ngOnDestroy() {
if(this.sub){
if (this.sub) {
this.sub.unsubscribe();
}
if(this.piwiksub){
this.piwiksub.unsubscribe();
if (this.piwiksub) {
this.piwiksub.unsubscribe();
}
if (this.keyword != null && this.keyword.length > 0) {
if (this.subPub) {
this.subPub.unsubscribe();
}
if (this.subData) {
this.subData.unsubscribe();
}
if (this.subSoftware) {
this.subSoftware.unsubscribe();
}
if (this.subOrps) {
this.subOrps.unsubscribe();
}
if (this.subProjects) {
this.subProjects.unsubscribe();
}
if (this.subOrg) {
this.subOrg.unsubscribe();
}
if (this.subDataPr) {
this.subDataPr.unsubscribe();
}
if(this.keyword !=null && this.keyword.length > 0){
if(this.subPub){
this.subPub.unsubscribe();
}
if(this.subData){
this.subData.unsubscribe();
}
if(this.subSoftware){
this.subSoftware.unsubscribe();
}
if(this.subOrps){
this.subOrps.unsubscribe();
}
if(this.subProjects){
this.subProjects.unsubscribe();
}
if(this.subOrg){
this.subOrg.unsubscribe();
}
if(this.subDataPr){
this.subDataPr.unsubscribe();
}
}
}
public searchPublications() {
this.activeTab = "publications";
this.advancedSearchLink ="/search/advanced/publications";
if( this.reloadPublications &&
this.fetchPublications.searchUtils.status != this.errorCodes.NONE /*&&
this.advancedSearchLink = "/search/advanced/publications";
if (this.reloadPublications &&
this.fetchPublications.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchPublications.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadPublications = false;
this.fetchPublications.getResultsByKeyword(this.keyword, 1, 10,this.properties, this.customFilter);
this.fetchPublications.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
this.linkToSearchPublications = this.properties.searchLinkToPublications;// + "?keyword=" + this.keyword;
}
}
public searchDatasets() {
this.activeTab = "research data";
this.advancedSearchLink ="/search/advanced/datasets";
if(this.reloadDatasets &&
this.fetchDatasets.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadDatasets = false;
this.fetchDatasets.getResultsByKeyword(this.keyword, 1, 10,this.properties, this.customFilter);
this.linkToSearchDatasets =this.properties.searchLinkToDatasets;// + "?keyword=" + this.keyword;
}
}
public searchSoftware() {
}
this.activeTab = "software";
this.advancedSearchLink ="/search/advanced/software";
if(this.reloadSoftware
&& this.fetchSoftware.searchUtils.status != this.errorCodes.NONE/* &&
public searchDatasets() {
this.activeTab = "research data";
this.advancedSearchLink = "/search/advanced/datasets";
if (this.reloadDatasets &&
this.fetchDatasets.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchDatasets.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadDatasets = false;
this.fetchDatasets.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
this.linkToSearchDatasets = this.properties.searchLinkToDatasets;// + "?keyword=" + this.keyword;
}
}
public searchSoftware() {
this.activeTab = "software";
this.advancedSearchLink = "/search/advanced/software";
if (this.reloadSoftware
&& this.fetchSoftware.searchUtils.status != this.errorCodes.NONE/* &&
( this.fetchSoftware.searchUtils.status == this.errorCodes.LOADING ||
this.fetchSoftware.searchUtils.status == this.errorCodes.DONE )*/) {
this.reloadSoftware = false;
this.fetchSoftware.getResultsByKeyword(this.keyword, 1, 10,this.properties, this.customFilter);
this.linkToSearchSoftware = this.properties.searchLinkToSoftware;// + "?keyword=" + this.keyword;
}
}
public searchOrps() {
this.activeTab = "other research products";
this.advancedSearchLink ="/search/advanced/other";
if(this.reloadOrps &&
this.fetchOrps.searchUtils.status != this.errorCodes.NONE /*&&
this.reloadSoftware = false;
this.fetchSoftware.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
this.linkToSearchSoftware = this.properties.searchLinkToSoftware;// + "?keyword=" + this.keyword;
}
}
public searchOrps() {
this.activeTab = "other research products";
this.advancedSearchLink = "/search/advanced/other";
if (this.reloadOrps &&
this.fetchOrps.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchOrps.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadOrps = false;
this.fetchOrps.getResultsByKeyword(this.keyword, 1, 10,this.properties, this.customFilter);
this.linkToSearchOrps =this.properties.searchLinkToOrps;
}
}
public searchProjects() {
this.activeTab = "projects";
this.advancedSearchLink ="/search/advanced/projects";
if(this.reloadProjects &&
this.fetchProjects.searchUtils.status != this.errorCodes.NONE /*&&
this.reloadOrps = false;
this.fetchOrps.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
this.linkToSearchOrps = this.properties.searchLinkToOrps;
}
}
public searchProjects() {
this.activeTab = "projects";
this.advancedSearchLink = "/search/advanced/projects";
if (this.reloadProjects &&
this.fetchProjects.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchProjects.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadProjects = false;
this.fetchProjects.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.linkToSearchProjects = this.properties.searchLinkToProjects;// + "?keyword=" + this.keyword;
}
}
public searchDataProviders() {
this.activeTab = "content providers";
this.advancedSearchLink ="/search/advanced/dataproviders";
if( this.reloadDataproviders &&
this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE /*&&
this.reloadProjects = false;
this.fetchProjects.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
this.linkToSearchProjects = this.properties.searchLinkToProjects;// + "?keyword=" + this.keyword;
}
}
public searchDataProviders() {
this.activeTab = "content providers";
this.advancedSearchLink = "/search/advanced/dataproviders";
if (this.reloadDataproviders &&
this.fetchDataproviders.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchDataproviders.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadDataproviders = false;
this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.linkToSearchDataproviders = this.properties.searchLinkToDataProviders;// + "?keyword=" + this.keyword;
}
}
public searchOrganizations() {
this.activeTab = "organizations";
this.advancedSearchLink ="/search/advanced/organizations";
if( this.reloadOrganizations &&
this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE /*&&
this.reloadDataproviders = false;
this.fetchDataproviders.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
this.linkToSearchDataproviders = this.properties.searchLinkToDataProviders;// + "?keyword=" + this.keyword;
}
}
public searchOrganizations() {
this.activeTab = "organizations";
this.advancedSearchLink = "/search/advanced/organizations";
if (this.reloadOrganizations &&
this.fetchOrganizations.searchUtils.status != this.errorCodes.NONE /*&&
this.fetchOrganizations.searchUtils.status != this.errorCodes.ERROR*/) {
this.reloadOrganizations = false;
this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10,this.properties);
this.linkToSearchOrganizations = this.properties.searchLinkToOrganizations;// + "?keyword=" + this.keyword;
}
}
this.reloadOrganizations = false;
this.fetchOrganizations.getResultsByKeyword(this.keyword, 1, 10, this.properties, this.customFilter);
this.linkToSearchOrganizations = this.properties.searchLinkToOrganizations;// + "?keyword=" + this.keyword;
}
}
public keywordChanged($event){
public keywordChanged($event) {
this.keyword = $event.value;
//console.info("Search Find: search with keyword \"" + this.keyword + "\"" );
this.location.go(location.pathname,"?keyword=" + this.keyword);
this.location.go(location.pathname, "?keyword=" + this.keyword);
this.reloadTabs();
if(this.activeTab == "publications") {
if (this.activeTab == "publications") {
this.searchPublications();
}
if(this.activeTab == "projects") {
if (this.activeTab == "projects") {
this.searchProjects();
}
if(this.activeTab == "content providers") {
if (this.activeTab == "content providers") {
this.searchDataProviders();
}
if(this.activeTab == "research data") {
if (this.activeTab == "research data") {
this.searchDatasets();
}
if(this.activeTab == "software") {
if (this.activeTab == "software") {
this.searchSoftware();
}
if(this.activeTab == "other research products") {
if (this.activeTab == "other research products") {
this.searchOrps();
}
if(this.activeTab == "organizations") {
if (this.activeTab == "organizations") {
this.searchOrganizations();
}
this.count();
}
}
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.activeTab != "publications" && this.showPublications){
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.activeTab != "publications" && this.showPublications) {
this.fetchPublications.searchUtils.status = this.errorCodes.LOADING;
this.fetchPublications.results = [];
this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword,this.properties, refineParams).subscribe(
data => {
this.fetchPublications.searchUtils.totalResults = data;
this.fetchPublications.searchUtils.status = this.errorCodes.DONE;
if(this.fetchPublications.searchUtils.totalResults == 0) {
this.fetchPublications.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
//console.log(err);
this.handleError("Error getting number of Publications", err);
this.fetchPublications.searchUtils.status = this.errorCodes.ERROR;
}
this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword, this.properties, refineParams).subscribe(
data => {
this.fetchPublications.searchUtils.totalResults = data;
this.fetchPublications.searchUtils.status = this.errorCodes.DONE;
if (this.fetchPublications.searchUtils.totalResults == 0) {
this.fetchPublications.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
//console.log(err);
this.handleError("Error getting number of Publications", err);
this.fetchPublications.searchUtils.status = this.errorCodes.ERROR;
}
);
}
if(this.activeTab != "research data" && this.showDatasets){
this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
this.fetchDatasets.results = [];
this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword,this.properties, refineParams).subscribe(
data => {
this.fetchDatasets.searchUtils.totalResults = data;
this.fetchDatasets.searchUtils.status = this.errorCodes.DONE;
if(this.fetchDatasets.searchUtils.totalResults == 0) {
this.fetchDatasets.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
//console.log(err);
this.handleError("Error getting number of Research Data", err);
this.fetchDatasets.searchUtils.status = this.errorCodes.ERROR;
}
);
if (this.activeTab != "research data" && this.showDatasets) {
this.fetchDatasets.searchUtils.status = this.errorCodes.LOADING;
this.fetchDatasets.results = [];
this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword, this.properties, refineParams).subscribe(
data => {
this.fetchDatasets.searchUtils.totalResults = data;
this.fetchDatasets.searchUtils.status = this.errorCodes.DONE;
if (this.fetchDatasets.searchUtils.totalResults == 0) {
this.fetchDatasets.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
//console.log(err);
this.handleError("Error getting number of Research Data", err);
this.fetchDatasets.searchUtils.status = this.errorCodes.ERROR;
}
);
}
if(this.activeTab != "software" && this.showSoftware){
this.fetchSoftware.searchUtils.status = this.errorCodes.LOADING;
this.fetchSoftware.results = [];
this.subSoftware = this._searchSoftwareService.numOfSearchSoftware(this.keyword,this.properties, refineParams).subscribe(
data => {
this.fetchSoftware.searchUtils.totalResults = data;
this.fetchSoftware.searchUtils.status = this.errorCodes.DONE;
if(this.fetchSoftware.searchUtils.totalResults == 0) {
this.fetchSoftware.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
this.handleError("Error getting number of Software", err);
/*console.log(err);
if(err.status == '404') {
this.fetchSoftware.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.fetchSoftware.searchUtils.status = this.errorCodes.ERROR;
} else {
this.fetchSoftware.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}*/
this.fetchSoftware.searchUtils.status = this.errorCodes.ERROR;
}
);
if (this.activeTab != "software" && this.showSoftware) {
this.fetchSoftware.searchUtils.status = this.errorCodes.LOADING;
this.fetchSoftware.results = [];
this.subSoftware = this._searchSoftwareService.numOfSearchSoftware(this.keyword, this.properties, refineParams).subscribe(
data => {
this.fetchSoftware.searchUtils.totalResults = data;
this.fetchSoftware.searchUtils.status = this.errorCodes.DONE;
if (this.fetchSoftware.searchUtils.totalResults == 0) {
this.fetchSoftware.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
this.handleError("Error getting number of Software", err);
/*console.log(err);
if(err.status == '404') {
this.fetchSoftware.searchUtils.status = this.errorCodes.NOT_FOUND;
} else if(err.status == '500') {
this.fetchSoftware.searchUtils.status = this.errorCodes.ERROR;
} else {
this.fetchSoftware.searchUtils.status = this.errorCodes.NOT_AVAILABLE;
}*/
this.fetchSoftware.searchUtils.status = this.errorCodes.ERROR;
}
);
}
if(this.activeTab != "other research products" && this.showOrps){
this.fetchOrps.searchUtils.status = this.errorCodes.LOADING;
this.fetchOrps.results = [];
this.subOrps = this._searchOrpsService.numOfSearchOrps(this.keyword,this.properties, refineParams).subscribe(
data => {
this.fetchOrps.searchUtils.totalResults = data;
this.fetchOrps.searchUtils.status = this.errorCodes.DONE;
if(this.fetchOrps.searchUtils.totalResults == 0) {
this.fetchOrps.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
//console.log(err);
this.handleError("Error getting number of Other Research Products", err);
this.fetchOrps.searchUtils.status = this.errorCodes.ERROR;
}
);
if (this.activeTab != "other research products" && this.showOrps) {
this.fetchOrps.searchUtils.status = this.errorCodes.LOADING;
this.fetchOrps.results = [];
this.subOrps = this._searchOrpsService.numOfSearchOrps(this.keyword, this.properties, refineParams).subscribe(
data => {
this.fetchOrps.searchUtils.totalResults = data;
this.fetchOrps.searchUtils.status = this.errorCodes.DONE;
if (this.fetchOrps.searchUtils.totalResults == 0) {
this.fetchOrps.searchUtils.status = this.errorCodes.NONE;
}
},
err => {
//console.log(err);
this.handleError("Error getting number of Other Research Products", err);
this.fetchOrps.searchUtils.status = this.errorCodes.ERROR;
}
);
}
if(this.activeTab != "projects" && this.showProjects){
if (this.activeTab != "projects" && this.showProjects) {
this.fetchProjects.searchUtils.status = this.errorCodes.LOADING;
this.fetchProjects.results = [];
this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword,this.properties).subscribe(
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);
this.handleError("Error getting number of Projects", err);
this.fetchProjects.searchUtils.status = this.errorCodes.ERROR;
}
);
}
if(this.activeTab != "content providers" && this.showDataProviders){
this.fetchDataproviders.results = [];
this.fetchDataproviders.getNumForSearch(this.keyword,this.properties);
}
if(this.activeTab != "organizations" && this.showOrganizations){
this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
this.fetchOrganizations.results = [];
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword,this.properties).subscribe(
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);
this.handleError("Error getting number of Organizations", err);
this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR;
this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword, this.properties, refineParams).subscribe(
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);
this.handleError("Error getting number of Projects", err);
this.fetchProjects.searchUtils.status = this.errorCodes.ERROR;
}
);
}
if (this.activeTab != "content providers" && this.showDataProviders) {
this.fetchDataproviders.results = [];
this.fetchDataproviders.getNumForSearch(this.keyword, this.properties, refineParams);
}
if (this.activeTab != "organizations" && this.showOrganizations) {
this.fetchOrganizations.searchUtils.status = this.errorCodes.LOADING;
this.fetchOrganizations.results = [];
this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword, this.properties, refineParams).subscribe(
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);
this.handleError("Error getting number of Organizations", err);
this.fetchOrganizations.searchUtils.status = this.errorCodes.ERROR;
}
);
}
}
);
}
}
}
private reloadTabs() {
this.reloadPublications = true;
this.reloadDatasets = true;
this.reloadSoftware = true;
this.reloadOrps = true;
this.reloadProjects = true;
this.reloadDataproviders = true;
this.reloadOrganizations = true;
this.fetchOrganizations.searchUtils.status = null;
this.fetchDataproviders.searchUtils.status = null;
this.fetchProjects.searchUtils.status = null;
this.fetchPublications.searchUtils.status = null;
this.fetchDatasets.searchUtils.status = null;
this.fetchSoftware.searchUtils.status = null;
this.fetchOrps.searchUtils.status = null;
}
private reloadTabs() {
this.reloadPublications = true;
this.reloadDatasets = true;
this.reloadSoftware = true;
this.reloadOrps = true;
this.reloadProjects = true;
this.reloadDataproviders = true;
this.reloadOrganizations = true;
this.fetchOrganizations.searchUtils.status = null;
this.fetchDataproviders.searchUtils.status = null;
this.fetchProjects.searchUtils.status = null;
this.fetchPublications.searchUtils.status = null;
this.fetchDatasets.searchUtils.status = null;
this.fetchSoftware.searchUtils.status = null;
this.fetchOrps.searchUtils.status = null;
}
private handleError(message: string, error) {
console.error("General Search Page: "+message, error);
}
private handleError(message: string, error) {
console.error("General Search Page: " + message, error);
}
}

View File

@ -8,7 +8,7 @@ import { ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
@Component({
@ -35,6 +35,7 @@ export class SearchDataprovidersComponent {
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null;
@Input() customFilter:SearchCustomFilter= null;
public results =[];
public filters =[];
public totalResults:number = 0 ;
@ -97,7 +98,7 @@ properties: EnvProperties;
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
this.searchUtils.size = 10;
}
this.searchPage.customFilter = this.customFilter;
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
});

View File

@ -8,7 +8,7 @@ import {ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {SearchFields, FieldDetails} from '../../utils/properties/searchFields';
import {SearchPageComponent } from '../searchUtils/searchPage.component';
import {SearchUtilsClass } from '../searchUtils/searchUtils.class';
import {SearchCustomFilter, SearchUtilsClass} from '../searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
@Component({
@ -34,6 +34,7 @@ export class SearchProjectsComponent {
private errorCodes: ErrorCodes;
private errorMessages: ErrorMessagesComponent;
@Input() piwikSiteId = null;
@Input() customFilter:SearchCustomFilter= null;
public results =[];
public filters: Filter[] =[];
public baseUrl:string;
@ -95,7 +96,7 @@ properties: EnvProperties;
if(this.searchUtils.size != 5 && this.searchUtils.size != 10 && this.searchUtils.size != 20 && this.searchUtils.size != 50) {
this.searchUtils.size = 10;
}
this.searchPage.customFilter = this.customFilter;
var queryParameters = this.searchPage.getQueryParametersFromUrl(params);
this._getResults(queryParameters, refine, this.searchUtils.page, this.searchUtils.size);
});

View File

@ -21,7 +21,6 @@ export class RefineFieldResultsService {
if(communityQuery!= null && communityQuery != '' ) {
url += communityQuery;
}
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
//.map(res => <any> res.json())

View File

@ -428,11 +428,14 @@ export class SearchDataprovidersService {
return this.numOfDataproviders(url, properties);
}
numOfSearchDataproviders(params: string, properties:EnvProperties):any {
numOfSearchDataproviders(params: string, properties:EnvProperties, refineQuery:string):any {
let url: string = properties.searchAPIURLLAst+"datasources/count?format=json";
if(params != "") {
url += "&q=" + StringUtils.URIEncode(params);
}
if(refineQuery!= null && refineQuery != '' ) {
url += refineQuery;
}
return this.numOfDataproviders(url, properties);
}

View File

@ -238,11 +238,14 @@ export class SearchProjectsService {
return this.numOfProjects(url, properties);
}
numOfSearchProjects(params: string, properties:EnvProperties ):any {
numOfSearchProjects(params: string, properties:EnvProperties, refineParams:string=null ):any {
let url = properties.searchAPIURLLAst+"projects/count?format=json";
if(params != "") {
url += "&q=" + StringUtils.URIEncode(params);
}
if(refineParams!= null && refineParams != '' ) {
url += refineParams;
}
return this.numOfProjects(url, properties);
}
}

View File

@ -1,7 +1,7 @@
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
import { ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from '../../utils/string-utils.class';
export class FetchDataproviders {
@ -35,7 +35,7 @@ export class FetchDataproviders {
}
}
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties){
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + StringUtils.URIEncode(keyword);
@ -44,8 +44,11 @@ export class FetchDataproviders {
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
this.subResults = this._searchDataprovidersService.searchDataproviders(parameters,null, page, size,[], properties).subscribe(
var refineParams = null;
if(customFilter){
refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId )));
}
this.subResults = this._searchDataprovidersService.searchDataproviders(parameters,refineParams, page, size,[], properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
//console.info("search Content Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");
@ -150,11 +153,11 @@ export class FetchDataproviders {
}
}
public getNumForSearch(keyword: string, properties:EnvProperties) {
public getNumForSearch(keyword: string, properties:EnvProperties, refineParams:string=null) {
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
this._searchDataprovidersService.numOfSearchDataproviders(keyword, properties).subscribe(
this._searchDataprovidersService.numOfSearchDataproviders(keyword, properties, refineParams).subscribe(
data => {
this.searchUtils.totalResults = data;
this.searchUtils.status = this.errorCodes.DONE;

View File

@ -1,7 +1,7 @@
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
import { ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from '../../utils/string-utils.class';
export class FetchOrganizations {
@ -35,7 +35,7 @@ export class FetchOrganizations {
}
public getResultsByKeyword(keyword:string , page: number, size: number, properties:EnvProperties){
public getResultsByKeyword(keyword:string , page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + StringUtils.URIEncode(keyword);
@ -43,8 +43,11 @@ export class FetchOrganizations {
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
this.subResults = this._searchOrganizationsService.searchOrganizations(parameters, null, page, size, [], properties).subscribe(
var refineParams = null;
if(customFilter){
refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId )));
}
this.subResults = this._searchOrganizationsService.searchOrganizations(parameters, refineParams, page, size, [], properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
//console.info("search Organizations: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");

View File

@ -1,7 +1,7 @@
import {SearchProjectsService} from '../../services/searchProjects.service';
import {ErrorCodes} from '../../utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../utils/errorMessages.component';
import {SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class';
import {SearchCustomFilter, SearchUtilsClass} from '../../searchPages/searchUtils/searchUtils.class';
import{EnvProperties} from '../../utils/properties/env-properties';
import {StringUtils} from '../../utils/string-utils.class';
export class FetchProjects{
@ -34,7 +34,7 @@ export class FetchProjects{
}
}
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties){
public getResultsByKeyword(keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){
var parameters = "";
if(keyword.length > 0){
parameters = "q=" + StringUtils.URIEncode(keyword);
@ -42,8 +42,11 @@ export class FetchProjects{
//var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = this.errorCodes.LOADING;
this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], properties).subscribe(
var refineParams = null;
if(customFilter){
refineParams = (refineParams?(refineParams+'&'):'')+"&fq="+StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId )));
}
this.subResults = this._searchProjectsService.searchProjects(parameters, refineParams, page, size, [], properties).subscribe(
data => {
this.searchUtils.totalResults = data[0];
//console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]");