@@ -113,14 +113,14 @@ public void execute(CommandContext commandContext, PlanItemInstanceEntity planIt
113113 cmmnEngineConfiguration .getCreateHumanTaskInterceptor ().beforeCreateHumanTask (beforeContext );
114114 }
115115
116- handleTaskName (planItemInstanceEntity , expressionManager , taskEntity , beforeContext );
116+ handleTaskName (planItemInstanceEntity , expressionManager , taskEntity , beforeContext , migrationContext );
117117 handleTaskDescription (planItemInstanceEntity , expressionManager , taskEntity , beforeContext );
118118 handleAssignee (planItemInstanceEntity , taskService , expressionManager , taskEntity , planItemInstanceEntityManager , beforeContext , migrationContext );
119- handleOwner (planItemInstanceEntity , taskService , expressionManager , taskEntity , beforeContext );
120- handlePriority (planItemInstanceEntity , expressionManager , taskEntity , beforeContext );
121- handleFormKey (planItemInstanceEntity , expressionManager , taskEntity , beforeContext );
122- handleDueDate (commandContext , planItemInstanceEntity , expressionManager , taskEntity , beforeContext );
123- handleCategory (planItemInstanceEntity , expressionManager , taskEntity , beforeContext );
119+ handleOwner (planItemInstanceEntity , taskService , expressionManager , taskEntity , beforeContext , migrationContext );
120+ handlePriority (planItemInstanceEntity , expressionManager , taskEntity , beforeContext , migrationContext );
121+ handleFormKey (planItemInstanceEntity , expressionManager , taskEntity , beforeContext , migrationContext );
122+ handleDueDate (commandContext , planItemInstanceEntity , expressionManager , taskEntity , beforeContext , migrationContext );
123+ handleCategory (planItemInstanceEntity , expressionManager , taskEntity , beforeContext , migrationContext );
124124
125125 TaskHelper .insertTask (taskEntity , true , cmmnEngineConfiguration );
126126
@@ -143,8 +143,8 @@ public void execute(CommandContext commandContext, PlanItemInstanceEntity planIt
143143 }
144144 }
145145
146- handleCandidateUsers (commandContext , planItemInstanceEntity , expressionManager , taskEntity , beforeContext );
147- handleCandidateGroups (commandContext , planItemInstanceEntity , expressionManager , taskEntity , beforeContext );
146+ handleCandidateUsers (commandContext , planItemInstanceEntity , expressionManager , taskEntity , beforeContext , migrationContext );
147+ handleCandidateGroups (commandContext , planItemInstanceEntity , expressionManager , taskEntity , beforeContext , migrationContext );
148148 handleTaskIdVariableStorage (planItemInstanceEntity , humanTask , expressionManager , taskEntity );
149149
150150 planItemInstanceEntity .setReferenceId (taskEntity .getId ());
@@ -178,10 +178,18 @@ public void execute(CommandContext commandContext, PlanItemInstanceEntity planIt
178178 }
179179
180180 protected void handleTaskName (PlanItemInstanceEntity planItemInstanceEntity , ExpressionManager expressionManager ,
181- TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext ) {
181+ TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext , MigrationContext migrationContext ) {
182+
183+ String nameStringValue = null ;
184+ if (migrationContext != null && migrationContext .getName () != null ) {
185+ nameStringValue = migrationContext .getName ();
186+
187+ } else if (StringUtils .isNotEmpty (beforeContext .getName ())) {
188+ nameStringValue = beforeContext .getName ();
189+ }
182190
183- if (StringUtils .isNotEmpty (beforeContext . getName () )) {
184- Object name = expressionManager .createExpression (beforeContext . getName () ).getValue (planItemInstanceEntity );
191+ if (StringUtils .isNotEmpty (nameStringValue )) {
192+ Object name = expressionManager .createExpression (nameStringValue ).getValue (planItemInstanceEntity );
185193 if (name != null ) {
186194 if (name instanceof String ) {
187195 taskEntity .setName ((String ) name );
@@ -232,10 +240,18 @@ protected void handleAssignee(PlanItemInstanceEntity planItemInstanceEntity, Tas
232240 }
233241
234242 protected void handleOwner (PlanItemInstanceEntity planItemInstanceEntity , TaskService taskService ,
235- ExpressionManager expressionManager , TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext ) {
243+ ExpressionManager expressionManager , TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext , MigrationContext migrationContext ) {
244+
245+ String ownerStringValue = null ;
246+ if (migrationContext != null && migrationContext .getOwner () != null ) {
247+ ownerStringValue = migrationContext .getOwner ();
248+
249+ } else if (StringUtils .isNotEmpty (beforeContext .getOwner ())) {
250+ ownerStringValue = beforeContext .getOwner ();
251+ }
236252
237- if (StringUtils .isNotEmpty (beforeContext . getOwner () )) {
238- Object ownerExpressionValue = expressionManager .createExpression (beforeContext . getOwner () ).getValue (planItemInstanceEntity );
253+ if (StringUtils .isNotEmpty (ownerStringValue )) {
254+ Object ownerExpressionValue = expressionManager .createExpression (ownerStringValue ).getValue (planItemInstanceEntity );
239255 String ownerValue = null ;
240256 if (ownerExpressionValue != null ) {
241257 ownerValue = ownerExpressionValue .toString ();
@@ -246,10 +262,18 @@ protected void handleOwner(PlanItemInstanceEntity planItemInstanceEntity, TaskSe
246262 }
247263
248264 protected void handlePriority (PlanItemInstanceEntity planItemInstanceEntity , ExpressionManager expressionManager ,
249- TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext ) {
265+ TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext , MigrationContext migrationContext ) {
266+
267+ String priorityStringValue = null ;
268+ if (migrationContext != null && migrationContext .getPriority () != null ) {
269+ priorityStringValue = migrationContext .getPriority ();
270+
271+ } else if (StringUtils .isNotEmpty (beforeContext .getPriority ())) {
272+ priorityStringValue = beforeContext .getPriority ();
273+ }
250274
251- if (StringUtils .isNotEmpty (beforeContext . getPriority () )) {
252- Object priority = expressionManager .createExpression (beforeContext . getPriority () ).getValue (planItemInstanceEntity );
275+ if (StringUtils .isNotEmpty (priorityStringValue )) {
276+ Object priority = expressionManager .createExpression (priorityStringValue ).getValue (planItemInstanceEntity );
253277 if (priority != null ) {
254278 if (priority instanceof String ) {
255279 try {
@@ -267,10 +291,18 @@ protected void handlePriority(PlanItemInstanceEntity planItemInstanceEntity, Exp
267291 }
268292
269293 protected void handleFormKey (PlanItemInstanceEntity planItemInstanceEntity , ExpressionManager expressionManager ,
270- TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext ) {
294+ TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext , MigrationContext migrationContext ) {
271295
272- if (StringUtils .isNotEmpty (beforeContext .getFormKey ())) {
273- Object formKey = expressionManager .createExpression (beforeContext .getFormKey ()).getValue (planItemInstanceEntity );
296+ String formKeyStringValue = null ;
297+ if (migrationContext != null && migrationContext .getFormKey () != null ) {
298+ formKeyStringValue = migrationContext .getFormKey ();
299+
300+ } else if (StringUtils .isNotEmpty (beforeContext .getFormKey ())) {
301+ formKeyStringValue = beforeContext .getFormKey ();
302+ }
303+
304+ if (StringUtils .isNotEmpty (formKeyStringValue )) {
305+ Object formKey = expressionManager .createExpression (formKeyStringValue ).getValue (planItemInstanceEntity );
274306 if (formKey != null ) {
275307 if (formKey instanceof String ) {
276308 taskEntity .setFormKey ((String ) formKey );
@@ -282,10 +314,18 @@ protected void handleFormKey(PlanItemInstanceEntity planItemInstanceEntity, Expr
282314 }
283315
284316 protected void handleDueDate (CommandContext commandContext , PlanItemInstanceEntity planItemInstanceEntity ,
285- ExpressionManager expressionManager , TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext ) {
317+ ExpressionManager expressionManager , TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext , MigrationContext migrationContext ) {
286318
287- if (StringUtils .isNotEmpty (beforeContext .getDueDate ())) {
288- Object dueDate = expressionManager .createExpression (beforeContext .getDueDate ()).getValue (planItemInstanceEntity );
319+ String dueDateStringValue = null ;
320+ if (migrationContext != null && migrationContext .getDueDate () != null ) {
321+ dueDateStringValue = migrationContext .getDueDate ();
322+
323+ } else if (StringUtils .isNotEmpty (beforeContext .getDueDate ())) {
324+ dueDateStringValue = beforeContext .getDueDate ();
325+ }
326+
327+ if (StringUtils .isNotEmpty (dueDateStringValue )) {
328+ Object dueDate = expressionManager .createExpression (dueDateStringValue ).getValue (planItemInstanceEntity );
289329 if (dueDate != null ) {
290330 if (dueDate instanceof Date ) {
291331 taskEntity .setDueDate ((Date ) dueDate );
@@ -313,10 +353,18 @@ protected void handleDueDate(CommandContext commandContext, PlanItemInstanceEnti
313353 }
314354
315355 protected void handleCategory (PlanItemInstanceEntity planItemInstanceEntity , ExpressionManager expressionManager ,
316- TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext ) {
356+ TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext , MigrationContext migrationContext ) {
317357
318- if (StringUtils .isNotEmpty (beforeContext .getCategory ())) {
319- final Object category = expressionManager .createExpression (beforeContext .getCategory ()).getValue (planItemInstanceEntity );
358+ String categoryStringValue = null ;
359+ if (migrationContext != null && migrationContext .getCategory () != null ) {
360+ categoryStringValue = migrationContext .getCategory ();
361+
362+ } else if (StringUtils .isNotEmpty (beforeContext .getCategory ())) {
363+ categoryStringValue = beforeContext .getCategory ();
364+ }
365+
366+ if (StringUtils .isNotEmpty (categoryStringValue )) {
367+ final Object category = expressionManager .createExpression (categoryStringValue ).getValue (planItemInstanceEntity );
320368 if (category != null ) {
321369 if (category instanceof String ) {
322370 taskEntity .setCategory ((String ) category );
@@ -329,10 +377,18 @@ protected void handleCategory(PlanItemInstanceEntity planItemInstanceEntity, Exp
329377
330378 @ SuppressWarnings ({ "unchecked" , "rawtypes" })
331379 protected void handleCandidateUsers (CommandContext commandContext , PlanItemInstanceEntity planItemInstanceEntity ,
332- ExpressionManager expressionManager , TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext ) {
380+ ExpressionManager expressionManager , TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext , MigrationContext migrationContext ) {
333381
334382 CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil .getCmmnEngineConfiguration (commandContext );
335- List <String > candidateUsers = beforeContext .getCandidateUsers ();
383+
384+ List <String > candidateUsers = null ;
385+ if (migrationContext != null && migrationContext .getCandidateUsers () != null ) {
386+ candidateUsers = migrationContext .getCandidateUsers ();
387+
388+ } else if (beforeContext .getCandidateUsers () != null ) {
389+ candidateUsers = beforeContext .getCandidateUsers ();
390+ }
391+
336392 if (candidateUsers != null && !candidateUsers .isEmpty ()) {
337393 List <IdentityLinkEntity > allIdentityLinkEntities = new ArrayList <>();
338394 for (String candidateUser : candidateUsers ) {
@@ -360,10 +416,18 @@ protected void handleCandidateUsers(CommandContext commandContext, PlanItemInsta
360416
361417 @ SuppressWarnings ({ "unchecked" , "rawtypes" })
362418 protected void handleCandidateGroups (CommandContext commandContext , PlanItemInstanceEntity planItemInstanceEntity ,
363- ExpressionManager expressionManager , TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext ) {
419+ ExpressionManager expressionManager , TaskEntity taskEntity , CreateHumanTaskBeforeContext beforeContext , MigrationContext migrationContext ) {
364420
365421 CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil .getCmmnEngineConfiguration (commandContext );
366- List <String > candidateGroups = beforeContext .getCandidateGroups ();
422+
423+ List <String > candidateGroups = null ;
424+ if (migrationContext != null && migrationContext .getCandidateGroups () != null ) {
425+ candidateGroups = migrationContext .getCandidateGroups ();
426+
427+ } else if (beforeContext .getCandidateGroups () != null ) {
428+ candidateGroups = beforeContext .getCandidateGroups ();
429+ }
430+
367431 if (candidateGroups != null && !candidateGroups .isEmpty ()) {
368432 List <IdentityLinkEntity > allIdentityLinkEntities = new ArrayList <>();
369433 for (String candidateGroup : candidateGroups ) {
0 commit comments