From 009781e95a8c37f79fc8e9324a2bf3d37aa93a5e Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 23 Dec 2022 00:04:47 +0000 Subject: [PATCH] --- server/PickList/ProductPickList.cs | 56 +++++++++++++++++++++++++++++ server/PickList/VendorPickList.cs | 56 +++++++++++++++++++++++++++++ server/biz/LicenseBiz.cs | 3 +- server/models/SubscriptionServer.cs | 1 - server/util/AySchema.cs | 2 +- todo.txt | 2 +- 6 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 server/PickList/ProductPickList.cs create mode 100644 server/PickList/VendorPickList.cs diff --git a/server/PickList/ProductPickList.cs b/server/PickList/ProductPickList.cs new file mode 100644 index 0000000..7573df3 --- /dev/null +++ b/server/PickList/ProductPickList.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using Newtonsoft.Json.Linq; +using Sockeye.Biz; +namespace Sockeye.PickList +{ + internal class ProductPickList : AyaPickList + { + public ProductPickList() + { + + DefaultListAType = SockType.Product; + SQLFrom = "from aproduct"; + AllowedRoles = BizRoles.GetRoleSet(DefaultListAType).Select; + dynamic dTemplate = new JArray(); + + dynamic cm = new JObject(); + cm.fld = "productname"; + dTemplate.Add(cm); + + cm = new JObject(); + cm.fld = "producttags"; + dTemplate.Add(cm); + + base.DefaultTemplate = dTemplate.ToString(Newtonsoft.Json.Formatting.None); + + //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely + ColumnDefinitions = new List(); + ColumnDefinitions.Add(new AyaPickListFieldDefinition + { + TKey = "Active", + FieldKey = "productactive", + ColumnDataType = UiFieldDataType.Bool, + SqlValueColumnName = "aproduct.active", + IsActiveColumn = true + }); + ColumnDefinitions.Add(new AyaPickListFieldDefinition + { + TKey = "Name", + FieldKey = "productname", + ColumnDataType = UiFieldDataType.Text, + SqlIdColumnName = "aproduct.id", + SqlValueColumnName = "aproduct.name", + IsRowId = true + }); + + ColumnDefinitions.Add(new AyaPickListFieldDefinition + { + TKey = "Tags", + FieldKey = "producttags", + ColumnDataType = UiFieldDataType.Tags, + SqlValueColumnName = "aproduct.tags" + }); + + } + }//eoc +}//eons \ No newline at end of file diff --git a/server/PickList/VendorPickList.cs b/server/PickList/VendorPickList.cs new file mode 100644 index 0000000..7639c44 --- /dev/null +++ b/server/PickList/VendorPickList.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using Newtonsoft.Json.Linq; +using Sockeye.Biz; +namespace Sockeye.PickList +{ + internal class VendorPickList : AyaPickList + { + public VendorPickList() + { + + DefaultListAType = SockType.Vendor; + SQLFrom = "from avendor"; + AllowedRoles = BizRoles.GetRoleSet(DefaultListAType).Select; + dynamic dTemplate = new JArray(); + + dynamic cm = new JObject(); + cm.fld = "vendorname"; + dTemplate.Add(cm); + + cm = new JObject(); + cm.fld = "vendortags"; + dTemplate.Add(cm); + + base.DefaultTemplate = dTemplate.ToString(Newtonsoft.Json.Formatting.None); + + //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely + ColumnDefinitions = new List(); + ColumnDefinitions.Add(new AyaPickListFieldDefinition + { + TKey = "Active", + FieldKey = "vendoractive", + ColumnDataType = UiFieldDataType.Bool, + SqlValueColumnName = "avendor.active", + IsActiveColumn = true + }); + ColumnDefinitions.Add(new AyaPickListFieldDefinition + { + TKey = "Name", + FieldKey = "vendorname", + ColumnDataType = UiFieldDataType.Text, + SqlIdColumnName = "avendor.id", + SqlValueColumnName = "avendor.name", + IsRowId = true + }); + + ColumnDefinitions.Add(new AyaPickListFieldDefinition + { + TKey = "Tags", + FieldKey = "vendortags", + ColumnDataType = UiFieldDataType.Tags, + SqlValueColumnName = "avendor.tags" + }); + + } + }//eoc +}//eons \ No newline at end of file diff --git a/server/biz/LicenseBiz.cs b/server/biz/LicenseBiz.cs index c10a20f..e3b294c 100644 --- a/server/biz/LicenseBiz.cs +++ b/server/biz/LicenseBiz.cs @@ -225,8 +225,7 @@ namespace Sockeye.Biz private async Task ValidateCanDeleteAsync(License inObj) { - if (await ct.SubscriptionServer.AnyAsync(m => m.LicenseId == inObj.Id)) - AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "generalerror", await Translate("SubscriptionServer")); + await Task.CompletedTask; } diff --git a/server/models/SubscriptionServer.cs b/server/models/SubscriptionServer.cs index bca122e..9c0a798 100644 --- a/server/models/SubscriptionServer.cs +++ b/server/models/SubscriptionServer.cs @@ -31,7 +31,6 @@ namespace Sockeye.Models public string OperatingSystem { get; set; } public string CustomerSubDomain { get; set; } public long? CustomerId { get; set; } - public long? LicenseId { get; set; } public string Wiki { get; set; } public List Tags { get; set; } diff --git a/server/util/AySchema.cs b/server/util/AySchema.cs index c14999b..3ead12d 100644 --- a/server/util/AySchema.cs +++ b/server/util/AySchema.cs @@ -889,7 +889,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("CREATE TABLE asubscriptionserver (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, active BOOL NOT NULL DEFAULT true, created TIMESTAMPTZ NOT NULL, " + "name TEXT NOT NULL, notes TEXT, datacenter TEXT NOT NULL, timezone TEXT NOT NULL, lastupdated TIMESTAMPTZ, subscriptionexpire TIMESTAMPTZ NOT NULL, " + "trial BOOL NOT NULL DEFAULT true, trialexpire TIMESTAMPTZ, trialcontact TEXT, trialemail TEXT, trialcompany TEXT, operatingsystem TEXT, customersubdomain TEXT, " - + "wiki TEXT, tags VARCHAR(255) ARRAY, licenseid BIGINT REFERENCES alicense(id), customerid BIGINT REFERENCES acustomer(id) )"); + + "wiki TEXT, tags VARCHAR(255) ARRAY, customerid BIGINT REFERENCES acustomer(id) )"); await ExecQueryAsync("CREATE TABLE aproduct (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL, active BOOL NOT NULL DEFAULT true, " diff --git a/todo.txt b/todo.txt index 4639460..9c83a22 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,5 @@ SERVER END -localized text keys + picklists data lists