This commit is contained in:
2020-01-22 00:47:17 +00:00
parent bee5fe85f9
commit b83cbed31a
12 changed files with 57 additions and 48 deletions

View File

@@ -5,22 +5,15 @@ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTcxODU5OTU0IiwiZXhwIjoiMTU3MjQ
## IMMEDIATE ITEMS
Rename objectfieldscontroller / routes
MAKE DATALIST ROUTE FOR FETCHING LISTS BY KEY
- REMOVE LISTS FROM INDIVIDUAL OBJECT ROUTES AS MUCH AS POSSIBLE
- Accepts datalist key
- finds applicable AyaDataList object for the key specified (maybe keeps a static list of them rather than finding upon reflection)
UnMock MOCK_WIDGET_DISPLAY_TEMPLATE_JSON into db with objects and with seeded data for test and or all lists
- One single object with all templates in JSON maybe? since there are not going to be multiple templates for same list object anyway
- Server can load it up and cache it like LT?
- Can it just make a default template if none is found? (no they are all required)
- Once both lists are working:
User Object datalists?
Rename DataFilter model / table etc to DataListFilter
Make up the user Object datalists
DataList object naming scheme, should it be prepended to they all align well?

View File

@@ -113,7 +113,7 @@ namespace AyaNova.Api.Controllers
/// <param name="inObj"></param>
/// <returns></returns>
[HttpPut("{id}")]
public async Task<IActionResult> PutDataFilter([FromRoute] long id, [FromBody] DataFilter inObj)
public async Task<IActionResult> PutDataFilter([FromRoute] long id, [FromBody] DataListFilter inObj)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -157,7 +157,7 @@ namespace AyaNova.Api.Controllers
/// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> PostDataFilter([FromBody] DataFilter inObj, ApiVersion apiVersion)
public async Task<IActionResult> PostDataFilter([FromBody] DataListFilter inObj, ApiVersion apiVersion)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -173,7 +173,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState));
//Create and validate
DataFilter o = await biz.CreateAsync(inObj);
DataListFilter o = await biz.CreateAsync(inObj);
if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else

View File

@@ -57,12 +57,12 @@ namespace AyaNova.DataList
var qFrom = DataList.SQLFrom;
//FILTERED?
DataFilter TheFilter = null;
DataListFilter TheFilter = null;
var qWhere = string.Empty;
var qOrderBy = string.Empty;
if (listOptions.DataFilterId > 0)
{
TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == listOptions.DataFilterId);
TheFilter = await ct.DataListFilter.FirstOrDefaultAsync(x => x.Id == listOptions.DataFilterId);
//WHERE CLAUSE - FILTER
qWhere = DataListSqlFilterCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, DataList.FieldDefinitions, UserId);
//ORDER BY CLAUSE - SORT

View File

