diff --git a/devdocs/specs/core-list-graph-datatable-filtering-sorting-paging.txt b/devdocs/specs/core-list-graph-datatable-filtering-sorting-paging.txt index 02b2b9e3..fe25d3c9 100644 --- a/devdocs/specs/core-list-graph-datatable-filtering-sorting-paging.txt +++ b/devdocs/specs/core-list-graph-datatable-filtering-sorting-paging.txt @@ -15,7 +15,7 @@ and also lists all the fields filterable, their type and the locale key to displ - List key Certain types have extended abilities, for example dates have the classic floating AyaNova date ranges pre-defined or specific dates Filters are saved to the database: - - Filter: Name, OwnerId, Public, ListKey, Filter (Json string) + - Filter: Name, UserId, Public, ListKey, Filter (Json string) - ListKey is always lower case to match biz object list key name - Filter format: - Array [{fld:"fieldname",op:"See filtercomparisonoperator class",value:"compareValue"},...] these are all AND in sql, no OR diff --git a/server/AyaNova/biz/DataFilterBiz.cs b/server/AyaNova/biz/DataFilterBiz.cs index 3ee6e651..b3a81968 100644 --- a/server/AyaNova/biz/DataFilterBiz.cs +++ b/server/AyaNova/biz/DataFilterBiz.cs @@ -61,7 +61,7 @@ namespace AyaNova.Biz { //do stuff with datafilter DataFilter outObj = inObj; - outObj.OwnerId = UserId; + outObj.UserId = UserId; await ct.DataFilter.AddAsync(outObj); @@ -91,7 +91,7 @@ namespace AyaNova.Biz { //do stuff with datafilter DataFilter outObj = inObj; - outObj.OwnerId = UserId; + outObj.UserId = UserId; TempContext.DataFilter.Add(outObj); @@ -117,7 +117,7 @@ namespace AyaNova.Biz internal async Task 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.OwnerId == UserId)); + var ret = await ct.DataFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId)); if (ret != null) { //Log @@ -135,7 +135,7 @@ namespace AyaNova.Biz { items = await ct.DataFilter .AsNoTracking() - .Where(m => m.ListKey == listKey && (m.Public == true || m.OwnerId == UserId)) + .Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId)) .OrderBy(m => m.Name) .Select(m => new NameIdItem() { @@ -158,8 +158,8 @@ namespace AyaNova.Biz internal bool Put(DataFilter dbObj, DataFilter inObj) { //preserve the owner ID if none was specified - if (inObj.OwnerId == 0) - inObj.OwnerId = dbObj.OwnerId; + if (inObj.UserId == 0) + inObj.UserId = dbObj.UserId; //Replace the db object with the PUT object CopyObject.Copy(inObj, dbObj, "Id"); @@ -216,16 +216,14 @@ namespace AyaNova.Biz private void Validate(DataFilter inObj, bool isNew) { - //OwnerId required + //UserId required if (!isNew) { - if (inObj.OwnerId == 0) - AddError(ApiErrorCode.VALIDATION_REQUIRED, "OwnerId"); + if (inObj.UserId == 0) + AddError(ApiErrorCode.VALIDATION_REQUIRED, "UserId"); } - // //Owner must be current user, there are no exceptions - // if (inObj.OwnerId != UserId) - // AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "OwnerId", "OwnerId must be current user Id"); + //Name required if (string.IsNullOrWhiteSpace(inObj.Name)) diff --git a/server/AyaNova/models/DataFilter.cs b/server/AyaNova/models/DataFilter.cs index 8ea8e18e..e5bea333 100644 --- a/server/AyaNova/models/DataFilter.cs +++ b/server/AyaNova/models/DataFilter.cs @@ -13,7 +13,7 @@ namespace AyaNova.Models public uint ConcurrencyToken { get; set; } [Required] - public long OwnerId { get; set; } + public long UserId { get; set; } [Required, MaxLength(255)] public string Name { get; set; }//max 255 characters ascii set [Required] diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 7350f2fb..f35852e8 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -262,7 +262,7 @@ namespace AyaNova.Util { LogUpdateMessage(log); - exec("CREATE TABLE adatafilter (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, public bool not null," + + exec("CREATE TABLE adatafilter (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))"); setSchemaLevel(++currentSchema); }