Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
80 lines (67 loc) · 2.94 KB

File metadata and controls

80 lines (67 loc) · 2.94 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.Linq;
namespace QueryTree.Engine
{
public class Query
{
private List<NodeBase> Nodes;
public Query(DatabaseType type, string queryJson, IList<ITableInfo> tables)
{
var nodeSettings = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(queryJson);
Nodes = new List<NodeBase>();
Nodes.AddRange(nodeSettings.Select(ns => CreateNode(ns, tables, type)));
foreach (var node in Nodes.Where(n => (n is DataProcessorNode)))
{
var inputDict = Nodes.Where(n => (node as DataProcessorNode).Inputs.Contains(n.ClientId)).ToDictionary(n => n.ClientId);
(node as DataProcessorNode).InputDict = inputDict;
}
foreach (var node in Nodes.Where(n => (n is IRequireConfiguration)))
{
(node as IRequireConfiguration).Configure(tables);
}
}
private NodeBase CreateNode(Dictionary<string, object> nodeSettings, IList<ITableInfo> tables, DatabaseType type)
{
NodeBase n = null;
// map the node_settings["Type"] to a node class
if (nodeSettings["Type"].ToString() == "Data Table")
n = new DatabaseTableNode();
else if (nodeSettings["Type"].ToString() == "Sort")
n = new SortNode();
else if (nodeSettings["Type"].ToString() == "Select")
n = new SelectNode();
else if (nodeSettings["Type"].ToString() == "Filter")
n = new FilterNode();
else if (nodeSettings["Type"].ToString() == "Join")
n = new JoinNode();
else if (nodeSettings["Type"].ToString() == "Summarize")
n = new SummarizeNode();
else if (nodeSettings["Type"].ToString() == "Append")
n = new AppendNode();
else if (nodeSettings["Type"].ToString() == "Bar Chart" || nodeSettings["Type"].ToString() == "Line Chart" || nodeSettings["Type"].ToString() == "Pie Chart")
n = new GraphNode();
else if (nodeSettings["Type"].ToString() == "Extract")
n = new ExtractNode();
if (n != null)
{
n.ClientId = (string)nodeSettings["Id"];
n.DatabaseType = type;
// let this node setup update its settings
n.UpdateSettings(nodeSettings);
}
return n;
}
public string GetSql(string nodeId, int? offset = null, int? limit = null)
{
var node = Nodes.FirstOrDefault(n => n.ClientId == nodeId);
return node.GetFetchDataQuery(offset, limit);
}
public string GetRowCountSql(string nodeId)
{
var node = Nodes.FirstOrDefault(n => n.ClientId == nodeId);
return node.GetCountQuerySql();
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.