mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
3647 Kusto Refresh Logic (#1067)
* 3647 Renamed ParentMetadata to DatabaseMetadata in FolderMetadata.cs. Removed Refresh function from IDataSource and DataSourceBase since it's not used outside of KustoDataSource. Added unit tests for ServerNode.cs. Removed unused constructor from TreeNode and unused AddChild function. * 3647 Refactored KustoDataSource. Moved Set logic for DatabaseMetadata and columns into separate functions * 3647 Reverted Rename of ParentMetadata in FolderMetadata. Reverted removal of Refresh function from DataSourceBase and IDatasource * 3647 Renamed SmoModel directories to DataSourceModel in Kusto projects. * 3647 Removed reference to Kusto.ServiceLayer in SqlTools.ServiceLayer
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.Kusto.ServiceLayer.ObjectExplorer.Nodes;
|
||||
using Microsoft.Kusto.ServiceLayer.DataSource;
|
||||
using Microsoft.Kusto.ServiceLayer.DataSource.Metadata;
|
||||
|
||||
namespace Microsoft.Kusto.ServiceLayer.ObjectExplorer.DataSourceModel
|
||||
{
|
||||
/// <summary>
|
||||
/// A Node in the tree representing a SMO-based object
|
||||
/// </summary>
|
||||
public class DataSourceTreeNode : TreeNode
|
||||
{
|
||||
public static int FolderSortPriority = 0;
|
||||
private static int _nextSortPriority = FolderSortPriority + 1; // 0 is reserved for folders
|
||||
|
||||
protected QueryContext context;
|
||||
|
||||
public DataSourceTreeNode(IDataSource dataSource, DataSourceObjectMetadata objectMetadata)
|
||||
: base(dataSource, objectMetadata)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an incrementing sort priority value to assist in automatically sorting
|
||||
/// elements in a tree
|
||||
/// </summary>
|
||||
public static int NextSortPriority
|
||||
{
|
||||
get
|
||||
{
|
||||
return System.Threading.Interlocked.Increment(ref _nextSortPriority);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void CacheInfoFromModel(DataSourceObjectMetadata objectMetadata)
|
||||
{
|
||||
base.ObjectMetadata = objectMetadata;
|
||||
NodeValue = objectMetadata.Name;
|
||||
}
|
||||
|
||||
public virtual DataSourceObjectMetadata GetParentObjectMetadata()
|
||||
{
|
||||
if (ObjectMetadata != null)
|
||||
{
|
||||
return ObjectMetadata;
|
||||
}
|
||||
// Return the parent's object, or null if it's not set / not a OETreeNode
|
||||
return ParentAs<DataSourceTreeNode>()?.GetParentObjectMetadata();
|
||||
}
|
||||
|
||||
public override object GetContext()
|
||||
{
|
||||
EnsureContextInitialized();
|
||||
return context;
|
||||
}
|
||||
|
||||
protected virtual void EnsureContextInitialized()
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
DataSourceObjectMetadata oeParent = GetParentObjectMetadata();
|
||||
QueryContext parentContext = Parent?.GetContextAs<QueryContext>();
|
||||
if (oeParent != null && parentContext != null)
|
||||
{
|
||||
context = parentContext.CopyWithParent(oeParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user