From b1fb4e7a3eb024f325e67f4daa1700e68471bf51 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Thu, 12 Sep 2019 10:30:48 +0000 Subject: [PATCH] [Trunk | Library]: 1. searchFields.ts: Method 'getFieldOperator()' added, to return operator (and/or) for a given 'fieldId'. 2. refineResults.class.ts: Use 'getFieldOperator()' method of 'searchFields.ts' to fill value of 'filter.filterOperator'. 3. searchPage.component.ts: Use 'getFieldOperator()' method of 'searchFields.ts' to get operator (and/or) for a given 'fieldId' and use this operator in the search query. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57048 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../searchUtils/searchPage.component.ts | 10 +++-- services/servicesUtils/refineResults.class.ts | 1 + utils/properties/searchFields.ts | 40 +++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/searchPages/searchUtils/searchPage.component.ts b/searchPages/searchUtils/searchPage.component.ts index 05c4645f..47e34f8a 100644 --- a/searchPages/searchUtils/searchPage.component.ts +++ b/searchPages/searchUtils/searchPage.component.ts @@ -185,11 +185,13 @@ export class SearchPageComponent { let values = (StringUtils.URIDecode(this.queryParameters.get(filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); var countvalues = 0; var fq = ""; + let filterOp: string = this.searchFieldsHelper.getFieldOperator(filterId); + console.info(filterId, filterOp); for(let value of values) { countvalues++; var paramId = this.fieldIdsMap[filterId].param; // parameters+='&' + paramId+ '='+ value;//+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or"); - fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId +" exact " +(value); + fq+=(fq.length > 0 ? " " + filterOp + " ":"" ) + filterId +" exact " +(value); } if(countvalues > 0){ fq="&fq="+StringUtils.URIEncode(fq); @@ -247,11 +249,13 @@ export class SearchPageComponent { if(params[filterId] != undefined) { this.queryParameters.set(filterId,decodeURIComponent(params[filterId])); let values = (decodeURIComponent(this.queryParameters.get(filterId))).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); - var countvalues = 0 + var countvalues = 0; + let filterOp: string = this.searchFieldsHelper.getFieldOperator(filterId); + console.info(filterId, filterOp); for(let value of values) { countvalues++; // parameters+= ((countvalues == 1)?" and (":" or ")+ filterId+ '='+ value; - fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId + " exact " + value;//StringUtils.quote(value); + fq+=(fq.length > 0 ? " " + filterOp + " ":"" ) + filterId + " exact " + value;//StringUtils.quote(value); } // parameters+= " ) "; if(countvalues > 0){ diff --git a/services/servicesUtils/refineResults.class.ts b/services/servicesUtils/refineResults.class.ts index 6068e522..01999671 100644 --- a/services/servicesUtils/refineResults.class.ts +++ b/services/servicesUtils/refineResults.class.ts @@ -19,6 +19,7 @@ export class RefineResultsUtils { filter.filterId = fields[j]; filter.originalFilterId = fields[j]; filter.valueIsUnique = searchFields.fieldHasUniqueValue(fields[j], entityType, usedBy); + filter.filterOperator = searchFields.getFieldOperator(fields[j]); //console.info("filter.title: "+filter.title+" filter.valueIsUnique: "+filter.valueIsUnique); let field = data[fields[j]]; diff --git a/utils/properties/searchFields.ts b/utils/properties/searchFields.ts index 474f9298..6802fceb 100644 --- a/utils/properties/searchFields.ts +++ b/utils/properties/searchFields.ts @@ -189,6 +189,46 @@ export class SearchFields { return false; } } + +/* +AND + Funder: relfunder, relfundinglevel0_id, relfundinglevel1_id, relfundinglevel2_id + Project: relproject + Community: community +OR + Type: instancetypename, datasourcetypeuiname + Language: resultlanguagename, datasourceodlanguages + Compatibility Level: datasourcecompatibilityname + Country: country + Content: datasourceodcontenttypes + Content Provider: resulthostingdatasource + Collected From: collectedfrom +BULLETS + Access Mode: resultbestaccessright + Special Clause 39: projectecsc39 + Versioning: + +RANGE + Publication date: resultacceptanceyear + Project life: projectstartyear, projectendyear + +? WHAT ABOUT ?: + Subjects: + Supported Identifiers: +*/ + + getFieldOperator(fieldId:string):string{ + if(fieldId == "relfunder" || fieldId == "relfundinglevel0_id" || fieldId == "relfundinglevel1_id" || fieldId == "relfundinglevel2_id" + || fieldId == "relproject" || fieldId == "community") { + return "and"; + } else if(fieldId == "instancetypename" || fieldId == "datasourcetypeuiname" + || fieldId == "resultlanguagename" || fieldId == "datasourceodlanguages" + || fieldId == "datasourcecompatibilityname" || fieldId == "country" || fieldId == "datasourceodcontenttypes" + || fieldId == "resulthostingdatasource" || fieldId == "collectedfrom") { + return "or"; + } + return "or"; + } } export class FieldDetails{ name:string;