Skip to content

Commit

Permalink
Maj fonctionnalités er
Browse files Browse the repository at this point in the history
  • Loading branch information
vinsag committed Oct 26, 2021
1 parent 31a136f commit a0d8fce
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
25 changes: 17 additions & 8 deletions controllers/er/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ function createErProxy(featureTypeName,typeSearch){
});
}
params = _.omit(params,'apikey');

/** Gestion affichage des valeurs avec has_geometrie
* si true : affichage uniquement des résultats avec géométrie
* si false: affichage des résultats avec ou sans géométrie
*/

if((params.admin == 'Y') && ((typeSearch == 'product') || (typeSearch == 'category'))) {
params.has_geometry=false;
} else {
params.has_geometry=true;
}
params = _.omit(params,'admin');

/** Gestion de la requete product */

if (typeSearch == 'product') {
//For module Product utilisation parametre name pour la recherche
if (params.name) {
Expand All @@ -51,12 +63,8 @@ function createErProxy(featureTypeName,typeSearch){
});
}
}

if((params.has_geometry) &&(!((params.field_date) || (params._limit)))) {
params.has_geometry =true;
}
}

}
//For _propertyNames, we need to transform the string in Array
if(params._propertyNames) {
params._propertyNames = params._propertyNames.split(';');
Expand Down Expand Up @@ -163,7 +171,7 @@ var productValidators = erValidators.concat([
check('publication_date').optional().isString(),
check('date_maj_deb').optional().isString(), // Param ne servant que pour admin
check('date_maj_fin').optional().isString(), // Param ne servant que pour admin
check('has_geometry').optional().isBoolean(),
check('admin').optional().isAlphanumeric().isLength({min:1,max:1}).withMessage('Le champ admin doit être Y ou N')


]);
Expand All @@ -179,7 +187,8 @@ router.post('/product',cors(corsOptionsGlobal),productValidators, createErProxy(
var categoryValidators = erValidators.concat([
check('name').optional().isString(),
check('type').optional().isAlphanumeric().isLength({min:1,max:1}).withMessage('Le type est sur 1 caractère'),
check('category_id').optional().isString()
check('category_id').optional().isString(),
check('admin').optional().isAlphanumeric().isLength({min:1,max:1}).withMessage('Le champ admin doit être Y ou N')
]);

router.get('/category', cors(corsOptionsGlobal),categoryValidators, createErProxy('PLAGE_ER_WFS:product_view' ,'category'));
Expand Down
6 changes: 0 additions & 6 deletions doc/er.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ paths:
type: string
require: false

- name: has_geometry
in: query
description: Recherche uniquement valeur avec géométrie ou non
type: boolean
require: false

- name: _limit
in: query
description: Limite de résultats à afficher(chiffre entre 1 et 1000)
Expand Down
7 changes: 3 additions & 4 deletions lib/buildErCqlFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function bboxToFilter(bbox){
if ( name.charAt(0) === '_' ){
continue;
}

if ( name == 'bbox' ){
parts.push(bboxToFilter(params['bbox'])) ;
}else if ( name == 'geom' ){
Expand All @@ -65,7 +65,7 @@ function bboxToFilter(bbox){
} else if (name == 'namepr') { //Traiter le cas du produit avec le parametre name
parts.push(' name ILIKE \'%'+ params[name] + '%\' OR name_complement ILIKE \'%'+ params[name] + '%\'');

} else if((name == 'has_geometry') && (params[name] =='false')){
} else if((name == 'has_geometry') && (params[name] ==false)){
continue; //We do nothing when value has geometry = false to get all results.

// Search in category
Expand All @@ -81,8 +81,7 @@ function bboxToFilter(bbox){
chaineCategoryId = chaineCategoryId + chaineConnector + ' category_id='+valueCat[i];
}
parts.push(chaineCategoryId);
}

}
} else {
parts.push(name+'=\''+ params[name]+'\'');
}
Expand Down
5 changes: 2 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apicarto",
"version": "v2.4.0",
"version": "v2.4.2",
"main": "index.js",
"scripts": {
"import": "npm run import-inao-appellation",
Expand Down

0 comments on commit a0d8fce

Please sign in to comment.