Skip to content

Commit

Permalink
adding metadata to object explorer node info (#320)
Browse files Browse the repository at this point in the history
* adding metadata to oe node info
  • Loading branch information
llali committed Apr 19, 2017
1 parent 96d46b5 commit 8c0885d
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 81 deletions.
6 changes: 3 additions & 3 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2053,11 +2053,11 @@ public static string SchemaHierarchy_TableTypeIndexes
}
}

public static string SchemaHierarchy_ServerInstance
public static string SchemaHierarchy_Server
{
get
{
return Keys.GetString(Keys.SchemaHierarchy_ServerInstance);
return Keys.GetString(Keys.SchemaHierarchy_Server);
}
}

Expand Down Expand Up @@ -3036,7 +3036,7 @@ public class Keys
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";
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1199,8 +1199,8 @@
<value>Table Type Indexes</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_ServerInstance" xml:space="preserve">
<value>ServerInstance</value>
<data name="SchemaHierarchy_Server" xml:space="preserve">
<value>Server</value>
<comment></comment>
</data>
<data name="SchemaHierarchy_SelectiveXmlIndexes" xml:space="preserve">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ SchemaHierarchy_ColumnStoreIndexes = Column Store Indexes

SchemaHierarchy_TableTypeIndexes = Table Type Indexes

SchemaHierarchy_ServerInstance = ServerInstance
SchemaHierarchy_Server = Server

SchemaHierarchy_SelectiveXmlIndexes = Selective XML Indexes

Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.SqlTools.ServiceLayer/Localization/sr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1351,11 +1351,6 @@
<target state="new">Table Type Indexes</target>
<note></note>
</trans-unit>
<trans-unit id="SchemaHierarchy_ServerInstance">
<source>ServerInstance</source>
<target state="new">ServerInstance</target>
<note></note>
</trans-unit>
<trans-unit id="SchemaHierarchy_SelectiveXmlIndexes">
<source>Selective XML Indexes</source>
<target state="new">Selective XML Indexes</target>
Expand Down Expand Up @@ -1416,6 +1411,11 @@
<target state="new">Column Encryption Keys</target>
<note></note>
</trans-unit>
<trans-unit id="SchemaHierarchy_Server">
<source>Server</source>
<target state="new">Server</target>
<note></note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// 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
{
/// <summary>
Expand Down Expand Up @@ -36,5 +38,10 @@ public class NodeInfo
/// is it expandable?
/// </summary>
public bool IsLeaf { get; set; }

/// <summary>
/// Object Metadata for smo objects to be used for scripting
/// </summary>
public ObjectMetadata Metadata { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ public enum NodeTypes
{
None,
SqlServersRoot,
DatabaseInstance,
DacInstance,
ServerInstance,
ScalarValuedFunctionInstance,
TableValuedFunctionInstance,
AggregateFunctionInstance,
Database,
Server,
ScalarValuedFunction,
TableValuedFunction,
AggregateFunction,
FileGroupInstance,
StoredProcedureInstance,
UserDefinedTableTypeInstance,
ViewInstance,
TableInstance,
HistoryTableInstance,
StoredProcedure,
UserDefinedTableType,
View,
Table,
HistoryTable,
Databases,
ExternalResources,
ServerLevelSecurity,
Expand Down Expand Up @@ -130,10 +129,10 @@ public enum NodeTypes
SecurityPolicies,
DatabaseScopedCredentials,
ExternalTables,
ExternalResourceInstance,
ExternalResource,
ExternalDataSources,
ExternalFileFormats,
ExternalTableInstance,
ExternalTable,
AlwaysEncryptedKeys,
ColumnMasterKeys,
ColumnEncryptionKeys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using Microsoft.SqlTools.ServiceLayer.Metadata.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Contracts;
using Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel;
using Microsoft.SqlTools.Utility;
Expand Down Expand Up @@ -52,6 +52,12 @@ public TreeNode(string value)
/// </summary>
public string NodeValue { get; set; }


/// <summary>
/// Object metadata for smo objects
/// </summary>
public ObjectMetadata ObjectMetadata { get; set; }

/// <summary>
/// The type of the node - for example Server, Database, Folder, Table
/// </summary>
Expand Down Expand Up @@ -170,7 +176,8 @@ public NodeInfo ToNodeInfo()
IsLeaf = this.IsAlwaysLeaf,
Label = this.Label,
NodePath = this.GetNodePath(),
NodeType = this.NodeType
NodeType = this.NodeType,
Metadata = this.ObjectMetadata
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public ServerNode(ConnectionCompleteParams connInfo, IMultiServiceProvider servi

NodeValue = connectionSummary.ServerName;
IsAlwaysLeaf = false;
NodeType = NodeTypes.ServerInstance.ToString();
NodeTypeId = NodeTypes.ServerInstance;
NodeType = NodeTypes.Server.ToString();
NodeTypeId = NodeTypes.Server;
Label = GetConnectionLabel();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ public virtual void CacheInfoFromModel(NamedSmoObject smoObject)
{
SmoObject = smoObject;
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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<ServerExplorerTree>
<Node Name="ServerInstance" LocLabel="SR.SchemaHierarchy_ServerInstance" Image="Server">
<Node Name="Server" LocLabel="SR.SchemaHierarchy_ServerInstance" Image="Server">
<Child Name="Databases"/>
<Child Name="ServerLevelSecurity"/>
<Child Name="ServerLevelServerObjects"/>
Expand Down Expand Up @@ -49,7 +49,7 @@
<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="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="Views"/>
<Child Name="Synonyms"/>
Expand Down Expand Up @@ -142,7 +142,7 @@
</Filters>
</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.-->
<Filters>
<Filter Property="TemporalType" Type="Enum" ValidFor="Sql2016|SqlvNext|AzureV12">
Expand All @@ -158,14 +158,14 @@
</Node>

<!-- 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="Indexes"/>
<Child Name="Statistics"/>
</Node>

<!-- 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="Statistics"/>
</Node>
Expand All @@ -192,7 +192,7 @@

<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="Triggers"/>
<Child Name="Indexes"/>
Expand Down Expand Up @@ -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="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="UserDefinedTableTypeKeys"/>
<Child Name="UserDefinedTableTypeConstraints"/>
Expand Down Expand Up @@ -267,7 +267,7 @@
<Child Name="SystemStoredProcedures"/>
</Node>
<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"/>
</Node>
<Node Name="StoredProcedureParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="StoredProcedureParameters" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/>
Expand All @@ -279,7 +279,7 @@
</Filter>
</Filters>
</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"/>
</Node>
<Node Name="TableValuedFunctionParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="FunctionParameters" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/>
Expand All @@ -291,13 +291,13 @@
</Filter>
</Filters>
</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"/>
</Node>
<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="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"/>
</Node>
<Node Name="AggregateFunctionParameters" LocLabel="SR.SchemaHierarchy_Parameters" BaseClass="ModelBased" Strategy="PopulateParentDetails" ChildQuerierTypes="SqlSubroutineParameter" DisableSort=""/>
Expand Down
Loading

0 comments on commit 8c0885d

Please sign in to comment.