1
- /*
1
+ /**
2
2
* Copyright 2016 Netflix, Inc.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
+ /**
17
+ *
18
+ */
16
19
package com .netflix .conductor .common .metadata .workflow ;
17
20
18
21
import com .github .vmg .protogen .annotations .ProtoField ;
21
24
22
25
import java .util .Collection ;
23
26
import java .util .HashMap ;
24
- import java .util .HashSet ;
25
27
import java .util .Iterator ;
26
28
import java .util .LinkedHashMap ;
27
29
import java .util .LinkedList ;
28
30
import java .util .List ;
29
31
import java .util .Map ;
30
32
import java .util .Objects ;
31
- import java .util .Set ;
32
33
33
34
/**
34
35
* @author Viren
35
36
*
36
- * This is the task definition defined as part of the {@link WorkflowDef}. The tasks definied in the Workflow definition are saved
37
+ * This is the task definition definied as part of the {@link WorkflowDef}. The tasks definied in the Workflow definition are saved
37
38
* as part of {@link WorkflowDef#tasks}
38
39
*/
39
40
@ ProtoMessage
40
41
public class WorkflowTask {
41
42
42
- /**
43
- * This field is deprecated and will be removed in the next version.
44
- * Please use {@link TaskType} instead.
45
- */
46
- @ Deprecated
47
- public enum Type {
48
- SIMPLE , DYNAMIC , FORK_JOIN , FORK_JOIN_DYNAMIC , DECISION , JOIN , SUB_WORKFLOW , EVENT , WAIT , USER_DEFINED ;
49
-
50
- private static Set <String > systemTasks = new HashSet <>();
51
- static {
52
- systemTasks .add (Type .SIMPLE .name ());
53
- systemTasks .add (Type .DYNAMIC .name ());
54
- systemTasks .add (Type .FORK_JOIN .name ());
55
- systemTasks .add (Type .FORK_JOIN_DYNAMIC .name ());
56
- systemTasks .add (Type .DECISION .name ());
57
- systemTasks .add (Type .JOIN .name ());
58
- systemTasks .add (Type .SUB_WORKFLOW .name ());
59
- systemTasks .add (Type .EVENT .name ());
60
- systemTasks .add (Type .WAIT .name ());
61
- //Do NOT add USER_DEFINED here...
62
- }
63
-
64
- public static boolean isSystemTask (String name ) {
65
- return systemTasks .contains (name );
66
- }
67
- }
68
-
69
43
@ ProtoField (id = 1 )
70
44
private String name ;
71
45
@@ -78,7 +52,7 @@ public static boolean isSystemTask(String name) {
78
52
//Key: Name of the input parameter. MUST be one of the keys defined in TaskDef (e.g. fileName)
79
53
//Value: mapping of the parameter from another task (e.g. task1.someOutputParameterAsFileName)
80
54
@ ProtoField (id = 4 )
81
- private Map <String , Object > inputParameters = new HashMap <>();
55
+ private Map <String , Object > inputParameters = new HashMap <String , Object >();
82
56
83
57
@ ProtoField (id = 5 )
84
58
private String type = TaskType .SIMPLE .name ();
@@ -201,7 +175,7 @@ public Map<String, Object> getInputParameters() {
201
175
public void setInputParameters (Map <String , Object > inputParameters ) {
202
176
this .inputParameters = inputParameters ;
203
177
}
204
-
178
+
205
179
/**
206
180
* @return the type
207
181
*/
@@ -212,7 +186,7 @@ public String getType() {
212
186
public void setWorkflowTaskType (TaskType type ) {
213
187
this .type = type .name ();
214
188
}
215
-
189
+
216
190
/**
217
191
* @param type the type to set
218
192
*/
@@ -234,7 +208,7 @@ public void setDecisionCases(Map<String, List<WorkflowTask>> decisionCases) {
234
208
this .decisionCases = decisionCases ;
235
209
}
236
210
237
-
211
+
238
212
/**
239
213
* @return the defaultCase
240
214
*/
@@ -263,7 +237,7 @@ public void setForkTasks(List<List<WorkflowTask>> forkTasks) {
263
237
this .forkTasks = forkTasks ;
264
238
}
265
239
266
-
240
+
267
241
/**
268
242
* @return the startDelay in seconds
269
243
*/
@@ -278,7 +252,7 @@ public void setStartDelay(int startDelay) {
278
252
this .startDelay = startDelay ;
279
253
}
280
254
281
-
255
+
282
256
/**
283
257
* @return the dynamicTaskNameParam
284
258
*/
@@ -288,13 +262,13 @@ public String getDynamicTaskNameParam() {
288
262
289
263
/**
290
264
* @param dynamicTaskNameParam the dynamicTaskNameParam to set to be used by DYNAMIC tasks
291
- *
265
+ *
292
266
*/
293
267
public void setDynamicTaskNameParam (String dynamicTaskNameParam ) {
294
268
this .dynamicTaskNameParam = dynamicTaskNameParam ;
295
269
}
296
270
297
-
271
+
298
272
/**
299
273
* @return the caseValueParam
300
274
*/
@@ -311,19 +285,19 @@ public String getDynamicForkJoinTasksParam() {
311
285
public void setDynamicForkJoinTasksParam (String dynamicForkJoinTasksParam ) {
312
286
this .dynamicForkJoinTasksParam = dynamicForkJoinTasksParam ;
313
287
}
314
-
288
+
315
289
public String getDynamicForkTasksParam () {
316
290
return dynamicForkTasksParam ;
317
291
}
318
-
292
+
319
293
public void setDynamicForkTasksParam (String dynamicForkTasksParam ) {
320
294
this .dynamicForkTasksParam = dynamicForkTasksParam ;
321
295
}
322
296
323
297
public String getDynamicForkTasksInputParamName () {
324
298
return dynamicForkTasksInputParamName ;
325
299
}
326
-
300
+
327
301
public void setDynamicForkTasksInputParamName (String dynamicForkTasksInputParamName ) {
328
302
this .dynamicForkTasksInputParamName = dynamicForkTasksInputParamName ;
329
303
}
@@ -334,25 +308,25 @@ public void setDynamicForkTasksInputParamName(String dynamicForkTasksInputParamN
334
308
public void setCaseValueParam (String caseValueParam ) {
335
309
this .caseValueParam = caseValueParam ;
336
310
}
337
-
311
+
338
312
/**
339
- *
313
+ *
340
314
* @return A javascript expression for decision cases. The result should be a scalar value that is used to decide the case branches.
341
315
* @see #getDecisionCases()
342
316
*/
343
317
public String getCaseExpression () {
344
318
return caseExpression ;
345
319
}
346
-
320
+
347
321
/**
348
- *
322
+ *
349
323
* @param caseExpression A javascript expression for decision cases. The result should be a scalar value that is used to decide the case branches.
350
324
*/
351
325
public void setCaseExpression (String caseExpression ) {
352
326
this .caseExpression = caseExpression ;
353
327
}
354
328
355
-
329
+
356
330
/**
357
331
* @return the subWorkflow
358
332
*/
@@ -382,21 +356,21 @@ public void setJoinOn(List<String> joinOn) {
382
356
}
383
357
384
358
/**
385
- *
359
+ *
386
360
* @return Sink value for the EVENT type of task
387
361
*/
388
362
public String getSink () {
389
363
return sink ;
390
364
}
391
-
365
+
392
366
/**
393
- *
367
+ *
394
368
* @param sink Name of the sink
395
369
*/
396
370
public void setSink (String sink ) {
397
371
this .sink = sink ;
398
372
}
399
-
373
+
400
374
/**
401
375
*
402
376
* @return If the task is optional. When set to true, the workflow execution continues even when the task is in failed status.
@@ -421,7 +395,7 @@ public void setTaskDefinition(TaskDef taskDefinition) {
421
395
}
422
396
423
397
/**
424
- *
398
+ *
425
399
* @param optional when set to true, the task is marked as optional
426
400
*/
427
401
public void setOptional (boolean optional ) {
@@ -532,38 +506,38 @@ public WorkflowTask next(String taskReferenceName, WorkflowTask parent) {
532
506
}
533
507
return null ;
534
508
}
535
-
509
+
536
510
public boolean has (String taskReferenceName ){
537
511
538
512
if (this .getTaskReferenceName ().equals (taskReferenceName )){
539
513
return true ;
540
514
}
541
-
515
+
542
516
TaskType tt = TaskType .USER_DEFINED ;
543
517
if (TaskType .isSystemTask (type )) {
544
518
tt = TaskType .valueOf (type );
545
519
}
546
-
520
+
547
521
switch (tt ){
548
-
522
+
549
523
case DECISION :
550
- case FORK_JOIN :
524
+ case FORK_JOIN :
551
525
for (List <WorkflowTask > childx : children ()){
552
526
for (WorkflowTask child : childx ){
553
527
if (child .has (taskReferenceName )){
554
528
return true ;
555
- }
529
+ }
556
530
}
557
531
}
558
532
break ;
559
533
default :
560
534
break ;
561
535
}
562
-
536
+
563
537
return false ;
564
-
538
+
565
539
}
566
-
540
+
567
541
public WorkflowTask get (String taskReferenceName ){
568
542
569
543
if (this .getTaskReferenceName ().equals (taskReferenceName )){
@@ -578,9 +552,9 @@ public WorkflowTask get(String taskReferenceName){
578
552
}
579
553
}
580
554
return null ;
581
-
555
+
582
556
}
583
-
557
+
584
558
@ Override
585
559
public String toString () {
586
560
return name + "/" + taskReferenceName ;
0 commit comments