@hpcc-js/marshaller 2.28.6 → 2.28.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +43 -43
  2. package/dist/index.es6.js +19 -19
  3. package/dist/index.es6.js.map +1 -1
  4. package/dist/index.js +17 -17
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +1 -1
  7. package/dist/index.min.js.map +1 -1
  8. package/package.json +16 -16
  9. package/src/__package__.ts +3 -3
  10. package/src/dashy.css +239 -239
  11. package/src/dashy.ts +521 -521
  12. package/src/ddl1/DDLApi.ts +229 -229
  13. package/src/ddl1/FlyoutButton.ts +120 -120
  14. package/src/ddl1/Graph.ts +93 -93
  15. package/src/ddl1/HTML.ts +77 -77
  16. package/src/ddl1/HipieDDL.ts +2437 -2437
  17. package/src/ddl1/HipieDDLMixin.ts +380 -380
  18. package/src/ddl1/Tabbed.ts +91 -91
  19. package/src/ddl1/TargetMarshaller.ts +57 -57
  20. package/src/ddl2/PopupManager.ts +89 -89
  21. package/src/ddl2/activities/activity.ts +431 -431
  22. package/src/ddl2/activities/databomb.ts +237 -237
  23. package/src/ddl2/activities/datasource.ts +52 -52
  24. package/src/ddl2/activities/dspicker.ts +106 -106
  25. package/src/ddl2/activities/filter.ts +542 -542
  26. package/src/ddl2/activities/form.ts +153 -153
  27. package/src/ddl2/activities/groupby.ts +439 -439
  28. package/src/ddl2/activities/hipiepipeline.ts +114 -114
  29. package/src/ddl2/activities/limit.ts +49 -49
  30. package/src/ddl2/activities/logicalfile.ts +62 -62
  31. package/src/ddl2/activities/nullview.ts +12 -12
  32. package/src/ddl2/activities/project.ts +764 -764
  33. package/src/ddl2/activities/rest.ts +568 -568
  34. package/src/ddl2/activities/roxie.ts +490 -490
  35. package/src/ddl2/activities/sampledata.json +16264 -16264
  36. package/src/ddl2/activities/sort.ts +176 -176
  37. package/src/ddl2/activities/wuresult.ts +395 -395
  38. package/src/ddl2/dashboard.css +13 -13
  39. package/src/ddl2/dashboard.ts +330 -330
  40. package/src/ddl2/dashboardDockPanel.ts +123 -123
  41. package/src/ddl2/dashboardGrid.ts +202 -202
  42. package/src/ddl2/ddl.ts +410 -410
  43. package/src/ddl2/ddleditor.ts +60 -60
  44. package/src/ddl2/dsTable.ts +238 -238
  45. package/src/ddl2/dvTable.ts +31 -31
  46. package/src/ddl2/graphadapter.ts +297 -297
  47. package/src/ddl2/javascriptadapter.ts +354 -354
  48. package/src/ddl2/model/element.ts +398 -398
  49. package/src/ddl2/model/visualization.ts +351 -351
  50. package/src/ddl2/model/vizChartPanel.ts +149 -149
  51. package/src/ddl2/pipelinePanel.css +4 -4
  52. package/src/ddl2/pipelinePanel.ts +465 -465
  53. package/src/index.ts +26 -26
