This commit is contained in:
@@ -5,22 +5,15 @@ eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOiIxNTcxODU5OTU0IiwiZXhwIjoiMTU3MjQ
|
|||||||
|
|
||||||
## IMMEDIATE ITEMS
|
## 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
|
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
|
- 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?
|
- 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)
|
- Can it just make a default template if none is found? (no they are all required)
|
||||||
- Once both lists are working:
|
- 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?
|
DataList object naming scheme, should it be prepended to they all align well?
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <param name="inObj"></param>
|
/// <param name="inObj"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut("{id}")]
|
[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)
|
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));
|
||||||
@@ -157,7 +157,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
/// <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> PostDataFilter([FromBody] DataFilter inObj, ApiVersion apiVersion)
|
public async Task<IActionResult> PostDataFilter([FromBody] DataListFilter 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));
|
||||||
@@ -173,7 +173,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
|
|
||||||
//Create and validate
|
//Create and validate
|
||||||
DataFilter o = await biz.CreateAsync(inObj);
|
DataListFilter 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
|
||||||
|
|||||||
@@ -57,12 +57,12 @@ namespace AyaNova.DataList
|
|||||||
var qFrom = DataList.SQLFrom;
|
var qFrom = DataList.SQLFrom;
|
||||||
|
|
||||||
//FILTERED?
|
//FILTERED?
|
||||||
DataFilter TheFilter = null;
|
DataListFilter TheFilter = null;
|
||||||
var qWhere = string.Empty;
|
var qWhere = string.Empty;
|
||||||
var qOrderBy = string.Empty;
|
var qOrderBy = string.Empty;
|
||||||
if (listOptions.DataFilterId > 0)
|
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
|
//WHERE CLAUSE - FILTER
|
||||||
qWhere = DataListSqlFilterCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, DataList.FieldDefinitions, UserId);
|
qWhere = DataListSqlFilterCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, DataList.FieldDefinitions, UserId);
|
||||||
//ORDER BY CLAUSE - SORT
|
//ORDER BY CLAUSE - SORT
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace AyaNova.DataList
|
|||||||
{
|
{
|
||||||
public static class DataListSqlFilterCriteriaBuilder
|
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))
|
if (string.IsNullOrWhiteSpace(dataFilter.Filter))
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace AyaNova.DataList
|
|||||||
|
|
||||||
// public static string DefaultPickListOrderBy => "ORDER BY NAME ASC";
|
// 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))
|
if (string.IsNullOrWhiteSpace(dataFilter.Sort))
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ namespace AyaNova
|
|||||||
// ******************** TESTING WIPE DB *****************************
|
// ******************** TESTING WIPE DB *****************************
|
||||||
//
|
//
|
||||||
//Set this to true to wipe the db and reinstall a trial license and re-seed the data
|
//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)
|
#if (DEBUG)
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ namespace AyaNova.Biz
|
|||||||
case AyaType.FileAttachment:
|
case AyaType.FileAttachment:
|
||||||
return ct.FileAttachment.Any(m => m.Id == id);
|
return ct.FileAttachment.Any(m => m.Id == id);
|
||||||
case AyaType.DataFilter:
|
case AyaType.DataFilter:
|
||||||
return ct.DataFilter.Any(m => m.Id == id);
|
return ct.DataListFilter.Any(m => m.Id == id);
|
||||||
case AyaType.FormCustom:
|
case AyaType.FormCustom:
|
||||||
return ct.FormCustom.Any(m => m.Id == id);
|
return ct.FormCustom.Any(m => m.Id == id);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,20 +40,20 @@ namespace AyaNova.Biz
|
|||||||
//EXISTS
|
//EXISTS
|
||||||
internal async Task<bool> ExistsAsync(long id)
|
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
|
/// 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
|
//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
|
//CREATE
|
||||||
internal async Task<DataFilter> CreateAsync(DataFilter inObj)
|
internal async Task<DataListFilter> CreateAsync(DataListFilter inObj)
|
||||||
{
|
{
|
||||||
Validate(inObj, true);
|
Validate(inObj, true);
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
@@ -61,11 +61,11 @@ namespace AyaNova.Biz
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//do stuff with datafilter
|
//do stuff with datafilter
|
||||||
DataFilter outObj = inObj;
|
DataListFilter outObj = inObj;
|
||||||
outObj.UserId = UserId;
|
outObj.UserId = UserId;
|
||||||
|
|
||||||
|
|
||||||
await ct.DataFilter.AddAsync(outObj);
|
await ct.DataListFilter.AddAsync(outObj);
|
||||||
await ct.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
//Handle child and associated items:
|
//Handle child and associated items:
|
||||||
@@ -83,7 +83,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//CREATE
|
//CREATE
|
||||||
internal DataFilter Create(AyContext TempContext, DataFilter inObj)
|
internal DataListFilter Create(AyContext TempContext, DataListFilter inObj)
|
||||||
{
|
{
|
||||||
Validate(inObj, true);
|
Validate(inObj, true);
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
@@ -91,11 +91,11 @@ namespace AyaNova.Biz
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//do stuff with datafilter
|
//do stuff with datafilter
|
||||||
DataFilter outObj = inObj;
|
DataListFilter outObj = inObj;
|
||||||
outObj.UserId = UserId;
|
outObj.UserId = UserId;
|
||||||
|
|
||||||
|
|
||||||
TempContext.DataFilter.Add(outObj);
|
TempContext.DataListFilter.Add(outObj);
|
||||||
TempContext.SaveChanges();
|
TempContext.SaveChanges();
|
||||||
|
|
||||||
//Handle child and associated items:
|
//Handle child and associated items:
|
||||||
@@ -115,10 +115,10 @@ namespace AyaNova.Biz
|
|||||||
/// GET
|
/// GET
|
||||||
|
|
||||||
//Get one
|
//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
|
//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)
|
if (ret != null)
|
||||||
{
|
{
|
||||||
//Log
|
//Log
|
||||||
@@ -134,7 +134,7 @@ namespace AyaNova.Biz
|
|||||||
List<NameIdItem> items = new List<NameIdItem>();
|
List<NameIdItem> items = new List<NameIdItem>();
|
||||||
if (!string.IsNullOrWhiteSpace(listKey))
|
if (!string.IsNullOrWhiteSpace(listKey))
|
||||||
{
|
{
|
||||||
items = await ct.DataFilter
|
items = await ct.DataListFilter
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId))
|
.Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId))
|
||||||
.OrderBy(m => m.Name)
|
.OrderBy(m => m.Name)
|
||||||
@@ -156,7 +156,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
|
|
||||||
//put
|
//put
|
||||||
internal bool Put(DataFilter dbObj, DataFilter inObj)
|
internal bool Put(DataListFilter dbObj, DataListFilter 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)
|
||||||
@@ -185,7 +185,7 @@ namespace AyaNova.Biz
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//DELETE
|
//DELETE
|
||||||
//
|
//
|
||||||
internal bool Delete(DataFilter dbObj)
|
internal bool Delete(DataListFilter 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
|
||||||
@@ -193,7 +193,7 @@ namespace AyaNova.Biz
|
|||||||
ValidateCanDelete(dbObj);
|
ValidateCanDelete(dbObj);
|
||||||
if (HasErrors)
|
if (HasErrors)
|
||||||
return false;
|
return false;
|
||||||
ct.DataFilter.Remove(dbObj);
|
ct.DataListFilter.Remove(dbObj);
|
||||||
ct.SaveChanges();
|
ct.SaveChanges();
|
||||||
|
|
||||||
//Delete sibling objects
|
//Delete sibling objects
|
||||||
@@ -214,7 +214,7 @@ namespace AyaNova.Biz
|
|||||||
//
|
//
|
||||||
|
|
||||||
//Can save or update?
|
//Can save or update?
|
||||||
private void Validate(DataFilter inObj, bool isNew)
|
private void Validate(DataListFilter inObj, bool isNew)
|
||||||
{
|
{
|
||||||
|
|
||||||
//UserId required
|
//UserId required
|
||||||
@@ -238,7 +238,7 @@ namespace AyaNova.Biz
|
|||||||
if (!PropertyHasErrors("Name"))
|
if (!PropertyHasErrors("Name"))
|
||||||
{
|
{
|
||||||
//Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
|
//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");
|
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name");
|
||||||
}
|
}
|
||||||
@@ -386,7 +386,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
//Can delete?
|
//Can delete?
|
||||||
private void ValidateCanDelete(DataFilter inObj)
|
private void ValidateCanDelete(DataListFilter inObj)
|
||||||
{
|
{
|
||||||
//Leaving this off for now
|
//Leaving this off for now
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
using AyaNova.Util;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace AyaNova.Models
|
namespace AyaNova.Models
|
||||||
{
|
{
|
||||||
@@ -20,9 +17,10 @@ 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<DataFilter> DataFilter { get; set; }
|
public virtual DbSet<DataListFilter> DataListFilter { 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; }
|
||||||
|
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
|
//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
|
//and commented out the above on configuring
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
namespace AyaNova.Models
|
namespace AyaNova.Models
|
||||||
{
|
{
|
||||||
|
|
||||||
public partial class DataFilter
|
public partial class DataListFilter
|
||||||
{
|
{
|
||||||
public long Id { get; set; }
|
public long Id { get; set; }
|
||||||
public uint ConcurrencyToken { get; set; }
|
public uint ConcurrencyToken { get; set; }
|
||||||
16
server/AyaNova/models/DataListTemplate.cs
Normal file
16
server/AyaNova/models/DataListTemplate.cs
Normal 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
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,8 +22,8 @@ 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 = 96;
|
internal const long EXPECTED_COLUMN_COUNT = 99;
|
||||||
internal const long EXPECTED_INDEX_COUNT = 24;
|
internal const long EXPECTED_INDEX_COUNT = 26;
|
||||||
|
|
||||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
//!!!!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)
|
if (currentSchema < 7)
|
||||||
{
|
{
|
||||||
LogUpdateMessage(log);
|
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))");
|
"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);
|
setSchemaLevel(++currentSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user