Skip to content

Commit 090187c

Browse files
abhinavverma-sfAbhinav  Verma
andauthored
fix(core): camunda update changes and valueType anyValue fix (#85)
* fix(core): fix valuetype any change fix valuetype any change GH-9-valueAny * fix(core): saurabh sinha json changes saurabh sinha json changes GH-9-valueAny --------- Co-authored-by: Abhinav Verma <[email protected]>
1 parent b8d2878 commit 090187c

File tree

7 files changed

+71
-36
lines changed

7 files changed

+71
-36
lines changed

projects/workflows-creator/src/lib/builder/builder.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ export class BuilderComponent<E> implements OnInit, OnChanges {
373373
) {
374374
if (
375375
((value as AllowedValuesMap)?.value as AllowedValuesMap)?.value ===
376-
ValueTypes.AnyValue
376+
ValueTypes.AnyValue || ((value as AllowedValuesMap)?.value === ValueTypes.AnyValue)
377377
) {
378378
/**
379379
* Remove node on changes event

projects/workflows-creator/src/lib/const.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ xmlns:camunda="http://camunda.org/schema/1.0/bpmn"
1414
xmlns:modeler="http://camunda.org/schema/modeler/1.0"
1515
id="Definitions_1aj5pzu"
1616
targetNamespace="http://bpmn.io/schema/bpmn"
17-
exporter="Camunda Modeler" exporterVersion="4.12.0"
17+
exporter="Camunda Modeler" exporterVersion="5.21.0"
1818
modeler:executionPlatform="Camunda Platform"
19-
modeler:executionPlatformVersion="7.15.0">
19+
modeler:executionPlatformVersion="7.21.0">
2020
</bpmn:definitions>
2121
`;
2222

23-
export const JSON_SCRIPT_START = `var json = S(\"{}\");\n`;
24-
export const JSON_SCRIPT_END = `\n json`;
23+
export const JSON_SCRIPT_START = `var json = {};\n`;
24+
export const JSON_SCRIPT_END = `\n JSON.stringify(json)`;
2525

2626
export const BASE_XML = new InjectionToken<string>('diagram.bpmn.base');
2727
export const MODDLE = new InjectionToken<CustomBpmnModdle>(
@@ -48,4 +48,4 @@ export const typeTuppleList: Array<ConditionOperatorPair> = [
4848
{condition: ConditionTypes.LessThan, operator: '<', value: true},
4949
{condition: ConditionTypes.ComingIn, operator: '-', value: true},
5050
{condition: ConditionTypes.PastBy, operator: '+', value: true},
51-
];
51+
];

projects/workflows-creator/src/lib/services/bpmn/elements/gateways/gateway.element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class GatewayElement extends BpmnElement {
2121
) {
2222
super();
2323
}
24-
tag = 'bpmn:ExclusiveGateway';
24+
tag = 'bpmn:InclusiveGateway';
2525
name = 'gateway';
2626
properties = {};
2727
statement: string | undefined;
@@ -40,4 +40,4 @@ export class GatewayElement extends BpmnElement {
4040
getIdentifier(): string {
4141
return GatewayElement.identifier;
4242
}
43-
}
43+
}

projects/workflows-creator/src/lib/services/bpmn/elements/process/process.element.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ export class ProcessElement extends BpmnElement {
3030
static identifier = 'ProcessElement';
3131
attributes = {
3232
isExecutable: true,
33+
historyTimeToLive: 'P3650D',
3334
};
3435

3536
getIdentifier(): string {
3637
return ProcessElement.identifier;
3738
}
38-
}
39+
}

projects/workflows-creator/src/lib/services/bpmn/strategies/create/task-create.strategy.ts

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -142,48 +142,63 @@ export class CreateTaskStrategy implements CreateStrategy<ModdleElement> {
142142
let read = '';
143143
if (froms.length > 0) {
144144
if (prevIds.length) {
145-
read = `var readObj = ${prevIds
146-
.map(id => `JSON.parse(execution.getVariable('${id}'))`)
147-
.join(' || ')} || {};`;
145+
read = `${prevIds
146+
.map(
147+
(id, index) =>
148+
`var readObj${index} = JSON.parse(execution.getVariable('${id}')) || {};`,
149+
)
150+
.join('\n')}
151+
`;
148152
}
149153
}
150-
const getVariables = froms
151-
.map(
152-
p =>
153-
`var ${(p as FromParam).from}Local = readObj.${
154-
(p as FromParam).from
155-
};`,
156-
)
157-
.join('\n');
154+
const getVariables = froms.map(
155+
p =>
156+
`
157+
var ${(p as FromParam).from}Local;
158+
${prevIds
159+
.map(
160+
(_: any, index: number) => `
161+
if(readObj${index}.${
162+
(p as FromParam).from
163+
} && readObj${index}.${(froms[0] as FromParam).from}.length){
164+
${(froms[0] as FromParam).from}Local = readObj${index}.${
165+
(froms[0] as FromParam).from
166+
};
167+
}
168+
`,
169+
)
170+
.join('\n')}
171+
`,
172+
);
158173
const setVariabels = Object.keys(params).reduce(
159174
(p: string, key: string) => {
160175
const tmp = params[key];
161176
if (isFormattedParam(tmp)) {
162-
return `${p}\njson.prop("${key}", ${tmp.formatter(state)});`;
177+
return `${p}\njson["${key}"] = ${tmp.formatter(state)};`;
163178
} else if (isFromParam(tmp)) {
164-
return `${p}\njson.prop("${key}", ${tmp.from}Local);`;
179+
return `${p}\njson["${key}"] = ${tmp.from}Local;`;
165180
} else if (isStateParam(tmp)) {
166181
if (
167182
tmp.state === 'recipients' &&
168183
Array.isArray(state.get(tmp.state))
169184
) {
170185
const metaValue = this.transposeArrayToString(state.get(tmp.state));
171-
return `${p}\njson.prop("${key}", [${metaValue ?? ''}]);`;
186+
return `${p}\njson["${key}"] = [${metaValue ?? ''}];`;
172187
}
173188

174-
return `${p}\njson.prop("${key}", "${state.get(tmp.state) ?? ''}");`;
189+
return `${p}\njson["${key}"] = "${state.get(tmp.state) ?? ''}";`;
175190
} else {
176-
return `${p}\njson.prop("${key}", "${tmp.value}");`;
191+
return `${p}\njson["${key}"] = "${tmp.value}";`;
177192
}
178193
},
179194
'',
180195
);
181196
return [
182197
read,
183198
getVariables,
184-
`var json = S("{}");`,
199+
`var json = {};`,
185200
setVariabels,
186-
'json',
201+
'JSON.stringify(json)',
187202
].join('\n');
188203
}
189204

@@ -207,4 +222,4 @@ export class CreateTaskStrategy implements CreateStrategy<ModdleElement> {
207222
return [node.prev[0].element.id];
208223
}
209224
}
210-
}
225+
}

projects/workflows-creator/src/lib/services/bpmn/strategies/link/gateway-link.strategy.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,13 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
193193
) {
194194
const lastNodeWithOutput = this.getLastNodeWithOutput(node);
195195
const read = `var readObj = JSON.parse(execution.getVariable('${lastNodeWithOutput.element.id}'));`;
196-
const declarations = `var ids = [];var json = S("{}");`;
196+
const declarations = `var ids = [];var json = {};`;
197197
const column = node.workflowNode.state.get('columnName');
198198
const condition = this.getCondition(node);
199199
const loop = this.createLoopScript(node, condition, isElse);
200200
const setters = `
201-
json.prop("taskIds", ids);
201+
json["taskIds"] = ids;
202+
json = JSON.stringify(json);
202203
execution.setVariable('${flowId}',json);
203204
if(ids.length > 0){true;}else {false;}
204205
`;
@@ -227,6 +228,25 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
227228
const valueType = node.workflowNode.state.get('valueType');
228229
const valueInputType = node.workflowNode.state.get('valueInputType');
229230

231+
if (
232+
valueInputType === InputTypes.Date &&
233+
(valueType === ValueTypes.Custom ||
234+
conditionType === ConditionTypes.Equal)
235+
) {
236+
return `
237+
for (var key in readObj) {
238+
var taskValuePair = readObj[key];
239+
if (taskValuePair && (taskValuePair.value || taskValuePair.value==='')) {
240+
var readDateValue = taskValuePair.value.split('T')[0];
241+
var customDate = "${condition}";
242+
243+
if (${isElse ? '!' : ''}(readDateValue === customDate)) {
244+
ids.push(taskValuePair.id);
245+
}
246+
}
247+
}
248+
`;
249+
}
230250
if (!conditionType && valueType && valueInputType === InputTypes.Date) {
231251
switch (valueType) {
232252
case ValueTypes.PastToday:
@@ -261,9 +281,7 @@ export class GatewayLinkStrategy implements LinkStrategy<ModdleElement> {
261281
var readDateValue = taskValuePair.value.split('T')[0];
262282
var customDate = "${condition}";
263283
264-
if (${
265-
isElse ? '!' : ''
266-
}(readDateValue === customDate)) {
284+
if (${isElse ? '!' : ''}(readDateValue === customDate)) {
267285
ids.push(taskValuePair.id);
268286
}
269287
}

projects/workflows-creator/src/lib/services/bpmn/strategies/link/or-gateway-link.strategy.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ export class OrGatewayLinkStrategy implements LinkStrategy<ModdleElement> {
112112
) {
113113
const lastNodeWithOutput = this.getLastNodeWithOutput(node);
114114
const read = `var readObj = JSON.parse(execution.getVariable('${lastNodeWithOutput.element.id}'));`;
115-
const declarations = `var ids = [];var json = S("{}");`;
115+
const declarations = `var ids = [];var json = {};`;
116116
const column = node.workflowNode.state.get('columnName');
117117
const condition = this.getCondition(node);
118118
const loop = this.createLoopScript(node, condition, isElse);
119119
const setters = `
120-
json.prop("taskIds", ids);
120+
json["taskIds"] = ids;
121+
json.stringify(json);
121122
execution.setVariable('${flowId}',json);
122123
if(ids.length > 0){true;}else {false;}
123124
`;
@@ -229,4 +230,4 @@ export class OrGatewayLinkStrategy implements LinkStrategy<ModdleElement> {
229230
return `${pair.operator}`;
230231
}
231232
}
232-
}
233+
}

0 commit comments

Comments
 (0)