Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/DynamoDS/Dynamo
Browse files Browse the repository at this point in the history
  • Loading branch information
zeusongit committed Jun 25, 2024
2 parents dd3f613 + 8000da9 commit 52163ec
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 16 deletions.
261 changes: 261 additions & 0 deletions doc/distrib/NodeHelpFiles/DSCore.Data.StringifyJSON.dyn
Original file line number Diff line number Diff line change
@@ -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
}
}
10 changes: 8 additions & 2 deletions src/DynamoCore/Configuration/LuceneConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@ public enum NodeFieldsEnum
/// <summary>
/// Node Input Parameters as string (there are nodes with same name and category but different parameters)
/// </summary>
Parameters
Parameters,

/// <summary>
/// Package author name
/// </summary>
Author
}

/// <summary>
Expand All @@ -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)};
}
}
19 changes: 11 additions & 8 deletions src/DynamoCore/Utilities/LuceneSearchUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -294,8 +295,9 @@ private bool IsMatchingCategory(string term, string FullCategoryName)
/// </summary>
/// <param name="fields">All fields to be searched in.</param>
/// <param name="SearchTerm">Search key to be searched for.</param>
/// <param name="IsPackageContext">Set this to true if the search context is packages instead of nodes.</param>
/// <returns></returns>
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;
Expand All @@ -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;

Expand Down
15 changes: 12 additions & 3 deletions src/DynamoCoreWpf/ViewModels/Core/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -1457,7 +1458,7 @@ internal IEnumerable<PackageManagerSearchElementViewModel> 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);
Expand Down
Loading

0 comments on commit 52163ec

Please sign in to comment.