diff --git a/doc/distrib/NodeHelpFiles/DSCore.Data.StringifyJSON.dyn b/doc/distrib/NodeHelpFiles/DSCore.Data.StringifyJSON.dyn new file mode 100644 index 00000000000..de03556678d --- /dev/null +++ b/doc/distrib/NodeHelpFiles/DSCore.Data.StringifyJSON.dyn @@ -0,0 +1,261 @@ +{ + "Uuid": "a19b2b4a-e4e6-43ab-9b41-f8d218bff28f", + "IsCustomNode": false, + "Description": "", + "Name": "Data.StringifyJSON", + "ElementResolver": { + "ResolutionMap": {} + }, + "Inputs": [], + "Outputs": [], + "Nodes": [ + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "DesignScript.Builtin.Dictionary.ByKeysValues@string[],var[]..[]", + "Id": "08f18916a7274fd2a3e8753422a18e1a", + "Inputs": [ + { + "Id": "15888aa5c92f4333b62381dc53a7943c", + "Name": "keys", + "Description": "Keys of dictionary\n\nstring[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "42754d17caba405f91710b253359e15a", + "Name": "values", + "Description": "Values of dictionary\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "87b8a691c8c3405aa89ab3d99bdee921", + "Name": "dictionary", + "Description": "Dictionary from keys and values", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Produces a Dictionary with the supplied keys and values. The number of entries is the shorter of keys or values.\n\nDictionary.ByKeysValues (keys: string[], values: var[]..[]): Dictionary" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.CodeBlockNodeModel, DynamoCore", + "NodeType": "CodeBlockNode", + "Code": "\"A\"..\"D\";\n0..3;", + "Id": "16349b6e899c4961b645729302c1feee", + "Inputs": [], + "Outputs": [ + { + "Id": "530cd82e9aaa40cab0aa11f7245e0fb6", + "Name": "", + "Description": "Value of expression at line 1", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + }, + { + "Id": "dc60e8406abe4289b8c27a81c73d84c3", + "Name": "", + "Description": "Value of expression at line 2", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Allows for DesignScript code to be authored directly" + }, + { + "ConcreteType": "Dynamo.Graph.Nodes.ZeroTouch.DSFunction, DynamoCore", + "NodeType": "FunctionNode", + "FunctionSignature": "DSCore.Data.StringifyJSON@var[]..[]", + "Id": "ceed8248f93f4a86bfa249c89dd13ddd", + "Inputs": [ + { + "Id": "8da1bd44f34a4e189c4f1afb1784d3aa", + "Name": "values", + "Description": "A List of values\n\nvar[]..[]", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "f869adbd6b19402cab5d19af05682d69", + "Name": "json", + "Description": "A JSON string where primitive types (e.g. double, int, boolean), Lists, and Dictionary's will be turned into the associated JSON type.", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Auto", + "Description": "Stringify converts an arbitrary value or a list of arbitrary values to JSON. Replication can be used to apply the operation over a list, producing a list of JSON strings.\n\nData.StringifyJSON (values: var[]..[]): string" + }, + { + "ConcreteType": "CoreNodeModels.Watch, CoreNodeModels", + "NodeType": "ExtensionNode", + "Id": "20b9b006868043fa9ab6447d34bb8014", + "Inputs": [ + { + "Id": "466a71719ebc456d9bdc61a7431926f0", + "Name": "", + "Description": "Node to show output from", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Outputs": [ + { + "Id": "92acce7c82484473ad6afe0e50b00def", + "Name": "", + "Description": "Node output", + "UsingDefaultValue": false, + "Level": 2, + "UseLevels": false, + "KeepListStructure": false + } + ], + "Replication": "Disabled", + "Description": "Visualize the node's output" + } + ], + "Connectors": [ + { + "Start": "87b8a691c8c3405aa89ab3d99bdee921", + "End": "8da1bd44f34a4e189c4f1afb1784d3aa", + "Id": "5c7fb247548744779a017f1597421a93", + "IsHidden": "False" + }, + { + "Start": "530cd82e9aaa40cab0aa11f7245e0fb6", + "End": "15888aa5c92f4333b62381dc53a7943c", + "Id": "5c842cd89ac24619ae8a0995c359da5b", + "IsHidden": "False" + }, + { + "Start": "dc60e8406abe4289b8c27a81c73d84c3", + "End": "42754d17caba405f91710b253359e15a", + "Id": "15250526e77c426a9da27e2b78595eea", + "IsHidden": "False" + }, + { + "Start": "f869adbd6b19402cab5d19af05682d69", + "End": "466a71719ebc456d9bdc61a7431926f0", + "Id": "db18b1f8bc994b5596fa71c15accc03c", + "IsHidden": "False" + } + ], + "Dependencies": [], + "NodeLibraryDependencies": [], + "Thumbnail": "", + "GraphDocumentationURL": null, + "ExtensionWorkspaceData": [ + { + "ExtensionGuid": "28992e1d-abb9-417f-8b1b-05e053bee670", + "Name": "Properties", + "Version": "2.14", + "Data": {} + }, + { + "ExtensionGuid": "DFBD9CC0-DB40-457A-939E-8C8555555A9D", + "Name": "Generative Design", + "Version": "2.0", + "Data": {} + } + ], + "Author": "", + "Linting": { + "activeLinter": "None", + "activeLinterId": "7b75fb44-43fd-4631-a878-29f4d5d8399a", + "warningCount": 0, + "errorCount": 0 + }, + "Bindings": [], + "View": { + "Dynamo": { + "ScaleFactor": 1.0, + "HasRunWithoutCrash": true, + "IsVisibleInDynamoLibrary": true, + "Version": "2.13.1.3887", + "RunType": "Manual", + "RunPeriod": "1000" + }, + "Camera": { + "Name": "Background Preview", + "EyeX": -17.0, + "EyeY": 24.0, + "EyeZ": 50.0, + "LookX": 12.0, + "LookY": -13.0, + "LookZ": -58.0, + "UpX": 0.0, + "UpY": 1.0, + "UpZ": 0.0 + }, + "ConnectorPins": [], + "NodeViews": [ + { + "Name": "Dictionary.ByKeysValues", + "ShowGeometry": true, + "Id": "08f18916a7274fd2a3e8753422a18e1a", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 651.2, + "Y": 248.8 + }, + { + "Name": "Code Block", + "ShowGeometry": true, + "Id": "16349b6e899c4961b645729302c1feee", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 396.8, + "Y": 248.8 + }, + { + "Name": "Data.StringifyJSON", + "ShowGeometry": true, + "Id": "ceed8248f93f4a86bfa249c89dd13ddd", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 1008.8, + "Y": 248.8 + }, + { + "Name": "Watch", + "ShowGeometry": true, + "Id": "20b9b006868043fa9ab6447d34bb8014", + "IsSetAsInput": false, + "IsSetAsOutput": false, + "Excluded": false, + "X": 1326.4, + "Y": 248.79999999999998 + } + ], + "Annotations": [], + "X": -247.20000000000005, + "Y": -50.400000000000034, + "Zoom": 1.0 + } +} \ No newline at end of file diff --git a/src/DynamoCore/Configuration/LuceneConfig.cs b/src/DynamoCore/Configuration/LuceneConfig.cs index b894de80c29..363bce391aa 100644 --- a/src/DynamoCore/Configuration/LuceneConfig.cs +++ b/src/DynamoCore/Configuration/LuceneConfig.cs @@ -185,7 +185,12 @@ public enum NodeFieldsEnum /// /// Node Input Parameters as string (there are nodes with same name and category but different parameters) /// - Parameters + Parameters, + + /// + /// Package author name + /// + Author } /// @@ -208,6 +213,7 @@ public enum NodeFieldsEnum public static string[] PackageIndexFields = { nameof(NodeFieldsEnum.Name), nameof(NodeFieldsEnum.Description), nameof(NodeFieldsEnum.SearchKeywords), - nameof(NodeFieldsEnum.Hosts)}; + nameof(NodeFieldsEnum.Hosts), + nameof(NodeFieldsEnum.Author)}; } } diff --git a/src/DynamoCore/Utilities/LuceneSearchUtility.cs b/src/DynamoCore/Utilities/LuceneSearchUtility.cs index 77cc6d85880..4224c63e878 100644 --- a/src/DynamoCore/Utilities/LuceneSearchUtility.cs +++ b/src/DynamoCore/Utilities/LuceneSearchUtility.cs @@ -214,10 +214,11 @@ internal Document InitializeIndexDocumentForPackages() var description = new TextField(nameof(LuceneConfig.NodeFieldsEnum.Description), string.Empty, Field.Store.YES); var keywords = new TextField(nameof(LuceneConfig.NodeFieldsEnum.SearchKeywords), string.Empty, Field.Store.YES); var hosts = new TextField(nameof(LuceneConfig.NodeFieldsEnum.Hosts), string.Empty, Field.Store.YES); + var author = new TextField(nameof(LuceneConfig.NodeFieldsEnum.Author), string.Empty, Field.Store.YES); var d = new Document() { - name, description, keywords, hosts + name, description, keywords, hosts, author }; return d; } @@ -294,8 +295,9 @@ private bool IsMatchingCategory(string term, string FullCategoryName) /// /// All fields to be searched in. /// Search key to be searched for. + /// Set this to true if the search context is packages instead of nodes. /// - internal string CreateSearchQuery(string[] fields, string SearchTerm) + internal string CreateSearchQuery(string[] fields, string SearchTerm, bool IsPackageContext = false) { //By Default the search will be normal SearchType searchType = SearchType.Normal; @@ -314,12 +316,13 @@ internal string CreateSearchQuery(string[] fields, string SearchTerm) var booleanQuery = new BooleanQuery(); string searchTerm = QueryParser.Escape(SearchTerm); - if (searchTerm.Contains('.')) - searchType = SearchType.ByCategory; - else if (searchTerm.Contains(' ')) - hasEmptySpaces = true; - else - searchType = SearchType.Normal; + if (!IsPackageContext) + { + if (searchTerm.Contains('.')) + searchType = SearchType.ByCategory; + else if (searchTerm.Contains(' ')) + hasEmptySpaces = true; + } var trimmedSearchTerm = hasEmptySpaces == true ? searchTerm.Replace(" ", "") : searchTerm; diff --git a/src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs b/src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs index c1828344520..97bf0f56d72 100644 --- a/src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs +++ b/src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs @@ -174,8 +174,17 @@ internal void BeginConnection(Guid nodeId, int portIndex, PortType portType) { bool isInPort = portType == PortType.Input; - if (!(Model.GetModelInternal(nodeId) is NodeModel node)) return; - PortModel portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex]; + if (Model.GetModelInternal(nodeId) is not NodeModel node) return; + PortModel portModel; + try + { + portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex]; + } + catch(Exception ex) + { + this.DynamoViewModel.Model.Logger.Log("Failed to make connection: " + ex.Message); + return; + } // Test if port already has a connection, if so grab it and begin connecting // to somewhere else (we don't allow the grabbing of the start connector). @@ -197,7 +206,7 @@ internal void BeginConnection(Guid nodeId, int portIndex, PortType portType) } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine(ex.Message); + this.DynamoViewModel.Model.Logger.Log(ex.Message); } } } diff --git a/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs b/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs index 84776f6f74f..383a0994fbe 100644 --- a/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/PackageManager/PackageManagerSearchViewModel.cs @@ -593,6 +593,7 @@ internal void AddPackageToSearchIndex(PackageManagerSearchElement package, Docum LuceneUtility.SetDocumentFieldValue(doc, nameof(LuceneConfig.NodeFieldsEnum.Name), package.Name); LuceneUtility.SetDocumentFieldValue(doc, nameof(LuceneConfig.NodeFieldsEnum.Description), package.Description); + LuceneUtility.SetDocumentFieldValue(doc, nameof(LuceneConfig.NodeFieldsEnum.Author), package.Maintainers); if (package.Keywords.Length > 0) { @@ -1457,7 +1458,7 @@ internal IEnumerable Search(string searchT FuzzyMinSim = LuceneConfig.MinimumSimilarity }; - Query query = parser.Parse(LuceneUtility.CreateSearchQuery(LuceneConfig.PackageIndexFields, searchTerm)); + Query query = parser.Parse(LuceneUtility.CreateSearchQuery(LuceneConfig.PackageIndexFields, searchTerm, true)); //indicate we want the first 50 results TopDocs topDocs = LuceneUtility.Searcher.Search(query, n: LuceneConfig.DefaultResultsCount); diff --git a/test/DynamoCoreWpfTests/PackageManager/PackageManagerSearchElementViewModelTests.cs b/test/DynamoCoreWpfTests/PackageManager/PackageManagerSearchElementViewModelTests.cs index 8ae630e8e3c..29ef0653d92 100644 --- a/test/DynamoCoreWpfTests/PackageManager/PackageManagerSearchElementViewModelTests.cs +++ b/test/DynamoCoreWpfTests/PackageManager/PackageManagerSearchElementViewModelTests.cs @@ -537,8 +537,8 @@ public void PackageSearchDialogSearchTestDependencyFilters() packageManagerSearchViewModel.NonHostFilter[3].FilterCommand.Execute(string.Empty); Assert.IsFalse(packageManagerSearchViewModel.NonHostFilter[4].OnChecked); } - - /// + + /// /// This unit test will validate that we can search packages in different languages and they will be found. /// [Test] @@ -549,6 +549,7 @@ public void PackageSearchDialogSearchDifferentLanguage() string packageVersionNumber = "1.0.0.0"; string packageCreatedDateString = "2016 - 12 - 02T13:13:20.135000 + 00:00"; string formItFilterName = "FormIt"; + var packageMaintainer = new User(){ username = "DynamoTest", _id = "90-63-17" }; //Packages list List packagesNameDifferentLanguages = new List { "paquete", "упаковка", "包裹" }; @@ -579,6 +580,7 @@ public void PackageSearchDialogSearchDifferentLanguage() name = package, versions = new List { tmpPackageVersion }, host_dependencies = new List { formItFilterName }, + maintainers = new List { packageMaintainer }, }), false); packageManagerSearchViewModel.AddToSearchResults(tmpPackage); }