diff --git a/devdocs/todo.txt b/devdocs/todo.txt index 5efd478a..a56f26b2 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -14,6 +14,7 @@ Clean up AyaObjectField definition for FORM FIELD STUFF: Extracted from ayaobjectfielddefinitions Essentially the same thing as it is now, so maybe just rename the existing one +Rename objectfieldscontroller / routes MAKE DATALIST ROUTE FOR FETCHING LISTS BY KEY - REMOVE LISTS FROM INDIVIDUAL OBJECT ROUTES AS MUCH AS POSSIBLE diff --git a/server/AyaNova/Controllers/DataFilterController.cs b/server/AyaNova/Controllers/DataListFilterController.cs similarity index 87% rename from server/AyaNova/Controllers/DataFilterController.cs rename to server/AyaNova/Controllers/DataListFilterController.cs index b4450f14..4f2ceb85 100644 --- a/server/AyaNova/Controllers/DataFilterController.cs +++ b/server/AyaNova/Controllers/DataListFilterController.cs @@ -24,10 +24,10 @@ namespace AyaNova.Api.Controllers [Route("api/v{version:apiVersion}/[controller]")] [Produces("application/json")] [Authorize] - public class DataFilterController : ControllerBase + public class DataListFilterController : ControllerBase { private readonly AyContext ct; - private readonly ILogger log; + private readonly ILogger log; private readonly ApiServerState serverState; @@ -37,7 +37,7 @@ namespace AyaNova.Api.Controllers /// /// /// - public DataFilterController(AyContext dbcontext, ILogger logger, ApiServerState apiServerState) + public DataListFilterController(AyContext dbcontext, ILogger logger, ApiServerState apiServerState) { ct = dbcontext; log = logger; @@ -60,7 +60,7 @@ namespace AyaNova.Api.Controllers return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); //Instantiate the business object handler - DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext); + DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext); if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType)) return StatusCode(403, new ApiNotAuthorizedResponse()); @@ -94,7 +94,7 @@ namespace AyaNova.Api.Controllers return BadRequest(new ApiErrorResponse(ModelState)); //Instantiate the business object handler - DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext); + DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext); var l = await biz.GetPickListAsync(ListKey); return Ok(ApiOkResponse.Response(l, true)); @@ -122,7 +122,7 @@ namespace AyaNova.Api.Controllers return BadRequest(new ApiErrorResponse(ModelState)); //Instantiate the business object handler - DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext); + DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext); var o = await biz.GetNoLogAsync(id); if (o == null) @@ -163,7 +163,7 @@ namespace AyaNova.Api.Controllers return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); //Instantiate the business object handler - DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext); + DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext); //If a user has change roles, or editOwnRoles then they can create, true is passed for isOwner since they are creating so by definition the owner if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType)) @@ -177,7 +177,7 @@ namespace AyaNova.Api.Controllers if (o == null) return BadRequest(new ApiErrorResponse(biz.Errors)); else - return CreatedAtAction(nameof(DataFilterController.GetDataFilter), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); + return CreatedAtAction(nameof(DataListFilterController.GetDataFilter), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); } @@ -202,7 +202,7 @@ namespace AyaNova.Api.Controllers return BadRequest(new ApiErrorResponse(ModelState)); //Instantiate the business object handler - DataFilterBiz biz = DataFilterBiz.GetBiz(ct, HttpContext); + DataListFilterBiz biz = DataListFilterBiz.GetBiz(ct, HttpContext); var o = await biz.GetNoLogAsync(id); if (o == null) diff --git a/server/AyaNova/biz/AyaFormFieldDefinitions.cs b/server/AyaNova/biz/AyaFormFieldDefinitions.cs index 34f685a4..a1b90d70 100644 --- a/server/AyaNova/biz/AyaFormFieldDefinitions.cs +++ b/server/AyaNova/biz/AyaFormFieldDefinitions.cs @@ -121,16 +121,16 @@ namespace AyaNova.Biz } - // public static string TranslateLTCustomFieldToInternalCustomFieldName(string lTCustomFieldName) - // { - // var i = System.Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace( - // lTCustomFieldName, // Our input - // "[^0-9]", // Select everything that is not in the range of 0-9 - // "" // Replace that with an empty string. - // )); + public static string TranslateLTCustomFieldToInternalCustomFieldName(string lTCustomFieldName) + { + var i = System.Convert.ToInt32(System.Text.RegularExpressions.Regex.Replace( + lTCustomFieldName, // Our input + "[^0-9]", // Select everything that is not in the range of 0-9 + "" // Replace that with an empty string. + )); - // return $"c{i}"; - // } + return $"c{i}"; + } diff --git a/server/AyaNova/biz/BizObjectFactory.cs b/server/AyaNova/biz/BizObjectFactory.cs index 838def79..d7f65b71 100644 --- a/server/AyaNova/biz/BizObjectFactory.cs +++ b/server/AyaNova/biz/BizObjectFactory.cs @@ -36,7 +36,7 @@ namespace AyaNova.Biz case AyaType.Locale: return new LocaleBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles); case AyaType.DataFilter: - return new DataFilterBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles); + return new DataListFilterBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles); case AyaType.FormCustom: return new FormCustomBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles); diff --git a/server/AyaNova/biz/DataFilterBiz.cs b/server/AyaNova/biz/DataListFilterBiz.cs similarity index 88% rename from server/AyaNova/biz/DataFilterBiz.cs rename to server/AyaNova/biz/DataListFilterBiz.cs index 7153690a..e1a75f47 100644 --- a/server/AyaNova/biz/DataFilterBiz.cs +++ b/server/AyaNova/biz/DataListFilterBiz.cs @@ -6,16 +6,17 @@ using Newtonsoft.Json.Linq; using AyaNova.Util; using AyaNova.Api.ControllerHelpers; using AyaNova.Models; +using AyaNova.DataList; namespace AyaNova.Biz { - internal class DataFilterBiz : BizObject + internal class DataListFilterBiz : BizObject { - internal DataFilterBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles) + internal DataListFilterBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles) { ct = dbcontext; UserId = currentUserId; @@ -24,15 +25,15 @@ namespace AyaNova.Biz BizType = AyaType.DataFilter; } - internal static DataFilterBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext) + internal static DataListFilterBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext) { - return new DataFilterBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items)); + return new DataListFilterBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items)); } //Version for internal use - internal static DataFilterBiz GetBizInternal(AyContext ct) + internal static DataListFilterBiz GetBizInternal(AyContext ct) { - return new DataFilterBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull); + return new DataListFilterBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, AuthorizationRoles.BizAdminFull); } //////////////////////////////////////////////////////////////////////////////////////////////// @@ -247,15 +248,17 @@ namespace AyaNova.Biz AddError(ApiErrorCode.VALIDATION_REQUIRED, "ListKey"); - List FieldList = null; - if (!AyaFormFieldDefinitions.IsValidFormFieldDefinitionKey(inObj.ListKey)) + var DataList = DataListFactory.GetAyaDataList(inObj.ListKey); + // List FieldList = null; + //if (!AyaFormFieldDefinitions.IsValidFormFieldDefinitionKey(inObj.ListKey)) + if (DataList == null) { - AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ListKey", $"ListKey \"{inObj.ListKey}\" is empty or in-valid"); - } - else - { - FieldList = AyaFormFieldDefinitions.AyaObjectFields(inObj.ListKey); + AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ListKey", $"ListKey \"{inObj.ListKey}\" DataListKey is not valid"); } + // else + // { + // FieldList = AyaDataListFieldDefinition.AyaObjectFields(inObj.ListKey); + // } if (inObj.ListKey.Length > 255) @@ -279,10 +282,10 @@ namespace AyaNova.Biz AddError(ApiErrorCode.VALIDATION_REQUIRED, "Filter", $"Filter array item {i}, \"fld\" property is empty and required"); //validate the field name if we can - if (FieldList != null) + if (DataList != null) { - var TheField = FieldList.SingleOrDefault(x => x.FieldKey.ToLowerInvariant() == fld); + var TheField = DataList.FieldDefinitions.SingleOrDefault(x => x.FieldKey.ToLowerInvariant() == fld); if (TheField == null) { @@ -348,10 +351,10 @@ namespace AyaNova.Biz AddError(ApiErrorCode.VALIDATION_REQUIRED, "Sort", $"Sort array item {i}, \"fld\" property is empty and required"); //validate the field name if we can - if (FieldList != null) + if (DataList != null) { - if (!FieldList.Exists(x => x.FieldKey.ToLowerInvariant() == fld && x.IsFilterable)) + if (!DataList.FieldDefinitions.Exists(x => x.FieldKey.ToLowerInvariant() == fld && x.IsFilterable)) { AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Sort", $"Sort array item {i}, fld property value \"{fld}\" is not a valid value for ListKey specified"); }