mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-26 09:35:38 -05:00
Dropped Ledger Views folder (#1626)
* adding dropped ledger views to the OE hierarchy with ledger view naming and icons * updating tests
This commit is contained in:
@@ -141,5 +141,6 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
||||
ColumnMasterKeys,
|
||||
ColumnEncryptionKeys,
|
||||
DroppedLedgerTables,
|
||||
DroppedLedgerViews,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,4 +136,47 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Custom name and icon for dropped ledger tables
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -895,6 +895,13 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
Type = typeof(bool),
|
||||
Values = new List<object> { 0 },
|
||||
});
|
||||
filters.Add(new NodePropertyFilter
|
||||
{
|
||||
Property = "IsDroppedLedgerView",
|
||||
Type = typeof(bool),
|
||||
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
||||
Values = new List<object> { 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<string> ApplicableParents() { return new[] { "DroppedLedgerViews" }; }
|
||||
|
||||
public override IEnumerable<INodeFilter> Filters
|
||||
{
|
||||
get
|
||||
{
|
||||
var filters = new List<INodeFilter>();
|
||||
filters.Add(new NodePropertyFilter
|
||||
{
|
||||
Property = "IsDroppedLedgerView",
|
||||
Type = typeof(bool),
|
||||
ValidFor = ValidForFlag.Sql2022|ValidForFlag.AzureV12,
|
||||
Values = new List<object> { 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
|
||||
|
||||
@@ -99,8 +99,10 @@
|
||||
<Node Name="Views" LocLabel="SR.SchemaHierarchy_Views" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewTreeNode">
|
||||
<Filters>
|
||||
<Filter Property="IsSystemObject" Value="0" Type="bool" />
|
||||
<Filter Property="IsDroppedLedgerView" Value="0" Type="bool" ValidFor="Sql2022|AzureV12"/>
|
||||
</Filters>
|
||||
<Child Name="SystemViews" IsSystemObject="1"/>
|
||||
<Child Name="DroppedLedgerViews" IsDroppedLedgerView="1"/>
|
||||
</Node>
|
||||
|
||||
<Node Name="Synonyms" LocLabel="SR.SchemaHierarchy_Synonyms" BaseClass="ModelBased" Strategy="MultipleElementsOfType" NodeType="Synonym" ChildQuerierTypes="SqlSynonym" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|Sql2017|Sql2019|Sql2022|AzureV12"/>
|
||||
@@ -249,6 +251,12 @@
|
||||
</Filters>
|
||||
</Node>
|
||||
|
||||
<Node Name="DroppedLedgerViews" LocLabel="SR.SchemaHierarchy_DroppedLedgerViews" BaseClass="ModelBased" IsMsShippedOwned="true" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewTreeNode">
|
||||
<Filters>
|
||||
<Filter Property="IsDroppedLedgerView" Value="1" Type="bool" ValidFor="Sql2022|AzureV12" />
|
||||
</Filters>
|
||||
</Node>
|
||||
|
||||
<Node Name="View" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" NodeType="View" Strategy="PopulateDetails">
|
||||
<Child Name="Columns"/>
|
||||
<Child Name="Triggers"/>
|
||||
|
||||
@@ -51,6 +51,38 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom name for dropped ledger views
|
||||
/// </summary>
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user