adding metadata to object explorer node info (#320)

* adding metadata to oe node info
This commit is contained in:
Leila Lali
2017-04-19 08:32:39 -07:00
committed by GitHub
parent 96d46b5c09
commit 8c0885da88
16 changed files with 121 additions and 81 deletions

View File

@@ -2053,11 +2053,11 @@ namespace Microsoft.SqlTools.ServiceLayer
} }
} }
public static string SchemaHierarchy_ServerInstance public static string SchemaHierarchy_Server
{ {
get get
{ {
return Keys.GetString(Keys.SchemaHierarchy_ServerInstance); return Keys.GetString(Keys.SchemaHierarchy_Server);
} }
} }
@@ -3036,7 +3036,7 @@ namespace Microsoft.SqlTools.ServiceLayer
public const string SchemaHierarchy_TableTypeIndexes = "SchemaHierarchy_TableTypeIndexes"; public const string SchemaHierarchy_TableTypeIndexes = "SchemaHierarchy_TableTypeIndexes";
public const string SchemaHierarchy_ServerInstance = "SchemaHierarchy_ServerInstance"; public const string SchemaHierarchy_Server = "SchemaHierarchy_Server";
public const string SchemaHierarchy_SelectiveXmlIndexes = "SchemaHierarchy_SelectiveXmlIndexes"; public const string SchemaHierarchy_SelectiveXmlIndexes = "SchemaHierarchy_SelectiveXmlIndexes";

View File

@@ -1199,8 +1199,8 @@
<value>Table Type Indexes</value> <value>Table Type Indexes</value>
<comment></comment> <comment></comment>
</data> </data>
<data name="SchemaHierarchy_ServerInstance" xml:space="preserve"> <data name="SchemaHierarchy_Server" xml:space="preserve">
<value>ServerInstance</value> <value>Server</value>
<comment></comment> <comment></comment>
</data> </data>
<data name="SchemaHierarchy_SelectiveXmlIndexes" xml:space="preserve"> <data name="SchemaHierarchy_SelectiveXmlIndexes" xml:space="preserve">

View File

@@ -597,7 +597,7 @@ SchemaHierarchy_ColumnStoreIndexes = Column Store Indexes
SchemaHierarchy_TableTypeIndexes = Table Type Indexes SchemaHierarchy_TableTypeIndexes = Table Type Indexes
SchemaHierarchy_ServerInstance = ServerInstance SchemaHierarchy_Server = Server
SchemaHierarchy_SelectiveXmlIndexes = Selective XML Indexes SchemaHierarchy_SelectiveXmlIndexes = Selective XML Indexes

View File

@@ -1351,11 +1351,6 @@
<target state="new">Table Type Indexes</target> <target state="new">Table Type Indexes</target>
<note></note> <note></note>
</trans-unit> </trans-unit>
<trans-unit id="SchemaHierarchy_ServerInstance">
<source>ServerInstance</source>
<target state="new">ServerInstance</target>
<note></note>
</trans-unit>
<trans-unit id="SchemaHierarchy_SelectiveXmlIndexes"> <trans-unit id="SchemaHierarchy_SelectiveXmlIndexes">
<source>Selective XML Indexes</source> <source>Selective XML Indexes</source>
<target state="new">Selective XML Indexes</target> <target state="new">Selective XML Indexes</target>
@@ -1416,6 +1411,11 @@
<target state="new">Column Encryption Keys</target> <target state="new">Column Encryption Keys</target>
<note></note> <note></note>
</trans-unit> </trans-unit>
<trans-unit id="SchemaHierarchy_Server">
<source>Server</source>
<target state="new">Server</target>
<note></note>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@@ -3,6 +3,8 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts
{ {
/// <summary> /// <summary>
@@ -36,5 +38,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts
/// is it expandable? /// is it expandable?
/// </summary> /// </summary>
public bool IsLeaf { get; set; } public bool IsLeaf { get; set; }
/// <summary>
/// Object Metadata for smo objects to be used for scripting
/// </summary>
public ObjectMetadata Metadata { get; set; }
} }
} }

