Skip to content

Commit

Permalink
bug/IVYPORTAL-17553-TaskWriteExpiryTimestamp-does-not-work-as-expecte…
Browse files Browse the repository at this point in the history
…d-LE

- Fix bug
  • Loading branch information
lmluat-axonivy committed Sep 10, 2024
1 parent 4786b00 commit c95006b
Showing 1 changed file with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,34 @@ public boolean canChangePriority(ITask task) {
return isNotDone(task) && hasPermission(task, IPermission.TASK_WRITE_ORIGINAL_PRIORITY);
}

/**
* Logic to check if user can change task expiry date:
* - Task not null
* - Task state is different from DONE, DESTROYED
* - User has permission TaskWriteExpiryTimestamp
* - The task has expiry handler or has expiry option 'Nobody & delete'
*
* @param task
* @return condition whether the user can change expiry time
*/

public boolean canChangeExpiry(ITask task) {
List<TaskBusinessState> taskStates = Arrays.asList(TaskBusinessState.DONE, TaskBusinessState.DESTROYED);
return (hasPermission(task, IPermission.TASK_WRITE_EXPIRY_TIMESTAMP)
|| (task != null && StringUtils.isNotBlank(task.getExpiryTaskStartElementPid())))
&& !taskStates.contains(task.getBusinessState());
List<TaskState> nonChangeableExpiryStates = Arrays.asList(TaskState.DONE,
TaskState.DESTROYED);

if (task == null || nonChangeableExpiryStates.contains(task.getState())) {
return false;
}

boolean isAutoDeleteAfterExpiry = StringUtils
.isBlank(task.getExpiryActivatorName())
&& StringUtils.isBlank(task.getExpiryTaskStartElementPid());

boolean hasExpiryHandler = StringUtils
.isNotBlank(task.getExpiryTaskStartElementPid());

return hasPermission(task, IPermission.TASK_WRITE_EXPIRY_TIMESTAMP)
&& (isAutoDeleteAfterExpiry || hasExpiryHandler);
}

public boolean canChangeDelayTimestamp(ITask task) {
Expand Down

0 comments on commit c95006b

Please sign in to comment.