This commit is contained in:
2020-02-14 20:36:51 +00:00
parent 7036d0ddd9
commit 49f98efa50
13 changed files with 53 additions and 61 deletions

View File

@@ -24,10 +24,10 @@ namespace AyaNova.Api.Controllers
[Route("api/v{version:apiVersion}/[controller]")] [Route("api/v{version:apiVersion}/[controller]")]
[Produces("application/json")] [Produces("application/json")]
[Authorize] [Authorize]
public class DataListSortFilterController : ControllerBase public class DataListViewController : ControllerBase
{ {
private readonly AyContext ct; private readonly AyContext ct;
private readonly ILogger<DataListSortFilterController> log; private readonly ILogger<DataListViewController> log;
private readonly ApiServerState serverState; private readonly ApiServerState serverState;
@@ -37,7 +37,7 @@ namespace AyaNova.Api.Controllers
/// <param name="dbcontext"></param> /// <param name="dbcontext"></param>
/// <param name="logger"></param> /// <param name="logger"></param>
/// <param name="apiServerState"></param> /// <param name="apiServerState"></param>
public DataListSortFilterController(AyContext dbcontext, ILogger<DataListSortFilterController> logger, ApiServerState apiServerState) public DataListViewController(AyContext dbcontext, ILogger<DataListViewController> logger, ApiServerState apiServerState)
{ {
ct = dbcontext; ct = dbcontext;
log = logger; log = logger;
@@ -46,18 +46,18 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Get full DataListSortFilter object /// Get full DataListView object
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns>A single DataFilter</returns> /// <returns>A single DataFilter</returns>
[HttpGet("{id}")] [HttpGet("{id}")]
public async Task<IActionResult> GetDataListSortFilter([FromRoute] long id) public async Task<IActionResult> GetDataListView([FromRoute] long id)
{ {
if (serverState.IsClosed) if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
//Instantiate the business object handler //Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext); DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType)) if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse()); return StatusCode(403, new ApiNotAuthorizedResponse());
@@ -75,11 +75,11 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Get DataListSortFilter pick list /// Get DataListView pick list
/// </summary> /// </summary>
/// <returns>List of public or owned data filters for listKey provided</returns> /// <returns>List of public or owned data list views listKey provided</returns>
[HttpGet("PickList", Name = nameof(DataListSortFilterPickList))] [HttpGet("PickList", Name = nameof(DataListViewPickList))]
public async Task<IActionResult> DataListSortFilterPickList([FromQuery] string ListKey) public async Task<IActionResult> DataListViewPickList([FromQuery] string ListKey)
{ {
if (serverState.IsClosed) if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -88,7 +88,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
//Instantiate the business object handler //Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext); DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
var l = await biz.GetPickListAsync(ListKey); var l = await biz.GetPickListAsync(ListKey);
return Ok(ApiOkResponse.Response(l, true)); return Ok(ApiOkResponse.Response(l, true));
@@ -97,13 +97,13 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Put (update) DataListSortFilter /// Put (update) DataListView
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <param name="inObj"></param> /// <param name="inObj"></param>
/// <returns></returns> /// <returns></returns>
[HttpPut("{id}")] [HttpPut("{id}")]
public async Task<IActionResult> PutDataListSortFilter([FromRoute] long id, [FromBody] DataListSortFilter inObj) public async Task<IActionResult> PutDataListView([FromRoute] long id, [FromBody] DataListView inObj)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -112,7 +112,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
//Instantiate the business object handler //Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext); DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
var o = await biz.GetAsync(id, false); var o = await biz.GetAsync(id, false);
if (o == null) if (o == null)
@@ -138,19 +138,19 @@ namespace AyaNova.Api.Controllers
/// <summary> /// <summary>
/// Post DataListSortFilter /// Post DataListView
/// </summary> /// </summary>
/// <param name="inObj"></param> /// <param name="inObj"></param>
/// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param> /// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
public async Task<IActionResult> PostDataListSortFilter([FromBody] DataListSortFilter inObj, ApiVersion apiVersion) public async Task<IActionResult> PostDataListView([FromBody] DataListView inObj, ApiVersion apiVersion)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
//Instantiate the business object handler //Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext); DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
//check roles //check roles
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType)) if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
@@ -160,23 +160,23 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
//Create and validate //Create and validate
DataListSortFilter o = await biz.CreateAsync(inObj); DataListView o = await biz.CreateAsync(inObj);
if (o == null) if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors)); return BadRequest(new ApiErrorResponse(biz.Errors));
else else
return CreatedAtAction(nameof(DataListSortFilterController.GetDataListSortFilter), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o)); return CreatedAtAction(nameof(DataListViewController.GetDataListView), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
} }
/// <summary> /// <summary>
/// Delete DataListSortFilter /// Delete DataListView
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns>Ok</returns> /// <returns>Ok</returns>
[HttpDelete("{id}")] [HttpDelete("{id}")]
public async Task<IActionResult> DeleteDataListSortFilter([FromRoute] long id) public async Task<IActionResult> DeleteDataListView([FromRoute] long id)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -185,7 +185,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
//Instantiate the business object handler //Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext); DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
var o = await biz.GetAsync(id, false); var o = await biz.GetAsync(id, false);
if (o == null) if (o == null)

View File

@@ -22,12 +22,6 @@ namespace AyaNova.DataList
//List to compile each columns where clause fragment for later assembly into sql query //List to compile each columns where clause fragment for later assembly into sql query
List<string> ColumnWhereClauses = new List<string>(); List<string> ColumnWhereClauses = new List<string>();
//StringBuilder sb = new StringBuilder();
bool ThisIsTheFirstColumnWhereGroup = true;
//iterate the list view fields and concatenate a sql query from it
//// [{key:"COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}]
for (int i = 0; i < listViewArray.Count; i++) for (int i = 0; i < listViewArray.Count; i++)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@@ -126,9 +120,7 @@ namespace AyaNova.DataList
ThisIsTheFirstFilterItemForThisColumn = false; ThisIsTheFirstFilterItemForThisColumn = false;
} }
//we've done at least one now
ThisIsTheFirstColumnWhereGroup = false;
if (ThereAreMultipleFilterItems) if (ThereAreMultipleFilterItems)
{ {
//The whole thing was in a group so close this group //The whole thing was in a group so close this group

View File

@@ -3,10 +3,10 @@ using Newtonsoft.Json.Linq;
using AyaNova.Biz; using AyaNova.Biz;
namespace AyaNova.DataList namespace AyaNova.DataList
{ {
internal class UserDataList : AyaDataList internal class TestUserDataList : AyaDataList
{ {
public UserDataList() public TestUserDataList()
{ {
DefaultListObjectType = AyaType.User; DefaultListObjectType = AyaType.User;

View File

@@ -32,7 +32,7 @@ namespace AyaNova.Biz
DEPRECATED_REUSELATER_15 = 15, DEPRECATED_REUSELATER_15 = 15,
DEPRECATED_REUSELATER_16 = 16, DEPRECATED_REUSELATER_16 = 16,
FileAttachment = 17, FileAttachment = 17,
DataListSortFilter = 18, DataListView = 18,
FormCustom = 19 FormCustom = 19

View File

@@ -36,7 +36,7 @@ namespace AyaNova.Biz
return await ct.Widget.AnyAsync(m => m.Id == id); return await ct.Widget.AnyAsync(m => m.Id == id);
case AyaType.FileAttachment: case AyaType.FileAttachment:
return await ct.FileAttachment.AnyAsync(m => m.Id == id); return await ct.FileAttachment.AnyAsync(m => m.Id == id);
case AyaType.DataListSortFilter: case AyaType.DataListView:
return await ct.DataListSortFilter.AnyAsync(m => m.Id == id); return await ct.DataListSortFilter.AnyAsync(m => m.Id == id);
case AyaType.FormCustom: case AyaType.FormCustom:

View File

@@ -35,8 +35,8 @@ namespace AyaNova.Biz
return new TrialBiz(dbcontext, userId, roles); return new TrialBiz(dbcontext, userId, roles);
case AyaType.Locale: case AyaType.Locale:
return new LocaleBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles); return new LocaleBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
case AyaType.DataListSortFilter: case AyaType.DataListView:
return new DataListSortFilterBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles); return new DataListViewBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
case AyaType.FormCustom: case AyaType.FormCustom:
return new FormCustomBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles); return new FormCustomBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);

View File

@@ -30,8 +30,8 @@ namespace AyaNova.Biz
TABLE = "afileattachment"; TABLE = "afileattachment";
COLUMN = "displayfilename"; COLUMN = "displayfilename";
break; break;
case AyaType.DataListSortFilter: case AyaType.DataListView:
TABLE = "adatalistsortfilter"; TABLE = "adatalistview";
break; break;
case AyaType.FormCustom: case AyaType.FormCustom:
TABLE = "aformcustom"; TABLE = "aformcustom";

View File

@@ -133,7 +133,7 @@ namespace AyaNova.Biz
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
//DATALISTFILTER //DATALISTFILTER
// //
roles.Add(AyaType.DataListSortFilter, new BizRoleSet() roles.Add(AyaType.DataListView, new BizRoleSet()
{ {
Change = AuthorizationRoles.BizAdminFull, Change = AuthorizationRoles.BizAdminFull,
ReadFullRecord = AuthorizationRoles.All ReadFullRecord = AuthorizationRoles.All

View File

@@ -13,21 +13,21 @@ namespace AyaNova.Biz
{ {
internal class DataListSortFilterBiz : BizObject internal class DataListViewBiz : BizObject
{ {
internal DataListSortFilterBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles) internal DataListViewBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles)
{ {
ct = dbcontext; ct = dbcontext;
UserId = currentUserId; UserId = currentUserId;
UserLocaleId = userLocaleId; UserLocaleId = userLocaleId;
CurrentUserRoles = UserRoles; CurrentUserRoles = UserRoles;
BizType = AyaType.DataListSortFilter; BizType = AyaType.DataListView;
} }
internal static DataListSortFilterBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext) internal static DataListViewBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)
{ {
return new DataListSortFilterBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items)); return new DataListViewBiz(ct, UserIdFromContext.Id(httpContext.Items), UserLocaleIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
} }
// //Version for internal use // //Version for internal use
@@ -47,7 +47,7 @@ namespace AyaNova.Biz
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE //CREATE
internal async Task<DataListSortFilter> CreateAsync(DataListSortFilter inObj) internal async Task<DataListView> CreateAsync(DataListView inObj)
{ {
await ValidateAsync(inObj, true); await ValidateAsync(inObj, true);
if (HasErrors) if (HasErrors)
@@ -55,7 +55,7 @@ namespace AyaNova.Biz
else else
{ {
//do stuff with datafilter //do stuff with datafilter
DataListSortFilter outObj = inObj; DataListView outObj = inObj;
outObj.UserId = UserId; outObj.UserId = UserId;
@@ -81,7 +81,7 @@ namespace AyaNova.Biz
/// GET /// GET
//Get one //Get one
internal async Task<DataListSortFilter> GetAsync(long fetchId, bool logTheGetEvent = true) internal async Task<DataListView> GetAsync(long fetchId, bool logTheGetEvent = true)
{ {
//This is simple so nothing more here, but often will be copying to a different output object or some other ops //This is simple so nothing more here, but often will be copying to a different output object or some other ops
var ret = await ct.DataListSortFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId)); var ret = await ct.DataListSortFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
@@ -124,7 +124,7 @@ namespace AyaNova.Biz
// //
//put //put
internal async Task<bool> PutAsync(DataListSortFilter dbObj, DataListSortFilter inObj) internal async Task<bool> PutAsync(DataListView dbObj, DataListView inObj)
{ {
//preserve the owner ID if none was specified //preserve the owner ID if none was specified
if (inObj.UserId == 0) if (inObj.UserId == 0)
@@ -154,7 +154,7 @@ namespace AyaNova.Biz
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
//DELETE //DELETE
// //
internal async Task<bool> DeleteAsync(DataListSortFilter dbObj) internal async Task<bool> DeleteAsync(DataListView dbObj)
{ {
//Determine if the object can be deleted, do the deletion tentatively //Determine if the object can be deleted, do the deletion tentatively
//Probably also in here deal with tags and associated search text etc //Probably also in here deal with tags and associated search text etc
@@ -185,7 +185,7 @@ namespace AyaNova.Biz
// //
//Can save or update? //Can save or update?
private async Task ValidateAsync(DataListSortFilter inObj, bool isNew) private async Task ValidateAsync(DataListView inObj, bool isNew)
{ {
//UserId required //UserId required
@@ -232,7 +232,7 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "ListKey", "255 max"); AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "ListKey", "255 max");
//Filter json must parse //Filter json must parse
if (!string.IsNullOrWhiteSpace(inObj.Filter)) if (!string.IsNullOrWhiteSpace(inObj.ListView))
{ {
try try
{ {

View File

@@ -17,7 +17,7 @@ namespace AyaNova.Models
public virtual DbSet<OpsJobLog> OpsJobLog { get; set; } public virtual DbSet<OpsJobLog> OpsJobLog { get; set; }
public virtual DbSet<Locale> Locale { get; set; } public virtual DbSet<Locale> Locale { get; set; }
public virtual DbSet<LocaleItem> LocaleItem { get; set; } public virtual DbSet<LocaleItem> LocaleItem { get; set; }
public virtual DbSet<DataListSortFilter> DataListSortFilter { get; set; } public virtual DbSet<DataListView> DataListSortFilter { get; set; }
public virtual DbSet<Tag> Tag { get; set; } public virtual DbSet<Tag> Tag { get; set; }
public virtual DbSet<FormCustom> FormCustom { get; set; } public virtual DbSet<FormCustom> FormCustom { get; set; }

View File

@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace AyaNova.Models namespace AyaNova.Models
{ {
public partial class DataListSortFilter public partial class DataListView
{ {
public long Id { get; set; } public long Id { get; set; }
public uint ConcurrencyToken { get; set; } public uint ConcurrencyToken { get; set; }
@@ -17,8 +17,8 @@ namespace AyaNova.Models
public bool Public { get; set; } public bool Public { get; set; }
[Required, MaxLength(255)] [Required, MaxLength(255)]
public string ListKey { get; set; }//max 255 characters ascii set public string ListKey { get; set; }//max 255 characters ascii set
public string Filter { get; set; }//JSON fragment filter collection public string ListView { get; set; }//JSON ListView object
public string Sort { get; set; }//JSON fragment sort collection
} }
} }

View File

@@ -22,7 +22,7 @@ namespace AyaNova.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
private const int DESIRED_SCHEMA_LEVEL = 9; private const int DESIRED_SCHEMA_LEVEL = 9;
internal const long EXPECTED_COLUMN_COUNT = 99; internal const long EXPECTED_COLUMN_COUNT = 98;
internal const long EXPECTED_INDEX_COUNT = 24; internal const long EXPECTED_INDEX_COUNT = 24;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
@@ -266,9 +266,9 @@ namespace AyaNova.Util
{ {
LogUpdateMessage(log); LogUpdateMessage(log);
await ExecQueryAsync("CREATE TABLE adatalistsortfilter (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null, public bool not null," + await ExecQueryAsync("CREATE TABLE adatalistview (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null, public bool not null," +
"listkey varchar(255) not null, filter text, sort text, UNIQUE(name))"); "listkey varchar(255) not null, listview text, UNIQUE(name))");
await SetSchemaLevelAsync(++currentSchema); await SetSchemaLevelAsync(++currentSchema);
} }

View File

@@ -288,7 +288,7 @@ namespace AyaNova.Util
await EraseTableAsync("afileattachment", conn); await EraseTableAsync("afileattachment", conn);
await EraseTableAsync("awidget", conn); await EraseTableAsync("awidget", conn);
await EraseTableAsync("aevent", conn); await EraseTableAsync("aevent", conn);
await EraseTableAsync("adatalistsortfilter", conn); await EraseTableAsync("adatalistview", conn);
// await EraseTableAsync("adatalisttemplate", conn); // await EraseTableAsync("adatalisttemplate", conn);
await EraseTableAsync("aformcustom", conn); await EraseTableAsync("aformcustom", conn);
await EraseTableAsync("asearchkey", conn); await EraseTableAsync("asearchkey", conn);