Skip to content

Commit 866cbef

Browse files
authored
Merge pull request #134 from Exabyte-io/feature/SOF-7817
feature/SOF 7817
2 parents 478aa9d + 4dc8475 commit 866cbef

File tree

11 files changed

+84
-19
lines changed

11 files changed

+84
-19
lines changed

dist/js/subworkflows/create.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ function createUnit({
132132
config,
133133
application,
134134
unitBuilders,
135-
unitFactoryCls
135+
unitFactoryCls,
136+
cache = []
136137
}) {
137138
const {
138139
type,
@@ -145,7 +146,7 @@ function createUnit({
145146
flavorName,
146147
flowchartId
147148
} = unitConfig;
148-
const builder = new unitBuilders.ExecutionUnitConfigBuilder(name, application, execName, flavorName, flowchartId);
149+
const builder = new unitBuilders.ExecutionUnitConfigBuilder(name, application, execName, flavorName, flowchartId, cache);
149150

150151
// config should contain "functions" and "attributes"
151152
const cfg = (0, _utils.applyConfig)({
@@ -202,6 +203,7 @@ function createDynamicUnits({
202203
}
203204
function createSubworkflow({
204205
subworkflowData,
206+
cache = [],
205207
AppRegistry = _ade.ApplicationRegistry,
206208
modelFactoryCls = _mode.ModelFactory,
207209
methodFactoryCls = _mode.MethodFactory,
@@ -232,7 +234,8 @@ function createSubworkflow({
232234
config: _config,
233235
application,
234236
unitBuilders,
235-
unitFactoryCls
237+
unitFactoryCls,
238+
cache
236239
}));
237240
});
238241
if (dynamicSubworkflow) {

dist/js/subworkflows/subworkflow.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
2020
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
2121
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2222
/* eslint max-classes-per-file:0 */
23-
2423
class BaseSubworkflow extends (0, _mixwith.mix)(_entity.NamedDefaultableRepetitionImportantSettingsInMemoryEntity).with(_convergence.ConvergenceMixin, _entity.ContextAndRenderFieldsMixin) {}
2524
class Subworkflow extends BaseSubworkflow {
2625
constructor(config, _Application = _ade.Application, _ModelFactory = _mode.ModelFactory, _UnitFactory = _units.UnitFactory) {

dist/js/units/builders/ExecutionUnitConfigBuilder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ var _UnitConfigBuilder = require("./UnitConfigBuilder");
1010
/* eslint-disable class-methods-use-this */
1111

1212
class ExecutionUnitConfigBuilder extends _UnitConfigBuilder.UnitConfigBuilder {
13-
constructor(name, application, execName, flavorName, flowchartId) {
13+
constructor(name, application, execName, flavorName, flowchartId, cache = []) {
1414
super({
1515
name,
1616
type: _enums.UNIT_TYPES.execution,
17-
flowchartId
17+
flowchartId,
18+
cache
1819
});
1920
try {
2021
this.initialize(application, execName, flavorName);

dist/js/units/builders/UnitConfigBuilder.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class UnitConfigBuilder {
1414
constructor({
1515
name,
1616
type,
17-
flowchartId
17+
flowchartId,
18+
cache = []
1819
}) {
1920
this.type = type;
2021
this._name = name;
@@ -23,7 +24,10 @@ class UnitConfigBuilder {
2324
this._monitors = [];
2425
this._preProcessors = [];
2526
this._postProcessors = [];
26-
this._flowchartId = flowchartId || this.constructor.generateFlowChartId(name);
27+
this.cache = cache;
28+
const countInCache = this.cache.filter(s => s === name).length;
29+
this.cache.push(name);
30+
this._flowchartId = flowchartId || this.generateFlowChartId(name, countInCache);
2731
}
2832
name(str) {
2933
this._name = str;
@@ -33,8 +37,10 @@ class UnitConfigBuilder {
3337
this._head = bool;
3438
return this;
3539
}
36-
static generateFlowChartId(...args) {
37-
if (this.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(...args);
40+
generateFlowChartId(seed, countInCache = 0) {
41+
const suffix = countInCache > 0 ? `-${countInCache}` : "";
42+
const seedWithSuffix = `${seed}${suffix}`;
43+
if (this.constructor.usePredefinedIds) return _utils.Utils.uuid.getUUIDFromNamespace(seedWithSuffix);
3844
return _utils.Utils.uuid.getUUID();
3945
}
4046
flowchartId(flowchartId) {

dist/js/workflows/create.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ function createSubworkflowUnit({
7878
appName,
7979
unitData,
8080
workflowData,
81+
cache,
8182
...swArgs
8283
}) {
8384
const {
@@ -104,6 +105,7 @@ function createSubworkflowUnit({
104105
});
105106
return (0, _create.createSubworkflow)({
106107
subworkflowData,
108+
cache,
107109
...swArgs
108110
});
109111
}
@@ -236,6 +238,7 @@ function createWorkflowUnits({
236238
workflowData,
237239
workflowSubworkflowMapByApplication,
238240
workflowCls,
241+
cache = [],
239242
...swArgs
240243
}) {
241244
const wfUnits = [];
@@ -268,6 +271,7 @@ function createWorkflowUnits({
268271
appName,
269272
unitData,
270273
workflowData: workflowSubworkflowMapByApplication,
274+
cache,
271275
...swArgs
272276
});
273277
break;
@@ -295,6 +299,7 @@ function createWorkflow({
295299
workflowCls = _workflow.Workflow,
296300
...swArgs
297301
}) {
302+
const cache = [];
298303
const {
299304
name
300305
} = workflowData;
@@ -304,6 +309,7 @@ function createWorkflow({
304309
workflowData,
305310
workflowSubworkflowMapByApplication,
306311
workflowCls,
312+
cache,
307313
...swArgs
308314
});
309315
wf.setName(name);

src/js/subworkflows/create.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function createTopLevel({ subworkflowData, modelFactoryCls, methodFactoryCls, Ap
9696
* @param unitFactoryCls {*} workflow unit class factory
9797
* @returns {*|{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []}}
9898
*/
99-
export function createUnit({ config, application, unitBuilders, unitFactoryCls }) {
99+
export function createUnit({ config, application, unitBuilders, unitFactoryCls, cache = [] }) {
100100
const { type, config: unitConfig } = config;
101101
if (type === "executionBuilder") {
102102
const { name, execName, flavorName, flowchartId } = unitConfig;
@@ -106,6 +106,7 @@ export function createUnit({ config, application, unitBuilders, unitFactoryCls }
106106
execName,
107107
flavorName,
108108
flowchartId,
109+
cache,
109110
);
110111

111112
// config should contain "functions" and "attributes"
@@ -148,6 +149,7 @@ function createDynamicUnits({
148149

149150
function createSubworkflow({
150151
subworkflowData,
152+
cache = [],
151153
AppRegistry = ApplicationRegistry,
152154
modelFactoryCls = ModelFactory,
153155
methodFactoryCls = MethodFactory,
@@ -171,6 +173,7 @@ function createSubworkflow({
171173
application,
172174
unitBuilders,
173175
unitFactoryCls,
176+
cache,
174177
}),
175178
);
176179
});

src/js/subworkflows/subworkflow.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { setNextLinks, setUnitsHead } from "../utils";
1515
import { ConvergenceMixin } from "./convergence";
1616

1717
/* eslint max-classes-per-file:0 */
18-
1918
class BaseSubworkflow extends mix(NamedDefaultableRepetitionImportantSettingsInMemoryEntity).with(
2019
ConvergenceMixin,
2120
ContextAndRenderFieldsMixin,

src/js/units/builders/ExecutionUnitConfigBuilder.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { UNIT_TYPES } from "../../enums";
55
import { UnitConfigBuilder } from "./UnitConfigBuilder";
66

77
export class ExecutionUnitConfigBuilder extends UnitConfigBuilder {
8-
constructor(name, application, execName, flavorName, flowchartId) {
9-
super({ name, type: UNIT_TYPES.execution, flowchartId });
8+
constructor(name, application, execName, flavorName, flowchartId, cache = []) {
9+
super({ name, type: UNIT_TYPES.execution, flowchartId, cache });
1010

1111
try {
1212
this.initialize(application, execName, flavorName);

src/js/units/builders/UnitConfigBuilder.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ import _ from "underscore";
44
export class UnitConfigBuilder {
55
static usePredefinedIds = false;
66

7-
constructor({ name, type, flowchartId }) {
7+
constructor({ name, type, flowchartId, cache = [] }) {
88
this.type = type;
99
this._name = name;
1010
this._head = false;
1111
this._results = [];
1212
this._monitors = [];
1313
this._preProcessors = [];
1414
this._postProcessors = [];
15-
this._flowchartId = flowchartId || this.constructor.generateFlowChartId(name);
15+
this.cache = cache;
16+
const countInCache = this.cache.filter((s) => s === name).length;
17+
this.cache.push(name);
18+
this._flowchartId = flowchartId || this.generateFlowChartId(name, countInCache);
1619
}
1720

1821
name(str) {
@@ -25,8 +28,11 @@ export class UnitConfigBuilder {
2528
return this;
2629
}
2730

28-
static generateFlowChartId(...args) {
29-
if (this.usePredefinedIds) return Utils.uuid.getUUIDFromNamespace(...args);
31+
generateFlowChartId(seed, countInCache = 0) {
32+
const suffix = countInCache > 0 ? `-${countInCache}` : "";
33+
const seedWithSuffix = `${seed}${suffix}`;
34+
if (this.constructor.usePredefinedIds)
35+
return Utils.uuid.getUUIDFromNamespace(seedWithSuffix);
3036
return Utils.uuid.getUUID();
3137
}
3238

src/js/workflows/create.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function updateUnitConfigs({ subworkflowData, unitConfigs }) {
4444
* @param swArgs {*} subworkflow classes
4545
* @returns {*} subworkflow object
4646
*/
47-
function createSubworkflowUnit({ appName, unitData, workflowData, ...swArgs }) {
47+
function createSubworkflowUnit({ appName, unitData, workflowData, cache, ...swArgs }) {
4848
const { name: unitName, unitConfigs, config } = unitData;
4949
const { subworkflows } = workflowData;
5050
const { [appName]: dataByApp } = subworkflows;
@@ -53,6 +53,7 @@ function createSubworkflowUnit({ appName, unitData, workflowData, ...swArgs }) {
5353
if (unitConfigs) subworkflowData = updateUnitConfigs({ subworkflowData, unitConfigs });
5454
return createSubworkflow({
5555
subworkflowData,
56+
cache,
5657
...swArgs,
5758
});
5859
}
@@ -157,6 +158,7 @@ function createWorkflowUnits({
157158
workflowData,
158159
workflowSubworkflowMapByApplication,
159160
workflowCls,
161+
cache = [],
160162
...swArgs
161163
}) {
162164
const wfUnits = [];
@@ -181,6 +183,7 @@ function createWorkflowUnits({
181183
appName,
182184
unitData,
183185
workflowData: workflowSubworkflowMapByApplication,
186+
cache,
184187
...swArgs,
185188
});
186189
break;
@@ -205,13 +208,15 @@ function createWorkflow({
205208
workflowCls = Workflow,
206209
...swArgs
207210
}) {
211+
const cache = [];
208212
const { name } = workflowData;
209213
console.log(`wode: creating ${appName} workflow ${name}`);
210214
const wf = createWorkflowUnits({
211215
appName,
212216
workflowData,
213217
workflowSubworkflowMapByApplication,
214218
workflowCls,
219+
cache,
215220
...swArgs,
216221
});
217222
wf.setName(name);

0 commit comments

Comments
 (0)