Skip to content

Commit

Permalink
default values also for save operation on task details
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Mar 26, 2020
1 parent 8d27eee commit d2afd5e
Showing 1 changed file with 25 additions and 4 deletions.
Expand Up @@ -436,11 +436,27 @@ private void afterOperation(AjaxRequestTarget target, OperationResult result) {
refresh(target);
}

@Override
public void savePerformed(AjaxRequestTarget target) {
savePerformed(target, false);
}

private boolean saveAndRun = false;

public void saveAndRunPerformed(AjaxRequestTarget target) {
saveAndRun = true;
savePerformed(target, true);
}

private void savePerformed(AjaxRequestTarget target, boolean run) {
PrismObjectWrapper<TaskType> taskWrapper = getObjectWrapper();
try {
PrismPropertyWrapper<TaskExecutionStatusType> executionStatus = taskWrapper.findProperty(ItemPath.create(TaskType.F_EXECUTION_STATUS));
executionStatus.getValue().setRealValue(TaskExecutionStatusType.RUNNABLE);
if (run) {
executionStatus.getValue().setRealValue(TaskExecutionStatusType.RUNNABLE);
} else {
executionStatus.getValue().setRealValue(TaskExecutionStatusType.SUSPENDED);
}

setupOwner(taskWrapper);
setupRecurrence(taskWrapper);
Expand All @@ -452,7 +468,11 @@ public void saveAndRunPerformed(AjaxRequestTarget target) {
}

if (!checkScheduleFilledForReccurentTask(taskWrapper)) {
getSession().error("Cannot run recurring task without setting scheduling for it.");
if (run) {
getSession().error("Cannot run recurring task without setting scheduling for it.");
} else {
getSession().warn("Cannot run recurring task without setting scheduling for it.");
}
target.add(getFeedbackPanel());
return;
}
Expand Down Expand Up @@ -507,10 +527,11 @@ public void finishProcessing(AjaxRequestTarget target, Collection<ObjectDeltaOpe
}

if (result.isSuccess() && executedDeltas != null) {
//TODO change to inProgress result, so there is a link to existing task
String taskOid = ObjectDeltaOperation.findFocusDeltaOidInCollection(executedDeltas);
if (taskOid != null) {
result.recordInProgress();
if (saveAndRun) {
result.recordInProgress();
}
result.setBackgroundTaskOid(taskOid);
}
}
Expand Down

0 comments on commit d2afd5e

Please sign in to comment.