@hpcc-js/comms 3.14.1 → 3.14.4
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.
- package/LICENSE +43 -43
- package/README.md +50 -50
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.umd.cjs +1 -1
- package/dist/browser/index.umd.cjs.map +1 -1
- package/dist/node/index.cjs +6 -6
- package/dist/node/index.cjs.map +4 -4
- package/dist/node/index.js +6 -6
- package/dist/node/index.js.map +4 -4
- package/package.json +5 -5
- package/src/__package__.ts +3 -3
- package/src/clienttools/eclMeta.ts +506 -506
- package/src/clienttools/eclcc.ts +628 -628
- package/src/connection.ts +288 -288
- package/src/ecl/activity.ts +82 -82
- package/src/ecl/dfuWorkunit.ts +363 -363
- package/src/ecl/graph.ts +196 -196
- package/src/ecl/logicalFile.ts +196 -196
- package/src/ecl/machine.ts +63 -63
- package/src/ecl/query.ts +265 -265
- package/src/ecl/queryGraph.ts +813 -813
- package/src/ecl/resource.ts +39 -39
- package/src/ecl/result.ts +245 -245
- package/src/ecl/scope.ts +188 -188
- package/src/ecl/sourceFile.ts +34 -34
- package/src/ecl/store.ts +154 -154
- package/src/ecl/targetCluster.ts +149 -149
- package/src/ecl/timer.ts +42 -42
- package/src/ecl/topology.ts +131 -131
- package/src/ecl/workunit.ts +1340 -1340
- package/src/ecl/xsdParser.ts +267 -267
- package/src/espConnection.ts +164 -164
- package/src/index.browser.ts +1 -1
- package/src/index.common.ts +40 -40
- package/src/index.node.ts +48 -48
- package/src/pem/trustwave.ts +909 -909
- package/src/services/fileSpray.ts +48 -48
- package/src/services/wsAccess.ts +8 -8
- package/src/services/wsAccount.ts +27 -27
- package/src/services/wsCloud.ts +73 -73
- package/src/services/wsCodesign.ts +18 -18
- package/src/services/wsDFU.ts +34 -34
- package/src/services/wsDFUXRef.ts +121 -121
- package/src/services/wsDali.ts +8 -8
- package/src/services/wsEcl.ts +123 -123
- package/src/services/wsElk.ts +8 -8
- package/src/services/wsLogaccess.ts +267 -263
- package/src/services/wsMachine.ts +89 -89
- package/src/services/wsPackageProcess.ts +8 -8
- package/src/services/wsResources.ts +8 -8
- package/src/services/wsSMC.ts +80 -80
- package/src/services/wsSasha.ts +7 -7
- package/src/services/wsStore.ts +32 -32
- package/src/services/wsTopology.ts +45 -45
- package/src/services/wsWorkunits.ts +151 -151
- package/src/services/wsdl/FileSpray/v1.23/FileSpray.ts +1008 -1008
- package/src/services/wsdl/FileSpray/v1.25/FileSpray.ts +1040 -1040
- package/src/services/wsdl/FileSpray/v1.26/FileSpray.ts +929 -929
- package/src/services/wsdl/FileSpray/v1.27/FileSpray.ts +930 -930
- package/src/services/wsdl/WsCloud/v1/WsCloud.ts +38 -38
- package/src/services/wsdl/WsCloud/v1.02/WsCloud.ts +77 -77
- package/src/services/wsdl/WsDFUXRef/v1.02/WsDFUXRef.ts +224 -224
- package/src/services/wsdl/WsDFUXRef/v1.04/WsDFUXRef.ts +227 -227
- package/src/services/wsdl/WsDali/v1.04/WsDali.ts +216 -216
- package/src/services/wsdl/WsDfu/v1.62/WsDfu.ts +1455 -1455
- package/src/services/wsdl/WsDfu/v1.63/WsDfu.ts +1465 -1465
- package/src/services/wsdl/WsDfu/v1.65/WsDfu.ts +1244 -1244
- package/src/services/wsdl/WsDfu/v1.66/WsDfu.ts +1267 -1267
- package/src/services/wsdl/WsDfu/v1.67/WsDfu.ts +1268 -1268
- package/src/services/wsdl/WsFileIO/v1.01/WsFileIO.ts +104 -104
- package/src/services/wsdl/WsPackageProcess/v1.04/WsPackageProcess.ts +519 -519
- package/src/services/wsdl/WsPackageProcess/v1.07/WsPackageProcess.ts +500 -500
- package/src/services/wsdl/WsResources/v1.01/WsResources.ts +119 -119
- package/src/services/wsdl/WsSMC/v1.24/WsSMC.ts +665 -665
- package/src/services/wsdl/WsSMC/v1.27/WsSMC.ts +591 -591
- package/src/services/wsdl/WsSMC/v1.28/WsSMC.ts +645 -645
- package/src/services/wsdl/WsSMC/v1.29/WsSMC.ts +660 -660
- package/src/services/wsdl/WsTopology/v1.31/WsTopology.ts +856 -856
- package/src/services/wsdl/WsTopology/v1.32/WsTopology.ts +786 -786
- package/src/services/wsdl/WsTopology/v1.33/WsTopology.ts +835 -835
- package/src/services/wsdl/WsWorkunits/v1.88/WsWorkunits.ts +2944 -2944
- package/src/services/wsdl/WsWorkunits/v1.94/WsWorkunits.ts +3072 -3072
- package/src/services/wsdl/WsWorkunits/v1.95/WsWorkunits.ts +3073 -3073
- package/src/services/wsdl/WsWorkunits/v1.97/WsWorkunits.ts +3134 -3134
- package/src/services/wsdl/WsWorkunits/v1.98/WsWorkunits.ts +3182 -3182
- package/src/services/wsdl/WsWorkunits/v1.99/WsWorkunits.ts +3162 -3162
- package/src/services/wsdl/WsWorkunits/v2/WsWorkunits.ts +3153 -3153
- package/src/services/wsdl/WsWorkunits/v2.02/WsWorkunits.ts +3162 -3162
- package/src/services/wsdl/WsWorkunits/v2.03/WsWorkunits.ts +3164 -3164
- package/src/services/wsdl/WsWorkunits/v2.04/WsWorkunits.ts +3171 -0
- package/src/services/wsdl/ws_access/v1.16/ws_access.ts +1086 -1086
- package/src/services/wsdl/ws_access/v1.17/ws_access.ts +1023 -1023
- package/src/services/wsdl/ws_account/v1.05/ws_account.ts +111 -111
- package/src/services/wsdl/ws_account/v1.06/ws_account.ts +109 -109
- package/src/services/wsdl/ws_account/v1.07/ws_account.ts +114 -114
- package/src/services/wsdl/ws_codesign/v1.1/ws_codesign.ts +95 -95
- package/src/services/wsdl/ws_elk/v1/ws_elk.ts +47 -47
- package/src/services/wsdl/ws_logaccess/v1/ws_logaccess.ts +83 -83
- package/src/services/wsdl/ws_logaccess/v1.02/ws_logaccess.ts +161 -161
- package/src/services/wsdl/ws_logaccess/v1.03/ws_logaccess.ts +190 -190
- package/src/services/wsdl/ws_logaccess/v1.04/ws_logaccess.ts +215 -215
- package/src/services/wsdl/ws_logaccess/v1.05/ws_logaccess.ts +219 -219
- package/src/services/wsdl/ws_logaccess/v1.08/ws_logaccess.ts +267 -267
- package/src/services/wsdl/ws_machine/v1.17/ws_machine.ts +567 -567
- package/src/services/wsdl/ws_machine/v1.18/ws_machine.ts +497 -497
- package/src/services/wsdl/ws_machine/v1.19/ws_machine.ts +497 -497
- package/src/services/wsdl/wsstore/v1.02/wsstore.ts +239 -239
- package/types/services/wsWorkunits.d.ts +1 -1
- package/types/services/wsdl/WsWorkunits/{v2.03 → v2.04}/WsWorkunits.d.ts +9 -3
package/src/ecl/graph.ts
CHANGED
|
@@ -1,196 +1,196 @@
|
|
|
1
|
-
import { Cache, Edge, Graph, StateObject, StringAnyMap, Subgraph, Vertex, XMLNode } from "@hpcc-js/util";
|
|
2
|
-
import { WsWorkunits } from "../services/wsWorkunits.ts";
|
|
3
|
-
import { BaseScope } from "./scope.ts";
|
|
4
|
-
import { Timer } from "./timer.ts";
|
|
5
|
-
import { Workunit } from "./workunit.ts";
|
|
6
|
-
|
|
7
|
-
export interface ECLGraphEx extends WsWorkunits.ECLGraph {
|
|
8
|
-
Time: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ECLGraph extends StateObject<ECLGraphEx, ECLGraphEx> implements ECLGraphEx {
|
|
12
|
-
protected wu: Workunit;
|
|
13
|
-
|
|
14
|
-
get properties(): ECLGraphEx { return this.get(); }
|
|
15
|
-
get Name(): string { return this.get("Name"); }
|
|
16
|
-
get Label(): string { return this.get("Label"); }
|
|
17
|
-
get Type(): string { return this.get("Type"); }
|
|
18
|
-
get Complete(): boolean { return this.get("Complete"); }
|
|
19
|
-
get WhenStarted(): string { return this.get("WhenStarted"); }
|
|
20
|
-
get WhenFinished(): string { return this.get("WhenFinished"); }
|
|
21
|
-
get Time(): number { return this.get("Time"); }
|
|
22
|
-
get Running(): boolean { return this.get("Running"); }
|
|
23
|
-
get RunningId(): number { return this.get("RunningId"); }
|
|
24
|
-
get Failed(): boolean { return this.get("Failed"); }
|
|
25
|
-
|
|
26
|
-
constructor(wu: Workunit, eclGraph: WsWorkunits.ECLGraph, eclTimers: Timer[]) {
|
|
27
|
-
super();
|
|
28
|
-
this.wu = wu;
|
|
29
|
-
let duration = 0;
|
|
30
|
-
for (const eclTimer of eclTimers) {
|
|
31
|
-
if (eclTimer.GraphName === eclGraph.Name && !eclTimer.HasSubGraphId) {
|
|
32
|
-
duration = Math.round(eclTimer.Seconds * 1000) / 1000;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
this.set({ Time: duration, ...eclGraph });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
fetchScopeGraph(subgraphID?: string): Promise<ScopeGraph> {
|
|
40
|
-
if (subgraphID) {
|
|
41
|
-
return this.wu.fetchGraphDetails([subgraphID], ["subgraph"]).then((scopes) => {
|
|
42
|
-
return createGraph(scopes);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return this.wu.fetchGraphDetails([this.Name], ["graph"]).then((scopes) => {
|
|
46
|
-
return createGraph(scopes);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export class GraphCache extends Cache<WsWorkunits.ECLGraph, ECLGraph> {
|
|
52
|
-
constructor() {
|
|
53
|
-
super((obj) => {
|
|
54
|
-
return Cache.hash([obj.Name]);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
type Callback = (tag: string, attributes: StringAnyMap, children: XMLNode[], _stack: XMLNode[]) => void;
|
|
60
|
-
function walkXmlJson(node: XMLNode, callback: Callback, stack?: XMLNode[]) {
|
|
61
|
-
stack = stack || [];
|
|
62
|
-
stack.push(node);
|
|
63
|
-
callback(node.name, node.$, node.children(), stack);
|
|
64
|
-
node.children().forEach((childNode) => {
|
|
65
|
-
walkXmlJson(childNode, callback, stack);
|
|
66
|
-
});
|
|
67
|
-
stack.pop();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function flattenAtt(nodes: XMLNode[]): StringAnyMap {
|
|
71
|
-
const retVal: StringAnyMap = {};
|
|
72
|
-
nodes.forEach((node: XMLNode) => {
|
|
73
|
-
if (node.name === "att") {
|
|
74
|
-
retVal[node.$["name"]] = node.$["value"];
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return retVal;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export class XGMMLGraph extends Graph<StringAnyMap, StringAnyMap, StringAnyMap> { }
|
|
81
|
-
export class XGMMLSubgraph extends Subgraph<StringAnyMap, StringAnyMap, StringAnyMap> { }
|
|
82
|
-
export class XGMMLVertex extends Vertex<StringAnyMap, StringAnyMap, StringAnyMap> { }
|
|
83
|
-
export class XGMMLEdge extends Edge<StringAnyMap, StringAnyMap, StringAnyMap> { }
|
|
84
|
-
|
|
85
|
-
export function createXGMMLGraph(id: string, graphs: XMLNode): XGMMLGraph {
|
|
86
|
-
const subgraphs: { [id: string]: XGMMLSubgraph } = {};
|
|
87
|
-
const vertices: { [id: string]: XGMMLVertex } = {};
|
|
88
|
-
const edges: { [id: string]: XGMMLEdge } = {};
|
|
89
|
-
|
|
90
|
-
const graph = new XGMMLGraph((item) => {
|
|
91
|
-
return item._!["id"];
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const stack: XGMMLSubgraph[] = [graph.root];
|
|
95
|
-
walkXmlJson(graphs, (tag: string, attributes: StringAnyMap, childNodes: XMLNode[], _stack) => {
|
|
96
|
-
const top = stack[stack.length - 1];
|
|
97
|
-
switch (tag) {
|
|
98
|
-
case "graph":
|
|
99
|
-
break;
|
|
100
|
-
case "node":
|
|
101
|
-
if (childNodes.length && childNodes[0].children().length && childNodes[0].children()[0].name === "graph") {
|
|
102
|
-
const subgraph = top.createSubgraph(flattenAtt(childNodes));
|
|
103
|
-
stack.push(subgraph);
|
|
104
|
-
subgraphs[attributes["id"]] = subgraph;
|
|
105
|
-
} else {
|
|
106
|
-
}
|
|
107
|
-
// TODO: Is this really a node when its also a subgraph?
|
|
108
|
-
const vertex = top.createVertex(flattenAtt(childNodes));
|
|
109
|
-
vertices[attributes["id"]] = vertex;
|
|
110
|
-
break;
|
|
111
|
-
case "edge":
|
|
112
|
-
const edge = top.createEdge(vertices[attributes["source"]], vertices[attributes["target"]], flattenAtt(childNodes));
|
|
113
|
-
edges[attributes["id"]] = edge;
|
|
114
|
-
break;
|
|
115
|
-
default:
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
return graph;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export class ScopeGraph extends Graph<BaseScope, BaseScope, BaseScope> { }
|
|
122
|
-
export class ScopeSubgraph extends Subgraph<BaseScope, BaseScope, BaseScope> { }
|
|
123
|
-
export class ScopeVertex extends Vertex<BaseScope, BaseScope, BaseScope> { }
|
|
124
|
-
export class ScopeEdge extends Edge<BaseScope, BaseScope, BaseScope> { }
|
|
125
|
-
|
|
126
|
-
export function createGraph(scopes: BaseScope[]): ScopeGraph {
|
|
127
|
-
const subgraphs: { [scopeName: string]: ScopeSubgraph } = {};
|
|
128
|
-
const edges: { [scopeName: string]: BaseScope } = {};
|
|
129
|
-
const vertices: { [scopeName: string]: ScopeVertex } = {};
|
|
130
|
-
|
|
131
|
-
let graph: ScopeGraph | undefined;
|
|
132
|
-
for (const scope of scopes) {
|
|
133
|
-
switch (scope.ScopeType) {
|
|
134
|
-
case "graph":
|
|
135
|
-
graph = new ScopeGraph(item => item._!.Id, scope);
|
|
136
|
-
subgraphs[scope.ScopeName] = graph.root;
|
|
137
|
-
break;
|
|
138
|
-
case "subgraph":
|
|
139
|
-
if (!graph) {
|
|
140
|
-
graph = new ScopeGraph(item => item._!.Id, scope);
|
|
141
|
-
subgraphs[scope.ScopeName] = graph.root;
|
|
142
|
-
}
|
|
143
|
-
const scopeStack = scope.parentScope().split(":");
|
|
144
|
-
let scopeParent1 = subgraphs[scope.parentScope()];
|
|
145
|
-
while (scopeStack.length && !scopeParent1) {
|
|
146
|
-
scopeParent1 = subgraphs[scopeStack.join(":")];
|
|
147
|
-
scopeStack.pop();
|
|
148
|
-
}
|
|
149
|
-
if (!scopeParent1) {
|
|
150
|
-
console.warn(`Missing SG:Parent (${scope.Id}): ${scope.parentScope()}`);
|
|
151
|
-
} else {
|
|
152
|
-
const parent1: ScopeSubgraph = scopeParent1;
|
|
153
|
-
subgraphs[scope.ScopeName] = parent1.createSubgraph(scope);
|
|
154
|
-
}
|
|
155
|
-
break;
|
|
156
|
-
case "activity":
|
|
157
|
-
const scopeParent2 = subgraphs[scope.parentScope()];
|
|
158
|
-
if (!scopeParent2) {
|
|
159
|
-
console.warn(`Missing A:Parent (${scope.Id}): ${scope.parentScope()}`);
|
|
160
|
-
} else {
|
|
161
|
-
vertices[scope.ScopeName] = scopeParent2.createVertex(scope);
|
|
162
|
-
}
|
|
163
|
-
break;
|
|
164
|
-
case "edge":
|
|
165
|
-
edges[scope.ScopeName] = scope;
|
|
166
|
-
break;
|
|
167
|
-
case "function":
|
|
168
|
-
const scopeParent3 = vertices[scope.parentScope()];
|
|
169
|
-
if (!scopeParent3) {
|
|
170
|
-
console.warn(`Missing F:Parent (${scope.Id}): ${scope.parentScope()}`);
|
|
171
|
-
} else {
|
|
172
|
-
scopeParent3._.children().push(scope);
|
|
173
|
-
}
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
for (const id in edges) {
|
|
178
|
-
const scope = edges[id];
|
|
179
|
-
const scopeParent3 = subgraphs[scope.parentScope()];
|
|
180
|
-
if (!scopeParent3) {
|
|
181
|
-
console.warn(`Missing E:Parent (${scope.Id}): ${scope.parentScope()}`);
|
|
182
|
-
} else {
|
|
183
|
-
const parent3: ScopeSubgraph = scopeParent3;
|
|
184
|
-
try {
|
|
185
|
-
const source = graph!.vertex(scope.attr("IdSource").RawValue);
|
|
186
|
-
const target = graph!.vertex(scope.attr("IdTarget").RawValue);
|
|
187
|
-
parent3.createEdge(source, target, scope);
|
|
188
|
-
} catch (e) {
|
|
189
|
-
// const sourceIndex = scope.attr("SourceIndex").RawValue;
|
|
190
|
-
// const targetIndex = scope.attr("TargetIndex").RawValue;
|
|
191
|
-
console.warn(`Invalid Edge: ${id}`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return graph!;
|
|
196
|
-
}
|
|
1
|
+
import { Cache, Edge, Graph, StateObject, StringAnyMap, Subgraph, Vertex, XMLNode } from "@hpcc-js/util";
|
|
2
|
+
import { WsWorkunits } from "../services/wsWorkunits.ts";
|
|
3
|
+
import { BaseScope } from "./scope.ts";
|
|
4
|
+
import { Timer } from "./timer.ts";
|
|
5
|
+
import { Workunit } from "./workunit.ts";
|
|
6
|
+
|
|
7
|
+
export interface ECLGraphEx extends WsWorkunits.ECLGraph {
|
|
8
|
+
Time: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class ECLGraph extends StateObject<ECLGraphEx, ECLGraphEx> implements ECLGraphEx {
|
|
12
|
+
protected wu: Workunit;
|
|
13
|
+
|
|
14
|
+
get properties(): ECLGraphEx { return this.get(); }
|
|
15
|
+
get Name(): string { return this.get("Name"); }
|
|
16
|
+
get Label(): string { return this.get("Label"); }
|
|
17
|
+
get Type(): string { return this.get("Type"); }
|
|
18
|
+
get Complete(): boolean { return this.get("Complete"); }
|
|
19
|
+
get WhenStarted(): string { return this.get("WhenStarted"); }
|
|
20
|
+
get WhenFinished(): string { return this.get("WhenFinished"); }
|
|
21
|
+
get Time(): number { return this.get("Time"); }
|
|
22
|
+
get Running(): boolean { return this.get("Running"); }
|
|
23
|
+
get RunningId(): number { return this.get("RunningId"); }
|
|
24
|
+
get Failed(): boolean { return this.get("Failed"); }
|
|
25
|
+
|
|
26
|
+
constructor(wu: Workunit, eclGraph: WsWorkunits.ECLGraph, eclTimers: Timer[]) {
|
|
27
|
+
super();
|
|
28
|
+
this.wu = wu;
|
|
29
|
+
let duration = 0;
|
|
30
|
+
for (const eclTimer of eclTimers) {
|
|
31
|
+
if (eclTimer.GraphName === eclGraph.Name && !eclTimer.HasSubGraphId) {
|
|
32
|
+
duration = Math.round(eclTimer.Seconds * 1000) / 1000;
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
this.set({ Time: duration, ...eclGraph });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fetchScopeGraph(subgraphID?: string): Promise<ScopeGraph> {
|
|
40
|
+
if (subgraphID) {
|
|
41
|
+
return this.wu.fetchGraphDetails([subgraphID], ["subgraph"]).then((scopes) => {
|
|
42
|
+
return createGraph(scopes);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return this.wu.fetchGraphDetails([this.Name], ["graph"]).then((scopes) => {
|
|
46
|
+
return createGraph(scopes);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export class GraphCache extends Cache<WsWorkunits.ECLGraph, ECLGraph> {
|
|
52
|
+
constructor() {
|
|
53
|
+
super((obj) => {
|
|
54
|
+
return Cache.hash([obj.Name]);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type Callback = (tag: string, attributes: StringAnyMap, children: XMLNode[], _stack: XMLNode[]) => void;
|
|
60
|
+
function walkXmlJson(node: XMLNode, callback: Callback, stack?: XMLNode[]) {
|
|
61
|
+
stack = stack || [];
|
|
62
|
+
stack.push(node);
|
|
63
|
+
callback(node.name, node.$, node.children(), stack);
|
|
64
|
+
node.children().forEach((childNode) => {
|
|
65
|
+
walkXmlJson(childNode, callback, stack);
|
|
66
|
+
});
|
|
67
|
+
stack.pop();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function flattenAtt(nodes: XMLNode[]): StringAnyMap {
|
|
71
|
+
const retVal: StringAnyMap = {};
|
|
72
|
+
nodes.forEach((node: XMLNode) => {
|
|
73
|
+
if (node.name === "att") {
|
|
74
|
+
retVal[node.$["name"]] = node.$["value"];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return retVal;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class XGMMLGraph extends Graph<StringAnyMap, StringAnyMap, StringAnyMap> { }
|
|
81
|
+
export class XGMMLSubgraph extends Subgraph<StringAnyMap, StringAnyMap, StringAnyMap> { }
|
|
82
|
+
export class XGMMLVertex extends Vertex<StringAnyMap, StringAnyMap, StringAnyMap> { }
|
|
83
|
+
export class XGMMLEdge extends Edge<StringAnyMap, StringAnyMap, StringAnyMap> { }
|
|
84
|
+
|
|
85
|
+
export function createXGMMLGraph(id: string, graphs: XMLNode): XGMMLGraph {
|
|
86
|
+
const subgraphs: { [id: string]: XGMMLSubgraph } = {};
|
|
87
|
+
const vertices: { [id: string]: XGMMLVertex } = {};
|
|
88
|
+
const edges: { [id: string]: XGMMLEdge } = {};
|
|
89
|
+
|
|
90
|
+
const graph = new XGMMLGraph((item) => {
|
|
91
|
+
return item._!["id"];
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const stack: XGMMLSubgraph[] = [graph.root];
|
|
95
|
+
walkXmlJson(graphs, (tag: string, attributes: StringAnyMap, childNodes: XMLNode[], _stack) => {
|
|
96
|
+
const top = stack[stack.length - 1];
|
|
97
|
+
switch (tag) {
|
|
98
|
+
case "graph":
|
|
99
|
+
break;
|
|
100
|
+
case "node":
|
|
101
|
+
if (childNodes.length && childNodes[0].children().length && childNodes[0].children()[0].name === "graph") {
|
|
102
|
+
const subgraph = top.createSubgraph(flattenAtt(childNodes));
|
|
103
|
+
stack.push(subgraph);
|
|
104
|
+
subgraphs[attributes["id"]] = subgraph;
|
|
105
|
+
} else {
|
|
106
|
+
}
|
|
107
|
+
// TODO: Is this really a node when its also a subgraph?
|
|
108
|
+
const vertex = top.createVertex(flattenAtt(childNodes));
|
|
109
|
+
vertices[attributes["id"]] = vertex;
|
|
110
|
+
break;
|
|
111
|
+
case "edge":
|
|
112
|
+
const edge = top.createEdge(vertices[attributes["source"]], vertices[attributes["target"]], flattenAtt(childNodes));
|
|
113
|
+
edges[attributes["id"]] = edge;
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return graph;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export class ScopeGraph extends Graph<BaseScope, BaseScope, BaseScope> { }
|
|
122
|
+
export class ScopeSubgraph extends Subgraph<BaseScope, BaseScope, BaseScope> { }
|
|
123
|
+
export class ScopeVertex extends Vertex<BaseScope, BaseScope, BaseScope> { }
|
|
124
|
+
export class ScopeEdge extends Edge<BaseScope, BaseScope, BaseScope> { }
|
|
125
|
+
|
|
126
|
+
export function createGraph(scopes: BaseScope[]): ScopeGraph {
|
|
127
|
+
const subgraphs: { [scopeName: string]: ScopeSubgraph } = {};
|
|
128
|
+
const edges: { [scopeName: string]: BaseScope } = {};
|
|
129
|
+
const vertices: { [scopeName: string]: ScopeVertex } = {};
|
|
130
|
+
|
|
131
|
+
let graph: ScopeGraph | undefined;
|
|
132
|
+
for (const scope of scopes) {
|
|
133
|
+
switch (scope.ScopeType) {
|
|
134
|
+
case "graph":
|
|
135
|
+
graph = new ScopeGraph(item => item._!.Id, scope);
|
|
136
|
+
subgraphs[scope.ScopeName] = graph.root;
|
|
137
|
+
break;
|
|
138
|
+
case "subgraph":
|
|
139
|
+
if (!graph) {
|
|
140
|
+
graph = new ScopeGraph(item => item._!.Id, scope);
|
|
141
|
+
subgraphs[scope.ScopeName] = graph.root;
|
|
142
|
+
}
|
|
143
|
+
const scopeStack = scope.parentScope().split(":");
|
|
144
|
+
let scopeParent1 = subgraphs[scope.parentScope()];
|
|
145
|
+
while (scopeStack.length && !scopeParent1) {
|
|
146
|
+
scopeParent1 = subgraphs[scopeStack.join(":")];
|
|
147
|
+
scopeStack.pop();
|
|
148
|
+
}
|
|
149
|
+
if (!scopeParent1) {
|
|
150
|
+
console.warn(`Missing SG:Parent (${scope.Id}): ${scope.parentScope()}`);
|
|
151
|
+
} else {
|
|
152
|
+
const parent1: ScopeSubgraph = scopeParent1;
|
|
153
|
+
subgraphs[scope.ScopeName] = parent1.createSubgraph(scope);
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case "activity":
|
|
157
|
+
const scopeParent2 = subgraphs[scope.parentScope()];
|
|
158
|
+
if (!scopeParent2) {
|
|
159
|
+
console.warn(`Missing A:Parent (${scope.Id}): ${scope.parentScope()}`);
|
|
160
|
+
} else {
|
|
161
|
+
vertices[scope.ScopeName] = scopeParent2.createVertex(scope);
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case "edge":
|
|
165
|
+
edges[scope.ScopeName] = scope;
|
|
166
|
+
break;
|
|
167
|
+
case "function":
|
|
168
|
+
const scopeParent3 = vertices[scope.parentScope()];
|
|
169
|
+
if (!scopeParent3) {
|
|
170
|
+
console.warn(`Missing F:Parent (${scope.Id}): ${scope.parentScope()}`);
|
|
171
|
+
} else {
|
|
172
|
+
scopeParent3._.children().push(scope);
|
|
173
|
+
}
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
for (const id in edges) {
|
|
178
|
+
const scope = edges[id];
|
|
179
|
+
const scopeParent3 = subgraphs[scope.parentScope()];
|
|
180
|
+
if (!scopeParent3) {
|
|
181
|
+
console.warn(`Missing E:Parent (${scope.Id}): ${scope.parentScope()}`);
|
|
182
|
+
} else {
|
|
183
|
+
const parent3: ScopeSubgraph = scopeParent3;
|
|
184
|
+
try {
|
|
185
|
+
const source = graph!.vertex(scope.attr("IdSource").RawValue);
|
|
186
|
+
const target = graph!.vertex(scope.attr("IdTarget").RawValue);
|
|
187
|
+
parent3.createEdge(source, target, scope);
|
|
188
|
+
} catch (e) {
|
|
189
|
+
// const sourceIndex = scope.attr("SourceIndex").RawValue;
|
|
190
|
+
// const targetIndex = scope.attr("TargetIndex").RawValue;
|
|
191
|
+
console.warn(`Invalid Edge: ${id}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return graph!;
|
|
196
|
+
}
|