@@ -11,7 +11,7 @@ namespace AyaNova.DataList
{
public static class DataListSqlFilterCriteriaBuilder
{
public static string DataFilterToSQLCriteria(AyaNova.Models.DataFilter dataFilter, List<AyaDataListFieldDefinition> objectFields, long userId)
public static string DataFilterToSQLCriteria(AyaNova.Models.DataListFilter dataFilter, List<AyaDataListFieldDefinition> objectFields, long userId)
{
if (string.IsNullOrWhiteSpace(dataFilter.Filter))

View File

@@ -10,7 +10,7 @@ namespace AyaNova.DataList
// public static string DefaultPickListOrderBy => "ORDER BY NAME ASC";
public static string DataFilterToSQLOrderBy(AyaNova.Models.DataFilter dataFilter)
public static string DataFilterToSQLOrderBy(AyaNova.Models.DataListFilter dataFilter)
{
if (string.IsNullOrWhiteSpace(dataFilter.Sort))

View File

@@ -408,7 +408,7 @@ namespace AyaNova
// ******************** TESTING WIPE DB *****************************
//
//Set this to true to wipe the db and reinstall a trial license and re-seed the data
var TESTING_REFRESH_DB = false;//#######################################################################################
var TESTING_REFRESH_DB = true;//#######################################################################################
#if (DEBUG)

View File

@@ -38,12 +38,12 @@ namespace AyaNova.Biz
case AyaType.User:
return ct.User.Any(m => m.Id == id);
case AyaType.Widget:
return ct.Widget.Any(m => m.Id == id);
return ct.Widget.Any(m => m.Id == id);
case AyaType.FileAttachment:
return ct.FileAttachment.Any(m => m.Id == id);
case AyaType.DataFilter:
return ct.DataFilter.Any(m => m.Id == id);
case AyaType.FormCustom:
return ct.DataListFilter.Any(m => m.Id == id);
case AyaType.FormCustom:
return ct.FormCustom.Any(m => m.Id == id);

View File

@@ -40,20 +40,20 @@ namespace AyaNova.Biz
//EXISTS
internal async Task<bool> ExistsAsync(long id)
{
return await ct.DataFilter.AnyAsync(e => e.Id == id);
return await ct.DataListFilter.AnyAsync(e => e.Id == id);
}
////////////////////////////////////////////////////////////////////////////////////////////////
/// GET
internal async Task<DataFilter> GetNoLogAsync(long fetchId)
internal async Task<DataListFilter> GetNoLogAsync(long fetchId)
{
//This is simple so nothing more here, but often will be copying to a different output object or some other ops
return await ct.DataFilter.SingleOrDefaultAsync(m => m.Id == fetchId);
return await ct.DataListFilter.SingleOrDefaultAsync(m => m.Id == fetchId);
}
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
internal async Task<DataFilter> CreateAsync(DataFilter inObj)
internal async Task<DataListFilter> CreateAsync(DataListFilter inObj)
{
Validate(inObj, true);
if (HasErrors)
@@ -61,11 +61,11 @@ namespace AyaNova.Biz
else
{
//do stuff with datafilter
DataFilter outObj = inObj;
DataListFilter outObj = inObj;
outObj.UserId = UserId;
await ct.DataFilter.AddAsync(outObj);
await ct.DataListFilter.AddAsync(outObj);
await ct.SaveChangesAsync();
//Handle child and associated items:
@@ -83,7 +83,7 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
internal DataFilter Create(AyContext TempContext, DataFilter inObj)
internal DataListFilter Create(AyContext TempContext, DataListFilter inObj)
{
Validate(inObj, true);
if (HasErrors)
@@ -91,11 +91,11 @@ namespace AyaNova.Biz
else
{
//do stuff with datafilter
DataFilter outObj = inObj;
DataListFilter outObj = inObj;
outObj.UserId = UserId;
TempContext.DataFilter.Add(outObj);
TempContext.DataListFilter.Add(outObj);
TempContext.SaveChanges();
//Handle child and associated items:
@@ -115,10 +115,10 @@ namespace AyaNova.Biz
/// GET
//Get one
internal async Task<DataFilter> GetAsync(long fetchId)
internal async Task<DataListFilter> GetAsync(long fetchId)
{
//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.DataFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
var ret = await ct.DataListFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
if (ret != null)
{
//Log
@@ -134,7 +134,7 @@ namespace AyaNova.Biz
List<NameIdItem> items = new List<NameIdItem>();
if (!string.IsNullOrWhiteSpace(listKey))
{
items = await ct.DataFilter
items = await ct.DataListFilter
.AsNoTracking()
.Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId))
.OrderBy(m => m.Name)
@@ -156,7 +156,7 @@ namespace AyaNova.Biz
//
//put
internal bool Put(DataFilter dbObj, DataFilter inObj)
internal bool Put(DataListFilter dbObj, DataListFilter inObj)
{
//preserve the owner ID if none was specified
if (inObj.UserId == 0)
@@ -185,7 +185,7 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////////////////////////////////////////
//DELETE
//
internal bool Delete(DataFilter dbObj)
internal bool Delete(DataListFilter dbObj)
{
//Determine if the object can be deleted, do the deletion tentatively
//Probably also in here deal with tags and associated search text etc
@@ -193,7 +193,7 @@ namespace AyaNova.Biz
ValidateCanDelete(dbObj);
if (HasErrors)
return false;
ct.DataFilter.Remove(dbObj);
ct.DataListFilter.Remove(dbObj);
ct.SaveChanges();
//Delete sibling objects
@@ -214,7 +214,7 @@ namespace AyaNova.Biz
//
//Can save or update?
private void Validate(DataFilter inObj, bool isNew)
private void Validate(DataListFilter inObj, bool isNew)
{
//UserId required
@@ -238,7 +238,7 @@ namespace AyaNova.Biz
if (!PropertyHasErrors("Name"))
{
//Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
if (ct.DataFilter.Any(m => m.Name == inObj.Name && m.Id != inObj.Id))
if (ct.DataListFilter.Any(m => m.Name == inObj.Name && m.Id != inObj.Id))
{
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name");
}
@@ -386,7 +386,7 @@ namespace AyaNova.Biz
//Can delete?
private void ValidateCanDelete(DataFilter inObj)
private void ValidateCanDelete(DataListFilter inObj)
{
//Leaving this off for now
}

View File

@@ -1,8 +1,5 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using AyaNova.Util;
using Microsoft.Extensions.Logging;
namespace AyaNova.Models
{
@@ -20,9 +17,10 @@ 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<DataFilter> DataFilter { get; set; }
public virtual DbSet<DataListFilter> DataListFilter { get; set; }
public virtual DbSet<Tag> Tag { get; set; }
public virtual DbSet<FormCustom> FormCustom { get; set; }
public virtual DbSet<DataListTemplate> DataListTemplate { get; set; }
//Note: had to add this constructor to work with the code in startup.cs that gets the connection string from the appsettings.json file
//and commented out the above on configuring

View File

@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace AyaNova.Models
{
public partial class DataFilter
public partial class DataListFilter
{
public long Id { get; set; }
public uint ConcurrencyToken { get; set; }

View File

@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
namespace AyaNova.Models
{
public partial class DataListTemplate
{
public long Id { get; set; }
public uint ConcurrencyToken { get; set; }
[Required]
public string DataListKey { get; set; }
public string Template { get; set; }//JSON fragment template
}
}

View File

@@ -22,8 +22,8 @@ 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 = 96;
internal const long EXPECTED_INDEX_COUNT = 24;
internal const long EXPECTED_COLUMN_COUNT = 99;
internal const long EXPECTED_INDEX_COUNT = 26;
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
@@ -261,13 +261,15 @@ namespace AyaNova.Util
//////////////////////////////////////////////////
//DATAFILTER table
//DATAFILTER / DATALISTTEMPLATE tables
if (currentSchema < 7)
{
LogUpdateMessage(log);
exec("CREATE TABLE adatafilter (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null, public bool not null," +
exec("CREATE TABLE adatalistfilter (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))");
exec("CREATE TABLE adatalisttemplate (id BIGSERIAL PRIMARY KEY, datalistkey text not null, template text, UNIQUE(datalistkey))");
setSchemaLevel(++currentSchema);
}