View File

@@ -13,18 +13,17 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
{ {
None, None,
SqlServersRoot, SqlServersRoot,
DatabaseInstance, Database,
DacInstance, Server,
ServerInstance, ScalarValuedFunction,
ScalarValuedFunctionInstance, TableValuedFunction,
TableValuedFunctionInstance, AggregateFunction,
AggregateFunctionInstance,
FileGroupInstance, FileGroupInstance,
StoredProcedureInstance, StoredProcedure,
UserDefinedTableTypeInstance, UserDefinedTableType,
ViewInstance, View,
TableInstance, Table,
HistoryTableInstance, HistoryTable,
Databases, Databases,
ExternalResources, ExternalResources,
ServerLevelSecurity, ServerLevelSecurity,
@@ -130,10 +129,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
SecurityPolicies, SecurityPolicies,
DatabaseScopedCredentials, DatabaseScopedCredentials,
ExternalTables, ExternalTables,
ExternalResourceInstance, ExternalResource,
ExternalDataSources, ExternalDataSources,
ExternalFileFormats, ExternalFileFormats,
ExternalTableInstance, ExternalTable,
AlwaysEncryptedKeys, AlwaysEncryptedKeys,
ColumnMasterKeys, ColumnMasterKeys,
ColumnEncryptionKeys ColumnEncryptionKeys

View File

@@ -8,7 +8,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using System.Linq; using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel; using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
@@ -52,6 +52,12 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
/// </summary> /// </summary>
public string NodeValue { get; set; } public string NodeValue { get; set; }
/// <summary>
/// Object metadata for smo objects
/// </summary>
public ObjectMetadata ObjectMetadata { get; set; }
/// <summary> /// <summary>
/// The type of the node - for example Server, Database, Folder, Table /// The type of the node - for example Server, Database, Folder, Table
/// </summary> /// </summary>
@@ -170,7 +176,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
IsLeaf = this.IsAlwaysLeaf, IsLeaf = this.IsAlwaysLeaf,
Label = this.Label, Label = this.Label,
NodePath = this.GetNodePath(), NodePath = this.GetNodePath(),
NodeType = this.NodeType NodeType = this.NodeType,
Metadata = this.ObjectMetadata
}; };
} }

View File

@@ -49,8 +49,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
NodeValue = connectionSummary.ServerName; NodeValue = connectionSummary.ServerName;
IsAlwaysLeaf = false; IsAlwaysLeaf = false;
NodeType = NodeTypes.ServerInstance.ToString(); NodeType = NodeTypes.Server.ToString();
NodeTypeId = NodeTypes.ServerInstance; NodeTypeId = NodeTypes.Server;
Label = GetConnectionLabel(); Label = GetConnectionLabel();
} }

View File

