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]")]
[Produces("application/json")]
[Authorize]
public class DataListSortFilterController : ControllerBase
public class DataListViewController : ControllerBase
{
private readonly AyContext ct;
private readonly ILogger<DataListSortFilterController> log;
private readonly ILogger<DataListViewController> log;
private readonly ApiServerState serverState;
@@ -37,7 +37,7 @@ namespace AyaNova.Api.Controllers
/// <param name="dbcontext"></param>
/// <param name="logger"></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;
log = logger;
@@ -46,18 +46,18 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Get full DataListSortFilter object
/// Get full DataListView object
/// </summary>
/// <param name="id"></param>
/// <returns>A single DataFilter</returns>
[HttpGet("{id}")]
public async Task<IActionResult> GetDataListSortFilter([FromRoute] long id)
public async Task<IActionResult> GetDataListView([FromRoute] long id)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
//Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext);
DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
@@ -75,11 +75,11 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Get DataListSortFilter pick list
/// Get DataListView pick list
/// </summary>
/// <returns>List of public or owned data filters for listKey provided</returns>
[HttpGet("PickList", Name = nameof(DataListSortFilterPickList))]
public async Task<IActionResult> DataListSortFilterPickList([FromQuery] string ListKey)
/// <returns>List of public or owned data list views listKey provided</returns>
[HttpGet("PickList", Name = nameof(DataListViewPickList))]
public async Task<IActionResult> DataListViewPickList([FromQuery] string ListKey)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -88,7 +88,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
//Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext);
DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
var l = await biz.GetPickListAsync(ListKey);
return Ok(ApiOkResponse.Response(l, true));
@@ -97,13 +97,13 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Put (update) DataListSortFilter
/// Put (update) DataListView
/// </summary>
/// <param name="id"></param>
/// <param name="inObj"></param>
/// <returns></returns>
[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)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -112,7 +112,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
//Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext);
DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
var o = await biz.GetAsync(id, false);
if (o == null)
@@ -138,19 +138,19 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Post DataListSortFilter
/// Post DataListView
/// </summary>
/// <param name="inObj"></param>
/// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> PostDataListSortFilter([FromBody] DataListSortFilter inObj, ApiVersion apiVersion)
public async Task<IActionResult> PostDataListView([FromBody] DataListView inObj, ApiVersion apiVersion)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
//Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext);
DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
//check roles
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
@@ -160,23 +160,23 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
//Create and validate
DataListSortFilter o = await biz.CreateAsync(inObj);
DataListView o = await biz.CreateAsync(inObj);
if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
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>
/// Delete DataListSortFilter
/// Delete DataListView
/// </summary>
/// <param name="id"></param>
/// <returns>Ok</returns>
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteDataListSortFilter([FromRoute] long id)
public async Task<IActionResult> DeleteDataListView([FromRoute] long id)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -185,7 +185,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
//Instantiate the business object handler
DataListSortFilterBiz biz = DataListSortFilterBiz.GetBiz(ct, HttpContext);
DataListViewBiz biz = DataListViewBiz.GetBiz(ct, HttpContext);
var o = await biz.GetAsync(id, false);
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<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++)
{
StringBuilder sb = new StringBuilder();
@@ -126,9 +120,7 @@ namespace AyaNova.DataList
ThisIsTheFirstFilterItemForThisColumn = false;
}
//we've done at least one now
ThisIsTheFirstColumnWhereGroup = false;
if (ThereAreMultipleFilterItems)
{
//The whole thing was in a group so close this group

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -133,7 +133,7 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////
//DATALISTFILTER
//
roles.Add(AyaType.DataListSortFilter, new BizRoleSet()
roles.Add(AyaType.DataListView, new BizRoleSet()
{
Change = AuthorizationRoles.BizAdminFull,
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;
UserId = currentUserId;
UserLocaleId = userLocaleId;
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
@@ -47,7 +47,7 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
internal async Task<DataListSortFilter> CreateAsync(DataListSortFilter inObj)
internal async Task<DataListView> CreateAsync(DataListView inObj)
{
await ValidateAsync(inObj, true);
if (HasErrors)
@@ -55,7 +55,7 @@ namespace AyaNova.Biz
else
{
//do stuff with datafilter
DataListSortFilter outObj = inObj;
DataListView outObj = inObj;
outObj.UserId = UserId;
@@ -81,7 +81,7 @@ namespace AyaNova.Biz
/// GET
//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
var ret = await ct.DataListSortFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
@@ -124,7 +124,7 @@ namespace AyaNova.Biz
//
//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
if (inObj.UserId == 0)
@@ -154,7 +154,7 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//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
//Probably also in here deal with tags and associated search text etc
@@ -185,7 +185,7 @@ namespace AyaNova.Biz
//
//Can save or update?
private async Task ValidateAsync(DataListSortFilter inObj, bool isNew)
private async Task ValidateAsync(DataListView inObj, bool isNew)
{
//UserId required
@@ -232,7 +232,7 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.VALIDATION_LENGTH_EXCEEDED, "ListKey", "255 max");
//Filter json must parse
if (!string.IsNullOrWhiteSpace(inObj.Filter))
if (!string.IsNullOrWhiteSpace(inObj.ListView))
{
try
{

View File

@@ -17,7 +17,7 @@ namespace AyaNova.Models
public virtual DbSet<OpsJobLog> OpsJobLog { get; set; }
public virtual DbSet<Locale> Locale { 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<FormCustom> FormCustom { get; set; }

View File

@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace AyaNova.Models
{
public partial class DataListSortFilter
public partial class DataListView
{
public long Id { get; set; }
public uint ConcurrencyToken { get; set; }
@@ -17,8 +17,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; }//JSON fragment filter collection
public string Sort { get; set; }//JSON fragment sort collection
public string ListView { get; set; }//JSON ListView object
}
}

View File

@@ -22,7 +22,7 @@ namespace AyaNova.Util
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
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;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
@@ -266,9 +266,9 @@ namespace AyaNova.Util
{
LogUpdateMessage(log);
await ExecQueryAsync("CREATE TABLE adatalistsortfilter (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))");
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, listview text, UNIQUE(name))");
await SetSchemaLevelAsync(++currentSchema);
}

View File

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