From 945cc24b44393dbae903f09560ed8678dc11de9d Mon Sep 17 00:00:00 2001 From: Matthias Ronge Date: Thu, 12 Sep 2024 09:22:33 +0200 Subject: [PATCH] Add tasks to processes to enable sorting by sortHelperStatus --- .../main/java/org/kitodo/data/database/beans/Process.java | 5 +++++ .../services/workflow/WorkflowControllerService.java | 3 +++ Kitodo/src/test/java/org/kitodo/MockDatabase.java | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java index 89a9e1f9074..a8c476ffc45 100644 --- a/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/database/beans/Process.java @@ -1047,4 +1047,9 @@ public void setHasComments(boolean hasComments) { throw new UnsupportedOperationException("cannot insert comments"); } } + + @Override + public String toString() { + return title + " [" + id + "]"; + } } diff --git a/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java b/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java index c7a7d92021a..0aecea1ca06 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/workflow/WorkflowControllerService.java @@ -692,7 +692,10 @@ private void processAutomaticTask(Task task) { public static void updateProcessSortHelperStatus(Process process) { if (!process.getTasks().isEmpty()) { String value = ProcessConverter.getCombinedProgressAsString(process, false); + logger.trace("Setting sortHelperStatus for process {} to '{}'", process, value); process.setSortHelperStatus(value); + } else { + logger.trace("Cannot set sortHelperStatus for process {}: process has no tasks", process); } } diff --git a/Kitodo/src/test/java/org/kitodo/MockDatabase.java b/Kitodo/src/test/java/org/kitodo/MockDatabase.java index c0527d04f74..12ba45b7c3a 100644 --- a/Kitodo/src/test/java/org/kitodo/MockDatabase.java +++ b/Kitodo/src/test/java/org/kitodo/MockDatabase.java @@ -1201,6 +1201,7 @@ private static void insertTasks() throws Exception { secondUser.getProcessingTasks().add(task); } ServiceManager.getTaskService().save(task); + firstProcess.getTasks().add(task); } ServiceManager.getUserService().save(firstUser); @@ -1227,6 +1228,7 @@ private static void insertTasks() throws Exception { role.getTasks().add(eleventhTask); ServiceManager.getTaskService().save(eleventhTask); firstUser.getProcessingTasks().add(eleventhTask); + secondProcess.getTasks().add(eleventhTask); Task twelfthTask = new Task(); twelfthTask.setTitle("Processed and Some"); @@ -1242,6 +1244,7 @@ private static void insertTasks() throws Exception { ServiceManager.getTaskService().save(twelfthTask); firstUser.getProcessingTasks().add(twelfthTask); ServiceManager.getUserService().save(firstUser); + secondProcess.getTasks().add(twelfthTask); Task thirteenTask = new Task(); thirteenTask.setTitle("Next Open"); @@ -1254,6 +1257,7 @@ private static void insertTasks() throws Exception { thirteenTask.getRoles().add(role); role.getTasks().add(thirteenTask); ServiceManager.getTaskService().save(thirteenTask); + secondProcess.getTasks().add(thirteenTask); ServiceManager.getRoleService().save(role);