From b454b318d07612b7683244faacf66e776d4e201d Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Sun, 31 May 2020 11:28:12 +0000 Subject: [PATCH] [Trunk | Library]: fetchResearchResults.class.ts: Add methods 'getResultsForCommunity()' and 'getNumForCommunity()' - used in community first page. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58810 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../fetchResearchResults.class.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/utils/fetchEntitiesClasses/fetchResearchResults.class.ts b/utils/fetchEntitiesClasses/fetchResearchResults.class.ts index d0c828c2..7917e159 100644 --- a/utils/fetchEntitiesClasses/fetchResearchResults.class.ts +++ b/utils/fetchEntitiesClasses/fetchResearchResults.class.ts @@ -47,6 +47,45 @@ export class FetchResearchResults { } } + public getResultsForCommunity(resultType:string, communityId: string, page: number, size: number, properties:EnvProperties) { + this.searchUtils.status = this.errorCodes.LOADING; + + this.subResults = this._searchResearchResultsService.search(resultType, "", "&fq=communityid=" + communityId, page, size, "resultdateofacceptance,descending", [], properties).subscribe( + data => { + this.searchUtils.totalResults = data[0]; + this.results = data[1]; + + this.searchUtils.status = this.errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = this.errorCodes.NONE; + } + }, + err => { + this.handleError("Error getting "+this.getEntityName(resultType,true)+" for community: "+communityId, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + } + ); + } + + public getNumForCommunity(resultType:string, communityId: string, properties:EnvProperties) { + this.searchUtils.status = this.errorCodes.LOADING; + + this.subResults = this._searchResearchResultsService.countTotalResults(resultType, properties, "&fq=communityid=" + communityId).subscribe( + data => { + this.searchUtils.totalResults = data; + + this.searchUtils.status = this.errorCodes.DONE; + if(this.searchUtils.totalResults == 0 ){ + this.searchUtils.status = this.errorCodes.NONE; + } + }, + err => { + this.handleError("Error getting number of "+this.getEntityName(resultType,true)+" for community: "+communityId, err); + this.searchUtils.status = this.errorMessages.getErrorCode(err.status); + } + ); + } + public getResultsByKeyword(resultType:string, keyword:string, page: number, size: number, properties:EnvProperties, customFilter:SearchCustomFilter=null){ var parameters = ""; if(keyword.length > 0){