-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateDeleteAllForEntity.ts
320 lines (248 loc) · 16.4 KB
/
generateDeleteAllForEntity.ts
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
import { domainmodels, microflows, datatypes, texts, IModel, expressions } from "mendixmodelsdk";
import { findOrCreateModuleAndFolder, MicroflowExists } from "./findOrCreateModuleAndFolder";
export function generateDeleteAllForEntity(model: IModel, domainModel: domainmodels.DomainModel, entityName: string, targetModule: string) {
/*
* JavaScript code generated by mendixmodelsdk.sdk.extras.JavaScriptSerializer
*/
const folder = findOrCreateModuleAndFolder(model, domainModel.containerAsModule.name, targetModule, entityName);
const entity = domainModel.entities.filter((entity: domainmodels.Entity) => entity.name === entityName)[0];
let microflowName = `${entityName}_DeleteAll`;
if (!MicroflowExists(model, targetModule, microflowName, folder)) {
/*
* JavaScript code generated by mendixmodelsdk.sdk.extras.JavaScriptSerializer
*/
var startEvent1 = microflows.StartEvent.create(model);
startEvent1.relativeMiddlePoint = { "x": -215, "y": 200 };
startEvent1.size = { "width": 20, "height": 20 };
var noExpression1 = expressions.NoExpression.create(model);
var endEvent1 = microflows.EndEvent.create(model);
endEvent1.relativeMiddlePoint = { "x": 1145, "y": 200 };
endEvent1.size = { "width": 20, "height": 20 };
endEvent1.returnValueModel = noExpression1; // Note: for this property a default value is defined.
var noExpression2 = expressions.NoExpression.create(model);
var noExpression3 = expressions.NoExpression.create(model);
var customRange1 = microflows.CustomRange.create(model);
customRange1.limitExpression = "1000";
customRange1.offsetExpression = "0";
customRange1.limitExpressionModel = noExpression2; // Note: for this property a default value is defined.
customRange1.offsetExpressionModel = noExpression3; // Note: for this property a default value is defined.
var sortItemList1 = microflows.SortItemList.create(model);
var databaseRetrieveSource1 = microflows.DatabaseRetrieveSource.create(model);
//databaseRetrieveSource1.entity = model.findEntityByQualifiedName("MyFirstModule.${entityName}");
databaseRetrieveSource1.entity = entity;
databaseRetrieveSource1.range = customRange1; // Note: for this property a default value is defined.
databaseRetrieveSource1.sortItemList = sortItemList1; // Note: for this property a default value is defined.
var retrieveAction1 = microflows.RetrieveAction.create(model);
retrieveAction1.retrieveSource = databaseRetrieveSource1; // Note: for this property a default value is defined.
retrieveAction1.outputVariableName = `${entityName}List`;
var actionActivity1 = microflows.ActionActivity.create(model);
actionActivity1.relativeMiddlePoint = { "x": 275, "y": 200 };
actionActivity1.size = { "width": 120, "height": 60 };
actionActivity1.action = retrieveAction1;
//actionActivity1.caption = "Activity";
actionActivity1.autoGenerateCaption = true;
var noExpression4 = expressions.NoExpression.create(model);
var expressionSplitCondition1 = microflows.ExpressionSplitCondition.create(model);
expressionSplitCondition1.expression = `\$${entityName}List != empty`;
expressionSplitCondition1.expressionModel = noExpression4; // Note: for this property a default value is defined.
var exclusiveSplit1 = microflows.ExclusiveSplit.create(model);
exclusiveSplit1.relativeMiddlePoint = { "x": 830, "y": 200 };
exclusiveSplit1.size = { "width": 90, "height": 60 };
exclusiveSplit1.splitCondition = expressionSplitCondition1; // Note: for this property a default value is defined.
exclusiveSplit1.caption = `${entityName}s?`;
var exclusiveMerge1 = microflows.ExclusiveMerge.create(model);
exclusiveMerge1.relativeMiddlePoint = { "x": 100, "y": 200 };
exclusiveMerge1.size = { "width": 90, "height": 60 };
var deleteAction1 = microflows.DeleteAction.create(model);
deleteAction1.deleteVariableName = `${entityName}List`;
var actionActivity2 = microflows.ActionActivity.create(model);
actionActivity2.relativeMiddlePoint = { "x": 465, "y": 75 };
actionActivity2.size = { "width": 120, "height": 60 };
actionActivity2.action = deleteAction1;
actionActivity2.caption = "Activity";
actionActivity2.autoGenerateCaption = true;
var noExpression5 = expressions.NoExpression.create(model);
var noExpression6 = expressions.NoExpression.create(model);
var templateArgument1 = microflows.TemplateArgument.create(model);
templateArgument1.expression = "toString($TotalCount)";
templateArgument1.expressionModel = noExpression6; // Note: for this property a default value is defined.
var stringTemplate1 = microflows.StringTemplate.create(model);
stringTemplate1.arguments.push(templateArgument1);
stringTemplate1.text = `Deleted all ${entityName}s (Count={1})`;
var logMessageAction1 = microflows.LogMessageAction.create(model);
logMessageAction1.node = `'${entityName}'`;
logMessageAction1.nodeModel = noExpression5; // Note: for this property a default value is defined.
logMessageAction1.messageTemplate = stringTemplate1; // Note: for this property a default value is defined.
var actionActivity3 = microflows.ActionActivity.create(model);
actionActivity3.relativeMiddlePoint = { "x": 1005, "y": 200 };
actionActivity3.size = { "width": 120, "height": 60 };
actionActivity3.action = logMessageAction1;
actionActivity3.caption = "Activity";
actionActivity3.autoGenerateCaption = true;
var integerType1 = datatypes.IntegerType.create(model);
var noExpression7 = expressions.NoExpression.create(model);
var createVariableAction1 = microflows.CreateVariableAction.create(model);
createVariableAction1.variableName = "TotalCount";
createVariableAction1.variableType = integerType1; // Note: for this property a default value is defined.
createVariableAction1.initialValue = "0";
createVariableAction1.initialValueModel = noExpression7; // Note: for this property a default value is defined.
var actionActivity4 = microflows.ActionActivity.create(model);
actionActivity4.relativeMiddlePoint = { "x": -75, "y": 200 };
actionActivity4.size = { "width": 120, "height": 60 };
actionActivity4.action = createVariableAction1;
actionActivity4.caption = "Activity";
actionActivity4.autoGenerateCaption = true;
var aggregateListAction1 = microflows.AggregateListAction.create(model);
aggregateListAction1.inputListVariableName = `${entityName}List`;
aggregateListAction1.aggregateFunction = microflows.AggregateFunctionEnum.Count;
aggregateListAction1.outputVariableName = "Count";
var actionActivity5 = microflows.ActionActivity.create(model);
actionActivity5.relativeMiddlePoint = { "x": 465, "y": 200 };
actionActivity5.size = { "width": 120, "height": 60 };
actionActivity5.action = aggregateListAction1;
actionActivity5.caption = "Activity";
actionActivity5.autoGenerateCaption = true;
var noExpression8 = expressions.NoExpression.create(model);
var changeVariableAction1 = microflows.ChangeVariableAction.create(model);
changeVariableAction1.changeVariableName = "TotalCount";
changeVariableAction1.value = "$TotalCount + $Count";
changeVariableAction1.valueModel = noExpression8; // Note: for this property a default value is defined.
var actionActivity6 = microflows.ActionActivity.create(model);
actionActivity6.relativeMiddlePoint = { "x": 655, "y": 200 };
actionActivity6.size = { "width": 120, "height": 60 };
actionActivity6.action = changeVariableAction1;
//actionActivity6.caption = "Activity";
actionActivity6.autoGenerateCaption = true;
var annotation1 = microflows.Annotation.create(model);
annotation1.relativeMiddlePoint = { "x": -30, "y": -60 };
annotation1.size = { "width": 230, "height": 50 };
annotation1.caption = "Only for development, be sure to disable this in a production environment.";
var microflowObjectCollection1 = microflows.MicroflowObjectCollection.create(model);
microflowObjectCollection1.objects.push(startEvent1);
microflowObjectCollection1.objects.push(endEvent1);
microflowObjectCollection1.objects.push(actionActivity1);
microflowObjectCollection1.objects.push(exclusiveSplit1);
microflowObjectCollection1.objects.push(exclusiveMerge1);
microflowObjectCollection1.objects.push(actionActivity2);
microflowObjectCollection1.objects.push(actionActivity3);
microflowObjectCollection1.objects.push(actionActivity4);
microflowObjectCollection1.objects.push(actionActivity5);
microflowObjectCollection1.objects.push(actionActivity6);
microflowObjectCollection1.objects.push(annotation1);
var noCase1 = microflows.NoCase.create(model);
var sequenceFlow1 = microflows.SequenceFlow.create(model);
sequenceFlow1.originConnectionIndex = 1;
sequenceFlow1.destinationConnectionIndex = 3;
sequenceFlow1.originBezierVector = { "width": 0, "height": 0 };
sequenceFlow1.destinationBezierVector = { "width": -30, "height": 0 };
sequenceFlow1.caseValue = noCase1; // Note: for this property a default value is defined.
var noCase2 = microflows.NoCase.create(model);
var sequenceFlow2 = microflows.SequenceFlow.create(model);
sequenceFlow2.originConnectionIndex = 1;
sequenceFlow2.destinationConnectionIndex = 3;
sequenceFlow2.originBezierVector = { "width": 30, "height": 0 };
sequenceFlow2.destinationBezierVector = { "width": -30, "height": 0 };
sequenceFlow2.caseValue = noCase2; // Note: for this property a default value is defined.
var enumerationCase1 = microflows.EnumerationCase.create(model);
enumerationCase1.value = "false";
var sequenceFlow3 = microflows.SequenceFlow.create(model);
sequenceFlow3.originConnectionIndex = 1;
sequenceFlow3.destinationConnectionIndex = 3;
sequenceFlow3.originBezierVector = { "width": 15, "height": 0 };
sequenceFlow3.destinationBezierVector = { "width": -30, "height": 0 };
sequenceFlow3.caseValue = enumerationCase1; // Note: for this property a default value is defined.
var noCase3 = microflows.NoCase.create(model);
var sequenceFlow4 = microflows.SequenceFlow.create(model);
sequenceFlow4.originConnectionIndex = 1;
sequenceFlow4.destinationConnectionIndex = 3;
sequenceFlow4.originBezierVector = { "width": 15, "height": 0 };
sequenceFlow4.destinationBezierVector = { "width": -30, "height": 0 };
sequenceFlow4.caseValue = noCase3; // Note: for this property a default value is defined.
var enumerationCase2 = microflows.EnumerationCase.create(model);
enumerationCase2.value = "true";
var sequenceFlow5 = microflows.SequenceFlow.create(model);
sequenceFlow5.destinationConnectionIndex = 1;
sequenceFlow5.originBezierVector = { "width": 0, "height": -70 };
sequenceFlow5.destinationBezierVector = { "width": 30, "height": 0 };
sequenceFlow5.caseValue = enumerationCase2; // Note: for this property a default value is defined.
var noCase4 = microflows.NoCase.create(model);
var sequenceFlow6 = microflows.SequenceFlow.create(model);
sequenceFlow6.originConnectionIndex = 3;
sequenceFlow6.originBezierVector = { "width": -30, "height": 0 };
sequenceFlow6.destinationBezierVector = { "width": 5, "height": -65 };
sequenceFlow6.caseValue = noCase4; // Note: for this property a default value is defined.
var noCase5 = microflows.NoCase.create(model);
var sequenceFlow7 = microflows.SequenceFlow.create(model);
sequenceFlow7.originConnectionIndex = 1;
sequenceFlow7.destinationConnectionIndex = 3;
sequenceFlow7.originBezierVector = { "width": 30, "height": 0 };
sequenceFlow7.destinationBezierVector = { "width": -15, "height": 0 };
sequenceFlow7.caseValue = noCase5; // Note: for this property a default value is defined.
var noCase6 = microflows.NoCase.create(model);
var sequenceFlow8 = microflows.SequenceFlow.create(model);
sequenceFlow8.originConnectionIndex = 1;
sequenceFlow8.destinationConnectionIndex = 3;
sequenceFlow8.originBezierVector = { "width": 30, "height": 0 };
sequenceFlow8.destinationBezierVector = { "width": -15, "height": 0 };
sequenceFlow8.caseValue = noCase6; // Note: for this property a default value is defined.
var noCase7 = microflows.NoCase.create(model);
var sequenceFlow9 = microflows.SequenceFlow.create(model);
sequenceFlow9.originConnectionIndex = 1;
sequenceFlow9.destinationConnectionIndex = 3;
sequenceFlow9.originBezierVector = { "width": 30, "height": 0 };
sequenceFlow9.destinationBezierVector = { "width": -30, "height": 0 };
sequenceFlow9.caseValue = noCase7; // Note: for this property a default value is defined.
var noCase8 = microflows.NoCase.create(model);
var sequenceFlow10 = microflows.SequenceFlow.create(model);
sequenceFlow10.originConnectionIndex = 1;
sequenceFlow10.destinationConnectionIndex = 3;
sequenceFlow10.originBezierVector = { "width": 30, "height": 0 };
sequenceFlow10.destinationBezierVector = { "width": -15, "height": 0 };
sequenceFlow10.caseValue = noCase8; // Note: for this property a default value is defined.
var voidType1 = datatypes.VoidType.create(model);
var translation1 = texts.Translation.create(model);
translation1.languageCode = "en_US";
var text1 = texts.Text.create(model);
text1.translations.push(translation1);
var entity_DeleteAll = microflows.Microflow.createIn(folder);
entity_DeleteAll.name = microflowName
entity_DeleteAll.objectCollection = microflowObjectCollection1; // Note: for this property a default value is defined.
entity_DeleteAll.flows.push(sequenceFlow1);
entity_DeleteAll.flows.push(sequenceFlow2);
entity_DeleteAll.flows.push(sequenceFlow3);
entity_DeleteAll.flows.push(sequenceFlow4);
entity_DeleteAll.flows.push(sequenceFlow5);
entity_DeleteAll.flows.push(sequenceFlow6);
entity_DeleteAll.flows.push(sequenceFlow7);
entity_DeleteAll.flows.push(sequenceFlow8);
entity_DeleteAll.flows.push(sequenceFlow9);
entity_DeleteAll.flows.push(sequenceFlow10);
entity_DeleteAll.microflowReturnType = voidType1;
entity_DeleteAll.allowConcurrentExecution = true;
entity_DeleteAll.concurrencyErrorMessage = text1; // Note: for this property a default value is defined.
sequenceFlow1.origin = startEvent1;
sequenceFlow1.destination = actionActivity4;
sequenceFlow2.origin = actionActivity1;
sequenceFlow2.destination = actionActivity5;
sequenceFlow3.origin = exclusiveSplit1;
sequenceFlow3.destination = actionActivity3;
sequenceFlow4.origin = exclusiveMerge1;
sequenceFlow4.destination = actionActivity1;
sequenceFlow5.origin = exclusiveSplit1;
sequenceFlow5.destination = actionActivity2;
sequenceFlow6.origin = actionActivity2;
sequenceFlow6.destination = exclusiveMerge1;
sequenceFlow7.origin = actionActivity3;
sequenceFlow7.destination = endEvent1;
sequenceFlow8.origin = actionActivity4;
sequenceFlow8.destination = exclusiveMerge1;
sequenceFlow9.origin = actionActivity5;
sequenceFlow9.destination = actionActivity6;
sequenceFlow10.origin = actionActivity6;
sequenceFlow10.destination = exclusiveSplit1;
let annotation = microflows.Annotation.createIn(entity_DeleteAll.objectCollection);
annotation.caption = "This microflow was automatically generated by Mendilangelo. Don't use this here but copy or move it to your own module.";
annotation.relativeMiddlePoint = { x: startEvent1.relativeMiddlePoint.x + 40, y: startEvent1.relativeMiddlePoint.y - 100 };
annotation.size = { width: 200, height: 100 };
}
}