[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
This commit is contained in:
konstantina.galouni 2019-09-12 10:30:48 +00:00
parent e0dddbf71e
commit b1fb4e7a3e
3 changed files with 48 additions and 3 deletions

View File

@ -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){

View File

@ -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]];

View File

@ -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;