@@ -56,6 +56,18 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
{ {
SmoObject = smoObject; SmoObject = smoObject;
NodeValue = smoObject.Name; NodeValue = smoObject.Name;
ScriptSchemaObjectBase schemaBasecObject = smoObject as ScriptSchemaObjectBase;
ObjectMetadata = new Metadata.Contracts.ObjectMetadata();
if (schemaBasecObject != null)
{
ObjectMetadata.MetadataTypeName = schemaBasecObject.Urn?.Type;
ObjectMetadata.Name = schemaBasecObject.Name;
ObjectMetadata.Schema = schemaBasecObject.Schema;
if (!string.IsNullOrEmpty(ObjectMetadata.Schema))
{
NodeValue = $"{ObjectMetadata.Schema}.{smoObject.Name}";
}
}
} }
public virtual NamedSmoObject GetParentSmoObject() public virtual NamedSmoObject GetParentSmoObject()

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<ServerExplorerTree> <ServerExplorerTree>
<Node Name="ServerInstance" LocLabel="SR.SchemaHierarchy_ServerInstance" Image="Server"> <Node Name="Server" LocLabel="SR.SchemaHierarchy_ServerInstance" Image="Server">
<Child Name="Databases"/> <Child Name="Databases"/>
<Child Name="ServerLevelSecurity"/> <Child Name="ServerLevelSecurity"/>
<Child Name="ServerLevelServerObjects"/> <Child Name="ServerLevelServerObjects"/>
@@ -49,7 +49,7 @@
<Node Name="ServerLevelServerTriggers" LocLabel="SR.SchemaHierarchy_ServerTriggers" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlServerDdlTrigger"/> <Node Name="ServerLevelServerTriggers" LocLabel="SR.SchemaHierarchy_ServerTriggers" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlServerDdlTrigger"/>
<Node Name="ServerLevelErrorMessages" LocLabel="SR.SchemaHierarchy_ErrorMessages" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlErrorMessage"/> <Node Name="ServerLevelErrorMessages" LocLabel="SR.SchemaHierarchy_ErrorMessages" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlErrorMessage"/>
<Node Name="DatabaseInstance" LocLabel="string.Empty" Image="Database" BaseClass="ModelBased" IsAsyncLoad="" Strategy="CreateModel"> <Node Name="Database" LocLabel="string.Empty" Image="Database" BaseClass="ModelBased" IsAsyncLoad="" Strategy="CreateModel">
<Child Name="Tables"/> <Child Name="Tables"/>
<Child Name="Views"/> <Child Name="Views"/>
<Child Name="Synonyms"/> <Child Name="Synonyms"/>
@@ -142,7 +142,7 @@
</Filters> </Filters>
</Node> </Node>
<Node Name="TableInstance" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlTable" TreeNode="HistoryTableInstanceTreeNode"> <Node Name="Table" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlTable" TreeNode="HistoryTableInstanceTreeNode">
<!-- TODO Add special history table handling to only return related history table instead of all! Under Table, we directly show any related history tables.--> <!-- TODO Add special history table handling to only return related history table instead of all! Under Table, we directly show any related history tables.-->
<Filters> <Filters>
<Filter Property="TemporalType" Type="Enum" ValidFor="Sql2016|SqlvNext|AzureV12"> <Filter Property="TemporalType" Type="Enum" ValidFor="Sql2016|SqlvNext|AzureV12">
@@ -158,14 +158,14 @@
</Node> </Node>
<!-- TODO This should use display item not ChildQuerierTypes --> <!-- TODO This should use display item not ChildQuerierTypes -->
<Node Name="HistoryTableInstance" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" Strategy="PopulateDetails" ChildQuerierTypes="SqlTable" ValidFor="Sql2016|SqlvNext|AzureV12"> <Node Name="HistoryTable" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" Strategy="PopulateDetails" ChildQuerierTypes="SqlTable" ValidFor="Sql2016|SqlvNext|AzureV12">
<Child Name="Columns"/> <Child Name="Columns"/>
<Child Name="Indexes"/> <Child Name="Indexes"/>
<Child Name="Statistics"/> <Child Name="Statistics"/>
</Node> </Node>
<!-- TODO This should use display item not ChildQuerierTypes --> <!-- TODO This should use display item not ChildQuerierTypes -->
<Node Name="ExternalTableInstance" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" Strategy="PopulateDetails" ChildQuerierTypes="SqlTable" ValidFor="Sql2016|SqlvNext|AzureV12"> <Node Name="ExternalTable" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" Strategy="PopulateDetails" ChildQuerierTypes="SqlTable" ValidFor="Sql2016|SqlvNext|AzureV12">
<Child Name="Columns"/> <Child Name="Columns"/>
<Child Name="Statistics"/> <Child Name="Statistics"/>
</Node> </Node>
@@ -192,7 +192,7 @@
<Node Name="SystemViews" LocLabel="SR.SchemaHierarchy_SystemViews" BaseClass="ModelBased" IsMsShippedOwned="true" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewInstanceTreeNode"/> <Node Name="SystemViews" LocLabel="SR.SchemaHierarchy_SystemViews" BaseClass="ModelBased" IsMsShippedOwned="true" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlView" TreeNode="ViewInstanceTreeNode"/>
<Node Name="ViewInstance" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" Strategy="PopulateDetails"> <Node Name="View" LocLabel="string.Empty" BaseClass="ModelBased" IsAsyncLoad="" Strategy="PopulateDetails">
<Child Name="Columns"/> <Child Name="Columns"/>
<Child Name="Triggers"/> <Child Name="Triggers"/>
<Child Name="Indexes"/> <Child Name="Indexes"/>
@@ -233,7 +233,7 @@
<Node Name="UserDefinedTypes" LocLabel="SR.SchemaHierarchy_UserDefinedTypes" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlUserDefinedType" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|SqlvNext|AzureV12"/> <Node Name="UserDefinedTypes" LocLabel="SR.SchemaHierarchy_UserDefinedTypes" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlUserDefinedType" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|SqlvNext|AzureV12"/>
<Node Name="XmlSchemaCollections" LocLabel="SR.SchemaHierarchy_XMLSchemaCollections" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlXmlSchemaCollection" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|SqlvNext|AzureV12"/> <Node Name="XmlSchemaCollections" LocLabel="SR.SchemaHierarchy_XMLSchemaCollections" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlXmlSchemaCollection" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|SqlvNext|AzureV12"/>
<Node Name="UserDefinedTableTypeInstance" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails"> <Node Name="UserDefinedTableType" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails">
<Child Name="UserDefinedTableTypeColumns"/> <Child Name="UserDefinedTableTypeColumns"/>
<Child Name="UserDefinedTableTypeKeys"/> <Child Name="UserDefinedTableTypeKeys"/>
<Child Name="UserDefinedTableTypeConstraints"/> <Child Name="UserDefinedTableTypeConstraints"/>
@@ -267,7 +267,7 @@
<Child Name="SystemStoredProcedures"/> <Child Name="SystemStoredProcedures"/>
</Node> </Node>
<Node Name="SystemStoredProcedures" LocLabel="SR.SchemaHierarchy_SystemStoredProcedures" BaseClass="ModelBased" IsMsShippedOwned="true" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlProcedure" TreeNode="StoredProcedureInstanceTreeNode"/> <Node Name="SystemStoredProcedures" LocLabel="SR.SchemaHierarchy_SystemStoredProcedures" BaseClass="ModelBased" IsMsShippedOwned="true" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlProcedure" TreeNode="StoredProcedureInstanceTreeNode"/>
<Node Name="StoredProcedureInstance" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails"> <Node Name="StoredProcedure" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails">
<Child Name="StoredProcedureParameters"/> <Child Name="StoredProcedureParameters"/>
</Node> </Node>
<Node Name="StoredProcedureParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="StoredProcedureParameters" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/> <Node Name="StoredProcedureParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="StoredProcedureParameters" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/>
@@ -279,7 +279,7 @@
</Filter> </Filter>
</Filters> </Filters>
</Node> </Node>
<Node Name="TableValuedFunctionInstance" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails"> <Node Name="TableValuedFunction" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails">
<Child Name="TableValuedFunctionParameters"/> <Child Name="TableValuedFunctionParameters"/>
</Node> </Node>
<Node Name="TableValuedFunctionParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="FunctionParameters" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/> <Node Name="TableValuedFunctionParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="FunctionParameters" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/>
@@ -291,13 +291,13 @@
</Filter> </Filter>
</Filters> </Filters>
</Node> </Node>
<Node Name="ScalarValuedFunctionInstance" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails"> <Node Name="ScalarValuedFunction" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails">
<Child Name="ScalarValuedFunctionParameters"/> <Child Name="ScalarValuedFunctionParameters"/>
</Node> </Node>
<Node Name="ScalarValuedFunctionParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="FunctionParameters" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/> <Node Name="ScalarValuedFunctionParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="FunctionParameters" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/>
<Node Name="AggregateFunctions" LocLabel="SR.SchemaHierarchy_AggregateFunctions" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlUserDefinedAggregate" TreeNode="AggregateFunctionInstanceTreeNode" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|SqlvNext|AzureV12"/> <Node Name="AggregateFunctions" LocLabel="SR.SchemaHierarchy_AggregateFunctions" BaseClass="ModelBased" Strategy="MultipleElementsOfType" ChildQuerierTypes="SqlUserDefinedAggregate" TreeNode="AggregateFunctionInstanceTreeNode" ValidFor="Sql2005|Sql2008|Sql2012|Sql2014|Sql2016|SqlvNext|AzureV12"/>
<Node Name="AggregateFunctionInstance" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails"> <Node Name="AggregateFunction" LocLabel="string.Empty" BaseClass="ModelBased" ChildQuerierTypes="" IsAsyncLoad="" Strategy="PopulateDetails">
<Child Name="AggregateFunctionParameters"/> <Child Name="AggregateFunctionParameters"/>
</Node> </Node>
<Node Name="AggregateFunctionParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="PopulateParentDetails" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/> <Node Name="AggregateFunctionParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="PopulateParentDetails" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/>

