Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge committed Sep 10, 2024
1 parent f08afc8 commit 6f8657d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.kitodo.production.helper.tasks.TaskManager;
import org.kitodo.production.metadata.MetadataLock;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.CommentService;
import org.kitodo.production.services.data.TaskService;
import org.kitodo.production.thread.TaskScriptThread;

Expand All @@ -63,6 +64,7 @@ public class WorkflowControllerService {
private final WebDav webDav = new WebDav();
private static final Logger logger = LogManager.getLogger(WorkflowControllerService.class);
private final TaskService taskService = ServiceManager.getTaskService();
private final CommentService commentService = ServiceManager.getCommentService();

/**
* Set Task status up.
Expand Down Expand Up @@ -372,7 +374,11 @@ public void reportProblem(Comment comment, TaskEditType taskEditType) throws DAO
correctionTask.setProcessingEnd(null);
correctionTask.setCorrection(true);
taskService.save(correctionTask);
lockTasksBetweenCurrentAndCorrectionTask(currentTask, correctionTask);
if (lockTasksBetweenCurrentAndCorrectionTask(currentTask, correctionTask)
&& Objects.nonNull(comment.getId())) {
commentService.refresh(comment);
currentTask = comment.getCurrentTask();
}
}
updateProcessSortHelperStatus(currentTask.getProcess());
}
Expand Down Expand Up @@ -474,7 +480,8 @@ private void closeParent(Process process) throws DAOException {
}
}

private void lockTasksBetweenCurrentAndCorrectionTask(Task currentTask, Task correctionTask) throws DAOException {
private boolean lockTasksBetweenCurrentAndCorrectionTask(Task currentTask, Task correctionTask)
throws DAOException {
List<Task> allTasksInBetween = taskService.getAllTasksInBetween(correctionTask.getOrdering(),
currentTask.getOrdering(), currentTask.getProcess().getId());
for (Task taskInBetween : allTasksInBetween) {
Expand All @@ -483,6 +490,7 @@ private void lockTasksBetweenCurrentAndCorrectionTask(Task currentTask, Task cor
taskInBetween.setProcessingEnd(null);
taskService.save(taskInBetween);
}
return !allTasksInBetween.isEmpty();
}

private List<Task> getAllHigherTasks(List<Task> tasks, Task task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public void shouldReportProblem() throws Exception {
"Report of problem was incorrect - task '" + correctionTask.getTitle() + "' is not a correction task!",
correctionTask.isCorrection());

Process process = currentTask.getProcess();
Process process = problem.getCurrentTask().getProcess();
for (Task task : process.getTasks()) {
if (correctionTask.getOrdering() < task.getOrdering() && task.getOrdering() < currentTask.getOrdering()) {
assertEquals("Report of problem was incorrect - tasks between were not set up to locked!",
Expand Down

0 comments on commit 6f8657d

Please sign in to comment.