diff --git a/claims/claim-utils/claimProjectSearchForm.component.ts b/claims/claim-utils/claimProjectSearchForm.component.ts index 01e6d8c0..27ec74d5 100644 --- a/claims/claim-utils/claimProjectSearchForm.component.ts +++ b/claims/claim-utils/claimProjectSearchForm.component.ts @@ -65,35 +65,36 @@ export class ClaimProjectsSearchFormComponent { } search(page,size) { - if(this.keyword.length == 0){ - this.showResults =false; + if (this.keyword.length == 0) { + this.showResults = false; return; } - this.showResults =true; + this.showResults = true; this.openaireResults = []; this.openaireResultsStatus = this.errorCodes.LOADING; this.prevFilters = this.filters; //searchProjects (params: string, refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties ):any { - this.sub = this._projectService.searchProjects(this.createOpenaireQueryParams(),(page==1)? this.refineFieldsQuery:null, page, size, (page==1)?this.refineFields:[], this.properties).subscribe( + this.sub = this._projectService.advancedSearchProjects(this.createOpenaireQueryParams(), page, size, this.properties, (page == 1) ? this.refineFieldsQuery : null, (page == 1) ? this.refineFields : [], this.createOpenaireRefineQuery()).subscribe( + // this.sub = this._projectService.searchProjects(this.createOpenaireQueryParams(),(page==1)? this.refineFieldsQuery:null, page, size, (page==1)?this.refineFields:[], this.properties).subscribe( data => { - if(data != null) { - this.openaireResultsPage=page; - this.openaireResultsNum = data[0]; - this.openaireResults =ClaimProjectsSearchFormComponent.openaire2ClaimEntity(data[1], this.properties); - if(data[2] && data[2].length > 0){ - this.filters = this.checkSelectedFilters( data[2], this.prevFilters); - } - - this.openaireResultsStatus = this.errorCodes.DONE; - if(this.openaireResultsNum == 0){ - this.openaireResultsStatus = this.errorCodes.NONE; - this.filters = this.checkSelectedFilters( [], this.prevFilters); - } - }else { - this.openaireResultsStatus = this.errorCodes.ERROR; + if (data != null) { + this.openaireResultsPage = page; + this.openaireResultsNum = data[0]; + this.openaireResults = ClaimProjectsSearchFormComponent.openaire2ClaimEntity(data[1], this.properties); + if (data[2] && data[2].length > 0) { + this.filters = this.checkSelectedFilters(data[2], this.prevFilters); } - }, + + this.openaireResultsStatus = this.errorCodes.DONE; + if (this.openaireResultsNum == 0) { + this.openaireResultsStatus = this.errorCodes.NONE; + this.filters = this.checkSelectedFilters([], this.prevFilters); + } + } else { + this.openaireResultsStatus = this.errorCodes.ERROR; + } + }, err => { this.openaireResultsStatus = this.errorCodes.ERROR; //console.log(err.status); @@ -202,12 +203,16 @@ export class ClaimProjectsSearchFormComponent { } - createOpenaireQueryParams():string { + createOpenaireQueryParams(): string { let query = ""; - if(this.keyword.length > 0){ - query += "q=" + StringUtils.quote(StringUtils.URIEncode(this.keyword)); + if (this.keyword.length > 0) { + // query += "q=" + StringUtils.quote(StringUtils.URIEncode(this.keyword)); + query += StringUtils.quote(StringUtils.URIEncode(this.keyword)); } + return query; + } + createOpenaireRefineQuery(): string { /*if(this.startYear.length > 0 ){ query+='&fq=projectstartyear exact \"'+this.startYear+'\"' } @@ -215,30 +220,30 @@ export class ClaimProjectsSearchFormComponent { query+='&fq=projectendyear exact \"'+this.endYear+'\"' }*/ let allFqs = ""; - for (let filter of this.filters){ - if(filter.countSelectedValues > 0){ - let count_selected=0; + for (let filter of this.filters) { + if (filter.countSelectedValues > 0) { + let count_selected = 0; let fq = ""; - for (let value of filter.values){ - if(value.selected == true){ + for (let value of filter.values) { + if (value.selected == true) { count_selected++; - fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + (StringUtils.quote(value.id)); + fq += (fq.length > 0 ? " " + filter.filterOperator + " " : "") + filter.filterId + " exact " + (StringUtils.quote(value.id)); } } - if(count_selected > 0){ - fq="&fq="+StringUtils.URIEncode(fq); + if (count_selected > 0) { + fq = "&fq=" + StringUtils.URIEncode(fq); allFqs += fq; } } } - for (let i=0; i=" ,"<=", "and" ) + allFqs += NewSearchPageComponent.createRangeFilterQuery(this.rangeFields[i], filter.selectedFromValue, filter.selectedToValue, " within ", ">=", "<=", "and") } - return query+allFqs; - + return allFqs + "&type=projects"; } + public yearChanged() { this.search(this.page, this.size); @@ -273,20 +278,21 @@ export class ClaimProjectsSearchFormComponent { } } - + filter.countAllValues = filter.values.length; } if(filters.length == 0 ){ - for(let j=0; j< prevFilters.length ; j++){ - let filter = Object.assign({}, prevFilters[j]); - filter.values = []; - for(let filterValue of prevFilters[j].values) { - if(filterValue.selected){ - filterValue.number = 0; - filter.values.push(filterValue); - } - } - filters.push(filter) + for(let j=0; j< prevFilters.length ; j++) { + let filter = Object.assign({}, prevFilters[j]); + filter.values = []; + for (let filterValue of prevFilters[j].values) { + if (filterValue.selected) { + filterValue.number = 0; + filter.values.push(filterValue); } + } + filter.countAllValues = filter.values.length; + filters.push(filter) + } } return filters; } diff --git a/services/searchProjects.service.ts b/services/searchProjects.service.ts index e9c48eaa..6d30b06c 100644 --- a/services/searchProjects.service.ts +++ b/services/searchProjects.service.ts @@ -230,7 +230,7 @@ export class SearchProjectsService { for(let z=0; z