View File

@@ -12,8 +12,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public DatabaseInstanceTreeNode() : base() public DatabaseInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "DatabaseInstance"; this.NodeType = "Database";
this.NodeTypeId = NodeTypes.DatabaseInstance; this.NodeTypeId = NodeTypes.Database;
OnInitialize(); OnInitialize();
} }
} }
@@ -23,8 +23,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public TableInstanceTreeNode() : base() public TableInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "TableInstance"; this.NodeType = "Table";
this.NodeTypeId = NodeTypes.TableInstance; this.NodeTypeId = NodeTypes.Table;
OnInitialize(); OnInitialize();
} }
} }
@@ -34,8 +34,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public ViewInstanceTreeNode() : base() public ViewInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "ViewInstance"; this.NodeType = "View";
this.NodeTypeId = NodeTypes.ViewInstance; this.NodeTypeId = NodeTypes.View;
OnInitialize(); OnInitialize();
} }
} }
@@ -45,8 +45,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public UserDefinedTableTypeInstanceTreeNode() : base() public UserDefinedTableTypeInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "UserDefinedTableTypeInstance"; this.NodeType = "UserDefinedTableType";
this.NodeTypeId = NodeTypes.UserDefinedTableTypeInstance; this.NodeTypeId = NodeTypes.UserDefinedTableType;
OnInitialize(); OnInitialize();
} }
} }
@@ -56,8 +56,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public StoredProcedureInstanceTreeNode() : base() public StoredProcedureInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "StoredProcedureInstance"; this.NodeType = "StoredProcedure";
this.NodeTypeId = NodeTypes.StoredProcedureInstance; this.NodeTypeId = NodeTypes.StoredProcedure;
OnInitialize(); OnInitialize();
} }
} }
@@ -67,8 +67,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public TableValuedFunctionInstanceTreeNode() : base() public TableValuedFunctionInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "TableValuedFunctionInstance"; this.NodeType = "TableValuedFunction";
this.NodeTypeId = NodeTypes.TableValuedFunctionInstance; this.NodeTypeId = NodeTypes.TableValuedFunction;
OnInitialize(); OnInitialize();
} }
} }
@@ -78,8 +78,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public ScalarValuedFunctionInstanceTreeNode() : base() public ScalarValuedFunctionInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "ScalarValuedFunctionInstance"; this.NodeType = "ScalarValuedFunction";
this.NodeTypeId = NodeTypes.ScalarValuedFunctionInstance; this.NodeTypeId = NodeTypes.ScalarValuedFunction;
OnInitialize(); OnInitialize();
} }
} }
@@ -89,8 +89,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public AggregateFunctionInstanceTreeNode() : base() public AggregateFunctionInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "AggregateFunctionInstance"; this.NodeType = "AggregateFunction";
this.NodeTypeId = NodeTypes.AggregateFunctionInstance; this.NodeTypeId = NodeTypes.AggregateFunction;
OnInitialize(); OnInitialize();
} }
} }
@@ -111,8 +111,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public ExternalTableInstanceTreeNode() : base() public ExternalTableInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "ExternalTableInstance"; this.NodeType = "ExternalTable";
this.NodeTypeId = NodeTypes.ExternalTableInstance; this.NodeTypeId = NodeTypes.ExternalTable;
OnInitialize(); OnInitialize();
} }
} }
@@ -122,8 +122,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public ExternalResourceInstanceTreeNode() : base() public ExternalResourceInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "ExternalResourceInstance"; this.NodeType = "ExternalResource";
this.NodeTypeId = NodeTypes.ExternalResourceInstance; this.NodeTypeId = NodeTypes.ExternalResource;
OnInitialize(); OnInitialize();
} }
} }
@@ -133,8 +133,8 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
public HistoryTableInstanceTreeNode() : base() public HistoryTableInstanceTreeNode() : base()
{ {
NodeValue = string.Empty; NodeValue = string.Empty;
this.NodeType = "HistoryTableInstance"; this.NodeType = "HistoryTable";
this.NodeTypeId = NodeTypes.HistoryTableInstance; this.NodeTypeId = NodeTypes.HistoryTable;
OnInitialize(); OnInitialize();
} }
} }
@@ -143,7 +143,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class ServerInstanceChildFactory : SmoChildFactoryBase internal partial class ServerInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "ServerInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "Server" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -578,7 +578,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class DatabaseInstanceChildFactory : SmoChildFactoryBase internal partial class DatabaseInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "DatabaseInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "Database" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -1147,7 +1147,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class TableInstanceChildFactory : SmoChildFactoryBase internal partial class TableInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "TableInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "Table" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -1209,7 +1209,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class HistoryTableInstanceChildFactory : SmoChildFactoryBase internal partial class HistoryTableInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "HistoryTableInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "HistoryTable" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -1254,7 +1254,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class ExternalTableInstanceChildFactory : SmoChildFactoryBase internal partial class ExternalTableInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "ExternalTableInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "ExternalTable" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -1454,7 +1454,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class ViewInstanceChildFactory : SmoChildFactoryBase internal partial class ViewInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "ViewInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "View" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -1875,7 +1875,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class UserDefinedTableTypeInstanceChildFactory : SmoChildFactoryBase internal partial class UserDefinedTableTypeInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "UserDefinedTableTypeInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "UserDefinedTableType" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -2297,7 +2297,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class StoredProcedureInstanceChildFactory : SmoChildFactoryBase internal partial class StoredProcedureInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "StoredProcedureInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "StoredProcedure" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -2375,7 +2375,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class TableValuedFunctionInstanceChildFactory : SmoChildFactoryBase internal partial class TableValuedFunctionInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "TableValuedFunctionInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "TableValuedFunction" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -2453,7 +2453,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class ScalarValuedFunctionInstanceChildFactory : SmoChildFactoryBase internal partial class ScalarValuedFunctionInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "ScalarValuedFunctionInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "ScalarValuedFunction" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {
@@ -2531,7 +2531,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
[Shared] [Shared]
internal partial class AggregateFunctionInstanceChildFactory : SmoChildFactoryBase internal partial class AggregateFunctionInstanceChildFactory : SmoChildFactoryBase
{ {
public override IEnumerable<string> ApplicableParents() { return new[] { "AggregateFunctionInstance" }; } public override IEnumerable<string> ApplicableParents() { return new[] { "AggregateFunction" }; }
protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent) protected override void OnExpandPopulateFolders(IList<TreeNode> currentChildren, TreeNode parent)
{ {

View File

@@ -50,7 +50,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
Assert.NotNull(session.Root); Assert.NotNull(session.Root);
NodeInfo nodeInfo = session.Root.ToNodeInfo(); NodeInfo nodeInfo = session.Root.ToNodeInfo();
Assert.Equal(nodeInfo.IsLeaf, false); Assert.Equal(nodeInfo.IsLeaf, false);
Assert.Equal(nodeInfo.NodeType, NodeTypes.ServerInstance.ToString()); Assert.Equal(nodeInfo.NodeType, NodeTypes.Server.ToString());
var children = session.Root.Expand(); var children = session.Root.Expand();
//All server children should be folder nodes //All server children should be folder nodes
@@ -61,7 +61,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
var databasesRoot = children.FirstOrDefault(x => x.NodeTypeId == NodeTypes.Databases); var databasesRoot = children.FirstOrDefault(x => x.NodeTypeId == NodeTypes.Databases);
var databasesChildren = await _service.ExpandNode(session, databasesRoot.GetNodePath()); var databasesChildren = await _service.ExpandNode(session, databasesRoot.GetNodePath());
var databases = databasesChildren.Where(x => x.NodeType == NodeTypes.DatabaseInstance.ToString()); var databases = databasesChildren.Where(x => x.NodeType == NodeTypes.Database.ToString());
//Verify the test databases is in the list //Verify the test databases is in the list
Assert.NotNull(databases); Assert.NotNull(databases);
@@ -85,15 +85,29 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.ObjectExplorer
{ {
var children = await _service.ExpandNode(session, node.NodePath); var children = await _service.ExpandNode(session, node.NodePath);
Assert.NotNull(children); Assert.NotNull(children);
if(children.Count() == 0 && !node.NodePath.Contains("System") && if(!node.NodePath.Contains("System") &&
!node.NodePath.Contains("FileTables") && !node.NodePath.Contains("External Tables")) !node.NodePath.Contains("FileTables") && !node.NodePath.Contains("External Tables"))
{ {
var labaleToUpper = node.Label.ToUpper(); var labaleToUpper = node.Label.ToUpper();
if (labaleToUpper.Contains("TABLE") || labaleToUpper.Contains("StoredProcedure") if (labaleToUpper.Contains("TABLE") || labaleToUpper.Contains("StoredProcedure")
|| labaleToUpper.Contains("VIEW")) || labaleToUpper.Contains("VIEW"))
{ {
//TOOD: Add a better validation. For now at least check tables not to be empty foreach (var child in children)
//Assert.True(false, "The list of tables, procedure and views cannot be empty"); {
if (child.NodeType != "Folder")
{
Assert.NotNull(child.Metadata);
if (!string.IsNullOrEmpty(child.Metadata.Schema))
{
Assert.Equal($"{child.Metadata.Schema}.{child.Metadata.Name}", child.Label);
}
else
{
Assert.Equal(child.Metadata.Name, child.Label);
}
}
}
} }
} }
foreach (var child in children) foreach (var child in children)

View File

@@ -75,7 +75,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
+ defaultConnectionDetails.UserName + ")"; + defaultConnectionDetails.UserName + ")";
Assert.Equal(expectedLabel, node.Label); Assert.Equal(expectedLabel, node.Label);
Assert.Equal(NodeTypes.ServerInstance.ToString(), node.NodeType); Assert.Equal(NodeTypes.Server.ToString(), node.NodeType);
string[] nodePath = node.GetNodePath().Split(TreeNode.PathPartSeperator); string[] nodePath = node.GetNodePath().Split(TreeNode.PathPartSeperator);
Assert.Equal(1, nodePath.Length); Assert.Equal(1, nodePath.Length);
Assert.Equal(defaultConnectionDetails.ServerName, nodePath[0]); Assert.Equal(defaultConnectionDetails.ServerName, nodePath[0]);

View File

@@ -103,7 +103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ObjectExplorer
private void VerifyServerNode(NodeInfo serverNode, ConnectionDetails details) private void VerifyServerNode(NodeInfo serverNode, ConnectionDetails details)
{ {
Assert.NotNull(serverNode); Assert.NotNull(serverNode);
Assert.Equal(NodeTypes.ServerInstance.ToString(), serverNode.NodeType); Assert.Equal(NodeTypes.Server.ToString(), serverNode.NodeType);
string[] pathParts = serverNode.NodePath.Split(TreeNode.PathPartSeperator); string[] pathParts = serverNode.NodePath.Split(TreeNode.PathPartSeperator);
Assert.Equal(1, pathParts.Length); Assert.Equal(1, pathParts.Length);
Assert.Equal(details.ServerName, pathParts[0]); Assert.Equal(details.ServerName, pathParts[0]);

View File

@@ -193,7 +193,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.ServiceHost
var schemaHierarchySearchPropertyLists = SR.SchemaHierarchy_SearchPropertyLists; var schemaHierarchySearchPropertyLists = SR.SchemaHierarchy_SearchPropertyLists;
var schemaHierarchyColumnStoreIndexes = SR.SchemaHierarchy_ColumnStoreIndexes; var schemaHierarchyColumnStoreIndexes = SR.SchemaHierarchy_ColumnStoreIndexes;
var schemaHierarchyTableTypeIndexes = SR.SchemaHierarchy_TableTypeIndexes; var schemaHierarchyTableTypeIndexes = SR.SchemaHierarchy_TableTypeIndexes;
var schemaHierarchyServerInstance = SR.SchemaHierarchy_ServerInstance; var schemaHierarchyServerInstance = SR.SchemaHierarchy_Server;
var schemaHierarchySelectiveXmlIndexes = SR.SchemaHierarchy_SelectiveXmlIndexes; var schemaHierarchySelectiveXmlIndexes = SR.SchemaHierarchy_SelectiveXmlIndexes;
var schemaHierarchyXmlNamespaces = SR.SchemaHierarchy_XmlNamespaces; var schemaHierarchyXmlNamespaces = SR.SchemaHierarchy_XmlNamespaces;
var schemaHierarchyXmlTypedPromotedPaths = SR.SchemaHierarchy_XmlTypedPromotedPaths; var schemaHierarchyXmlTypedPromotedPaths = SR.SchemaHierarchy_XmlTypedPromotedPaths;

View File

@@ -7,6 +7,8 @@ using System.Globalization;
using Xunit; using Xunit;
using ServiceLayerSr = Microsoft.SqlTools.ServiceLayer.Localization.sr; using ServiceLayerSr = Microsoft.SqlTools.ServiceLayer.Localization.sr;
using HostingSr = Microsoft.SqlTools.Hosting.Localization.sr;
using CredentialSr = Microsoft.SqlTools.Credentials.Localization.sr;
namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
{ {
@@ -23,7 +25,6 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.Utility
Assert.NotNull(SR.QueryServiceFileWrapperNotInitialized); Assert.NotNull(SR.QueryServiceFileWrapperNotInitialized);
Assert.NotNull(SR.QueryServiceColumnNull); Assert.NotNull(SR.QueryServiceColumnNull);
var sr = new ServiceLayerSr();
Assert.NotNull(ServiceLayerSr.ResourceManager); Assert.NotNull(ServiceLayerSr.ResourceManager);
ServiceLayerSr.Culture = CultureInfo.CurrentCulture; ServiceLayerSr.Culture = CultureInfo.CurrentCulture;
Assert.NotNull(ServiceLayerSr.Culture); Assert.NotNull(ServiceLayerSr.Culture);