diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs index 566ab816..f9c924c9 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs @@ -2053,6 +2053,14 @@ namespace Microsoft.SqlTools.ServiceLayer } } + public static string SchemaHierarchy_DroppedLedgerViews + { + get + { + return Keys.GetString(Keys.SchemaHierarchy_DroppedLedgerViews); + } + } + public static string SchemaHierarchy_AlwaysEncryptedKeys { get @@ -10656,6 +10664,9 @@ namespace Microsoft.SqlTools.ServiceLayer public const string SchemaHierarchy_DroppedLedgerTables = "SchemaHierarchy_DroppedLedgerTables"; + public const string SchemaHierarchy_DroppedLedgerViews = "SchemaHierarchy_DroppedLedgerViews"; + + public const string SchemaHierarchy_AlwaysEncryptedKeys = "SchemaHierarchy_AlwaysEncryptedKeys"; diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx index 2c7ce566..3a455d25 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx @@ -1284,6 +1284,10 @@ Dropped Ledger Tables + + Dropped Ledger Views + + Always Encrypted Keys diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings index b07df0e7..3f4d126b 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.strings @@ -632,6 +632,8 @@ SchemaHierarchy_ExternalTables = External Tables SchemaHierarchy_DroppedLedgerTables = Dropped Ledger Tables +SchemaHierarchy_DroppedLedgerViews = Dropped Ledger Views + SchemaHierarchy_AlwaysEncryptedKeys = Always Encrypted Keys SchemaHierarchy_ColumnMasterKeys = Column Master Keys diff --git a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf index ea7aa62d..69951c84 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf +++ b/src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf @@ -6326,6 +6326,11 @@ The Query Processor estimates that implementing the following index could improv Dropped Ledger Tables + + Dropped Ledger Views + Dropped Ledger Views + + \ No newline at end of file diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs index f9697582..81bd1c91 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/Nodes/NodeTypes.cs @@ -141,5 +141,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes ColumnMasterKeys, ColumnEncryptionKeys, DroppedLedgerTables, + DroppedLedgerViews, } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTableCustomNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTableCustomNode.cs index 5c7f2e57..4310b3c3 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTableCustomNode.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTableCustomNode.cs @@ -136,4 +136,47 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel return string.Empty; } } + + + /// + /// Custom name and icon for dropped ledger tables + /// + internal partial class DroppedLedgerTablesChildFactory : SmoChildFactoryBase + { + public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext) + { + try + { + Table? table = smoObject as Table; + if (table != null && IsPropertySupported("LedgerType", smoContext, table, CachedSmoProperties)) + { + if (table.LedgerType == LedgerTableType.AppendOnlyLedgerTable) + { + return $"{table.Schema}.{table.Name} ({SR.AppendOnlyLedger_LabelPart})"; + } + else if (table.LedgerType == LedgerTableType.UpdatableLedgerTable) + { + return $"{table.Schema}.{table.Name} ({SR.UpdatableLedger_LabelPart})"; + } + } + } + catch + { + //Ignore the exception and just not change create custom name + } + + return string.Empty; + } + + public override string GetNodeSubType(object smoObject, SmoQueryContext smoContext) + { + return "Ledger"; + } + + public override string GetNodePathName(object smoObject) + { + return TableCustomNodeHelper.GetPathName(smoObject); + } + } + } diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNodes.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNodes.cs index 453eff60..10799099 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNodes.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNodes.cs @@ -895,6 +895,13 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel Type = typeof(bool), Values = new List { 0 }, }); + filters.Add(new NodePropertyFilter + { + Property = "IsDroppedLedgerView", + Type = typeof(bool), + ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12, + Values = new List { 0 }, + }); return filters; } } @@ -909,6 +916,14 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel IsMsShippedOwned = true, SortPriority = SmoTreeNode.NextSortPriority, }); + currentChildren.Add(new FolderNode { + NodeValue = SR.SchemaHierarchy_DroppedLedgerViews, + NodeType = "Folder", + NodeTypeId = NodeTypes.DroppedLedgerViews, + IsSystemObject = false, + IsMsShippedOwned = true, + SortPriority = SmoTreeNode.NextSortPriority, + }); } internal override Type[] ChildQuerierTypes @@ -1837,6 +1852,44 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel } } + [Export(typeof(ChildFactory))] + [Shared] + internal partial class DroppedLedgerViewsChildFactory : SmoChildFactoryBase + { + public override IEnumerable ApplicableParents() { return new[] { "DroppedLedgerViews" }; } + + public override IEnumerable Filters + { + get + { + var filters = new List(); + filters.Add(new NodePropertyFilter + { + Property = "IsDroppedLedgerView", + Type = typeof(bool), + ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12, + Values = new List { 1 }, + }); + return filters; + } + } + + internal override Type[] ChildQuerierTypes + { + get + { + return new [] { typeof(SqlViewQuerier), }; + } + } + + public override TreeNode CreateChild(TreeNode parent, object context) + { + var child = new ViewTreeNode(); + InitializeChild(parent, child, context); + return child; + } + } + [Export(typeof(ChildFactory))] [Shared] internal partial class ViewChildFactory : SmoChildFactoryBase diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNodesDefinition.xml b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNodesDefinition.xml index 0fd84bce..b7b89992 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNodesDefinition.xml +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoTreeNodesDefinition.xml @@ -99,8 +99,10 @@ + + @@ -249,6 +251,12 @@ + + + + + + diff --git a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoViewCustomNode.cs b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoViewCustomNode.cs index 01b2bb5a..d0325108 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoViewCustomNode.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/ObjectExplorer/SmoModel/SmoViewCustomNode.cs @@ -51,6 +51,38 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel } } + /// + /// Custom name for dropped ledger views + /// + internal partial class DroppedLedgerViewsChildFactory : SmoChildFactoryBase + { + public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext) + { + try + { + View? view = smoObject as View; + if (view != null && + IsPropertySupported("LedgerViewType", smoContext, view, CachedSmoProperties)) + { + return $"{view.Schema}.{view.Name} ({SR.Ledger_LabelPart})"; + } + } + catch {} //Ignore the exception and just not change create custom name + + return string.Empty; + } + + public override string GetNodeSubType(object smoObject, SmoQueryContext smoContext) + { + return "Ledger"; + } + + public override string GetNodePathName(object smoObject) + { + return ViewCustomNodeHelper.GetPathName(smoObject); + } + } + internal static class ViewCustomNodeHelper { internal static string GetPathName(object smoObject) diff --git a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/Baselines/AllSqlObjects.txt b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/Baselines/AllSqlObjects.txt index e941830b..0597bd0f 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/Baselines/AllSqlObjects.txt +++ b/test/Microsoft.SqlTools.ServiceLayer.Test.Common/TestData/ObjectExplorer/Baselines/AllSqlObjects.txt @@ -1,4 +1,4 @@ -NodeType: Table Label: HumanResources.MSSQL_DroppedLedgerTable_Ledger_For_Drop_<> SubType: Status: +NodeType: Table Label: HumanResources.MSSQL_DroppedLedgerTable_Ledger_For_Drop_<> (Updatable Ledger) SubType:Ledger Status: NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status: NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status: NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status: @@ -178,6 +178,15 @@ NodeType: Constraint Label: DF_Person_ModifiedDate SubType: Status: NodeType: Trigger Label: TableTrigger SubType: Status: NodeType: Index Label: PK_Person_BusinessEntityID (Unique, Clustered) SubType:PrimaryKey Status: NodeType: Statistic Label: PK_Person_BusinessEntityID SubType: Status: +NodeType: View Label: HumanResources.MSSQL_DroppedLedgerView_Ledger_For_Drop_Ledger_<> (Ledger) SubType:Ledger Status: +NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status: +NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status: +NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status: +NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status: +NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status: +NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status: +NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status: +NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status: NodeType: View Label: HumanResources.Employee_Ledger_AppendOnly_Ledger (Ledger) SubType:Ledger Status: NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status: NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status: @@ -216,15 +225,6 @@ NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status: NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status: NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status: NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status: -NodeType: View Label: HumanResources.MSSQL_DroppedLedgerView_Ledger_For_Drop_Ledger_<> (Ledger) SubType:Ledger Status: -NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status: -NodeType: Column Label: NationalIDNumber (nvarchar(15), not null) SubType: Status: -NodeType: Column Label: LoginID (nvarchar(256), not null) SubType: Status: -NodeType: Column Label: OrganizationNode (hierarchyid, null) SubType: Status: -NodeType: Column Label: ledger_transaction_id (bigint, null) SubType: Status: -NodeType: Column Label: ledger_sequence_number (bigint, null) SubType: Status: -NodeType: Column Label: ledger_operation_type (int, not null) SubType: Status: -NodeType: Column Label: ledger_operation_type_desc (nvarchar(6), not null) SubType: Status: NodeType: View Label: HumanResources.vEmployee SubType: Status: NodeType: Column Label: BusinessEntityID (int, not null) SubType: Status: NodeType: Column Label: Title (nvarchar(8), null) SubType: Status: diff --git a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodePathGeneratorTests.cs b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodePathGeneratorTests.cs index 1e22478b..f28e3008 100644 --- a/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodePathGeneratorTests.cs +++ b/test/Microsoft.SqlTools.ServiceLayer.UnitTests/ObjectExplorer/NodePathGeneratorTests.cs @@ -93,7 +93,9 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer "testServer/Databases/testDatabase/Views/testSchema.testTable/Columns/testColumn", "testServer/Databases/System Databases/testDatabase/Views/testSchema.testTable/Columns/testColumn", "testServer/Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn", - "testServer/Databases/System Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn" + "testServer/Databases/System Databases/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn", + "testServer/Databases/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/testColumn", + "testServer/Databases/System Databases/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/testColumn" }; Assert.AreEqual(expectedPaths.Count, paths.Count); @@ -113,7 +115,8 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer "testServer/testDatabase/Tables/System Tables/testSchema.testTable/Columns/testColumn", "testServer/testDatabase/Tables/Dropped Ledger Tables/testSchema.testTable/Columns/testColumn", "testServer/testDatabase/Views/testSchema.testTable/Columns/testColumn", - "testServer/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn" + "testServer/testDatabase/Views/System Views/testSchema.testTable/Columns/testColumn", + "testServer/testDatabase/Views/Dropped Ledger Views/testSchema.testTable/Columns/testColumn" }; Assert.AreEqual(expectedPaths.Count, paths.Count);