@@ -1,297 +1,297 @@
1
- import { Widget } from "@hpcc-js/common";
2
- import { Edge, IGraphData, Lineage, Subgraph, Vertex } from "@hpcc-js/graph";
3
- import { Activity } from "./activities/activity";
4
- import { Databomb } from "./activities/databomb";
5
- import { DSPicker } from "./activities/dspicker";
6
- import { Form } from "./activities/form";
7
- import { LogicalFile } from "./activities/logicalfile";
8
- import { RestResult, RestResultRef } from "./activities/rest";
9
- import { RoxieResult, RoxieResultRef } from "./activities/roxie";
10
- import { WUResult } from "./activities/wuresult";
11
- import { Element, ElementContainer, State } from "./model/element";
12
- import { Visualization } from "./model/visualization";
13
- import { VizChartPanel } from "./model/vizChartPanel";
14
-
15
- export interface VertexData {
16
- view?: Element;
17
- activity?: Activity;
18
- visualization?: Visualization;
19
- chartPanel?: VizChartPanel;
20
- state?: State;
21
- }
22
-
23
- export class GraphAdapter {
24
- private subgraphMap: { [key: string]: Subgraph } = {};
25
- private vertexMap: { [key: string]: Vertex } = {};
26
- private edgeMap: { [key: string]: Edge } = {};
27
- private hierarchy: Lineage[] = [];
28
- private vertices: Widget[] = [];
29
- private edges: Edge[] = [];
30
-
31
- constructor(private _ec: ElementContainer) {
32
- }
33
-
34
- clear() {
35
- this.subgraphMap = {};
36
- this.vertexMap = {};
37
- this.edgeMap = {};
38
-
39
- this.hierarchy = [];
40
- this.vertices = [];
41
- this.edges = [];
42
- }
43
-
44
- createSubgraph(id: string, label: string, data?: VertexData): Subgraph {
45
- let retVal: Subgraph = this.subgraphMap[id];
46
- if (!retVal) {
47
- retVal = new Subgraph()
48
- // .classed({ subgraph: true })
49
- // .showIcon(false)
50
- .columns(["DS"])
51
- .data([[data]])
52
- ;
53
- this.subgraphMap[id] = retVal;
54
- }
55
- this.vertices.push(retVal);
56
- retVal.title(`${label}`);
57
- retVal.getBBox(true);
58
- return retVal;
59
- }
60
-
61
- createVertex(id: string, label: string, data?: VertexData, tooltip: string = "", fillColor: string = "#dcf1ff"): Vertex {
62
- let retVal: Vertex = this.vertexMap[id];
63
- if (!retVal) {
64
- retVal = new Vertex()
65
- .columns(["DS"])
66
- .data([[data]])
67
- .icon_diameter(0)
68
- ;
69
- this.vertexMap[id] = retVal;
70
- }
71
- this.vertices.push(retVal);
72
- retVal
73
- .textbox_shape_colorFill(fillColor)
74
- .text(tooltip ? `${label}\n${tooltip}` : `${label}`)
75
- .tooltip(tooltip)
76
- ;
77
- retVal.getBBox(true);
78
- return retVal;
79
- }
80
-
81
- createEdge(sourceID: string, targetID: string) {
82
- const edgeID = `${sourceID}->${targetID}`;
83
- let retVal = this.edgeMap[edgeID];
84
- if (!retVal) {
85
- retVal = new Edge()
86
- .sourceVertex(this.vertexMap[sourceID])
87
- .targetVertex(this.vertexMap[targetID])
88
- ;
89
- this.edgeMap[edgeID] = retVal;
90
- }
91
- this.edges.push(retVal);
92
- return retVal;
93
- }
94
-
95
- createDatasource(dsDetails: Activity): string {
96
- if (dsDetails instanceof DSPicker) {
97
- dsDetails = dsDetails.selection().datasource();
98
- }
99
- if (dsDetails instanceof WUResult) {
100
- const serverID = `${dsDetails.url()}`;
101
- const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
102
- const wuID = `${dsDetails.url()}/${dsDetails.wuid()}`;
103
- const wu: Subgraph = this.createSubgraph(wuID, `${dsDetails.wuid()}`);
104
- this.hierarchy.push({ parent: server, child: wu });
105
- const resultID = `${wuID}/${dsDetails.resultName()}`;
106
- const result: Vertex = this.createVertex(resultID, dsDetails.resultName(), { activity: dsDetails });
107
- this.hierarchy.push({ parent: wu, child: result });
108
- return resultID;
109
- } else if (dsDetails instanceof LogicalFile) {
110
- const serverID = `${dsDetails.url()}`;
111
- const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
112
- const lfID = `${serverID}/${dsDetails.logicalFile()}`;
113
- const lf: Vertex = this.createVertex(lfID, dsDetails.logicalFile(), { activity: dsDetails });
114
- this.hierarchy.push({ parent: server, child: lf });
115
- return lfID;
116
- } else if (dsDetails instanceof RoxieResultRef) {
117
- const serverID = `${dsDetails.url()}`;
118
- const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
119
- const surfaceID = dsDetails.serviceID(); // `${dsDetails.url()}/${dsDetails.querySet()}`;
120
- const surface: Subgraph = this.createSubgraph(surfaceID, dsDetails.querySet());
121
- this.hierarchy.push({ parent: server, child: surface });
122
- const roxieID = surfaceID;
123
- this.hierarchy.push({
124
- parent: surface,
125
- child: this.createVertex(roxieID, dsDetails.queryID())
126
- });
127
- const roxieResultID = `${surfaceID}/${dsDetails.resultName()}`;
128
- this.hierarchy.push({
129
- parent: surface,
130
- child: this.createVertex(roxieResultID, dsDetails.resultName(), { activity: dsDetails })
131
- });
132
- this.createEdge(roxieID, roxieResultID);
133
- return roxieResultID;
134
- } else if (dsDetails instanceof RoxieResult) {
135
- const serverID = `${dsDetails.service().url()}`;
136
- const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
137
- const querySetID = dsDetails.serviceID();
138
- const querySet: Subgraph = this.createSubgraph(querySetID, dsDetails.service().querySet());
139
- this.hierarchy.push({ parent: server, child: querySet });
140
- const queryID = `${querySetID}/${dsDetails.service().queryID()}`;
141
- const query: Subgraph = this.createSubgraph(queryID, dsDetails.service().queryID());
142
- this.hierarchy.push({ parent: querySet, child: query });
143
- const resultID = `${queryID}/${dsDetails.resultName()}`;
144
- this.hierarchy.push({
145
- parent: query,
146
- child: this.createVertex(resultID, dsDetails.resultName(), { activity: dsDetails })
147
- });
148
- this.createEdge(queryID, resultID);
149
- return resultID;
150
- } else if (dsDetails instanceof RestResultRef) {
151
- const serverID = `${dsDetails.url()}`;
152
- const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
153
- const surfaceID = dsDetails.serviceID();
154
- const surface: Subgraph = this.createSubgraph(surfaceID, dsDetails.action());
155
- this.hierarchy.push({ parent: server, child: surface });
156
- const roxieID = surfaceID;
157
- this.hierarchy.push({
158
- parent: surface,
159
- child: this.createVertex(roxieID, dsDetails.action())
160
- });
161
- const roxieResultID = `${surfaceID}/${dsDetails.resultName()}`;
162
- this.hierarchy.push({
163
- parent: surface,
164
- child: this.createVertex(roxieResultID, dsDetails.resultName(), { activity: dsDetails })
165
- });
166
- this.createEdge(roxieID, roxieResultID);
167
- return roxieResultID;
168
- } else if (dsDetails instanceof RestResult) {
169
- const serverID = `${dsDetails.service().url()}`;
170
- const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
171
- const serviceID = dsDetails.serviceID();
172
- const actionID = `${serverID}/${dsDetails.service().action()}`;
173
- const action: Subgraph = this.createSubgraph(serviceID, dsDetails.service().action());
174
- this.hierarchy.push({ parent: server, child: action });
175
- const resultID = `${actionID}/${dsDetails.resultName()}`;
176
- this.hierarchy.push({
177
- parent: action,
178
- child: this.createVertex(resultID, dsDetails.resultName(), { activity: dsDetails })
179
- });
180
- this.createEdge(actionID, resultID);
181
- return resultID;
182
- } else if (dsDetails instanceof Form) {
183
- const id = dsDetails.hash();
184
- this.createVertex(id, dsDetails.label(), { activity: dsDetails });
185
- return id;
186
- } else if (dsDetails instanceof Databomb) {
187
- const id = dsDetails.id();
188
- this.createVertex(id, dsDetails.label(), { activity: dsDetails });
189
- return id;
190
- } else {
191
- const id = dsDetails.hash();
192
- this.createVertex(id, dsDetails.label(), { activity: dsDetails });
193
- return id;
194
- }
195
- }
196
-
197
- createActivity(sourceID: string, view: Element, activity: Activity, label?: string): string {
198
- const surface: Subgraph = this.createSubgraph(view.id(), `${view.id()}`, { view });
199
- let fillColor = null;
200
- let tooltip = "";
201
- if (activity.exists()) {
202
- const errors = activity.validate();
203
- if (errors.length) {
204
- fillColor = "pink";
205
- tooltip = errors.map(error => `${error.source}: ${error.msg}`).join("\n");
206
- }
207
- } else {
208
- fillColor = "lightgrey";
209
- }
210
- const vertex: Vertex = this.createVertex(activity.id(), label || `${activity.classID()}`, { view, activity }, tooltip, fillColor);
211
- if (sourceID) {
212
- this.createEdge(sourceID, activity.id());
213
- }
214
- this.hierarchy.push({ parent: surface, child: vertex });
215
- return activity.id();
216
- }
217
-
218
- createGraph(): IGraphData {
219
- this.hierarchy = [];
220
- this.vertices = [];
221
- this.edges = [];
222
-
223
- this._ec.elements().forEach(e => {
224
- this.createDatasource(e.hipiePipeline().datasource());
225
- });
226
-
227
- const lastID: { [key: string]: string } = {};
228
- for (const view of this._ec.elements()) {
229
- const pipeline = view.hipiePipeline();
230
- let prevID = this.createDatasource(pipeline.datasource());
231
- for (const activity of pipeline.activities()) {
232
- prevID = this.createActivity(prevID, view, activity);
233
- }
234
- const visualization = view.visualization();
235
- const mappings = visualization.mappings();
236
- const mappingVertexID = this.createActivity(prevID, view, mappings, "Mappings");
237
- const vizSubgraphID = `${visualization.id()}-sg`;
238
- const surface: Subgraph = this.createSubgraph(vizSubgraphID, "Visualization", { visualization });
239
- this.hierarchy.push({
240
- parent: this.subgraphMap[view.id()],
241
- child: surface
242
- });
243
- this.hierarchy.push({
244
- parent: surface,
245
- child: this.vertexMap[mappings.id()]
246
- });
247
- const vizVertexID = `${visualization.id()}-viz`;
248
- const widgetVertex: Vertex = this.createVertex(vizVertexID, visualization.chartPanel().widget().classID(), { view, chartPanel: visualization.chartPanel() });
249
- this.createEdge(mappingVertexID, vizVertexID);
250
- this.hierarchy.push({
251
- parent: surface,
252
- child: widgetVertex
253
- });
254
- const stateVertexID = `${visualization.id()}-state`;
255
- const stateVertex: Vertex = this.createVertex(stateVertexID, "Selection", { view, state: view.state() });
256
- this.createEdge(vizVertexID, stateVertexID)
257
- .weight(10)
258
- .strokeDasharray("1,5")
259
- .text("updates")
260
- ;
261
- this.createEdge(prevID, stateVertexID);
262
- this.hierarchy.push({
263
- parent: this.subgraphMap[view.id()],
264
- child: stateVertex
265
- });
266
- prevID = stateVertexID;
267
- lastID[pipeline.id()] = prevID;
268
- }
269
-
270
- // Mapping Secondary Sources ---
271
- for (const view of this._ec.elements()) {
272
- const visualization = view.visualization();
273
- const secondaryElement = this._ec.element(visualization.secondaryDataviewID());
274
- if (secondaryElement) {
275
- const mappings = secondaryElement.visualization().mappings();
276
- this.createEdge(mappings.id(), `${visualization.id()}-viz`);
277
- }
278
- }
279
-
280
- for (const viz of this._ec.elements()) {
281
- const view = viz.hipiePipeline();
282
- for (const updateInfo of view.updatedByGraph()) {
283
- this.createEdge(lastID[this._ec.element(updateInfo.from).hipiePipeline().id()], updateInfo.to.id())
284
- .weight(10)
285
- .strokeDasharray("1,5")
286
- .text("updates")
287
- ;
288
- }
289
- }
290
-
291
- return {
292
- vertices: this.vertices,
293
- edges: this.edges,
294
- hierarchy: this.hierarchy
295
- };
296
- }
297
- }
1
+ import { Widget } from "@hpcc-js/common";
2
+ import { Edge, IGraphData, Lineage, Subgraph, Vertex } from "@hpcc-js/graph";
3
+ import { Activity } from "./activities/activity";
4
+ import { Databomb } from "./activities/databomb";
5
+ import { DSPicker } from "./activities/dspicker";
6
+ import { Form } from "./activities/form";
7
+ import { LogicalFile } from "./activities/logicalfile";
8
+ import { RestResult, RestResultRef } from "./activities/rest";
9
+ import { RoxieResult, RoxieResultRef } from "./activities/roxie";
10
+ import { WUResult } from "./activities/wuresult";
11
+ import { Element, ElementContainer, State } from "./model/element";
12
+ import { Visualization } from "./model/visualization";
13
+ import { VizChartPanel } from "./model/vizChartPanel";
14
+
15
+ export interface VertexData {
16
+ view?: Element;
17
+ activity?: Activity;
18
+ visualization?: Visualization;
19
+ chartPanel?: VizChartPanel;
20
+ state?: State;
21
+ }
22
+
23
+ export class GraphAdapter {
24
+ private subgraphMap: { [key: string]: Subgraph } = {};
25
+ private vertexMap: { [key: string]: Vertex } = {};
26
+ private edgeMap: { [key: string]: Edge } = {};
27
+ private hierarchy: Lineage[] = [];
28
+ private vertices: Widget[] = [];
29
+ private edges: Edge[] = [];
30
+
31
+ constructor(private _ec: ElementContainer) {
32
+ }
33
+
34
+ clear() {
35
+ this.subgraphMap = {};
36
+ this.vertexMap = {};
37
+ this.edgeMap = {};
38
+
39
+ this.hierarchy = [];
40
+ this.vertices = [];
41
+ this.edges = [];
42
+ }
43
+
44
+ createSubgraph(id: string, label: string, data?: VertexData): Subgraph {
45
+ let retVal: Subgraph = this.subgraphMap[id];
46
+ if (!retVal) {
47
+ retVal = new Subgraph()
48
+ // .classed({ subgraph: true })
49
+ // .showIcon(false)
50
+ .columns(["DS"])
51
+ .data([[data]])
52
+ ;
53
+ this.subgraphMap[id] = retVal;
54
+ }
55
+ this.vertices.push(retVal);
56
+ retVal.title(`${label}`);
57
+ retVal.getBBox(true);
58
+ return retVal;
59
+ }
60
+
61
+ createVertex(id: string, label: string, data?: VertexData, tooltip: string = "", fillColor: string = "#dcf1ff"): Vertex {
62
+ let retVal: Vertex = this.vertexMap[id];
63
+ if (!retVal) {
64
+ retVal = new Vertex()
65
+ .columns(["DS"])
66
+ .data([[data]])
67
+ .icon_diameter(0)
68
+ ;
69
+ this.vertexMap[id] = retVal;
70
+ }
71
+ this.vertices.push(retVal);
72
+ retVal
73
+ .textbox_shape_colorFill(fillColor)
74
+ .text(tooltip ? `${label}\n${tooltip}` : `${label}`)
75
+ .tooltip(tooltip)
76
+ ;
77
+ retVal.getBBox(true);
78
+ return retVal;
79
+ }
80
+
81
+ createEdge(sourceID: string, targetID: string) {
82
+ const edgeID = `${sourceID}->${targetID}`;
83
+ let retVal = this.edgeMap[edgeID];
84
+ if (!retVal) {
85
+ retVal = new Edge()
86
+ .sourceVertex(this.vertexMap[sourceID])
87
+ .targetVertex(this.vertexMap[targetID])
88
+ ;
89
+ this.edgeMap[edgeID] = retVal;
90
+ }
91
+ this.edges.push(retVal);
92
+ return retVal;
93
+ }
94
+
95
+ createDatasource(dsDetails: Activity): string {
96
+ if (dsDetails instanceof DSPicker) {
97
+ dsDetails = dsDetails.selection().datasource();
98
+ }
99
+ if (dsDetails instanceof WUResult) {
100
+ const serverID = `${dsDetails.url()}`;
101
+ const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
102
+ const wuID = `${dsDetails.url()}/${dsDetails.wuid()}`;
103
+ const wu: Subgraph = this.createSubgraph(wuID, `${dsDetails.wuid()}`);
104
+ this.hierarchy.push({ parent: server, child: wu });
105
+ const resultID = `${wuID}/${dsDetails.resultName()}`;
106
+ const result: Vertex = this.createVertex(resultID, dsDetails.resultName(), { activity: dsDetails });
107
+ this.hierarchy.push({ parent: wu, child: result });
108
+ return resultID;
109
+ } else if (dsDetails instanceof LogicalFile) {
110
+ const serverID = `${dsDetails.url()}`;
111
+ const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
112
+ const lfID = `${serverID}/${dsDetails.logicalFile()}`;
113
+ const lf: Vertex = this.createVertex(lfID, dsDetails.logicalFile(), { activity: dsDetails });
114
+ this.hierarchy.push({ parent: server, child: lf });
115
+ return lfID;
116
+ } else if (dsDetails instanceof RoxieResultRef) {
117
+ const serverID = `${dsDetails.url()}`;
118
+ const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
119
+ const surfaceID = dsDetails.serviceID(); // `${dsDetails.url()}/${dsDetails.querySet()}`;
120
+ const surface: Subgraph = this.createSubgraph(surfaceID, dsDetails.querySet());
121
+ this.hierarchy.push({ parent: server, child: surface });
122
+ const roxieID = surfaceID;
123
+ this.hierarchy.push({
124
+ parent: surface,
125
+ child: this.createVertex(roxieID, dsDetails.queryID())
126
+ });
127
+ const roxieResultID = `${surfaceID}/${dsDetails.resultName()}`;
128
+ this.hierarchy.push({
129
+ parent: surface,
130
+ child: this.createVertex(roxieResultID, dsDetails.resultName(), { activity: dsDetails })
131
+ });
132
+ this.createEdge(roxieID, roxieResultID);
133
+ return roxieResultID;
134
+ } else if (dsDetails instanceof RoxieResult) {
135
+ const serverID = `${dsDetails.service().url()}`;
136
+ const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
137
+ const querySetID = dsDetails.serviceID();
138
+ const querySet: Subgraph = this.createSubgraph(querySetID, dsDetails.service().querySet());
139
+ this.hierarchy.push({ parent: server, child: querySet });
140
+ const queryID = `${querySetID}/${dsDetails.service().queryID()}`;
141
+ const query: Subgraph = this.createSubgraph(queryID, dsDetails.service().queryID());
142
+ this.hierarchy.push({ parent: querySet, child: query });
143
+ const resultID = `${queryID}/${dsDetails.resultName()}`;
144
+ this.hierarchy.push({
145
+ parent: query,
146
+ child: this.createVertex(resultID, dsDetails.resultName(), { activity: dsDetails })
147
+ });
148
+ this.createEdge(queryID, resultID);
149
+ return resultID;
150
+ } else if (dsDetails instanceof RestResultRef) {
151
+ const serverID = `${dsDetails.url()}`;
152
+ const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
153
+ const surfaceID = dsDetails.serviceID();
154
+ const surface: Subgraph = this.createSubgraph(surfaceID, dsDetails.action());
155
+ this.hierarchy.push({ parent: server, child: surface });
156
+ const roxieID = surfaceID;
157
+ this.hierarchy.push({
158
+ parent: surface,
159
+ child: this.createVertex(roxieID, dsDetails.action())
160
+ });
161
+ const roxieResultID = `${surfaceID}/${dsDetails.resultName()}`;
162
+ this.hierarchy.push({
163
+ parent: surface,
164
+ child: this.createVertex(roxieResultID, dsDetails.resultName(), { activity: dsDetails })
165
+ });
166
+ this.createEdge(roxieID, roxieResultID);
167
+ return roxieResultID;
168
+ } else if (dsDetails instanceof RestResult) {
169
+ const serverID = `${dsDetails.service().url()}`;
170
+ const server: Subgraph = this.createSubgraph(serverID, `${serverID}`);
171
+ const serviceID = dsDetails.serviceID();
172
+ const actionID = `${serverID}/${dsDetails.service().action()}`;
173
+ const action: Subgraph = this.createSubgraph(serviceID, dsDetails.service().action());
174
+ this.hierarchy.push({ parent: server, child: action });
175
+ const resultID = `${actionID}/${dsDetails.resultName()}`;
176
+ this.hierarchy.push({
177
+ parent: action,
178
+ child: this.createVertex(resultID, dsDetails.resultName(), { activity: dsDetails })
179
+ });
180
+ this.createEdge(actionID, resultID);
181
+ return resultID;
182
+ } else if (dsDetails instanceof Form) {
183
+ const id = dsDetails.hash();
184
+ this.createVertex(id, dsDetails.label(), { activity: dsDetails });
185
+ return id;
186
+ } else if (dsDetails instanceof Databomb) {
187
+ const id = dsDetails.id();
188
+ this.createVertex(id, dsDetails.label(), { activity: dsDetails });
189
+ return id;
190
+ } else {
191
+ const id = dsDetails.hash();
192
+ this.createVertex(id, dsDetails.label(), { activity: dsDetails });
193
+ return id;
194
+ }
195
+ }
196
+
197
+ createActivity(sourceID: string, view: Element, activity: Activity, label?: string): string {
198
+ const surface: Subgraph = this.createSubgraph(view.id(), `${view.id()}`, { view });
199
+ let fillColor = null;
200
+ let tooltip = "";
201
+ if (activity.exists()) {
202
+ const errors = activity.validate();
203
+ if (errors.length) {
204
+ fillColor = "pink";
205
+ tooltip = errors.map(error => `${error.source}: ${error.msg}`).join("\n");
206
+ }
207
+ } else {
208
+ fillColor = "lightgrey";
209
+ }
210
+ const vertex: Vertex = this.createVertex(activity.id(), label || `${activity.classID()}`, { view, activity }, tooltip, fillColor);
211
+ if (sourceID) {
212
+ this.createEdge(sourceID, activity.id());
213
+ }
214
+ this.hierarchy.push({ parent: surface, child: vertex });
215
+ return activity.id();
216
+ }
217
+
218
+ createGraph(): IGraphData {
219
+ this.hierarchy = [];
220
+ this.vertices = [];
221
+ this.edges = [];
222
+
223
+ this._ec.elements().forEach(e => {
224
+ this.createDatasource(e.hipiePipeline().datasource());
225
+ });
226
+
227
+ const lastID: { [key: string]: string } = {};
228
+ for (const view of this._ec.elements()) {
229
+ const pipeline = view.hipiePipeline();
230
+ let prevID = this.createDatasource(pipeline.datasource());
231
+ for (const activity of pipeline.activities()) {
232
+ prevID = this.createActivity(prevID, view, activity);
233
+ }
234
+ const visualization = view.visualization();
235
+ const mappings = visualization.mappings();
236
+ const mappingVertexID = this.createActivity(prevID, view, mappings, "Mappings");
237
+ const vizSubgraphID = `${visualization.id()}-sg`;
238
+ const surface: Subgraph = this.createSubgraph(vizSubgraphID, "Visualization", { visualization });
239
+ this.hierarchy.push({
240
+ parent: this.subgraphMap[view.id()],
241
+ child: surface
242
+ });
243
+ this.hierarchy.push({
244
+ parent: surface,
245
+ child: this.vertexMap[mappings.id()]
246
+ });
247
+ const vizVertexID = `${visualization.id()}-viz`;
248
+ const widgetVertex: Vertex = this.createVertex(vizVertexID, visualization.chartPanel().widget().classID(), { view, chartPanel: visualization.chartPanel() });
249
+ this.createEdge(mappingVertexID, vizVertexID);
250
+ this.hierarchy.push({
251
+ parent: surface,
252
+ child: widgetVertex
253
+ });
254
+ const stateVertexID = `${visualization.id()}-state`;
255
+ const stateVertex: Vertex = this.createVertex(stateVertexID, "Selection", { view, state: view.state() });
256
+ this.createEdge(vizVertexID, stateVertexID)
257
+ .weight(10)
258
+ .strokeDasharray("1,5")
259
+ .text("updates")
260
+ ;
261
+ this.createEdge(prevID, stateVertexID);
262
+ this.hierarchy.push({
263
+ parent: this.subgraphMap[view.id()],
264
+ child: stateVertex
265
+ });
266
+ prevID = stateVertexID;
267
+ lastID[pipeline.id()] = prevID;
268
+ }
269
+
270
+ // Mapping Secondary Sources ---
271
+ for (const view of this._ec.elements()) {
272
+ const visualization = view.visualization();
273
+ const secondaryElement = this._ec.element(visualization.secondaryDataviewID());
274
+ if (secondaryElement) {
275
+ const mappings = secondaryElement.visualization().mappings();
276
+ this.createEdge(mappings.id(), `${visualization.id()}-viz`);
277
+ }
278
+ }
279
+
280
+ for (const viz of this._ec.elements()) {
281
+ const view = viz.hipiePipeline();
282
+ for (const updateInfo of view.updatedByGraph()) {
283
+ this.createEdge(lastID[this._ec.element(updateInfo.from).hipiePipeline().id()], updateInfo.to.id())
284
+ .weight(10)
285
+ .strokeDasharray("1,5")
286
+ .text("updates")
287
+ ;
288
+ }
289
+ }
290
+
291
+ return {
292
+ vertices: this.vertices,
293
+ edges: this.edges,
294
+ hierarchy: this.hierarchy
295
+ };
296
+ }
297
+ }