From 9897924879686564a65d7b1f0083937e4ae12344 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 30 Nov 2018 00:48:51 +0000 Subject: [PATCH] --- .../core-list-graph-datatable-filtering-paging.txt | 3 +++ server/AyaNova/biz/DataFilterBiz.cs | 13 +++++++++---- server/AyaNova/biz/IFilterableObject.cs | 5 ----- server/AyaNova/biz/WidgetBiz.cs | 6 +----- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/devdocs/specs/core-list-graph-datatable-filtering-paging.txt b/devdocs/specs/core-list-graph-datatable-filtering-paging.txt index 4e861318..dc4d01d6 100644 --- a/devdocs/specs/core-list-graph-datatable-filtering-paging.txt +++ b/devdocs/specs/core-list-graph-datatable-filtering-paging.txt @@ -33,11 +33,14 @@ Upon user selecting a filter to use the list query string has the regular paging - If list not found then it will return a 404 instead of the list - server loads the filter, generates the sql based on the stored filter, adds the sort by and offset / page, runs the query and then returns the data as json collection to the client +NOTE: determined it would be too much trouble for too little gain to validate that the fields specified in the filter actually exist for that object LIST FILTERING TODO - DONE test for fetching widget filter options (localized, so have two users test each for expected response) +Need way to check if fields are valid for the object list in question both from the list Datafilter route and future SQL builder + Add test for excercising all of DataFilterController route including rights to non personal alternative owner etc Add test for correctly validated Widget datafilter when saved or updated via datafiltercontroller (sanity check of the filter settings and options IFilterableObject implemented) diff --git a/server/AyaNova/biz/DataFilterBiz.cs b/server/AyaNova/biz/DataFilterBiz.cs index 22f89a09..c915d669 100644 --- a/server/AyaNova/biz/DataFilterBiz.cs +++ b/server/AyaNova/biz/DataFilterBiz.cs @@ -261,19 +261,24 @@ namespace AyaNova.Biz var filterItem = v[i]; if (filterItem["fld"] == null) AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"fld\" property "); - else{ - //todo: find the filteroptions object adn confirm this is a valid value for fld - } + else + { + var fld = filterItem["fld"].Value(); + if (string.IsNullOrWhiteSpace(fld)) + AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, \"fld\" property is empty and required"); + + } if (filterItem["op"] == null) AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"op\" property "); else { var opType = filterItem["op"].Value(); if (!FilterComparisonOperator.Operators.Contains(opType)) - AddError(ValidationErrorType.InvalidValue, "Filter", $"Filter array item {i}, \"op\" value of \"{opType}\" is not a valid FilterComparisonOperator type"); + AddError(ValidationErrorType.InvalidValue, "Filter", $"Filter array item {i}, \"op\" property value of \"{opType}\" is not a valid FilterComparisonOperator type"); } if (filterItem["value"] == null) AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"value\" property "); + //NOTE: value of nothing, null or empty is a valid value so no checking for it here } } catch (Newtonsoft.Json.JsonReaderException ex) diff --git a/server/AyaNova/biz/IFilterableObject.cs b/server/AyaNova/biz/IFilterableObject.cs index 2c3d8bc6..12d34cbd 100644 --- a/server/AyaNova/biz/IFilterableObject.cs +++ b/server/AyaNova/biz/IFilterableObject.cs @@ -16,11 +16,6 @@ namespace AyaNova.Biz //FILTEROPTIONS COLLECTION FilterOptions FilterOptions { get; } - List FilterFields {get;} - - //VALIDATE FILTER? - - } diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index 76ee7061..403c35c4 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -33,11 +33,7 @@ namespace AyaNova.Biz } } - public static List FilterFields(){ - List fields=new List(); - fields.Add(new FilterField()) - } - + internal WidgetBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles) { ct = dbcontext;