From 5437cc97e37c0ec2a4107d6ab361782ccbcc746f Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Tue, 1 Nov 2016 13:44:55 +0000 Subject: [PATCH] Data Providers:: Fix queries in search page, create advance search page, do the proper query for compatible DP and make filters work, add a page for Entity Registries (first draft) git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44374 d315682c-612b-4755-9ff5-7f18f6832af3 --- portal-2/src/app/app.routing.ts | 17 +- .../advancedSearchDataProviders.component.ts | 112 +++++++++++++ .../advancedSearchPublications.component.ts | 1 + .../compatibleDataProviders.component.ts | 149 ++++++++++------- .../entityRegistries.component.ts | 151 ++++++++++++++++++ portal-2/src/app/searchPages/search.module.ts | 7 + .../searchDataproviders.component.ts | 102 ++++++------ .../searchPages/searchDatasets.component.ts | 4 +- .../searchPages/searchProjects.component.ts | 11 +- .../advancedSearchForm.component.ts | 20 +-- .../advancedSearchPage.component.ts | 4 +- .../searchUtils/searchFilter.component.ts | 16 +- .../app/services/ISVocabularies.service.ts | 15 +- .../services/searchDataproviders.service.ts | 2 +- .../navigationBar.component.ts | 2 + .../utils/properties/openaireProperties.ts | 4 +- .../src/app/utils/properties/searchFields.ts | 27 +++- .../utils/staticAutoComplete2.component.ts | 2 +- portal-2/src/server.ts | 3 + 19 files changed, 506 insertions(+), 143 deletions(-) create mode 100644 portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts diff --git a/portal-2/src/app/app.routing.ts b/portal-2/src/app/app.routing.ts index f9304ed5..c3a67842 100644 --- a/portal-2/src/app/app.routing.ts +++ b/portal-2/src/app/app.routing.ts @@ -20,6 +20,8 @@ import { SearchDatasetsComponent } from './searchPages/searchDatasets.component' import { SearchOrganizationsComponent } from './searchPages/searchOrganizations.component'; import { SearchPeopleComponent } from './searchPages/searchPeople.component'; import { AdvancedSearchPublicationsComponent } from './searchPages/advanced/advancedSearchPublications.component'; +import { AdvancedSearchDataProvidersComponent } from './searchPages/advanced/advancedSearchDataProviders.component'; + import { DepositComponent } from './deposit/deposit.component'; import { DepositResultComponent } from './deposit/depositResult.component'; import { ErrorPageComponent } from './error/errorPage.component'; @@ -27,13 +29,14 @@ import { TestComponent } from './test/test.component'; import { SearchAllComponent } from './searchAll/searchAll.component'; import { SearchCompatibleDataprovidersComponent } from './searchPages/dataProviders/compatibleDataProviders.component'; +import { SearchEntityRegistriesComponent } from './searchPages/dataProviders/entityRegistries.component'; const appRoutes: Routes = [ { path: '', component: SearchComponent, pathMatch: 'full' }, { path: 'claims', component: ClaimsAdminComponent }, - { path: 'home', component: HomeComponent }, - { path: 'claim', component: ClaimComponent }, - { path: 'myclaims', component: MyClaimsComponent }, + { path: 'home', component: HomeComponent }, + { path: 'claim', component: ClaimComponent }, + { path: 'myclaims', component: MyClaimsComponent }, { path: 'search/person', component: PersonComponent }, { path: 'search/project', component: ProjectComponent }, { path: 'search/organization', component: OrganizationComponent }, @@ -41,6 +44,7 @@ const appRoutes: Routes = [ { path: 'search/publication', component: PublicationComponent }, { path: 'search/dataprovider', component: DataProviderComponent}, { path: 'search/data-providers', component: SearchCompatibleDataprovidersComponent}, + { path: 'search/entity-registries', component: SearchEntityRegistriesComponent}, { path: 'search/find', component: SearchComponent }, { path: 'linking', component: LinkingComponent }, { path: 'bulk-linking', component: BulkLinkingComponent}, @@ -51,12 +55,13 @@ const appRoutes: Routes = [ { path: 'search/find/organizations', component: SearchOrganizationsComponent }, { path: 'search/find/people', component: SearchPeopleComponent }, { path: 'search/advanced/publications', component: AdvancedSearchPublicationsComponent }, + { path: 'search/advanced/dataproviders', component: AdvancedSearchDataProvidersComponent }, { path: 'deposit', component: DepositComponent}, - { path: 'deposit-results', component: DepositResultComponent}, + { path: 'deposit-results', component: DepositResultComponent}, { path: 'test', component: TestComponent}, { path: 'search', component: SearchAllComponent }, - { path: 'error', component: ErrorPageComponent}, - { path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored + { path: 'error', component: ErrorPageComponent}, + { path: '**', component: ErrorPageComponent } // it has to be the last one - otherwise the next declaration are ignored ]; diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts new file mode 100644 index 00000000..5b5c0181 --- /dev/null +++ b/portal-2/src/app/searchPages/advanced/advancedSearchDataProviders.component.ts @@ -0,0 +1,112 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import {Observable} from 'rxjs/Observable'; +import { Router, ActivatedRoute} from '@angular/router'; +import {Filter, Value,AdvancedField} from '../searchUtils/searchHelperClasses.class'; +import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {AdvancedSearchPageComponent} from '../searchUtils/advancedSearchPage.component'; +import {SearchFields} from '../../utils/properties/searchFields'; + + + +@Component({ + selector: 'advanced-search-dataprovider', + template: ` + + + + ` + }) + +export class AdvancedSearchDataProvidersComponent { + private results =[]; + private filters =[]; + private totalResults:number = 0 ; + private page :number = 1; + private size :number = 10; + public status:number; + private baseUrl: string; + private searchFields:SearchFields = new SearchFields(); + + private fieldIds: string[] = this.searchFields.ADVANCED_DATAPROVIDER_PARAM; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; + private selectedFields:AdvancedField[] = []; + + @ViewChild (AdvancedSearchPageComponent) searchPage : AdvancedSearchPageComponent ; + + + constructor (private route: ActivatedRoute, private _searchDataProvidersService: SearchDataprovidersService ) { + + this.results =[]; + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status =errorCodes.LOADING; + this.baseUrl = OpenaireProperties.getLinkToSearchAdvancedPublications(); + + + + } + ngOnInit() { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status =errorCodes.LOADING; + this.sub = this.route.queryParams.subscribe(params => { + let page = (params['page']=== undefined)?1:+params['page']; + this.page = ( page <= 0 ) ? 1 : page; + this.searchPage.fieldIds = this.fieldIds; + this.searchPage.selectedFields = this.selectedFields; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.searchPage.getSelectedFiltersFromUrl(params); + this.getResults(this.searchPage.createQueryParameters(), this.page, this.size); + + }); + } + ngOnDestroy() { + this.sub.unsubscribe(); + } + sub: any; + public getResults(parameters:string, page: number, size: number){ + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status = errorCodes.LOADING; + console.info("Advanced Search Publications: Execute search query "+parameters); + this._searchDataProvidersService.searchDataproviders(parameters, null, page, size, []).subscribe( + data => { + this.totalResults = data[0]; + console.info("Adv Search Data providers total="+this.totalResults); + this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status = errorCodes.DONE; + if(this.totalResults == 0 ){ + this.status = errorCodes.NONE; + } + }, + err => { + console.error(err); + console.info("error"); + //TODO check erros (service not available, bad request) + // if( ){ + // this.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status = errorCodes.NOT_AVAILABLE; + } + ); + } + private setFilters(){ + //TODO set filters from + } + + private queryChanged($event) { + var parameters = $event.value; + this.getResults(parameters, this.page,this.size); + console.info("queryChanged: Execute search query "+parameters); + + } + + +} diff --git a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts index 535b1541..88500a3a 100644 --- a/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts +++ b/portal-2/src/app/searchPages/advanced/advancedSearchPublications.component.ts @@ -78,6 +78,7 @@ export class AdvancedSearchPublicationsComponent { this.totalResults = data[0]; console.info("searchPubl total="+this.totalResults); this.results = data[1]; + this.searchPage.updateBaseUrlWithParameters(); var errorCodes:ErrorCodes = new ErrorCodes(); this.status = errorCodes.DONE; if(this.totalResults == 0 ){ diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts index 6076c5a6..ad0bae09 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts @@ -7,6 +7,7 @@ import {SearchDataprovidersService} from '../../services/searchDataproviders.ser import {SearchResult} from '../../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; @Component({ selector: 'search-dataproviders', @@ -29,68 +30,97 @@ export class SearchCompatibleDataprovidersComponent { private keyword = ''; private page :number = 1; private size :number = 10; - private sub: any; + private sub: any; private subResults: any; + private _location:Location; + private searchFields:SearchFields = new SearchFields(); + private refineFields: string[] = this.searchFields.DATAPROVIDER_INDEX; + private indexIdsMap: { [key:string]:string } = this.searchFields.DATAPROVIDER_INDEX_PARAM_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; + private _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[{field:"compatibility",opName:"cm",opValue:"not", values:["UNKNOWN","hostedBy","notCompatible"]},{field:"type",opName:"tp",opValue:"not",values: ["other"]}]; + // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; + private _prefixQuery: string = ""; + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { var errorCodes:ErrorCodes = new ErrorCodes(); this.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders(); + for(var i = 0; i < this._prefixQueryFields.length; i++ ){ + for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ + this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" + + this._prefixQueryFields[i].values[j] + "&" + + this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; + } + } + this._prefixQuery+="&"; } private ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.indexIdsMap = this.indexIdsMap; + this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; - this.filters = this.createFilters(); - for(var i=0; i< this.filters.length ; i++){ - var filter = this.filters[i]; - console.info(params); - if(params[filter.filterId] != undefined) { - let values = params[filter.filterId].split(","); - for(let value of values) { - for(let filterValue of filter.values) { - if(filterValue.id == value) { - filterValue.selected = true; - filter.countSelectedValues++; - } - } - } - } - } + this.keyword = (params['keyword']?params['keyword']:''); + this.page = (params['page']=== undefined)?1:+params['page']; + this.filters = this.createFilters(); + // for(var i=0; i< this.filters.length ; i++){ + // var filter = this.filters[i]; + // console.info(params); + // if(params[filter.filterId] != undefined) { + // let values = params[filter.filterId].split(","); + // for(let value of values) { + // for(let filterValue of filter.values) { + // if(filterValue.id == value) { + // filterValue.selected = true; + // filter.countSelectedValues++; + // } + // } + // } + // } + // } + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, false, this.page, this.size); // this.getResults(this.keyword, this.page, this.size, "searchPage"); }); } private ngOnDestroy() { - this.sub.unsubscribe(); - } -/* - public getResults(parameters:string, page: number, size: number, flag: string){ - console.info("getResults: Execute search query "+parameters); -//q=(not datasourcecompatibilityid exact 'UNKNOWN' )and (not datasourcecompatibilityid exact 'hostedBy' ) and (not datasourcecompatibilityid exact 'notCompatible' ) -// (datasourcecompatibilityid <> "UNKNOWN") and (datasourcecompatibilityid <> "hostedBy") and (datasourcecompatibilityid <> "notCompatible") - this._searchDataprovidersService.searchDataproviders(parameters, page, size, flag).subscribe( - data => { - this.totalResults = data[0]; - console.info("searchPubl total="+this.totalResults); - this.results = data[1]; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.DONE; - if(this.totalResults == 0 ){ - this.status = errorCodes.NONE; - } - }, - err => { - console.error(err); - console.info("error"); - this.totalResults = 0; - this.results = []; - var errorCodes:ErrorCodes = new ErrorCodes(); - this.status = errorCodes.ERROR; - } - ); - } -*/ + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } } + private _getResults(parameters:string,refine:boolean, page: number, size: number){ + // if(!refine && !this.searchPage){ + // this.searchPage = new SearchPageComponent(this._location); + // } + this.subResults = this._searchDataprovidersService.searchDataproviders(this._prefixQuery+parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( + data => { + this.totalResults = data[0]; + console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.results = data[1]; + // this.filters = data[2]; + this.searchPage.checkSelectedFilters(this.filters); + // this.filters = this.searchPage.checkSelectedFilters(data[2]); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status = errorCodes.DONE; + if(this.totalResults == 0 ){ + this.status = errorCodes.NONE; + } + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status = errorCodes.ERROR; + } + ); + } private setFilters(){ //TODO set filters from } @@ -98,29 +128,34 @@ export class SearchCompatibleDataprovidersComponent { private queryChanged($event) { var parameters = $event.value; console.info("queryChanged: Execute search query "+parameters); - //this.getResults(parameters, this.page, this.size, "searchPage"); + this._getResults(parameters, false, this.page, this.size); } private createFilters():Filter[] { var filter_names=["Type","Compatibility Level"]; - var filter_ids=["type","compatibility"]; + var filter_ids=["datasourcetypeuiid","datasourcecompatibilityid"]; var searchFields = new SearchFields(); - var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; //["datasourcetypeid","openairecompatibilityid"]; + var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; var value_names=[ - ["Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", "Publication Repositories Aggregators", + ["Publication Repositories", + "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", + + "Publication Repositories Aggregators", + "Institutional Repositories Aggregators", + "Thematic Repositories Aggregators", "Other Repositories Aggregators", "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; - var value_ids=[ - ["instRepo","thematicRepo", "otherRepo", "pubRepoAggr", "dataRepo", "dataRepoAggr", "jRepo", "jRepoAggr", "cris", "pubCat"], - ["compBasic","comp2", "comp2plus", "comp3","comp2data"]]; + // var value_ids=[ + // ["instRepo","thematicRepo", "otherRepo", "pubRepoAggr", "dataRepo", "dataRepoAggr", "jRepo", "jRepoAggr", "cris", "pubCat"], + // ["compBasic","comp2", "comp2plus", "comp3","comp2data"]]; var value_original_ids=[ - ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::thematic or aggregator::pubsrepository::institutional or aggregator::pubsrepository::unknown", + ["HEADER","pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown","HEADER", "aggregator::pubsrepository::thematic","aggregator::pubsrepository::institutional","aggregator::pubsrepository::unknown", "datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"], ["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]]; var filters: Filter[] =[]; for(var i =0 ; i < filter_names.length;i++){ var values:Value[] = []; for(var j =0 ; j < value_names[i].length;j++){ - var value:Value = {name: value_names[i][j], id: value_ids[i][j], number:j, selected:false} + var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} values.push(value); } var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or'} diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts index e69de29b..606804c5 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistries.component.ts @@ -0,0 +1,151 @@ +import {Component, Input, ViewChild} from '@angular/core'; +import { ActivatedRoute} from '@angular/router'; + +import { Filter, Value} from '../searchUtils/searchHelperClasses.class'; + +import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; +import {SearchResult} from '../../utils/entities/searchResult'; +import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties'; +import {SearchFields} from '../../utils/properties/searchFields'; +import {SearchPageComponent } from '../searchUtils/searchPage.component'; + +@Component({ + selector: 'search-entity-registries', + template: ` + + + + + ` + +}) +export class SearchEntityRegistriesComponent { + public results =[]; + private filters =[]; + public totalResults:number = 0 ; + private baseUrl:string; + public status:number; + private keyword = ''; + private page :number = 1; + private size :number = 10; + private sub: any; private subResults: any; + private _location:Location; + private searchFields:SearchFields = new SearchFields(); + private refineFields: string[] = this.searchFields.DATAPROVIDER_INDEX; + private indexIdsMap: { [key:string]:string } = this.searchFields.DATAPROVIDER_INDEX_PARAM_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; + private _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[ + {field:"type",opName:"tp",opValue:"and",values: ["other"]}]; + // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; + private _prefixQuery: string = ""; + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; + + constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status =errorCodes.LOADING; + this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders(); + for(var i = 0; i < this._prefixQueryFields.length; i++ ){ + for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ + this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" + + this._prefixQueryFields[i].values[j] + "&" + + this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; + } + } + this._prefixQuery+="&"; + } + + private ngOnInit() { + this.searchPage.refineFields = this.refineFields; + this.searchPage.indexIdsMap = this.indexIdsMap; + this.searchPage.fieldIdsMap = this.fieldIdsMap; + this.sub = this.route.queryParams.subscribe(params => { + this.keyword = (params['keyword']?params['keyword']:''); + this.page = (params['page']=== undefined)?1:+params['page']; + this.filters = this.createFilters(); + + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, false, this.page, this.size); + }); + } + + private ngOnDestroy() { + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } } + private _getResults(parameters:string,refine:boolean, page: number, size: number){ + this.subResults = this._searchDataprovidersService.searchDataproviders(this._prefixQuery+parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( + data => { + this.totalResults = data[0]; + console.info("search Entity Registries: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + this.results = data[1]; + // this.filters = data[2]; + this.searchPage.checkSelectedFilters(this.filters); + // this.filters = this.searchPage.checkSelectedFilters(data[2]); + this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status = errorCodes.DONE; + if(this.totalResults == 0 ){ + this.status = errorCodes.NONE; + } + }, + err => { + console.error(err); + //TODO check erros (service not available, bad request) + // if( ){ + // this.status = ErrorCodes.ERROR; + // } + var errorCodes:ErrorCodes = new ErrorCodes(); + this.status = errorCodes.ERROR; + } + ); + } + private setFilters(){ + //TODO set filters from + } + + private queryChanged($event) { + var parameters = $event.value; + console.info("queryChanged: Execute search query "+parameters); + this._getResults(parameters, false, this.page, this.size); + } + private createFilters():Filter[] { + var filter_names=["Type","Compatibility Level"]; + var filter_ids=["datasourcetypeuiid","datasourcecompatibilityid"]; + var searchFields = new SearchFields(); + var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; + var value_names=[ + [], + // ["Publication Repositories", + // "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", + // "Publication Repositories Aggregators", + // "Institutional Repositories Aggregators", + // "Thematic Repositories Aggregators", "Other Repositories Aggregators", + // "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], + ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; + // var value_ids=[ + // ["instRepo","thematicRepo", "otherRepo", "pubRepoAggr", "dataRepo", "dataRepoAggr", "jRepo", "jRepoAggr", "cris", "pubCat"], + // ["compBasic","comp2", "comp2plus", "comp3","comp2data"]]; + var value_original_ids=[ + [], + // ["HEADER","pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown","HEADER", "aggregator::pubsrepository::thematic","aggregator::pubsrepository::institutional","aggregator::pubsrepository::unknown", + // "datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"], + ["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]]; + var filters: Filter[] =[]; + for(var i =0 ; i < filter_names.length;i++){ + var values:Value[] = []; + for(var j =0 ; j < value_names[i].length;j++){ + var value:Value = {name: value_names[i][j], id: value_original_ids[i][j], number:j, selected:false} + values.push(value); + } + var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or'} + filters.push(filter); + } + return filters; + } + +} diff --git a/portal-2/src/app/searchPages/search.module.ts b/portal-2/src/app/searchPages/search.module.ts index 9513e514..2f451b87 100644 --- a/portal-2/src/app/searchPages/search.module.ts +++ b/portal-2/src/app/searchPages/search.module.ts @@ -28,8 +28,11 @@ import {SearchPeopleComponent} from './searchPeople.component'; import {SearchComponent} from './find/search.component'; import {SearchCompatibleDataprovidersComponent} from './dataProviders/compatibleDataProviders.component'; +import {SearchEntityRegistriesComponent} from './dataProviders/entityRegistries.component'; + //Advanced import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPublications.component'; +import { AdvancedSearchDataProvidersComponent } from './advanced/advancedSearchDataProviders.component'; @NgModule({ imports: [ @@ -50,10 +53,12 @@ import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPu AdvancedSearchFormComponent, SearchPublicationsComponent, AdvancedSearchPublicationsComponent, + AdvancedSearchDataProvidersComponent, SearchDataprovidersComponent, SearchComponent, SearchProjectsComponent, SearchCompatibleDataprovidersComponent, + SearchEntityRegistriesComponent, SearchDatasetsComponent, SearchOrganizationsComponent, SearchPeopleComponent @@ -65,6 +70,7 @@ import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPu exports: [ SearchAllComponent, AdvancedSearchPublicationsComponent, + AdvancedSearchDataProvidersComponent, SearchPublicationsComponent, SearchProjectsComponent, SearchDataprovidersComponent, @@ -73,6 +79,7 @@ import { AdvancedSearchPublicationsComponent } from './advanced/advancedSearchPu SearchPeopleComponent, SearchComponent, SearchCompatibleDataprovidersComponent, + SearchEntityRegistriesComponent, SearchResultComponent ] }) diff --git a/portal-2/src/app/searchPages/searchDataproviders.component.ts b/portal-2/src/app/searchPages/searchDataproviders.component.ts index 68b72f58..819e81a5 100644 --- a/portal-2/src/app/searchPages/searchDataproviders.component.ts +++ b/portal-2/src/app/searchPages/searchDataproviders.component.ts @@ -1,9 +1,7 @@ import {Component, Input, ViewChild} from '@angular/core'; import { ActivatedRoute} from '@angular/router'; import {Location} from '@angular/common'; - import { Filter, Value} from './searchUtils/searchHelperClasses.class'; - import {SearchDataprovidersService} from '../services/searchDataproviders.service'; import {SearchResult} from '../utils/entities/searchResult'; import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties'; @@ -30,37 +28,43 @@ export class SearchDataprovidersComponent { private keyword = ''; private page :number = 1; private size :number = 10; - private sub: any; + private sub: any; private subResults: any; private _location:Location; - private refineFields = []; private searchFields:SearchFields = new SearchFields(); + private refineFields: string[] = this.searchFields.DATAPROVIDER_INDEX; + private indexIdsMap: { [key:string]:string } = this.searchFields.DATAPROVIDER_INDEX_PARAM_MAP; + private fieldIdsMap: { [key:string]:{ name:string, operator:string, type:string, indexField:string }} = this.searchFields.DATAPROVIDER_FIELDS_MAP; + @ViewChild (SearchPageComponent) searchPage : SearchPageComponent ; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { - //this.results =[]; - //this.filters =[]; var errorCodes:ErrorCodes = new ErrorCodes(); this.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchDataProviders(); - if(!this.searchPage){ - this.searchPage = new SearchPageComponent(this._location); - } } private ngOnInit() { this.searchPage.refineFields = this.refineFields; + this.searchPage.indexIdsMap = this.indexIdsMap; + this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { - this.keyword = (params['keyword']?params['keyword']:''); - this.page = (params['page']=== undefined)?1:+params['page']; + this.keyword = (params['keyword']?params['keyword']:''); + this.page = (params['page']=== undefined)?1:+params['page']; - this.filters = this.createFilters(); - this.getResults(this.keyword, true, this.page, this.size); + + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this._getResults(queryParameters, true, this.page, this.size); }); } private ngOnDestroy() { - this.sub.unsubscribe(); + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } } public getResultsForEntity(entity:string, id:string, page: number, size: number){ @@ -105,14 +109,18 @@ export class SearchDataprovidersComponent { this._getResults(parameters,refine,page,size); } private _getResults(parameters:string,refine:boolean, page: number, size: number){ - - this._searchDataprovidersService.searchDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( + if(!refine && !this.searchPage){ + this.searchPage = new SearchPageComponent(this._location); + } + this.subResults = this._searchDataprovidersService.searchDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( data => { this.totalResults = data[0]; - console.info("search Datasets: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); + console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); this.results = data[1]; - this.filters = this.searchPage.checkSelectedFilters(data[2]); - this.searchPage.updateBaseUrlWithParameters(this.filters); + this.filters = data[2]; + this.searchPage.checkSelectedFilters(this.filters); + // this.filters = this.searchPage.checkSelectedFilters(data[2]); + this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.status = errorCodes.DONE; if(this.totalResults == 0 ){ @@ -168,32 +176,32 @@ export class SearchDataprovidersComponent { this._getResults(parameters, true, this.page, this.size); } - private createFilters():Filter[] { - var filter_names=["Type","Compatibility Level"]; - var filter_ids=["type","compatibility"]; - var searchFields = new SearchFields(); - var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; //["datasourcetypeid","openairecompatibilityid"]; - var value_names=[ - ["Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", "Publication Repositories Aggregators", - "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], - ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; - var value_ids=[ - ["instRepo","thematicRepo", "otherRepo", "pubRepoAggr", "dataRepo", "dataRepoAggr", "jRepo", "jRepoAggr", "cris", "pubCat"], - ["compBasic","comp2", "comp2plus", "comp3","comp2data"]]; - var value_original_ids=[ - ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::thematic or aggregator::pubsrepository::institutional or aggregator::pubsrepository::unknown", - "datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"], - ["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]]; - var filters: Filter[] =[]; - for(var i =0 ; i < filter_names.length;i++){ - var values:Value[] = []; - for(var j =0 ; j < value_names[i].length;j++){ - var value:Value = {name: value_names[i][j], id: value_ids[i][j], number:j, selected:false} - values.push(value); - } - var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or'} - filters.push(filter); - } - return filters; - } + // private createFilters():Filter[] { + // var filter_names=["Type","Compatibility Level"]; + // var filter_ids=["type","compatibility"]; + // var searchFields = new SearchFields(); + // var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; //["datasourcetypeid","openairecompatibilityid"]; + // var value_names=[ + // ["Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", "Publication Repositories Aggregators", + // "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], + // ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; + // var value_ids=[ + // ["instRepo","thematicRepo", "otherRepo", "pubRepoAggr", "dataRepo", "dataRepoAggr", "jRepo", "jRepoAggr", "cris", "pubCat"], + // ["compBasic","comp2", "comp2plus", "comp3","comp2data"]]; + // var value_original_ids=[ + // ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::thematic or aggregator::pubsrepository::institutional or aggregator::pubsrepository::unknown", + // "datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"], + // ["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"]]; + // var filters: Filter[] =[]; + // for(var i =0 ; i < filter_names.length;i++){ + // var values:Value[] = []; + // for(var j =0 ; j < value_names[i].length;j++){ + // var value:Value = {name: value_names[i][j], id: value_ids[i][j], number:j, selected:false} + // values.push(value); + // } + // var filter:Filter = {title: filter_names[i], filterId: filter_ids[i], originalFilterId: filter_original_ids[i], values : values, countSelectedValues:0, "filterOperator": 'or'} + // filters.push(filter); + // } + // return filters; + // } } diff --git a/portal-2/src/app/searchPages/searchDatasets.component.ts b/portal-2/src/app/searchPages/searchDatasets.component.ts index 5b2ab749..a558faa6 100644 --- a/portal-2/src/app/searchPages/searchDatasets.component.ts +++ b/portal-2/src/app/searchPages/searchDatasets.component.ts @@ -56,8 +56,8 @@ export class SearchDatasetsComponent { this.page = (params['page']=== undefined)?1:+params['page']; // this.getRefineResults(); //this.getResults(this.keyword, this.page, this.size, "searchPage"); - this.searchPage.getSelectedFiltersFromUrl(params); - this.getResults(this.keyword, true, this.page, this.size); + var queryParameters = this.searchPage.getQueryParametersFromUrl(params); + this.getResults(queryParameters, true, this.page, this.size); }); } diff --git a/portal-2/src/app/searchPages/searchProjects.component.ts b/portal-2/src/app/searchPages/searchProjects.component.ts index f33d94ee..9c7dc62a 100644 --- a/portal-2/src/app/searchPages/searchProjects.component.ts +++ b/portal-2/src/app/searchPages/searchProjects.component.ts @@ -28,6 +28,7 @@ export class SearchProjectsComponent { private page :number = 1; private size :number = 10; private sub: any; + private subResults: any; private searchFields:SearchFields = new SearchFields(); private refineFields: string[] = this.searchFields.PROJECT_INDEX; private indexIdsMap: { [key:string]:string } = this.searchFields.PROJECT_INDEX_PARAM_MAP; @@ -43,7 +44,6 @@ export class SearchProjectsComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchProjects(); - this.refineFields = this.searchFields.PROJECT_INDEX; } @@ -68,7 +68,12 @@ export class SearchProjectsComponent { } private ngOnDestroy() { - this.sub.unsubscribe(); + if(this.sub){ + this.sub.unsubscribe(); + } + if(this.subResults){ + this.subResults.unsubscribe(); + } } public getResults(keyword:string,refine:boolean, page: number, size: number){ @@ -82,7 +87,7 @@ export class SearchProjectsComponent { if(!refine && !this.searchPage){ this.searchPage = new SearchPageComponent(this._location); } - this._searchProjectsService.searchProjects(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( + this.subResults = this._searchProjectsService.searchProjects(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, this.searchPage.getFields()).subscribe( data => { this.totalResults = data[0]; console.info("search Projects: [Parameters:"+parameters+" ] [total results:"+this.totalResults+"]"); diff --git a/portal-2/src/app/searchPages/searchUtils/advancedSearchForm.component.ts b/portal-2/src/app/searchPages/searchUtils/advancedSearchForm.component.ts index ab4513e6..be3776c2 100644 --- a/portal-2/src/app/searchPages/searchUtils/advancedSearchForm.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/advancedSearchForm.component.ts @@ -30,18 +30,18 @@ import {SearchFields} from '../../utils/properties/searchFields';