This commit is contained in:
2018-12-12 16:10:02 +00:00
parent 880635c600
commit 7e0834d2fa
6 changed files with 80 additions and 21 deletions

View File

@@ -73,7 +73,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), ct);
//SEARCH INDEXING
// Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
// Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
return outObj;
@@ -103,7 +103,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, outObj.Id, BizType, AyaEvent.Created), TempContext);
//SEARCH INDEXING
// Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
// Search.ProcessNewObjectKeywords(UserLocaleId, outObj.Id, BizType, outObj.Name, outObj.Name);
return outObj;
@@ -175,7 +175,7 @@ namespace AyaNova.Biz
EventLogProcessor.LogEventToDatabase(new Event(UserId, dbObj.Id, BizType, AyaEvent.Modified), ct);
//Update keywords
// Search.ProcessUpdatedObjectKeywords(UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
// Search.ProcessUpdatedObjectKeywords(UserLocaleId, dbObj.Id, BizType, dbObj.Name, dbObj.Name);
return true;
}
@@ -316,6 +316,71 @@ namespace AyaNova.Biz
}
}
//VALIDATE SORT
//Filter json must parse
if (!string.IsNullOrWhiteSpace(inObj.Sort))
{
try
{
var v = JArray.Parse(inObj.Sort);
for (int i = 0; i < v.Count; i++)
{
var sortItem = v[i];
if (sortItem["fld"] == null)
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"fld\" property ");
else
{
var fld = sortItem["fld"].Value<string>();
if (string.IsNullOrWhiteSpace(fld))
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, \"fld\" property is empty and required");
//validate the field name if we can
if (ListValidFilterOptions != null)
{
if (!ListValidFilterOptions.Flds.Exists(x => x.Fld == fld))
{
AddError(ValidationErrorType.InvalidValue, "Filter", $"Filter array item {i}, fld property value \"{fld}\" is not a valid value for ListKey specified");
}
}
}
if (sortItem["op"] == null)
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing required \"op\" property ");
else
{
var opType = sortItem["op"].Value<string>();
if (!FilterComparisonOperator.Operators.Contains(opType))
AddError(ValidationErrorType.InvalidValue, "Filter", $"Filter array item {i}, \"op\" property value of \"{opType}\" is not a valid FilterComparisonOperator type");
}
if (sortItem["value"] == null)
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing or is empty the required \"value\" property ");
else
{
if (sortItem["value"].Type == JTokenType.String && string.IsNullOrWhiteSpace(sortItem["value"].Value<string>()))
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing or is empty the required \"value\" property ");
if (sortItem["value"].Type == JTokenType.Array && sortItem["value"].Count() == 0)
AddError(ValidationErrorType.RequiredPropertyEmpty, "Filter", $"Filter array item {i}, object is missing or is empty the required \"value\" property ARRAY ");
}
//NOTE: value of nothing, null or empty is a valid value so no checking for it here
}
}
catch (Newtonsoft.Json.JsonReaderException ex)
{
AddError(ValidationErrorType.InvalidValue, "Sort", "Sort is not valid JSON string: " + ex.Message);
}
}
return;
}

View File

@@ -201,6 +201,9 @@ namespace AyaNova.Biz
//BUILD ORDER BY AND APPEND IT
//TODO: Code a separate order by builder block
#pragma warning disable EF1000
var items = await ct.Widget

View File

@@ -20,7 +20,8 @@ namespace AyaNova.Models
public bool Public { get; set; }
[Required, MaxLength(255)]
public string ListKey { get; set; }//max 255 characters ascii set
public string Filter { get; set; }//can be empty I guess meaning nothing selected in it
public string Filter { get; set; }//JSON fragment filter collection
public string Sort { get; set; }//JSON fragment sort collection
}
}

View File

@@ -301,7 +301,7 @@ namespace AyaNova.Util
LogUpdateMessage(log);
exec("CREATE TABLE adatafilter (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, public bool not null," +
"listkey varchar(255) not null, filter text, UNIQUE(name))");
"listkey varchar(255) not null, filter text, sort text, UNIQUE(name))");
setSchemaLevel(++currentSchema);
}