From 177c25b18448e1253aa2732a68878ce2862f8bf4 Mon Sep 17 00:00:00 2001 From: Matthias Ronge Date: Wed, 10 Apr 2024 16:11:49 +0200 Subject: [PATCH 001/113] Introduce an interface for the DTO objects --- .../data/interfaces/BatchInterface.java | 56 ++ .../data/interfaces/ClientInterface.java | 71 ++ .../data/interfaces/DataFactoryInterface.java | 118 +++ .../kitodo/data/interfaces/DataInterface.java | 36 + .../data/interfaces/DocketInterface.java | 73 ++ .../data/interfaces/FilterInterface.java | 33 + .../data/interfaces/ProcessInterface.java | 680 ++++++++++++++++++ .../data/interfaces/ProjectInterface.java | 281 ++++++++ .../data/interfaces/PropertyInterface.java | 71 ++ .../kitodo/data/interfaces/RoleInterface.java | 107 +++ .../data/interfaces/RulesetInterface.java | 110 +++ .../kitodo/data/interfaces/TaskInterface.java | 508 +++++++++++++ .../data/interfaces/TemplateInterface.java | 182 +++++ .../kitodo/data/interfaces/UserInterface.java | 375 ++++++++++ .../data/interfaces/WorkflowInterface.java | 59 ++ .../kitodo/data/interfaces/package-info.java | 30 + .../org/kitodo/production/dto/BaseDTO.java | 4 +- .../production/dto/BaseTemplateDTO.java | 34 +- .../org/kitodo/production/dto/BatchDTO.java | 11 +- .../org/kitodo/production/dto/ClientDTO.java | 18 +- .../org/kitodo/production/dto/DTOFactory.java | 106 +++ .../org/kitodo/production/dto/DocketDTO.java | 15 +- .../org/kitodo/production/dto/FilterDTO.java | 4 +- .../org/kitodo/production/dto/ProcessDTO.java | 52 +- .../org/kitodo/production/dto/ProjectDTO.java | 25 +- .../kitodo/production/dto/PropertyDTO.java | 4 +- .../org/kitodo/production/dto/RoleDTO.java | 28 +- .../org/kitodo/production/dto/RulesetDTO.java | 15 +- .../org/kitodo/production/dto/TaskDTO.java | 59 +- .../kitodo/production/dto/TemplateDTO.java | 21 +- .../org/kitodo/production/dto/UserDTO.java | 55 +- .../kitodo/production/dto/WorkflowDTO.java | 4 +- .../kitodo/production/forms/BatchForm.java | 10 +- .../production/forms/CommentTooltipView.java | 24 +- .../production/forms/CurrentTaskForm.java | 18 +- .../kitodo/production/forms/DesktopForm.java | 18 +- .../kitodo/production/forms/ProcessForm.java | 46 +- .../production/forms/ProcessListBaseView.java | 52 +- .../kitodo/production/forms/ProjectForm.java | 8 +- .../production/forms/SearchResultForm.java | 54 +- .../org/kitodo/production/forms/UserForm.java | 12 +- .../createprocess/CreateProcessForm.java | 4 +- .../SelectProjectDialogView.java | 30 +- .../SelectTemplateDialogView.java | 16 +- .../createprocess/TitleRecordLinkTab.java | 6 +- .../dataeditor/AddDocStrucTypeDialog.java | 4 +- .../helper/SearchResultGeneration.java | 40 +- .../kitodo/production/model/LazyDTOModel.java | 6 +- .../services/data/BatchService.java | 25 +- .../services/data/DocketService.java | 33 +- .../services/data/FilterService.java | 56 +- .../services/data/ImportService.java | 6 +- .../services/data/ProcessService.java | 309 ++++---- .../services/data/ProjectService.java | 87 +-- .../services/data/RulesetService.java | 31 +- .../production/services/data/TaskService.java | 95 +-- .../services/data/TemplateService.java | 61 +- .../production/services/data/UserService.java | 4 +- .../services/data/WorkflowService.java | 19 +- .../data/base/ClientSearchService.java | 4 +- .../data/base/ProjectSearchService.java | 4 +- .../services/data/base/SearchService.java | 62 +- .../data/base/TitleSearchService.java | 4 +- .../production/services/file/FileService.java | 38 +- .../java/org/kitodo/DataFactoryProvider.java | 33 + .../production/forms/IndexingFormIT.java | 4 +- .../production/forms/SearchResultFormIT.java | 10 +- .../production/model/LazyDTOModelIT.java | 6 +- .../NewspaperProcessesGeneratorIT.java | 4 +- .../command/KitodoScriptServiceIT.java | 38 +- .../services/data/FilterServiceIT.java | 10 +- .../services/data/ProcessServiceIT.java | 26 +- .../services/data/ProcessServiceTest.java | 76 +- .../services/data/ProjectServiceIT.java | 6 +- .../services/data/TemplateServiceIT.java | 24 +- 75 files changed, 3832 insertions(+), 836 deletions(-) create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/BatchInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ClientInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DataFactoryInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DataInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DocketInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/FilterInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ProcessInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ProjectInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/PropertyInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/RoleInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/RulesetInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/TaskInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/TemplateInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/UserInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/WorkflowInterface.java create mode 100644 Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/package-info.java create mode 100644 Kitodo/src/main/java/org/kitodo/production/dto/DTOFactory.java create mode 100644 Kitodo/src/test/java/org/kitodo/DataFactoryProvider.java diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/BatchInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/BatchInterface.java new file mode 100644 index 00000000000..3bb0ed82321 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/BatchInterface.java @@ -0,0 +1,56 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.util.List; + +/** + * Interface for batches of processes. Processes can be assembled in batches to + * take on or complete tasks for entire batches with a single user interaction. + */ +public interface BatchInterface extends DataInterface { + + /** + * Returns the title of the batch. If no textual title was assigned, the + * title returned is “Batch ‹i›” with its database ID. + * + * @return the title of the batch + */ + String getTitle(); + + /** + * Gives the batch a text-based title. + * + * @param title + * title to use + */ + void setTitle(String title); + + /** + * Returns the processes belonging to the batch. This list is not guaranteed + * to be in reliable order. + * + * @return the processes belonging to the batch + */ + List getProcesses(); + + /** + * Sets the list of processes belonging to the batch. The list should not + * contain duplicates, and must not contain {@code null}s. + * + * @param processes + * contain the list of processes belonging to the batch to be + * determined + */ + void setProcesses(List processes); + +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ClientInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ClientInterface.java new file mode 100644 index 00000000000..e47e91715e6 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ClientInterface.java @@ -0,0 +1,71 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.util.List; + +/** + * Interface for working with clients. Clients are related organizations that + * are allowed to use this instance of Production for their own projects. Users + * can work for several clients or just one. + */ +public interface ClientInterface extends DataInterface { + + /** + * Returns the name of the client. + * + * @return the name of the client + */ + String getName(); + + /** + * Sets the name of the client. + * + * @param name + * the name of the client + */ + void setName(String name); + + /** + * Specifies the users who work for this client. This list is not guaranteed + * to be in reliable order. + * + * @return the users who work for this client + */ + List getUsers(); + + /** + * Sets the list of users working for this client. The list should not + * contain duplicates, and must not contain {@code null}s. + * + * @param users + * The users. + */ + void setUsers(List users); + + /** + * Returns the client's projects. This list is not guaranteed to be in + * reliable order. + * + * @return the client's projects + */ + List getProjects(); + + /** + * Sets the lists of the client's projects. The list should not contain + * duplicates, and must not contain {@code null}s. + * + * @param projects + * The projects. + */ + void setProjects(List projects); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DataFactoryInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DataFactoryInterface.java new file mode 100644 index 00000000000..dd9369b0fbf --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DataFactoryInterface.java @@ -0,0 +1,118 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +/** + * Factory interface for the objects of the interface. An instance of the + * interface can be used to obtain objects of the interface. This allows new + * objects of the interface to be obtained without being aware of the + * implementation. + */ +public interface DataFactoryInterface { + + /** + * Returns a new batch. The batch has not yet been persisted and does not + * yet have a database ID. + * + * @return a new batch + */ + BatchInterface newBatch(); + + /** + * Returns a new client. The client has not yet been persisted and does not + * yet have a database ID. + * + * @return a new client + */ + ClientInterface newClient(); + + /** + * Returns a new docket generation statement. The client has not yet been + * persisted and does not yet have a database ID. + * + * @return a new docket generation + */ + DocketInterface newDocket(); + + /** + * Returns a new store for a search string. The filter string has not yet + * been persisted and does not yet have a database ID. + * + * @return a new search string + */ + FilterInterface newFilter(); + + /** + * Returns a new process. The process has not yet been persisted and does + * not yet have a database ID. + * + * @return a new process + */ + ProcessInterface newProcess(); + + /** + * Returns a new project. The project has not yet been persisted and does + * not yet have a database ID. + * + * @return a new project + */ + ProjectInterface newProject(); + + /** + * Returns a new container for a property key-value pair. The property has + * not yet been persisted and does not yet have a database ID. + * + * @return a new property + */ + PropertyInterface newProperty(); + + /** + * Returns a new storage for the business domain specification. The ruleset + * has not yet been persisted and does not yet have a database ID. + * + * @return a new business specification + */ + RulesetInterface newRuleset(); + + /** + * Returns a new task. The task has not yet been persisted and does not yet + * have a database ID. + * + * @return a new task + */ + TaskInterface newTask(); + + /** + * Returns a new production template. The production template has not yet + * been persisted and does not yet have a database ID. + * + * @return a new template + */ + TemplateInterface newTemplate(); + + /** + * Returns a new user. The user has not yet been persisted and does not yet + * have a database ID. + * + * @return a new user + */ + UserInterface newUser(); + + /** + * Returns a new workflow. Returns a new workflow reference. The workflow + * has not yet been persisted in the database and does not yet have a record + * number. + * + * @return a new batch + */ + WorkflowInterface newWorkflow(); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DataInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DataInterface.java new file mode 100644 index 00000000000..483c43c9359 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DataInterface.java @@ -0,0 +1,36 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +/** + * Meta interface over the data interfaces of this interface. + */ +public interface DataInterface { + /** + * Returns the record number of the object in the database. Can be + * {@code null} if the object has not yet been persisted. + * + * @return the record number + */ + Integer getId(); + + /** + * Sets the data record number of the object. This should only happen when + * data from a third-party source is integrated during operation, or in + * tests. Normally the data record number is assigned by the database when + * the object is saved. + * + * @param id + * data record number to use + */ + void setId(Integer id); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DocketInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DocketInterface.java new file mode 100644 index 00000000000..3f4e6fd9706 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/DocketInterface.java @@ -0,0 +1,73 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +/** + * Interface for configuring the docket generator. + */ +public interface DocketInterface extends DataInterface { + + /** + * Returns the name of the configuration file, without a path. The file must + * exist in the XSLT directory. The directory is set in the configuration + * file. + * + * @return the XSLT file name + */ + String getFile(); + + /** + * Sets the name of the configuration file. The file must exist in the XSLT + * directory. The file name must be specified without a path. + * + * @param file + * XSLT file name + */ + void setFile(String file); + + /** + * Returns the display name of the configuration. It is displayed to the + * user in a selection dialog. + * + * @return the display name + */ + String getTitle(); + + /** + * Sets the display name of the configuration. + * + * @param title + * the display name + */ + void setTitle(String title); + + /** + * Returns the client that this docket generator configuration is associated + * with. Technically, multiple client can use the same docket generator + * configuration (file), but they must be made available independently for + * each client using one configuration object each. This determines which + * docket generator configurations are visible to a client at all, and they + * can be named differently. + * + * @return client that this docket is associated with + */ + ClientInterface getClient(); + + /** + * Sets the client to which this docket generator configuration is + * associated. + * + * @param client + * client to which this docket is associated + */ + void setClient(ClientInterface client); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/FilterInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/FilterInterface.java new file mode 100644 index 00000000000..dae5d27b561 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/FilterInterface.java @@ -0,0 +1,33 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +/** + * Interface for persisting search queries from users. + */ +public interface FilterInterface extends DataInterface { + + /** + * Returns the search query string. + * + * @return the search query + */ + String getValue(); + + /** + * Sets the search query string. + * + * @param value + * query string to specify + */ + void setValue(String value); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ProcessInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ProcessInterface.java new file mode 100644 index 00000000000..3141374eed7 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ProcessInterface.java @@ -0,0 +1,680 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import org.kitodo.data.database.enums.CorrectionComments; + +/** + * An interface for processes. A process represents one production process of + * creating a digital copy of an archival item, according to a workflow based on + * a production template. It consists of several tasks that must be carried out + * by humans or automatically. + */ +public interface ProcessInterface extends DataInterface { + + /** + * Returns the process name. + * + * @return the process name + */ + String getTitle(); + + /** + * Sets the process name. Since the process name is used in file paths, it + * should only contain characters compatible with the operating file system. + * Also, for scripting, there should be no spaces in the process name. + * + * @param title + * the process name + */ + void setTitle(String title); + + /** + * Returns the time the process was created. The string is formatted + * according to {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @return the time the process was created + */ + String getCreationDate(); + + /** + * Sets the time of process creation. The string must be parsable with + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @param creationDate + * the time of process creation + * @throws ParseException + * if the time cannot be converted + */ + void setCreationDate(String creationDate); + + /** + * Returns the docket generation statement to use when creating a docket for + * this process. + * + * @return the docket generation statement + */ + DocketInterface getDocket(); + + /** + * Sets the docket generation statement to use when creating a docket for + * this process. + * + * @param docket + * the docket generation statement + */ + void setDocket(DocketInterface docket); + + /** + * Returns the business domain specification this process is using. + * + * @return the business domain specification + */ + RulesetInterface getRuleset(); + + /** + * Sets the business domain specification this process is using. + * + * @param ruleset + * the business domain specification + */ + void setRuleset(RulesetInterface ruleset); + + /** + * Returns the task list of this process. + * + * @return the task list + */ + List getTasks(); + + /** + * Sets the task list of this process. + * + * @param tasks + * the task list + */ + void setTasks(List tasks); + + /** + * Returns the project the process belongs to. Digitization processes are + * organized in projects. + * + * @return the project the process belongs to + */ + ProjectInterface getProject(); + + /** + * Specifies the project to which the process belongs. + * + * @param project + * project to which the process should belong + */ + void setProject(ProjectInterface project); + + /** + * Specifies the batches to which the process is assigned. A process can + * belong to several batches, but for batch automation to work, a process + * must be assigned to exactly one batch. + * + * @return the batches to which the process is assigned + */ + List getBatches(); + + /** + * Sets the list that specifies the batches to which the process is + * associated. A process can belong to several batches, but but for batch + * automation to work, a process must be assigned to exactly one batch. The + * list should not contain duplicates, and must not contain {@code null}s. + * + * @param batches + * list of batches to which the process is associated + */ + void setBatches(List batches); + + /** + * Returns the operational properties of the process. Properties are a tool + * for third-party modules to store operational properties as key-value + * pairs, that the application has no knowledge of. This list is not + * guaranteed to be in reliable order. + * + * @return list of properties + */ + List getProperties(); + + /** + * Sets the list of operational properties of the process. This list is not + * guaranteed to preserve its order. It must not contain {@code null}s. + * + * @param properties + * list of properties as PropertyInterface + */ + void setProperties(List properties); + + /** + * Returns the user who is currently blocking the process's business data. + * Since the business data is in a file, a user can be granted exclusive + * access to this file, so that several users do not overwrite concurrent + * changes by each other. Can be {@code null} if the business data is not + * currently blocked by any user. + * + * @return the user blocking the process + */ + UserInterface getBlockedUser(); + + /** + * Sets exclusive (write) access to the business data in this process for a + * user. Or, set {@code null} to release the blockage. This is a transient + * value that is not persisted. + * + * @param blockedUser + * user to grant write access to + */ + void setBlockedUser(UserInterface blockedUser); + + /** + * Returns the percentage of tasks in the process that are completed. The + * total of tasks awaiting preconditions, startable, in progress, and + * completed is {@code 100.0d}. + * + * @return percentage of tasks completed + */ + Double getProgressClosed(); + + /** + * Sets the percentage of completed tasks. This should only be set manually + * if this information is obtained from a third party source. Normally, the + * percentage is determined from the statuses of the tasks in the process. + * If you set this, it will only be used for display to the user, the status + * of the tasks will not be changed. The value must be between {@code 0.0d} + * and {@code 100.0d}, and the values set by + * {@link #setProgressLocked(Double)}, {@link #setProgressOpen(Double)}, + * {@link #setProgressInProcessing(Double)} and + * {@link #setProgressClosed(Double)} must total {@code 100.0d}. For a + * process with no tasks, set {@code 0.0d}. + * + * @param progressClosed + * the percentage of completed tasks + */ + void setProgressClosed(Double progressClosed); + + /** + * Returns the percentage of tasks in the process that are currently being + * processed. The progress total of tasks waiting for preconditions, + * startable, in progress, and completed is {@code 100.0d}. + * + * @return percentage of tasks in progress + */ + Double getProgressInProcessing(); + + /** + * Sets the percentage of tasks that are currently being processed. This + * should only be set manually if this information is obtained from a third + * party source. Normally, the percentage is determined from the statuses of + * the tasks in the process. If you set this, it will only be used for + * display to the user, the status of the tasks will not be changed. The + * value must be between {@code 0.0d} and {@code 100.0d}, and the values set + * by {@link #setProgressLocked(Double)}, {@link #setProgressOpen(Double)}, + * {@link #setProgressInProcessing(Double)} and + * {@link #setProgressClosed(Double)} must total {@code 100.0d}. For a + * process with no tasks, set {@code 0.0d}. + * + * @param progressInProcessing + * percentage of tasks currently being processed + */ + void setProgressInProcessing(Double progressInProcessing); + + /** + * Returns the percentage of tasks in the process, that cannot yet be + * carried out, because previous tasks have not yet been completed. The + * progress total of tasks waiting for preconditions, startable, in + * progress, and completed is {@code 100.0d}. + * + * @return percentage of tasks waiting + */ + Double getProgressLocked(); + + /** + * Sets the percentage of tasks, that cannot yet be carried out, because + * previous tasks have not yet been completed. This should only be set + * manually if this information is obtained from a third party source. + * Normally, the percentage is determined from the statuses of the tasks in + * the process. If you set this, it will only be used for display to the + * user, the status of the tasks will not be changed. The value must be + * between {@code 0.0d} and {@code 100.0d}, and the values set by + * {@link #setProgressLocked(Double)}, {@link #setProgressOpen(Double)}, + * {@link #setProgressInProcessing(Double)} and + * {@link #setProgressClosed(Double)} must total {@code 100.0d}. For a + * process with no tasks, set {@code 100.0d}. + * + * @param progressLocked + * percentage of tasks waiting + */ + void setProgressLocked(Double progressLocked); + + /** + * Returns the contents of the wiki field as HTML. Wiki means that something + * can be changed quickly by anyone. It is a kind of sticky note on which + * editors can exchange information about a process. + * + * @return wiki field as HTML + */ + String getWikiField(); + + /** + * Sets the content of the wiki field. Primitive HTML tags formatting may be + * used. + * + * @param wikiField + * wiki field as HTML + */ + void setWikiField(String wikiField); + + /** + * Returns the percentage of the process's tasks that are now ready to be + * processed but have not yet been started. The progress total of tasks + * waiting for preconditions, startable, in progress, and completed is + * {@code 100.0d}. + * + * @return percentage of startable tasks + */ + Double getProgressOpen(); + + /** + * Sets the percentage of tasks, that are now ready to be processed. This + * should only be set manually if this information is obtained from a third + * party source. Normally, the percentage is determined from the statuses of + * the tasks in the process. If you set this, it will only be used for + * display to the user, the status of the tasks will not be changed. The + * value must be between {@code 0.0d} and {@code 100.0d}, and the values set + * by {@link #setProgressLocked(Double)}, {@link #setProgressOpen(Double)}, + * {@link #setProgressInProcessing(Double)} and + * {@link #setProgressClosed(Double)} must total {@code 100.0d}. For a + * process with no tasks, set {@code 0.0d}. + * + * @param progressOpen + * percentage of startable tasks + */ + void setProgressOpen(Double progressOpen); + + /** + * Returns a coded overview of the progress of the process. The larger the + * number, the more advanced the process is, so it can be used to sort by + * progress. The numeric code consists of twelve digits, each three digits + * from 000 to 100 indicate the percentage of tasks completed, currently in + * progress, ready to start and not yet ready, in that order. For example, + * 000000025075 means that 25% of the tasks are ready to be started and 75% + * of the tasks are not yet ready to be started because previous tasks have + * not yet been processed. + * + * @return overview of the processing status + */ + String getProgressCombined(); + + /** + * Sets the coded overview of the processing status of the process. This + * should only be set manually if this information comes from a third-party + * source. Typically, sorting progress is determined from the progress + * properties of the tasks in the process. The numeric code consists of + * twelve digits, each three digits from 000 to 100 indicate the percentage + * of tasks completed, currently in progress, ready to start and not yet + * ready, in that order. The sum of the four groups of numbers must be 100. + * + * @param progressCombined + * coded overview of the progress with pattern + * ([01]\d{2}){4} + */ + void setProgressCombined(String progressCombined); + + /** + * Returns a process identifier URI. Internally, this is the record number + * of the process in the processes table of the database, but for external + * data it can also be another identifier that resolves to a directory in + * the application's processes directory on the file system. + * + * @return the union resource identifier of the process + */ + String getProcessBaseUri(); + + /** + * Sets the union resource identifier of the process. This should only be + * set manually if the data comes from a third party source, otherwise, this + * is the process record number set by the database. + * + * @param processBaseUri + * the identification URI of the process + */ + void setProcessBaseUri(String processBaseUri); + + /** + * Returns all batches to which the process belongs. A comma-space-separated + * list of the batch labels is returned. If not, it's a blank string. + * + * @return batches to which the process belongs + */ + String getBatchID(); + + /** + * Sets all batches to which the process belongs as a comma-space-separated + * list (for display). The setter should be used by data from a third party + * source. Internally, this information is fetched from the database. Set to + * "" if not. + * + * @param batchID + * human-readable information about which batches the process + * belongs to + */ + void setBatchID(String batchID); + + /** + * Returns the record number of the parent process, if any. Is {@code null} + * if there is no parent process above. + * + * @return record number of the parent process + */ + Integer getParentID(); + + /** + * Sets a parent process based on its record number. Or {@code null} to not + * set a parent process. + * + * @param parentID + * record number of the parent process + */ + void setParentID(Integer parentID); + + /** + * Returns whether the process has children. + * + * @return whether the process has children + */ + boolean hasChildren(); + + /** + * Sets whether the process is a parent. The setter can be used when + * representing data from a third-party source. Internally, parenthood + * results from a parent relationship of the process in the database. + * Setting this to true cannot insert child processes into the database. + * + * @param hasChildren + * whether the process has children + * @throws UnsupportedOperationException + * when trying to set this to true for a process without + * children + */ + void setHasChildren(boolean hasChildren); + + /** + * Returns the sort count. Sort counting is applicable to a process, if it + * is a child process and is a counted item of a series. This allows to sort + * the children according to their count. Can be {@code null} if there is no + * count. + * + * @return the sort count + */ + Integer getSortHelperArticles(); + + /** + * Sets the sort count. + * + * @param sortHelperArticles + * the sort count + */ + void setSortHelperArticles(Integer sortHelperArticles); + + /** + * Returns the number of outline elements in a process. This is a business + * statistical characteristic. + * + * @return the number of outline elements in a process + */ + Integer getSortHelperDocstructs(); + + /** + * Sets the number of outline elements in a process. Since the detailed + * business objects are in a file, the number can be stored here when + * saving, so that statistics on the number of outline elements can be + * obtained with an acceptable response time. + * + * @param sortHelperDocstructs + * the number of outline elements in a process + */ + void setSortHelperDocstructs(Integer sortHelperDocstructs); + + /** + * Returns a coded overview of the progress of the process. The larger the + * number, the more advanced the process is, so it can be used to sort by + * progress. The numeric code consists of twelve digits, each three digits + * from 000 to 100 indicate the percentage of tasks completed, currently in + * progress, ready to start and not yet ready, in that order. For example, + * 000000025075 means that 25% of the tasks are ready to be started and 75% + * of the tasks are not yet ready to be started because previous tasks have + * not yet been processed. + * + * @return overview of the processing status + */ + String getSortHelperStatus(); + + /** + * Sets the coded overview of the processing status of the process. This + * should only be set manually if this information comes from a third-party + * source. Typically, sorting progress is determined from the progress + * properties of the tasks in the process. The numeric code consists of + * twelve digits, each three digits from 000 to 100 indicate the percentage + * of tasks completed, currently in progress, ready to start and not yet + * ready, in that order. The sum of the four groups of numbers must be 100. + * + * @param sortHelperStatus + * coded overview of the progress with pattern + * ([01]\d{2}){4} + */ + void setSortHelperStatus(String sortHelperStatus); + + /** + * Returns the number of media in a process. This is a business statistical + * characteristic. + * + * @return the number of media in a process + */ + Integer getSortHelperImages(); + + /** + * Sets the number of media in a process. Since counting all media files on + * the file system for many processes is slow, the number can be stored here + * when saving, so that statistics on the number of media can be obtained + * with an acceptable response time. + * + * @param sortHelperImages + * the number of media in a process + */ + void setSortHelperImages(Integer sortHelperImages); + + /** + * Returns the number of metadata entries in a process. This is a business + * statistical characteristic. + * + * @return the number of media in a process + */ + Integer getSortHelperMetadata(); + + /** + * Sets the number of metadata entries in a process. Since the detailed + * business objects are in a file, the number can be stored here when + * saving, so that statistics on the number of metadata entries can be + * obtained with an acceptable response time. + * + * @param sortHelperMetadata + * the number of metadata entries in a process + */ + void setSortHelperMetadata(Integer sortHelperMetadata); + + /** + * Returns the media form of the business object at runtime. Can be + * {@code null} if no runtime value is available. + * + * @return the id of the division representing the media form + */ + String getBaseType(); + + /** + * Sets the media form of the business object in the database. This is a + * transient value that is not persisted. + * + * @param baseType + * id of the division representing the media form + */ + void setBaseType(String baseType); + + /** + * Returns the amount of metadata of the process at runtime. Can be + * {@code null} if no runtime value is available. + * + * @return the amount of metadata + */ + Integer getNumberOfMetadata(); + + /** + * Sets the number of metadata entries in a process. This is a transient + * value that is not persisted. + * + * @param numberOfMetadata + * the number of metadata entries in a process + */ + void setNumberOfMetadata(Integer numberOfMetadata); + + /** + * Returns the number of media in a process at runtime. Can be {@code null} + * if no runtime value is available. + * + * @return the number of media in a process + */ + Integer getNumberOfImages(); + + /** + * Sets the number of media in a process. This is a transient value that is + * not persisted. + * + * @param numberOfImages + * the number of media in a process + */ + void setNumberOfImages(Integer numberOfImages); + + /** + * Returns the number of outline elements in a process. Can be {@code null} + * if no runtime value is available. + * + * @return the number of outline elements in a process + */ + Integer getNumberOfStructures(); + + /** + * Sets the number of outline elements in a process at runtime. This is a + * transient value that is not persisted. + * + * @param numberOfStructures + * the number of outline elements in a process + */ + void setNumberOfStructures(Integer numberOfStructures); + + /** + * Returns the name of the last user who was involved in the process. This + * is the user who recently has a task of the process in progress, or who + * most recently had one in progress. The name is returned comma-separated, + * last name first. Can be {@code null} if no user has worked on the process + * yet. + * + * @return name of last user handling task + */ + String getLastEditingUser(); + + /** + * Sets the name of the last user who was involved in the process. This + * should only be set if the data comes from a third party; internally, it + * is determined in the database. + * + * @param lastEditingUser + * user name, comma-separated, last name first + */ + void setLastEditingUser(String lastEditingUser); + + /** + * Returns the day on which a task of this process was last started. + * + * @return day on which a task of this process was last started + */ + Date getProcessingBeginLastTask(); + + /** + * Sets the day on which a task of this process was last started. This + * should only be set if the data comes from a third party; internally, it + * is determined in the database. + * + * @param processingBeginLastTask + * the day on which a task of this process was last started + */ + void setProcessingBeginLastTask(Date processingBeginLastTask); + + /** + * Returns the day on which a task from this process was last completed. + * + * @return day on which a task from this process was last completed + */ + Date getProcessingEndLastTask(); + + /** + * Sets the day on which a task of this process was last completed. This + * should only be set if the data comes from a third party; internally, it + * is determined in the database. + * + * @param processingEndLastTask + * the day on which a task of this process was last completed + */ + void setProcessingEndLastTask(Date processingEndLastTask); + + /** + * Returns the error corrections processing state of the process. The value + * is specified as integer of {@link CorrectionComments}. + * + * @return the error corrections processing state + */ + Integer getCorrectionCommentStatus(); + + /** + * Sets the error corrections processing state of the process. The value + * must be specified as integer of {@link CorrectionComments}. + * + * @param status + * the error corrections processing state + */ + void setCorrectionCommentStatus(Integer status); + + /** + * Returns whether the process has any comments. + * + * @return whether the process has comments + */ + boolean hasComments(); + + /** + * Sets whether the process has any comments. This should only be set if the + * data comes from a third party; internally, it is determined in the + * database. + * + * @param hasComments + * whether the process has comments + */ + void setHasComments(boolean hasComments); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ProjectInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ProjectInterface.java new file mode 100644 index 00000000000..2b416e8bfe9 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/ProjectInterface.java @@ -0,0 +1,281 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.util.List; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.text.ParseException; + +/** + * An interface to manage digitization projects. + */ +public interface ProjectInterface extends DataInterface { + + /** + * Returns the name of the project. + * + * @return the name of the project + */ + String getTitle(); + + /** + * Sets the name of the project. + * + * @param title + * the name of the project + */ + void setTitle(String title); + + /** + * Returns the start time of the project. The value is a {@link Date} (a + * specific instant in time, with millisecond precision). It is a freely + * configurable value, not the date the project object was created in the + * database. This can be, for example, the start of the funding period. The + * string is formatted according to + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @return the start time + */ + String getStartDate(); + + /** + * Sets the start time of the project. The string must be parsable with + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @param startDate + * the start time + * @throws ParseException + * if the time cannot be converted + */ + void setStartDate(String startDate); + + /** + * Returns the project end time. The value is a {@link Date} (a specific + * instant in time, with millisecond precision). This is a freely + * configurable value, regardless of when the project was last actually + * worked on. For example, this can be the time at which the project must be + * completed in order to be billed. The timing can be used to monitor that + * the project is on time. + * + *

+ * The string is formatted according to + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @return the end time + */ + String getEndDate(); + + /** + * Sets the project end time. The string must be parsable with + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @param endDate + * the end time + * @throws ParseException + * if the time cannot be converted + */ + void setEndDate(String endDate); + + /** + * Returned the file format for exporting the project's business objects. In + * earlier times, the business objects were converted into the target format + * using native Java code. The desired target format was returned here. + * Today the export is done using XSLT, which is not covered by this. + * + * @return always empty + * @deprecated Today the export is done using XSLT, which is configured + * elsewhere. + */ + @Deprecated + default String getFileFormatDmsExport() { + return ""; + } + + /** + * Formerly to set the file format for exporting business objects. + * + * @param fileFormatDmsExport + * unused + * @deprecated Functionless today. + */ + @Deprecated + default void setFileFormatDmsExport(String fileFormatDmsExport) { + } + + /** + * Returned the file format used to store business objects internally. In + * earlier times, several more bad than good file formats were used to store + * the business objects internally. + * + * @return always empty + * @deprecated The less suitable formats are no longer supported since + * version 3. + */ + default String getFileFormatInternal() { + return ""; + } + + /** + * Set the file format used to store business objects internally. + * + * @param fileFormatInternal + * unused + * @deprecated Functionless today. + */ + void setFileFormatInternal(String fileFormatInternal); + + /** + * Returns the name of the copyright holder of the business objects. These + * are often the digitizing institution and also the sponsor. + * + * @return metsRightsOwner the name of the copyright holder + */ + String getMetsRightsOwner(); + + /** + * Sets the name of the copyright owner of the business objects. The + * effective maximum length of this VARCHAR field is subject to the maximum + * row size of 64k shared by all columns, and the charset. + * + * @param metsRightsOwner + * the name of the copyright holder + */ + void setMetsRightsOwner(String metsRightsOwner); + + /** + * Returns the number of media objects to produce. This is a freely + * configurable value, not a determined statistic. The value can be used to + * monitor whether the project is on time. + * + * @return the number of media objects to produce + */ + Integer getNumberOfPages(); + + /** + * Sets the number of media objects to produce. This is usually roughly + * determined as part of project planning and can be stored here as a + * reminder. + * + * @param numberOfPages + * the number of media objects to produce + */ + void setNumberOfPages(Integer numberOfPages); + + /** + * Returns the number of physical archival items to be digitized. This is a + * freely configurable value, not a collected statistical value. The value + * can be used to monitor whether the project is on time. + * + * @return number of volumes as Integer + */ + Integer getNumberOfVolumes(); + + /** + * Sets the number of physical archival materials to be digitized. This is + * usually roughly determined as part of project planning and can be stored + * here as a reminder. + * + * @param numberOfVolumes + * as Integer + */ + void setNumberOfVolumes(Integer numberOfVolumes); + + /** + * Returns whether the project is active. Completed projects are typically + * not hard deleted, but are simply marked as completed. This means that + * even in the event of complaints, the old stocks can still be accessed and + * corrected. + * + * @return whether the project is active + */ + Boolean isActive(); + + /** + * Sets whether the project is active. Deactivated projects are hidden from + * general operation. + * + * @param active + * whether project is active + */ + void setActive(boolean active); + + /** + * Returns the client running this project. + * + * @return the client + */ + ClientInterface getClient(); + + /** + * Specifies the tenant that is executing this project. + * + * @param client + * the client + */ + void setClient(ClientInterface client); + + /** + * Returns the non-deactivated production templates associated with the + * project. + * + * @return the active production templates + */ + List getActiveTemplates(); + + /** + * Sets the active production templates associated with the project. This + * list is not guaranteed to be in reliable order. + * + * @param templates + * the active production templates + */ + void setActiveTemplates(List templates); + + /** + * Returns the users contributing to this project. + * + * @return the users contributing to this project + */ + List getUsers(); + + /** + * Specifies the users who will contribute to this project. + * + * @param users + * the users contributing to this project + */ + void setUsers(List users); + + /** + * Returns whether processes exist in the project. A project that contains + * processes cannot be deleted. + * + * @return whether processes exist in the project + */ + boolean hasProcesses(); + + /** + * Set whether project has processes. The setter can be used when + * representing data from a third-party source. Internally it depends on, + * whether there are process objects in the database for a project. Setting + * this to true cannot insert processes into the database. + * + * @param hasProcesses + * as boolean + * @throws UnsupportedOperationException + * when trying to set this to true for a project without + * processes + */ + void setHasProcesses(boolean hasProcesses); + +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/PropertyInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/PropertyInterface.java new file mode 100644 index 00000000000..a26fa81b6b5 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/PropertyInterface.java @@ -0,0 +1,71 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.text.ParseException; +import java.text.SimpleDateFormat; + +/** + * An interface to manage process properties. Properties are key-value pairs + * that can be added to processes by third-party modules. They should not be + * used to store technical metadata. Such should be part of the business domain. + */ +public interface PropertyInterface extends DataInterface { + /** + * Returns the key of the property's key-value pair. + * + * @return the key + */ + String getTitle(); + + /** + * Sets the key of the property's key-value pair. + * + * @param title + * key to set + */ + void setTitle(String title); + + /** + * Returns the value of the property's key-value pair. + * + * @return the value + */ + String getValue(); + + /** + * Sets the value of the property's key-value pair. + * + * @param value + * value to set + */ + void setValue(String value); + + /** + * Returns the creation time of the property. The string is formatted + * according to {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @return the creation time + */ + String getCreationDate(); + + /** + * Sets the creation time of the property. The string must be parsable with + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @param creationDate + * creation time to set + * @throws ParseException + * if the time cannot be converted + */ + void setCreationDate(String creationDate); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/RoleInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/RoleInterface.java new file mode 100644 index 00000000000..217df792b06 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/RoleInterface.java @@ -0,0 +1,107 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * An interface for managing user roles. Users can have different task-related + * or general-administrative roles, including different roles for different + * clients they work for. A role is always assigned to one client. + */ +public interface RoleInterface extends DataInterface { + + /** + * Returns the name of the role. + * + * @return the name of the role + */ + String getTitle(); + + /** + * Sets the name of the role. + * + * @param title + * name of the role to set + */ + void setTitle(String title); + + /** + * Specifies the users who hold this role. This list is not guaranteed to be + * in reliable order. + * + * @return list of users who hold this role + */ + List getUsers(); + + /** + * Sets the list of users who hold this role. + * + * @param users + * list of users who hold this role to set + */ + void setUsers(List users); + + /** + * Returns how many users hold this role. + * + * @return how many users hold this role + */ + default Integer getUsersSize() { + List users = getUsers(); + return Objects.nonNull(users) ? users.size() : null; + } + + /** + * Sets how many users hold this role. The setter can be used when + * representing data from a third-party source. Internally it depends on, + * whether there are user objects in the database linked to the role. No + * additional users can be added to the role here. + * + * @param size + * how many users hold this role to set + * @throws SecurityException + * when trying to assign this role to unspecified users + * @throws IndexOutOfBoundsException + * for an illegal endpoint index value + */ + default void setUsersSize(Integer size) { + int newSize = Objects.nonNull(size) ? size : 0; + List users = Optional.of(getUsers()).orElse(Collections.emptyList()); + int currentSize = users.size(); + if (newSize == currentSize) { + return; + } + if (newSize > currentSize) { + throw new SecurityException("cannot add arbitrary users"); + } + setUsers(users.subList(0, newSize)); + } + + /** + * Returns the client in whose realm this role grants permissions. + * + * @return the client in whose realm this role grants permissions + */ + ClientInterface getClient(); + + /** + * Sets the client in whose realm this role grants permissions. + * + * @param client + * client in whose realm this role grants permissions to set. + */ + void setClient(ClientInterface client); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/RulesetInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/RulesetInterface.java new file mode 100644 index 00000000000..6b8d5bb4715 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/RulesetInterface.java @@ -0,0 +1,110 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +/** + * An interface for managing the business domain in the form of a ruleset. The + * ruleset defines divisions and metadata keys with their value ranges, and + * describes which division must or may be marked with which metadata. It also + * contains visual settings of the editor GUI. + */ +public interface RulesetInterface extends DataInterface { + + /** + * Returns the name of the configuration file, without a path. The file must + * exist in the ruleset directory. The directory is set in the configuration + * file. + * + * @return the XML file name + */ + String getFile(); + + /** + * Sets the name of the configuration file. The file must exist in the + * ruleset directory. The file name must be specified without a path. + * + * @param file + * XML file name + */ + void setFile(String file); + + /** + * Returns the display name of the business domain model. It is displayed to + * the user in a selection dialog. + * + * @return the display name + */ + String getTitle(); + + /** + * Sets the display name of the business domain model. + * + * @param title + * the display name + */ + void setTitle(String title); + + /** + * Returns whether the elements of the ruleset should be displayed in the + * declared order. If not, they are displayed alphabetically. It varies at + * which points this sorting takes effect and what is sorted on. + * + * @return whether the elements should be in declared order + */ + boolean isOrderMetadataByRuleset(); + + /** + * Sets whether the elements of the ruleset should be displayed in the + * declared order. + * + * @param orderMetadataByRuleset + * whether the elements should be in declared order + */ + void setOrderMetadataByRuleset(boolean orderMetadataByRuleset); + + /** + * Determines whether the ruleset is active. A deactivated rule set is not + * offered for selection, but can continue to be used where it is already in + * use. + * + * @return whether the ruleset is active + */ + Boolean isActive(); + + /** + * Sets whether the ruleset is active. + * + * @param active + * whether the ruleset is active + */ + void setActive(boolean active); + + /** + * Returns the client that this ruleset is associated with. Technically, + * multiple client can use the same docket generator configuration (file), + * but they must be made available independently for each client using one + * configuration object each. This determines which rulesets are visible to + * a client at all, and they can be named differently. + * + * @return client that this ruleset is associated with + */ + ClientInterface getClient(); + + /** + * Sets the client to which this ruleset is associated. + * + * @param client + * client to which this ruleset is associated + */ + void setClient(ClientInterface client); + +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/TaskInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/TaskInterface.java new file mode 100644 index 00000000000..811309bedc3 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/TaskInterface.java @@ -0,0 +1,508 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.text.ParseException; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import org.kitodo.data.database.enums.TaskEditType; +import org.kitodo.data.database.enums.TaskStatus; + +public interface TaskInterface extends DataInterface { + + /** + * Returns the name of the task. This is usually a human-readable, + * aphoristic summary of the activity to be performed. + * + * @return the name + */ + String getTitle(); + + /** + * Sets the name of the task. + * + * @param title + * name to set + */ + void setTitle(String title); + + /** + * Returns the translated name of the task at runtime. This can be + * translated at runtime for the user currently performing this task via the + * application's language resource files. Can be {@code null} if currently + * no value is available. + * + * @return translated name + */ + String getLocalizedTitle(); + + /** + * Sets the translated name of the task at runtime. This is a transient + * value that is not persisted. + * + * @param localizedTitle + * translated name to set + */ + void setLocalizedTitle(String localizedTitle); + + /** + * Returns the ordinal number of the task. Tasks can be processed + * sequentially. When a task with a lower ordinal number is completed, the + * task with the next higher ordinal number can be processed. If several + * tasks share the same ordinal number, they can be processed in parallel. + * + * @return ordinal number of the task + */ + Integer getOrdering(); + + /** + * Sets the ordinal number of the task. This sets the consecutive execution + * point relative to the other tasks in the process. May be the same as the + * number of another task if they are to be processed in parallel. Must not + * be {@code null}. + * + * @param ordering + * ordinal number of the task + */ + void setOrdering(Integer ordering); + + /** + * Returns the processing status of the task. A task can: + *

+ *
LOCKED
+ *
wait for previous tasks to complete to become ready to start
+ *
OPEN
+ *
ready to go and waiting to be taken over
+ *
INWORK
+ *
currently being carried out
+ *
DONE
+ *
be finished
+ *
+ * + * @return the processing status + */ + TaskStatus getProcessingStatus(); + + /** + * Sets the processing status of the task. + * + * @param processingStatus + * processing status to set + */ + void setProcessingStatus(TaskStatus processingStatus); + + /** + * Returns the translated processing status of the task at runtime. This can + * be translated at runtime for the user currently displaying this task. Can + * be {@code null} if currently no value is available. + * + * @return translated processing status + */ + String getProcessingStatusTitle(); + + /** + * Sets the translated processing status of the task at runtime. This is a + * transient value that is not persisted. + * + * @param processingStatus + * translated processing status to set + */ + void setProcessingStatusTitle(String processingStatusTitle); + + /** + * Returns the processing type of the task. Possible are: + *
+ *
UNNOWKN
+ *
The processing type of the task is not defined.
+ *
MANUAL_SINGLE
+ *
The task was taken over and carried out by a user.
+ *
MANUAL_MULTI
+ *
The task was taken over and carried out by a user as part of the + * batch processing functionality.
+ *
ADMIN
+ *
The task status has been changed administratively using the status + * increase or status decrease functions.
+ *
AUTOMATIC
+ *
The automatic task was carried out by the workflow system.
+ *
QUEUE
+ *
The task status was changed via the Active MQ interface.
+ *
+ * + * @return the processing type + */ + TaskEditType getEditType(); + + /** + * Sets the processing type of the task. + * + * @param editType + * processing type to set + */ + void setEditType(TaskEditType editType); + + /** + * Returns the translated processing type of the task at runtime. This can + * be translated at runtime for the user currently displaying this task. Can + * be {@code null} if currently no value is available. + * + * @return translated processing status + */ + String getEditTypeTitle(); + + /** + * Sets the translated processing tipe of the task at runtime. This is a + * transient value that is not persisted. + * + * @param processingStatus + * translated processing type to set + */ + void setEditTypeTitle(String editTypeTitle); + + /** + * Returns the user who last worked on the task. + * + * @return the user who last worked on the task + */ + UserInterface getProcessingUser(); + + /** + * Sets the user who last worked on the task. + * + * @param processingUser + * user to set + */ + void setProcessingUser(UserInterface processingUser); + + /** + * Returns the time the task status was last changed. This references + * any activity on the task that involves a change in status. The + * string is formatted according to + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @return the time the task status was last changed + */ + String getProcessingTime(); + + /** + * Sets the time the task status was last changed. The string must be + * parsable with {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @param processingTime + * time to set + * @throws ParseException + * if the time cannot be converted + */ + void setProcessingTime(String processingTime); + + /** + * Returns the time when the task was accepted for processing. The string is + * formatted according to + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @return the time when the task was accepted for processing + */ + String getProcessingBegin(); + + /** + * Sets the time the task was accepted for processing. The string must be + * parsable with {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @param processingTime + * time to set + * @throws ParseException + * if the time cannot be converted + */ + void setProcessingBegin(String processingBegin); + + /** + * Returns the time when the task was completed. The string is formatted + * according to {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @return the time when the task was completed + */ + String getProcessingEnd(); + + /** + * Sets the time the task was completed. The string must be parsable with + * {@link SimpleDateFormat}{@code ("yyyy-MM-dd HH:mm:ss")}. + * + * @param processingTime + * time to set + * @throws ParseException + * if the time cannot be converted + */ + void setProcessingEnd(String processingEnd); + + /** + * Returns the process this task belongs to. Can be {@code null} if the task + * belongs to a production template, and not a process. + * + * @return the process this task belongs to + */ + ProcessInterface getProcess(); + + /** + * Sets the process this task belongs to. A task can only ever be assigned + * to either a process or a production template. + * + * @param process + * process this task belongs to + */ + void setProcess(ProcessInterface process); + + /** + * Returns the project the process belongs to. + * + * @return the project the process belongs to + */ + ProjectInterface getProject(); + + /** + * Sets the project the process belongs to. + * + * @param project + * project to set + */ + void setProject(ProjectInterface project); + + /** + * Returns the production template this task belongs to. Can be {@code null} + * if the task belongs to a process, and not a production template. + * + * @return the production template this task belongs to + */ + TemplateInterface getTemplate(); + + /** + * Sets the production template this task belongs to. A task can only ever + * be assigned to either a production template or a process. + * + * @param process + * process this task belongs to + */ + void setTemplate(TemplateInterface template); + + /** + * Returns a list of the IDs of the roles, whose holders are allowed to + * perform this task. This list is not guaranteed to be in reliable order. + * + * @return list of the IDs of the roles + */ + List getRoleIds(); + + /** + * Specifies a list of role IDs whose holders are allowed to perform this + * task. The list should not contain duplicates, and must not contain + * {@code null}s. It is not specified whether setting the roles using IDs is + * an action at the current time. Subsequent edits to the ID list may or may + * not affect the stored roles. + * + * @param roleIds + * list of role IDs + */ + void setRoleIds(List roleIds); + + /** + * Returns how many roles are allowed to take on this task. + * + * @return how many roles are allowed to take on this task + */ + default int getRolesSize() { + List roles = getRoleIds(); + return Objects.nonNull(roles) ? roles.size() : 0; + } + + /** + * Sets how many roles are allowed to take on this task. The setter can be + * used when representing data from a third-party source. Internally it + * depends on, whether there are role objects in the database linked to the + * process. No additional roles can be added to the process here. + * + * @param size + * how many users hold this role to set + * @throws SecurityException + * when trying to assign unspecified roles to this process + * @throws IndexOutOfBoundsException + * for an illegal endpoint index value + */ + default void setRolesSize(int rolesSize) { + int newSize = Objects.nonNull(rolesSize) ? rolesSize : 0; + List users = Optional.of(getRoleIds()).orElse(Collections.emptyList()); + int currentSize = users.size(); + if (newSize == currentSize) { + return; + } + if (newSize > currentSize) { + throw new SecurityException("cannot add arbitrary roles"); + } + setRoleIds(users.subList(0, newSize)); + } + + /** + * Returns whether the task is in a correction run. In a five-step workflow, + * if a correction request occurs from the fourth step to the second step, + * steps two and three are in the correction run. + * + * @return whether the task is in a correction run + */ + boolean isCorrection(); + + /** + * Sets whether the task is in a correction run. + * + * @param correction + * whether the task is in a correction run + */ + void setCorrection(boolean correction); + + /** + * Returns whether the task is of automatic type. Automatic tasks are taken + * over by the workflow system itself, the actions selected in it are + * carried out, such as an export or a script call, and then the task is + * completed. + * + * @return whether the task is automatic + */ + boolean isTypeAutomatic(); + + /** + * Sets whether the task is of automatic type. + * + * @param typeAutomatic + * whether the task is automatic + */ + void setTypeAutomatic(boolean typeAutomatic); + + /** + * Returns whether the editor for the digital copy is made available to the + * user. The editor offers a UI in which the structure of the previously + * loosely digitized media can be detailed. + * + * @return whether the editor is available + */ + boolean isTypeMetadata(); + + /** + * Sets whether the editor is available in the task. + * + * @param typeMetadata + * whether the editor is available + */ + void setTypeMetadata(boolean typeMetadata); + + /** + * Returns whether this task gives the user file system access. They can + * then access the folder for or containing the digitized files and create, + * view or edit files. + * + * @return whether the user gets file access + */ + boolean isTypeImagesRead(); + + /** + * Sets whether this task gives the user file system access. + * + * @param typeImagesRead + * whether the user gets file access + */ + void setTypeImagesRead(boolean typeImagesRead); + + /** + * Returns whether the user is allowed to create or modify files. When + * digitizing, the user probably needs write access to the file area of the + * process, but perhaps not for control tasks. + * + * @return whether the user gets write access + */ + boolean isTypeImagesWrite(); + + /** + * Sets whether the user is allowed to create or modify files. + * + * @param typeImagesWrite + * whether the user gets write access + */ + void setTypeImagesWrite(boolean typeImagesWrite); + + /** + * Returns whether accepting or completing this task applies to the batch. + * If so, with a single UI interaction, the user automatically executes an + * action for all tasks of all processes in the batch that, have the same + * name and are in the same state. This saves users from a lot of mouse + * work. + * + * @return whether actions apply to the batch + */ + boolean isBatchStep(); + + /** + * Set information if batch is available for task - there is more than one + * task with the same title assigned to the batch.). + * + * @param batchAvailable + * as boolean + */ + void setBatchAvailable(boolean batchAvailable); + + /** + * Returns whether batch automation is possible for this task. For + * automation to work, the process containing the task must be assigned to + * exactly one batch. + * + * @return whether batch automation is possible + */ + boolean isBatchAvailable(); + + /** + * Sets whether batch automation is possible for this task. The setter can + * be used when representing data from a third-party source. Internally it + * depends on, whether the process containing the task is assigned to + * exactly one batch. + * + * @param batchStep + * whether batch automation is possible + * @throws UnsupportedOperationException + * when the value doesn't match the background database + */ + void setBatchStep(boolean batchStep); + + /** + * Returns the status of the task regarding necessary corrections. Possible + * are: + *
+ *
0
+ *
There are no corrections.
+ *
1
+ *
All necessary corrections have been made.
+ *
2
+ *
Corrections are pending.
+ *
+ * + * @return the status regarding corrections + * @see org.kitodo.data.database.enums.CorrectionComments + */ + Integer getCorrectionCommentStatus(); + + /** + * Sets the status of the task regarding necessary corrections. Must be a + * number from 0 to 2. + * + * @param status + * the status regarding corrections + * @see org.kitodo.data.database.enums.CorrectionComments + */ + void setCorrectionCommentStatus(Integer status); + +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/TemplateInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/TemplateInterface.java new file mode 100644 index 00000000000..8e19a4f6b82 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/TemplateInterface.java @@ -0,0 +1,182 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.io.InputStream; +import java.util.List; + +public interface TemplateInterface extends DataInterface { + + /** + * Returns the process template name. + * + * @return the process template name + */ + String getTitle(); + + /** + * Sets the process template name. + * + * @param title + * the process template name + */ + void setTitle(String title); + + /** + * Returns the day the process template was created. + * + * @return the day the process template was created + */ + String getCreationDate(); + + /** + * Sets the day of process template creation. + * + * @param creationDate + * the day of process template creation + */ + void setCreationDate(String creationDate); + + /** + * Returns the docket generation statement to use when creating dockets for + * processes derived from this process template. + * + * @return the docket generation statement + */ + DocketInterface getDocket(); + + /** + * Sets the docket generation statement to use when creating dockets for + * processes derived from this process template. + * + * @param docket + * the docket generation statement + */ + void setDocket(DocketInterface docket); + + /** + * Returns the business domain specification processes derived from this + * process template template shall be using. + * + * @return the business domain specification + */ + RulesetInterface getRuleset(); + + /** + * Sets the business domain specification processes derived from this + * process template template shall be using. + * + * @param ruleset + * the business domain specification + */ + void setRuleset(RulesetInterface ruleset); + + /** + * Returns the task list of this process template. + * + * @return the task list + */ + List getTasks(); + + /** + * Sets the task list of this process template. + * + * @param tasks + * the task list + */ + void setTasks(List tasks); + + /** + * Returns a read handle for the SVG image of this production template's + * workflow. If the file cannot be read (due to an error), returns an empty + * input stream. + * + * @return read file handle for the SVG + */ + InputStream getDiagramImage(); + + /** + * Returns whether this production template is active. Production templates + * that are no not to be used (anymore) can be deactivated. If processes + * exist from them, they cannot be deleted. + * + * @return whether this production template is active + */ + boolean isActive(); + + /** + * Sets whether this production template is active. + * + * @param active + * whether this production template is active + */ + void setActive(boolean active); + + /** + * Sets the workflow from which the production template was created. + * + * @param workflow + * workflow to set + */ + void setWorkflow(WorkflowInterface workflow); + + /** + * Returns the workflow from which the production template was created. The + * tasks of the production template are not created directly in the + * production template, but are edited using the workflow. + * + * @return the workflow + */ + WorkflowInterface getWorkflow(); + + /** + * Returns whether the production template is valid. To do this, it must + * contain at least one task and each task must have at least one role + * assigned to it. + * + * @return whether the production template is valid + */ + boolean isCanBeUsedForProcess(); + + /** + * Sets whether the production template is valid. The setter can be used + * when representing data from a third-party source. Internally it depends + * on whether the production template is valid. Setting this to true cannot + * fix errors. + * + * @param canBeUsedForProcess + * as boolean + * @throws UnsupportedOperationException + * when trying to set this on the database + */ + default void setCanBeUsedForProcess(boolean canBeUsedForProcess) { + throw new UnsupportedOperationException("not allowed"); + } + + /** + * Returns the list of all projects that use this production template. A + * production template can be used in multiple projects, even across + * multiple clients. This list is not guaranteed to be in reliable order. + * + * @return the list of all projects that use this production template + */ + List getProjects(); + + /** + * Sets the list of all projects that use this production template. The list + * should not contain duplicates, and must not contain {@code null}s. + * + * @param projects + * projects list to set + */ + void setProjects(List projects); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/UserInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/UserInterface.java new file mode 100644 index 00000000000..f25adb59d05 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/UserInterface.java @@ -0,0 +1,375 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * An interface for editing users of the web application. + */ +public interface UserInterface extends DataInterface { + + /** + * Returns the user's login name. + * + * @return the user name + */ + String getLogin(); + + /** + * Sets the user's login name. Since the user is also created as a Linux + * system user, the user name should follow the naming conventions and not + * match any existing Linux user. To avoid hassle when accessing file space + * using case-insensitive CIFS, it is recommended to only use lowercase + * letters in the name. + * + * @param login + * user name to set + */ + void setLogin(String login); + + /** + * Returns the user's first name. + * + * @return the first name + */ + String getName(); + + /** + * Sets the user's first name. + * + * @param name + * first name to set + */ + void setName(String name); + + /** + * Returns the user's surname. + * + * @return the surname + */ + String getSurname(); + + /** + * Sets the user's surname. + * + * @param surname + * surname to set + */ + void setSurname(String surname); + + /** + * Returns the user's full name. The spelling is last name—comma—first name. + * + * @return the full name + */ + String getFullName(); + + /** + * Sets the user's full name. + * + * @param fullName + * full name to set + */ + void setFullName(String fullName); + + /** + * Returns the user's location. Users from different locations collaborate + * in this web application. Specifying the location simplifies user + * maintenance. + * + * @return the location + */ + String getLocation(); + + /** + * Sets the user's location. + * + * @param location + * place name + */ + void setLocation(String location); + + /** + * Returns the login name to the directory service. This provides the + * ability to use a username independent of the Linux username to + * authenticate against a corporate directory service. For logging into the + * web application, the user can use either username. + * + * @return different user name for the directory service + */ + String getLdapLogin(); + + /** + * Sets a different user name for the directory service. The emphasis here + * is on "different", the remote username must not be the same as any + * primary username. Multiple local users cannot be mapped to the same + * remote username either. + * + * @param ldapLogin + * different user name to set + */ + void setLdapLogin(String ldapLogin); + + /** + * Returns whether the user is logged in. This allows a administrators to + * check whether they can stop the application for maintenance purposes, or + * who they needs to call first. + * + * @return whether the user is logged in + */ + boolean isActive(); + + /** + * Sets whether the user is logged in. The setter can be used when + * representing data from a third-party source. Internally, this depends on + * the existence of a user session in the servlet container. This cannot be + * changed here. + * + * @param active + * as boolean + * @throws UnsupportedOperationException + * when trying to change this + */ + default void setActive(boolean active) { + if (active != isActive()) { + throw new UnsupportedOperationException(active ? "cannot log user in" : "cannot log user out"); + } + } + + /** + * Returns the user's saved search queries. This list is not guaranteed to + * be in reliable order. + * + * @return the saved search queries + */ + List getFilters(); + + /** + * Sets a list of the user's saved searches. The list should not contain + * duplicates, and must not contain {@code null}s. + * + * @param filters + * list of saved search queries to set + */ + void setFilters(List filters); + + /** + * Returns the number of saved search queries. + * + * @return the number of saved search queries + */ + default Integer getFiltersSize() { + List queries = getFilters(); + return Objects.nonNull(queries) ? queries.size() : null; + } + + /** + * Sets the number of saved search queries. The setter can be used when + * representing data from a third-party source. Internally it depends on, + * whether there are filter objects in the database linked to the user. No + * additional filters can be added to the process here. + * + * @param size + * how many users hold this role to set + * @throws UnsupportedOperationException + * when trying to add unspecified filters to this user + * @throws IndexOutOfBoundsException + * for an illegal endpoint index value + */ + default void setFiltersSize(Integer filtersSize) { + if (Objects.isNull(filtersSize)) { + setFilters(null); + return; + } + List filters = Optional.of(getFilters()).orElse(Collections.emptyList()); + if (filtersSize == filters.size()) { + return; + } + while (filtersSize > filters.size()) { + throw new UnsupportedOperationException("cannot add arbitrary filters"); + } + setFilters(filters.subList(0, filtersSize)); + } + + /** + * Returns all of the user's roles. This list is not guaranteed to be in + * reliable order. + * + * @return a list of all roles of the user + */ + List getRoles(); + + /** + * Sets a list of all of the user's roles. + * + * @param roles + * list to set + */ + void setRoles(List roles); + + /** + * Returns the number of roles the user has. + * + * @return the number of roles + */ + default int getRolesSize() { + List roles = getRoles(); + return Objects.nonNull(roles) ? roles.size() : 0; + } + + /** + * Sets the number of roles the user has. The setter can be used when + * representing data from a third-party source. Internally it depends on, + * whether there are role objects in the database linked to the user. No + * additional roles can be added to the user here. + * + * @param size + * number of roles to set + * @throws SecurityException + * when trying to assign unspecified roles to this user + * @throws IndexOutOfBoundsException + * for an illegal endpoint index value + */ + default void setRolesSize(Integer rolesSize) { + int newSize = Objects.nonNull(rolesSize) ? rolesSize : 0; + List users = Optional.of(getRoles()).orElse(Collections.emptyList()); + int currentSize = users.size(); + if (newSize == currentSize) { + return; + } + if (newSize > currentSize) { + throw new SecurityException("cannot add arbitrary roles"); + } + setRoles(users.subList(0, newSize)); + } + + /** + * Returns all clients the user interacts with. + * + * @return the clients + */ + List getClients(); + + /** + * Sets the list of all clients that the user interacts with. + * + * @param clients + * clients to set + */ + void setClients(List clients); + + /** + * Returns the number of clients the user interacts with. + * + * @return the number of clients + */ + default int getClientsSize() { + List clients = getClients(); + return Objects.nonNull(clients) ? clients.size() : 0; + } + + /** + * Sets the number of roles the user has. The setter can be used when + * representing data from a third-party source. Internally it depends on, + * whether there are role objects in the database linked to the user. No + * additional roles can be added to the user here. + * + * @param size + * number of roles to set + * @throws SecurityException + * when trying to assign unspecified roles to this user + * @throws IndexOutOfBoundsException + * for an illegal endpoint index value + */ + default void setClientsSize(Integer clientsSize) { + int newSize = Objects.nonNull(clientsSize) ? clientsSize : 0; + List users = Optional.of(getClients()).orElse(Collections.emptyList()); + int currentSize = users.size(); + if (newSize == currentSize) { + return; + } + if (newSize > currentSize) { + throw new SecurityException("cannot add arbitrary clients"); + } + setClients(users.subList(0, newSize)); + } + + /** + * Returns all projects the user collaborates on. + * + * @return all projects + */ + List getProjects(); + + /** + * Sets the list of all projects the user is working on. + * + * @param projects + * list of projects to set + */ + void setProjects(List projects); + + /** + * Returns the number of projects the user is working on. + * + * @return the number of projects + */ + default int getProjectsSize() { + List projects = getProjects(); + return Objects.nonNull(projects) ? projects.size() : 0; + } + + /** + * Sets the number of roles the user has. The setter can be used when + * representing data from a third-party source. Internally it depends on, + * whether there are role objects in the database linked to the user. No + * additional roles can be added to the user here. + * + * @param size + * number of roles to set + * @throws UnsupportedOperationException + * when trying to assign unspecified projects to this user + * @throws IndexOutOfBoundsException + * for an illegal endpoint index value + */ + default void setProjectsSize(Integer projectsSize) { + int newSize = Objects.nonNull(projectsSize) ? projectsSize : 0; + List users = Optional.of(getProjects()).orElse(Collections.emptyList()); + int currentSize = users.size(); + if (newSize == currentSize) { + return; + } + if (newSize > currentSize) { + throw new UnsupportedOperationException("cannot add arbitrary projects"); + } + setProjects(users.subList(0, newSize)); + } + + /** + * Returns all tasks the user is currently working on. + * + * @return all tasks the user is working on + */ + List getProcessingTasks(); + + /** + * Sets a list of all tasks that the user should work on. + * + * @param processingTasks + * list of tasks to set + */ + void setProcessingTasks(List processingTasks); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/WorkflowInterface.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/WorkflowInterface.java new file mode 100644 index 00000000000..6c2f620d0a4 --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/WorkflowInterface.java @@ -0,0 +1,59 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.data.interfaces; + +import org.kitodo.data.database.enums.WorkflowStatus; + +public interface WorkflowInterface extends DataInterface { + + /** + * Returns the label of the workflow. + * + * @return the label + */ + String getTitle(); + + /** + * Sets the label of the workflow. + * + * @param title + * label to set + */ + void setTitle(String title); + + /** + * Returns the stage of the workflow. Statuses: + * + *
+ *
DRAFT
+ *
the workflow is being created
+ *
ACTIVE
+ *
the workflow is in use
+ *
ARCHIVED
+ *
the workflow is no longer used
+ *
+ * + * @return the stage + */ + String getStatus(); + + /** + * Sets the stage of the workflow. One of {@link WorkflowStatus}. + * + * @param status + * as String + * @throws IllegalArgumentException + * if {@link WorkflowStatus} has no constant with the specified + * name + */ + void setStatus(String status); +} diff --git a/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/package-info.java b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/package-info.java new file mode 100644 index 00000000000..bff108fb0fc --- /dev/null +++ b/Kitodo-DataManagement/src/main/java/org/kitodo/data/interfaces/package-info.java @@ -0,0 +1,30 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +/** + * Provides an interface for some particularly central data objects of the + * application. Data objects from the database or third-party sources can be + * used agnostically in the implementation via the interface. These are: + *
    + *
  • for access management: users ({@link UserInterface}) with roles + * ({@link RoleInterface}) who work for clients ({@link ClientInterface}) + *
  • for project management: business domain configurations + * ({@link RulesetInterface}), workflows ({@link WorkflowInterface}), production + * templates ({@link TemplateInterface}) and runnotes ({@link DocketInterface}) + *
  • for operations: processes ({@link ProcessInterface}) with properties + * ({@link PropertyInterface}), with their tasks ({@link TaskInterface}), in + * batches ({@link BatchInterface}) + *
+ * The interface objects are based on the common interface + * {@link DataInterface}. The factory methods are provided by the + * {@link DataFactoryInterface}. + */ +package org.kitodo.data.interfaces; diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/BaseDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/BaseDTO.java index 76e4814fdda..d6fccb4e3bf 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/BaseDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/BaseDTO.java @@ -13,7 +13,9 @@ import java.io.Serializable; -public abstract class BaseDTO implements Serializable { +import org.kitodo.data.interfaces.DataInterface; + +public abstract class BaseDTO implements Serializable, DataInterface { private Integer id; diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/BaseTemplateDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/BaseTemplateDTO.java index 948957c88ca..3b90e3551c9 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/BaseTemplateDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/BaseTemplateDTO.java @@ -14,13 +14,17 @@ import java.util.ArrayList; import java.util.List; +import org.kitodo.data.interfaces.DocketInterface; +import org.kitodo.data.interfaces.RulesetInterface; +import org.kitodo.data.interfaces.TaskInterface; + public abstract class BaseTemplateDTO extends BaseDTO { private String title; private String creationDate; - private DocketDTO docket; - private RulesetDTO ruleset; - private List tasks = new ArrayList<>(); + private DocketInterface docket; + private RulesetInterface ruleset; + private List tasks = new ArrayList<>(); /** * Get title. @@ -63,9 +67,9 @@ public void setCreationDate(String creationDate) { /** * Get docket. * - * @return docket as DocketDTO + * @return docket as DocketInterface */ - public DocketDTO getDocket() { + public DocketInterface getDocket() { return docket; } @@ -73,18 +77,18 @@ public DocketDTO getDocket() { * Set docket. * * @param docket - * as DocketDTO + * as DocketInterface */ - public void setDocket(DocketDTO docket) { + public void setDocket(DocketInterface docket) { this.docket = docket; } /** * Get ruleset. * - * @return ruleset as RulesetDTO + * @return ruleset as RulesetInterface */ - public RulesetDTO getRuleset() { + public RulesetInterface getRuleset() { return ruleset; } @@ -92,18 +96,18 @@ public RulesetDTO getRuleset() { * Set ruleset. * * @param ruleset - * as RulesetDTO + * as RulesetInterface */ - public void setRuleset(RulesetDTO ruleset) { + public void setRuleset(RulesetInterface ruleset) { this.ruleset = ruleset; } /** * Get list of tasks. * - * @return list of tasks as TaskDTO + * @return list of tasks as TaskInterface */ - public List getTasks() { + public List getTasks() { return tasks; } @@ -111,9 +115,9 @@ public List getTasks() { * Set list of tasks. * * @param tasks - * list of tasks as TaskDTO + * list of tasks as TaskInterface */ - public void setTasks(List tasks) { + public void setTasks(List tasks) { this.tasks = tasks; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/BatchDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/BatchDTO.java index d705c80952f..f16b49fe585 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/BatchDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/BatchDTO.java @@ -14,13 +14,16 @@ import java.util.ArrayList; import java.util.List; +import org.kitodo.data.interfaces.BatchInterface; +import org.kitodo.data.interfaces.ProcessInterface; + /** * Batch DTO object. */ -public class BatchDTO extends BaseDTO { +public class BatchDTO extends BaseDTO implements BatchInterface { private String title; - private List processes = new ArrayList<>(); + private List processes = new ArrayList<>(); /** * Get title. @@ -46,7 +49,7 @@ public void setTitle(String title) { * * @return List of processes as ProcessDTO */ - public List getProcesses() { + public List getProcesses() { return processes; } @@ -56,7 +59,7 @@ public List getProcesses() { * @param processes * as List of processes as ProcessDTO */ - public void setProcesses(List processes) { + public void setProcesses(List processes) { this.processes = processes; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/ClientDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/ClientDTO.java index 79defcb36d7..a0ee6c745e6 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/ClientDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/ClientDTO.java @@ -14,11 +14,15 @@ import java.util.ArrayList; import java.util.List; -public class ClientDTO extends BaseDTO { +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.UserInterface; + +public class ClientDTO extends BaseDTO implements ClientInterface { private String name; - private List users = new ArrayList<>(); - private List projects = new ArrayList<>(); + private List users = new ArrayList<>(); + private List projects = new ArrayList<>(); /** * Gets title. @@ -44,7 +48,7 @@ public void setName(String name) { * * @return The users. */ - public List getUsers() { + public List getUsers() { return users; } @@ -54,7 +58,7 @@ public List getUsers() { * @param users * The users. */ - public void setUsers(List users) { + public void setUsers(List users) { this.users = users; } @@ -63,7 +67,7 @@ public void setUsers(List users) { * * @return The projects. */ - public List getProjects() { + public List getProjects() { return projects; } @@ -73,7 +77,7 @@ public List getProjects() { * @param projects * The projects. */ - public void setProjects(List projects) { + public void setProjects(List projects) { this.projects = projects; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/DTOFactory.java b/Kitodo/src/main/java/org/kitodo/production/dto/DTOFactory.java new file mode 100644 index 00000000000..1a83222fbfe --- /dev/null +++ b/Kitodo/src/main/java/org/kitodo/production/dto/DTOFactory.java @@ -0,0 +1,106 @@ +/* + * (c) Kitodo. Key to digital objects e. V. + * + * This file is part of the Kitodo project. + * + * It is licensed under GNU General Public License version 3 or later. + * + * For the full copyright and license information, please read the + * GPL3-License.txt file that was distributed with this source code. + */ + +package org.kitodo.production.dto; + +import org.kitodo.data.interfaces.BatchInterface; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.DataFactoryInterface; +import org.kitodo.data.interfaces.DocketInterface; +import org.kitodo.data.interfaces.FilterInterface; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.PropertyInterface; +import org.kitodo.data.interfaces.RulesetInterface; +import org.kitodo.data.interfaces.TaskInterface; +import org.kitodo.data.interfaces.TemplateInterface; +import org.kitodo.data.interfaces.UserInterface; +import org.kitodo.data.interfaces.WorkflowInterface; + +/** + * A factory object for data transfer objects. + */ +public class DTOFactory implements DataFactoryInterface { + + private static final DTOFactory instance = new DTOFactory(); + + /** + * Returns the instance of the factory object. The factory object implements + * the {@link DataFactoryInterface}. Since interfaces cannot have static + * methods, it must be accessed here via an instance of the class, even + * though the class has no state (no fields). + * + * @return the factory instance + */ + public static DTOFactory instance() { + return instance; + } + + @Override + public BatchInterface newBatch() { + return new BatchDTO(); + } + + @Override + public ClientInterface newClient() { + return new ClientDTO(); + } + + @Override + public DocketInterface newDocket() { + return new DocketDTO(); + } + + @Override + public FilterInterface newFilter() { + return new FilterDTO(); + } + + @Override + public ProcessInterface newProcess() { + return new ProcessDTO(); + } + + @Override + public ProjectInterface newProject() { + return new ProjectDTO(); + } + + @Override + public PropertyInterface newProperty() { + return new PropertyDTO(); + } + + @Override + public RulesetInterface newRuleset() { + return new RulesetDTO(); + } + + @Override + public TaskInterface newTask() { + return new TaskDTO(); + } + + @Override + public TemplateInterface newTemplate() { + return new TemplateDTO(); + } + + @Override + public UserInterface newUser() { + return new UserDTO(); + } + + @Override + public WorkflowInterface newWorkflow() { + return new WorkflowDTO(); + } +} diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/DocketDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/DocketDTO.java index 339ab165879..f81a79b8d50 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/DocketDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/DocketDTO.java @@ -11,15 +11,18 @@ package org.kitodo.production.dto; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.DocketInterface; + /** * Docket DTO object. */ -public class DocketDTO extends BaseDTO { +public class DocketDTO extends BaseDTO implements DocketInterface { private String file; private String title; private Boolean active = true; - private ClientDTO client; + private ClientInterface client; /** * Get file. @@ -81,9 +84,9 @@ public void setActive(boolean active) { /** * Get client object. * - * @return value of clientDTO + * @return value of clientInterface */ - public ClientDTO getClient() { + public ClientInterface getClient() { return client; } @@ -91,9 +94,9 @@ public ClientDTO getClient() { * Set client object. * * @param client - * as org.kitodo.production.dto.ClientDTO + * as org.kitodo.production.dto.ClientInterface */ - public void setClientDTO(ClientDTO client) { + public void setClient(ClientInterface client) { this.client = client; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/FilterDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/FilterDTO.java index fcd3b18b900..547a15651c8 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/FilterDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/FilterDTO.java @@ -11,10 +11,12 @@ package org.kitodo.production.dto; +import org.kitodo.data.interfaces.FilterInterface; + /** * Filter DTO object. */ -public class FilterDTO extends BaseDTO { +public class FilterDTO extends BaseDTO implements FilterInterface { private String value; diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/ProcessDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/ProcessDTO.java index a4d492e4d25..a28c4f223ff 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/ProcessDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/ProcessDTO.java @@ -16,15 +16,21 @@ import java.util.List; import java.util.Objects; +import org.kitodo.data.interfaces.BatchInterface; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.PropertyInterface; +import org.kitodo.data.interfaces.UserInterface; + /** * Process DTO object. */ -public class ProcessDTO extends BaseTemplateDTO { +public class ProcessDTO extends BaseTemplateDTO implements ProcessInterface { - private ProjectDTO project; - private List batches = new ArrayList<>(); - private List properties = new ArrayList<>(); - private UserDTO blockedUser; + private ProjectInterface project; + private List batches = new ArrayList<>(); + private List properties = new ArrayList<>(); + private UserInterface blockedUser; private Double progressClosed; private Double progressInProcessing; private Double progressOpen; @@ -53,28 +59,28 @@ public class ProcessDTO extends BaseTemplateDTO { /** * Get project. * - * @return project as ProjectDTO + * @return project as ProjectInterface */ - public ProjectDTO getProject() { + public ProjectInterface getProject() { return project; } /** * Set project. * - * @param project - * as ProjectDTO + * @param projectInterface + * as ProjectInterface */ - public void setProject(ProjectDTO project) { - this.project = project; + public void setProject(ProjectInterface projectInterface) { + this.project = (ProjectInterface) projectInterface; } /** * Get list of batches. * - * @return list of batches as BatchDTO + * @return list of batches as BatchInterface */ - public List getBatches() { + public List getBatches() { return batches; } @@ -82,18 +88,18 @@ public List getBatches() { * Set list of batches. * * @param batches - * list of batches as BatchDTO + * list of batches as BatchInterface */ - public void setBatches(List batches) { + public void setBatches(List batches) { this.batches = batches; } /** * Get list of properties. * - * @return list of properties as PropertyDTO + * @return list of properties as PropertyInterface */ - public List getProperties() { + public List getProperties() { if (Objects.isNull(this.properties)) { properties = new ArrayList<>(); } @@ -104,18 +110,18 @@ public List getProperties() { * Set list of properties. * * @param properties - * list of properties as PropertyDTO + * list of properties as PropertyInterface */ - public void setProperties(List properties) { + public void setProperties(List properties) { this.properties = properties; } /** * Get blocked user. * - * @return blocked user as UserDTO + * @return blocked user as UserInterface */ - public UserDTO getBlockedUser() { + public UserInterface getBlockedUser() { return blockedUser; } @@ -123,9 +129,9 @@ public UserDTO getBlockedUser() { * Set blocked user. * * @param blockedUser - * as UserDTO + * as UserInterface */ - public void setBlockedUser(UserDTO blockedUser) { + public void setBlockedUser(UserInterface blockedUser) { this.blockedUser = blockedUser; } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/ProjectDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/ProjectDTO.java index 4acd1820d67..c2d54b0a5ab 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/ProjectDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/ProjectDTO.java @@ -14,10 +14,15 @@ import java.util.ArrayList; import java.util.List; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TemplateInterface; +import org.kitodo.data.interfaces.UserInterface; + /** * Project DTO object. */ -public class ProjectDTO extends BaseDTO { +public class ProjectDTO extends BaseDTO implements ProjectInterface { private String title; private String startDate; @@ -28,9 +33,9 @@ public class ProjectDTO extends BaseDTO { private Integer numberOfPages; private Integer numberOfVolumes; private Boolean active = true; - private ClientDTO client; - private List templates = new ArrayList<>(); - private List users = new ArrayList<>(); + private ClientInterface client; + private List templates = new ArrayList<>(); + private List users = new ArrayList<>(); private boolean hasProcesses; /** @@ -209,7 +214,7 @@ public void setActive(boolean active) { * * @return The client. */ - public ClientDTO getClient() { + public ClientInterface getClient() { return client; } @@ -218,7 +223,7 @@ public ClientDTO getClient() { * * @param client The client. */ - public void setClient(ClientDTO client) { + public void setClient(ClientInterface client) { this.client = client; } @@ -227,7 +232,7 @@ public void setClient(ClientDTO client) { * * @return list of active templates as TemplateDTO */ - public List getTemplates() { + public List getActiveTemplates() { return templates; } @@ -237,7 +242,7 @@ public List getTemplates() { * @param templates * as list of TemplateDTO */ - public void setTemplates(List templates) { + public void setActiveTemplates(List templates) { this.templates = templates; } @@ -246,7 +251,7 @@ public void setTemplates(List templates) { * * @return list of users as UserDTO */ - public List getUsers() { + public List getUsers() { return users; } @@ -256,7 +261,7 @@ public List getUsers() { * @param users * as list of UserDTO */ - public void setUsers(List users) { + public void setUsers(List users) { this.users = users; } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/PropertyDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/PropertyDTO.java index 3ef55dcad8f..c5cd86eff05 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/PropertyDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/PropertyDTO.java @@ -11,10 +11,12 @@ package org.kitodo.production.dto; +import org.kitodo.data.interfaces.PropertyInterface; + /** * Property DTO object. */ -public class PropertyDTO extends BaseDTO { +public class PropertyDTO extends BaseDTO implements PropertyInterface { private String title; private String value; diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/RoleDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/RoleDTO.java index b54e46eb268..523e4854dbf 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/RoleDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/RoleDTO.java @@ -14,15 +14,19 @@ import java.util.ArrayList; import java.util.List; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.RoleInterface; +import org.kitodo.data.interfaces.UserInterface; + /** * Role DTO object. */ -public class RoleDTO extends BaseDTO { +public class RoleDTO extends BaseDTO implements RoleInterface { private String title; - private List users = new ArrayList<>(); + private List users = new ArrayList<>(); private Integer usersSize; - private ClientDTO client; + private ClientInterface client; /** * Get title. @@ -46,9 +50,9 @@ public void setTitle(String title) { /** * Get list of users. * - * @return list of users as UserDTO + * @return list of users as UserInterface */ - public List getUsers() { + public List getUsers() { return users; } @@ -56,9 +60,9 @@ public List getUsers() { * Set list of users. * * @param users - * list of users as UserDTO + * list of users as UserInterface */ - public void setUsers(List users) { + public void setUsers(List users) { this.users = users; } @@ -84,18 +88,18 @@ public void setUsersSize(Integer usersSize) { /** * Get client FTO object. * - * @return the client DTO object + * @return the client Interface object */ - public ClientDTO getClient() { + public ClientInterface getClient() { return client; } /** - * Set client DTO object. + * Set client Interface object. * - * @param client as DTO object. + * @param client as Interface object. */ - public void setClient(ClientDTO client) { + public void setClient(ClientInterface client) { this.client = client; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/RulesetDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/RulesetDTO.java index c84f2a5f438..9196240951f 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/RulesetDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/RulesetDTO.java @@ -11,16 +11,19 @@ package org.kitodo.production.dto; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.RulesetInterface; + /** * Ruleset DTO object. */ -public class RulesetDTO extends BaseDTO { +public class RulesetDTO extends BaseDTO implements RulesetInterface { private String file; private String title; private Boolean orderMetadataByRuleset = false; private Boolean active = true; - private ClientDTO client; + private ClientInterface client; /** * Get file. @@ -101,9 +104,9 @@ public void setActive(boolean active) { /** * Get client object. * - * @return value of clientDTO + * @return value of clientInterface */ - public ClientDTO getClient() { + public ClientInterface getClient() { return client; } @@ -111,9 +114,9 @@ public ClientDTO getClient() { * Set client object. * * @param client - * as org.kitodo.production.dto.ClientDTO + * as org.kitodo.production.dto.ClientInterface */ - public void setClientDTO(ClientDTO client) { + public void setClient(ClientInterface client) { this.client = client; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/TaskDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/TaskDTO.java index be5d5a79765..bbf74549de0 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/TaskDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/TaskDTO.java @@ -16,11 +16,16 @@ import org.kitodo.data.database.enums.TaskEditType; import org.kitodo.data.database.enums.TaskStatus; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TaskInterface; +import org.kitodo.data.interfaces.TemplateInterface; +import org.kitodo.data.interfaces.UserInterface; /** * Task DTO object. */ -public class TaskDTO extends BaseDTO { +public class TaskDTO extends BaseDTO implements TaskInterface { private String title; private String localizedTitle; @@ -29,13 +34,13 @@ public class TaskDTO extends BaseDTO { private String processingStatusTitle; private TaskEditType editType; private String editTypeTitle; - private UserDTO processingUser; + private UserInterface processingUser; private String processingTime; private String processingBegin; private String processingEnd; - private ProcessDTO process; - private ProjectDTO project; - private TemplateDTO template; + private ProcessInterface process; + private ProjectInterface project; + private TemplateInterface template; private List roleIds = new ArrayList<>(); private int rolesSize; private boolean correction; @@ -182,21 +187,21 @@ public void setEditTypeTitle(String editTypeTitle) { } /** - * Get processing user as UserDTO. + * Get processing user as UserInterface. * - * @return processing user as UserDTO + * @return processing user as UserInterface */ - public UserDTO getProcessingUser() { + public UserInterface getProcessingUser() { return processingUser; } /** - * Set processing user as UserDTO. + * Set processing user as UserInterface. * * @param processingUser - * as UserDTO + * as UserInterface */ - public void setProcessingUser(UserDTO processingUser) { + public void setProcessingUser(UserInterface processingUser) { this.processingUser = processingUser; } @@ -258,30 +263,30 @@ public void setProcessingEnd(String processingEnd) { } /** - * Get process as ProcessDTO. + * Get process as ProcessInterface. * - * @return process as ProcessDTO + * @return process as ProcessInterface */ - public ProcessDTO getProcess() { + public ProcessInterface getProcess() { return process; } /** - * Set process as ProcessDTO. + * Set process as ProcessInterface. * * @param process - * as ProcessDTO + * as ProcessInterface */ - public void setProcess(ProcessDTO process) { + public void setProcess(ProcessInterface process) { this.process = process; } /** * Get project. * - * @return project as ProjectDTO + * @return project as ProjectInterface */ - public ProjectDTO getProject() { + public ProjectInterface getProject() { return project; } @@ -289,28 +294,28 @@ public ProjectDTO getProject() { * Set project. * * @param project - * as ProjectDTO + * as ProjectInterface */ - public void setProject(ProjectDTO project) { + public void setProject(ProjectInterface project) { this.project = project; } /** - * Get template as TemplateDTO. + * Get template as TemplateInterface. * - * @return template as TemplateDTO + * @return template as TemplateInterface */ - public TemplateDTO getTemplate() { + public TemplateInterface getTemplate() { return template; } /** - * Set template as TemplateDTO. + * Set template as TemplateInterface. * * @param template - * as TemplateDTO + * as TemplateInterface */ - public void setTemplate(TemplateDTO template) { + public void setTemplate(TemplateInterface template) { this.template = template; } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/TemplateDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/TemplateDTO.java index fe91ed24be1..f83067a7050 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/TemplateDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/TemplateDTO.java @@ -16,14 +16,17 @@ import java.util.List; import java.util.Objects; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TemplateInterface; +import org.kitodo.data.interfaces.WorkflowInterface; import org.kitodo.production.services.ServiceManager; -public class TemplateDTO extends BaseTemplateDTO { +public class TemplateDTO extends BaseTemplateDTO implements TemplateInterface { private boolean active; - private WorkflowDTO workflow; + private WorkflowInterface workflow; private boolean canBeUsedForProcess; - private List projects = new ArrayList<>(); + private List projects = new ArrayList<>(); /** * Get diagram image. @@ -59,9 +62,9 @@ public void setActive(boolean active) { /** * Set workflow. * - * @param workflow as org.kitodo.production.dto.WorkflowDTO + * @param workflow as org.kitodo.production.dto.WorkflowInterface */ - public void setWorkflow(WorkflowDTO workflow) { + public void setWorkflow(WorkflowInterface workflow) { this.workflow = workflow; } @@ -70,7 +73,7 @@ public void setWorkflow(WorkflowDTO workflow) { * * @return value of workflow */ - public WorkflowDTO getWorkflow() { + public WorkflowInterface getWorkflow() { return workflow; } @@ -98,7 +101,7 @@ public void setCanBeUsedForProcess(boolean canBeUsedForProcess) { * * @return value of projects */ - public List getProjects() { + public List getProjects() { return projects; } @@ -106,9 +109,9 @@ public List getProjects() { * Set projects. * * @param projects - * as List of ProjectDTO + * as List of ProjectInterface */ - public void setProjects(List projects) { + public void setProjects(List projects) { this.projects = projects; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/UserDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/UserDTO.java index 9f89877a9e5..fbd186b3151 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/UserDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/UserDTO.java @@ -14,10 +14,17 @@ import java.util.ArrayList; import java.util.List; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.FilterInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.RoleInterface; +import org.kitodo.data.interfaces.TaskInterface; +import org.kitodo.data.interfaces.UserInterface; + /** * User DTO object. */ -public class UserDTO extends BaseDTO { +public class UserDTO extends BaseDTO implements UserInterface { private String login; private String name; @@ -26,15 +33,15 @@ public class UserDTO extends BaseDTO { private String location; private String ldapLogin; private boolean active = true; - private List filters = new ArrayList<>(); + private List filters = new ArrayList<>(); private Integer filtersSize; - private List roles = new ArrayList<>(); + private List roles = new ArrayList<>(); private Integer rolesSize; - private List clients = new ArrayList<>(); + private List clients = new ArrayList<>(); private int clientsSize; - private List projects = new ArrayList<>(); + private List projects = new ArrayList<>(); private Integer projectsSize; - private List processingTasks = new ArrayList<>(); + private List processingTasks = new ArrayList<>(); /** * Get login. @@ -172,9 +179,9 @@ public void setActive(boolean active) { /** * Get list of filters. * - * @return list of filters as FilterDTO + * @return list of filters as FilterInterface */ - public List getFilters() { + public List getFilters() { return filters; } @@ -182,9 +189,9 @@ public List getFilters() { * Set list of filters. * * @param filters - * list of filters as FilterDTO + * list of filters as FilterInterface */ - public void setFilters(List filters) { + public void setFilters(List filters) { this.filters = filters; } @@ -210,9 +217,9 @@ public void setFiltersSize(Integer filtersSize) { /** * Get list of roles. * - * @return list of roles as RoleDTO + * @return list of roles as RoleInterface */ - public List getRoles() { + public List getRoles() { return roles; } @@ -220,9 +227,9 @@ public List getRoles() { * Set list of roles. * * @param roles - * list of roles as RoleDTO + * list of roles as RoleInterface */ - public void setRoles(List roles) { + public void setRoles(List roles) { this.roles = roles; } @@ -250,7 +257,7 @@ public void setRolesSize(Integer rolesSize) { * * @return The clients. */ - public List getClients() { + public List getClients() { return clients; } @@ -259,7 +266,7 @@ public List getClients() { * * @param clients The clients. */ - public void setClients(List clients) { + public void setClients(List clients) { this.clients = clients; } @@ -284,9 +291,9 @@ public void setClientsSize(Integer clientsSize) { /** * Get list of projects. * - * @return list of projects as ProjectDTO + * @return list of projects as ProjectInterface */ - public List getProjects() { + public List getProjects() { return projects; } @@ -294,9 +301,9 @@ public List getProjects() { * Set list of projects. * * @param projects - * list of projects as ProjectDTO + * list of projects as ProjectInterface */ - public void setProjects(List projects) { + public void setProjects(List projects) { this.projects = projects; } @@ -323,9 +330,9 @@ public void setProjectsSize(Integer projectsSize) { /** * Get list of processing tasks. * - * @return list of processing tasks as TaskDTO + * @return list of processing tasks as TaskInterface */ - public List getProcessingTasks() { + public List getProcessingTasks() { return processingTasks; } @@ -333,9 +340,9 @@ public List getProcessingTasks() { * Set list of processing tasks. * * @param processingTasks - * list of processing tasks as TaskDTO + * list of processing tasks as TaskInterface */ - public void setProcessingTasks(List processingTasks) { + public void setProcessingTasks(List processingTasks) { this.processingTasks = processingTasks; } } diff --git a/Kitodo/src/main/java/org/kitodo/production/dto/WorkflowDTO.java b/Kitodo/src/main/java/org/kitodo/production/dto/WorkflowDTO.java index 9996f99f690..fd14930dc2a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/dto/WorkflowDTO.java +++ b/Kitodo/src/main/java/org/kitodo/production/dto/WorkflowDTO.java @@ -11,7 +11,9 @@ package org.kitodo.production.dto; -public class WorkflowDTO extends BaseDTO { +import org.kitodo.data.interfaces.WorkflowInterface; + +public class WorkflowDTO extends BaseDTO implements WorkflowInterface { private String title; private String status; diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/BatchForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/BatchForm.java index 8a960682f72..9bd0f864629 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/BatchForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/BatchForm.java @@ -35,8 +35,8 @@ import org.kitodo.data.database.enums.CommentType; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProcessInterface; import org.kitodo.export.ExportDms; -import org.kitodo.production.dto.ProcessDTO; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; import org.kitodo.production.helper.batch.BatchProcessHelper; @@ -108,7 +108,7 @@ public void loadProcessData() { * Filter processes. */ public void filterProcesses() { - List processDTOS = new ArrayList<>(); + List processInterfaces = new ArrayList<>(); QueryBuilder query = new BoolQueryBuilder(); if (Objects.nonNull(this.processfilter)) { @@ -123,17 +123,17 @@ public void filterProcesses() { int batchMaxSize = ConfigCore.getIntParameter(ParameterCore.BATCH_DISPLAY_LIMIT, -1); try { if (batchMaxSize > 0) { - processDTOS = ServiceManager.getProcessService().findByQuery(query, + processInterfaces = ServiceManager.getProcessService().findByQuery(query, ServiceManager.getProcessService().sortByCreationDate(SortOrder.DESC), 0, batchMaxSize, false); } else { - processDTOS = ServiceManager.getProcessService().findByQuery(query, + processInterfaces = ServiceManager.getProcessService().findByQuery(query, ServiceManager.getProcessService().sortByCreationDate(SortOrder.DESC), false); } } catch (DataException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } try { - this.currentProcesses = ServiceManager.getProcessService().convertDtosToBeans(processDTOS); + this.currentProcesses = ServiceManager.getProcessService().convertDtosToBeans(processInterfaces); } catch (DAOException e) { this.currentProcesses = new ArrayList<>(); Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/CommentTooltipView.java b/Kitodo/src/main/java/org/kitodo/production/forms/CommentTooltipView.java index f877552f0fc..996f711b175 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/CommentTooltipView.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/CommentTooltipView.java @@ -22,8 +22,8 @@ import org.kitodo.data.database.beans.Comment; import org.kitodo.data.database.exceptions.DAOException; -import org.kitodo.production.dto.ProcessDTO; -import org.kitodo.production.dto.TaskDTO; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.TaskInterface; import org.kitodo.production.helper.Helper; import org.kitodo.production.services.ServiceManager; @@ -31,7 +31,7 @@ @RequestScoped public class CommentTooltipView { - private final Map> comments; + private final Map> comments; /** * Default constructor. @@ -43,16 +43,16 @@ public CommentTooltipView() { /** * Get comments of given process. * - * @param processDTO process as ProcessDTO + * @param processInterface process as ProcessInterface * @return List of Comment objects */ - public List getComments(ProcessDTO processDTO) { - if (comments.containsKey(processDTO)) { - return comments.get(processDTO); + public List getComments(ProcessInterface processInterface) { + if (comments.containsKey(processInterface)) { + return comments.get(processInterface); } try { - comments.put(processDTO, ServiceManager.getProcessService().getComments(processDTO)); - return comments.get(processDTO); + comments.put(processInterface, ServiceManager.getProcessService().getComments(processInterface)); + return comments.get(processInterface); } catch (DAOException e) { Helper.setErrorMessage(e); return Collections.emptyList(); @@ -62,10 +62,10 @@ public List getComments(ProcessDTO processDTO) { /** * Get comments of process containing the given task. * - * @param taskDTO task as TaskDTO + * @param taskInterface task as TaskInterface * @return List of Comment objects */ - public List getComments(TaskDTO taskDTO) { - return getComments(taskDTO.getProcess()); + public List getComments(TaskInterface taskInterface) { + return getComments(taskInterface.getProcess()); } } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/CurrentTaskForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/CurrentTaskForm.java index ac72fe4625f..2b6c04b5af7 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/CurrentTaskForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/CurrentTaskForm.java @@ -38,9 +38,9 @@ import org.kitodo.data.database.enums.TaskStatus; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.TaskInterface; import org.kitodo.export.ExportDms; import org.kitodo.export.TiffHeader; -import org.kitodo.production.dto.TaskDTO; import org.kitodo.production.enums.GenerationMode; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.filters.FilterMenu; @@ -66,7 +66,7 @@ public class CurrentTaskForm extends BaseForm { private static final Logger logger = LogManager.getLogger(CurrentTaskForm.class); private Process myProcess = new Process(); private Task currentTask = new Task(); - private List selectedTasks = new ArrayList<>(); + private List selectedTasks = new ArrayList<>(); private final WebDav myDav = new WebDav(); private String scriptPath; private transient BatchTaskHelper batchHelper; @@ -417,7 +417,7 @@ public void setTaskById(int id) { * * @return List of selected Tasks */ - public List getSelectedTasks() { + public List getSelectedTasks() { return this.selectedTasks; } @@ -427,7 +427,7 @@ public List getSelectedTasks() { * @param selectedTasks * provided by data table */ - public void setSelectedTasks(List selectedTasks) { + public void setSelectedTasks(List selectedTasks) { this.selectedTasks = selectedTasks; } @@ -743,12 +743,12 @@ public String[] getTaskCustomColumnNames() { /** * Retrieve and return process property value of property with given name 'propertyName' from process of given - * TaskDTO 'task'. - * @param task the TaskDTO object from which the property value is retrieved + * TaskInterface 'task'. + * @param task the TaskInterface object from which the property value is retrieved * @param propertyName name of the property for the property value is retrieved * @return property value if process has property with name 'propertyName', empty String otherwise */ - public static String getTaskProcessPropertyValue(TaskDTO task, String propertyName) { + public static String getTaskProcessPropertyValue(TaskInterface task, String propertyName) { return ProcessService.getPropertyValue(task.getProcess(), propertyName); } @@ -765,10 +765,10 @@ public static int getCorrespondingTemplateTaskId(Task task) { /** * Calculate and return age of given tasks process as a String. * - * @param task TaskDTO object whose process is used + * @param task TaskInterface object whose process is used * @return process age of given tasks process */ - public String getProcessDuration(TaskDTO task) { + public String getProcessDuration(TaskInterface task) { return ProcessService.getProcessDuration(task.getProcess()); } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/DesktopForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/DesktopForm.java index 1e056073113..119ff53454e 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/DesktopForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/DesktopForm.java @@ -25,10 +25,10 @@ import org.elasticsearch.ElasticsearchStatusException; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TaskInterface; import org.kitodo.exceptions.ProjectDeletionException; -import org.kitodo.production.dto.ProcessDTO; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.TaskDTO; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; import org.kitodo.production.helper.WebDav; @@ -43,9 +43,9 @@ public class DesktopForm extends BaseForm { private static final Logger logger = LogManager.getLogger(DesktopForm.class); private static final String SORT_TITLE = "title"; private static final String SORT_ID = "id"; - private List taskList = new ArrayList<>(); - private List processList = new ArrayList<>(); - private List projectList = new ArrayList<>(); + private List taskList = new ArrayList<>(); + private List processList = new ArrayList<>(); + private List projectList = new ArrayList<>(); /** * Default constructor. @@ -78,7 +78,7 @@ public List getObjectTypes() { * * @return task list */ - public List getTasks() { + public List getTasks() { try { if (ServiceManager.getSecurityAccessService().hasAuthorityToViewTaskList() && taskList.isEmpty()) { taskList = ServiceManager.getTaskService().loadData(0, 10, SORT_TITLE, SortOrder.ASCENDING, new HashMap<>()); @@ -95,7 +95,7 @@ public List getTasks() { * * @return process list */ - public List getProcesses() { + public List getProcesses() { try { if (ServiceManager.getSecurityAccessService().hasAuthorityToViewProcessList() && processList.isEmpty()) { processList = ServiceManager.getProcessService().loadData(0, 10, SORT_ID, SortOrder.DESCENDING, null); @@ -112,7 +112,7 @@ public List getProcesses() { * * @return project list */ - public List getProjects() { + public List getProjects() { try { if (ServiceManager.getSecurityAccessService().hasAuthorityToViewProjectList() && projectList.isEmpty()) { projectList = ServiceManager.getProjectService().loadData(0, 10, SORT_TITLE, SortOrder.ASCENDING, null); diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java index 0bd56c0dcbf..936616d2c31 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java @@ -48,11 +48,11 @@ import org.kitodo.data.database.enums.TaskStatus; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.TaskInterface; import org.kitodo.exceptions.InvalidImagesException; import org.kitodo.exceptions.MediaNotFoundException; import org.kitodo.production.controller.SecurityAccessController; -import org.kitodo.production.dto.ProcessDTO; -import org.kitodo.production.dto.TaskDTO; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.filters.FilterMenu; import org.kitodo.production.helper.CustomListColumnInitializer; @@ -151,28 +151,28 @@ public String[] getProcessPropertyNames() { /** * Retrieve and return process property value of property with given name - * 'propertyName' from given ProcessDTO 'process'. + * 'propertyName' from given ProcessInterface 'process'. * * @param process - * the ProcessDTO object from which the property value is retrieved + * the ProcessInterface object from which the property value is retrieved * @param propertyName * name of the property for the property value is retrieved * @return property value if process has property with name 'propertyName', * empty String otherwise */ - public static String getPropertyValue(ProcessDTO process, String propertyName) { + public static String getPropertyValue(ProcessInterface process, String propertyName) { return ProcessService.getPropertyValue(process, propertyName); } /** * Calculate and return age of given process as a String. * - * @param processDTO - * ProcessDTO object whose duration/age is calculated + * @param processInterface + * ProcessInterface object whose duration/age is calculated * @return process age of given process */ - public static String getProcessDuration(ProcessDTO processDTO) { - return ProcessService.getProcessDuration(processDTO); + public static String getProcessDuration(ProcessInterface processInterface) { + return ProcessService.getProcessDuration(processInterface); } /** @@ -202,12 +202,12 @@ public String save() { /** * Create Child for given Process. - * @param processDTO the process to create a child for. + * @param processInterface the process to create a child for. * @return path to createProcessForm */ - public String createProcessAsChild(ProcessDTO processDTO) { + public String createProcessAsChild(ProcessInterface processInterface) { try { - Process process = ServiceManager.getProcessService().getById(processDTO.getId()); + Process process = ServiceManager.getProcessService().getById(processInterface.getId()); if (Objects.nonNull(process.getTemplate()) && Objects.nonNull(process.getProject())) { return CREATE_PROCESS_PATH + "&templateId=" + process.getTemplate().getId() + "&projectId=" + process.getProject().getId() + "&parentId=" + process.getId(); @@ -652,11 +652,11 @@ private void executeKitodoScriptForProcesses(List processes, String kit private List getProcessesForActions() { // TODO: find a way to pass filters - List filteredProcesses = new ArrayList<>(); + List filteredProcesses = new ArrayList<>(); for (Object object : lazyDTOModel.load(0, 100000, "", SortOrder.ASCENDING, null)) { - if (object instanceof ProcessDTO) { - filteredProcesses.add((ProcessDTO) object); + if (object instanceof ProcessInterface) { + filteredProcesses.add((ProcessInterface) object); } } List processesForActions = new ArrayList<>(); @@ -1073,12 +1073,12 @@ public void setFilter(String filter) { * Returns a String containing titles of all current tasks of the given process, e.g. "OPEN" tasks and tasks * "INWORK". * - * @param processDTO + * @param processInterface * process for which current task titles are returned * @return String containing titles of current tasks of given process */ - public String getCurrentTaskTitles(ProcessDTO processDTO) { - return ServiceManager.getProcessService().createProgressTooltip(processDTO); + public String getCurrentTaskTitles(ProcessInterface processInterface) { + return ServiceManager.getProcessService().createProgressTooltip(processInterface); } /** @@ -1130,11 +1130,11 @@ public String convertProcessingDate(Date date) { /** * Get all tasks of given process which should be visible to the user. - * @param processDTO process as DTO object - * @return List of filtered tasks as DTO objects + * @param processInterface process as Interface object + * @return List of filtered tasks as Interface objects */ - public List getCurrentTasksForUser(ProcessDTO processDTO) { - return ServiceManager.getProcessService().getCurrentTasksForUser(processDTO, ServiceManager.getUserService().getCurrentUser()); + public List getCurrentTasksForUser(ProcessInterface processInterface) { + return ServiceManager.getProcessService().getCurrentTasksForUser(processInterface, ServiceManager.getUserService().getCurrentUser()); } /** @@ -1215,7 +1215,7 @@ private int getProcessId(Object process) { if (process instanceof Process) { return ((Process) process).getId(); } else { - return ((ProcessDTO) process).getId(); + return ((ProcessInterface) process).getId(); } } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java index 581e07eead6..8e05e0f95a6 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java @@ -11,8 +11,6 @@ package org.kitodo.production.forms; -import com.itextpdf.text.DocumentException; - import java.io.IOException; import java.net.URI; import java.util.ArrayList; @@ -31,8 +29,8 @@ import org.kitodo.data.database.beans.Process; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProcessInterface; import org.kitodo.export.ExportDms; -import org.kitodo.production.dto.ProcessDTO; import org.kitodo.production.enums.ChartMode; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; @@ -48,6 +46,8 @@ import org.primefaces.model.charts.hbar.HorizontalBarChartModel; import org.primefaces.model.charts.pie.PieChartModel; +import com.itextpdf.text.DocumentException; + public class ProcessListBaseView extends BaseForm { private static final Logger logger = LogManager.getLogger(ProcessListBaseView.class); @@ -115,7 +115,7 @@ public void setAllSelected(boolean allSelected) { /** * Returns the list of the processes currently selected in the user interface. - * Converts ProcessDTO instances to Process instances in case of displaying search results. + * Converts ProcessInterface instances to Process instances in case of displaying search results. * * @return value of selectedProcesses */ @@ -133,11 +133,11 @@ public List getSelectedProcesses() { } } if (!selectedProcessesOrProcessDTOs.isEmpty()) { - if (selectedProcessesOrProcessDTOs.get(0) instanceof ProcessDTO) { - // list contains ProcessDTO instances + if (selectedProcessesOrProcessDTOs.get(0) instanceof ProcessInterface) { + // list contains ProcessInterface instances try { selectedProcesses = ServiceManager.getProcessService() - .convertDtosToBeans((List) selectedProcessesOrProcessDTOs); + .convertDtosToBeans((List) selectedProcessesOrProcessDTOs); } catch (DAOException e) { Helper.setErrorMessage(ERROR_LOADING_MANY, new Object[]{ObjectType.PROCESS.getTranslationPlural()}, logger, e); @@ -432,13 +432,13 @@ private void exportDMSForProcesses(List processes) { /** * If processes are generated with calendar. * - * @param processDTO + * @param processInterface * the process dto to check. * @return true if processes are created with calendar, false otherwise */ - public boolean createProcessesWithCalendar(ProcessDTO processDTO) { + public boolean createProcessesWithCalendar(ProcessInterface processInterface) { try { - return ProcessService.canCreateProcessWithCalendar(processDTO); + return ProcessService.canCreateProcessWithCalendar(processInterface); } catch (IOException | DAOException e) { Helper.setErrorMessage(ERROR_READING, new Object[] {ObjectType.PROCESS.getTranslationSingular() }, logger, e); @@ -449,13 +449,13 @@ public boolean createProcessesWithCalendar(ProcessDTO processDTO) { /** * If a process can be created as child. * - * @param processDTO + * @param processInterface * the process dto to check. * @return true if processes can be created as child, false otherwise */ - public boolean createProcessAsChildPossible(ProcessDTO processDTO) { + public boolean createProcessAsChildPossible(ProcessInterface processInterface) { try { - return ProcessService.canCreateChildProcess(processDTO); + return ProcessService.canCreateChildProcess(processInterface); } catch (IOException | DAOException e) { Helper.setErrorMessage(ERROR_READING, new Object[] {ObjectType.PROCESS.getTranslationSingular() }, logger, e); @@ -479,9 +479,9 @@ public void downloadToHome(int processId) { /** * Starts generation of xml logfile for current process. */ - public void createXML(ProcessDTO processDTO) { + public void createXML(ProcessInterface processInterface) { try { - ProcessService.createXML(ServiceManager.getProcessService().getById(processDTO.getId()), getUser()); + ProcessService.createXML(ServiceManager.getProcessService().getById(processInterface.getId()), getUser()); } catch (IOException | DAOException e) { Helper.setErrorMessage("Error creating log file in home directory", logger, e); } @@ -529,26 +529,26 @@ public void downloadDocket(int id) { /** * Upload from home for single process. */ - public void uploadFromHome(ProcessDTO processDTO) { + public void uploadFromHome(ProcessInterface processInterface) { try { WebDav myDav = new WebDav(); - myDav.uploadFromHome(ServiceManager.getProcessService().getById(processDTO.getId())); - Helper.setMessage("directoryRemoved", processDTO.getTitle()); + myDav.uploadFromHome(ServiceManager.getProcessService().getById(processInterface.getId())); + Helper.setMessage("directoryRemoved", processInterface.getTitle()); } catch (DAOException e) { Helper.setErrorMessage(ERROR_LOADING_ONE, - new Object[] {ObjectType.PROCESS.getTranslationSingular(), processDTO.getId() }, logger, e); + new Object[] {ObjectType.PROCESS.getTranslationSingular(), processInterface.getId() }, logger, e); } } /** * Delete Process. * - * @param processDTO + * @param processInterface * process to delete. */ - public void delete(ProcessDTO processDTO) { + public void delete(ProcessInterface processInterface) { try { - Process process = ServiceManager.getProcessService().getById(processDTO.getId()); + Process process = ServiceManager.getProcessService().getById(processInterface.getId()); if (process.getChildren().isEmpty()) { try { ProcessService.deleteProcess(process); @@ -597,16 +597,16 @@ public boolean canBeExported(int processId) { /** * Returns the list of currently selected processes. This list is used both when displaying search results * and when displaying the process list, which is why it may contain either instances of Process or - * instances of ProcessDTO. + * instances of ProcessInterface. * - * @return list of instances of Process or ProcessDTO + * @return list of instances of Process or ProcessInterface */ public List getSelectedProcessesOrProcessDTOs() { return selectedProcessesOrProcessDTOs; } - public void setSelectedProcessesOrProcessDTOs(List selectedProcessesOrProcessDTOs) { - this.selectedProcessesOrProcessDTOs = selectedProcessesOrProcessDTOs; + public void setSelectedProcessesOrProcessDTOs(List selectedProcessesOrProcessInterfaces) { + this.selectedProcessesOrProcessDTOs = selectedProcessesOrProcessInterfaces; } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/ProjectForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/ProjectForm.java index b073e24e298..0cbdf4048d3 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProjectForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProjectForm.java @@ -46,11 +46,11 @@ import org.kitodo.data.database.enums.PreviewHoverMode; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TemplateInterface; import org.kitodo.exceptions.ProjectDeletionException; import org.kitodo.forms.FolderGenerator; import org.kitodo.production.controller.SecurityAccessController; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.TemplateDTO; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; import org.kitodo.production.model.LazyDTOModel; @@ -373,7 +373,7 @@ public String deleteFolder() { * * @return list of assignable templates */ - public List getTemplates() { + public List getTemplates() { try { return ServiceManager.getTemplateService().findAllAvailableForAssignToProject(this.project.getId()); } catch (DataException e) { @@ -827,7 +827,7 @@ public void loadProject(int id) { * * @return list of projects */ - public List getProjects() { + public List getProjects() { try { return ServiceManager.getProjectService().findAll(); } catch (DataException e) { diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/SearchResultForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/SearchResultForm.java index 381101459e7..ec1ef9f7f50 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/SearchResultForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/SearchResultForm.java @@ -30,9 +30,9 @@ import org.kitodo.data.database.enums.TaskStatus; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; -import org.kitodo.production.dto.ProcessDTO; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.TaskDTO; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TaskInterface; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; import org.kitodo.production.services.ServiceManager; @@ -48,8 +48,8 @@ public class SearchResultForm extends ProcessListBaseView { private static final String SEARCH_RESULT_VIEW_ID = "/pages/searchResult.xhtml"; private static final String SEARCH_RESULT_TABLE_ID = "searchResultTabView:searchResultForm:searchResultTable"; - private List filteredList = new ArrayList<>(); - private List resultList = new ArrayList<>(); + private List filteredList = new ArrayList<>(); + private List resultList = new ArrayList<>(); private String searchQuery; private String currentTaskFilter; private Integer currentProjectFilter; @@ -64,12 +64,12 @@ public class SearchResultForm extends ProcessListBaseView { */ public String searchForProcessesBySearchQuery() { ProcessService processService = ServiceManager.getProcessService(); - HashMap resultHash = new HashMap<>(); - List results; + HashMap resultHash = new HashMap<>(); + List results; try { results = processService.findByAnything(searchQuery); - for (ProcessDTO processDTO : results) { - resultHash.put(processDTO.getId(), processDTO); + for (ProcessInterface processInterface : results) { + resultHash.put(processInterface.getId(), processInterface); } this.resultList = new ArrayList<>(resultHash.values()); refreshFilteredList(); @@ -99,9 +99,9 @@ void filterListByProject() { */ void filterListByTaskAndStatus() { if (Objects.nonNull(currentTaskFilter) && Objects.nonNull(currentTaskStatusFilter)) { - for (ProcessDTO processDTO : new ArrayList<>(this.filteredList)) { + for (ProcessInterface processInterface : new ArrayList<>(this.filteredList)) { boolean remove = true; - for (TaskDTO task : processDTO.getTasks()) { + for (TaskInterface task : processInterface.getTasks()) { if (task.getTitle().equalsIgnoreCase(currentTaskFilter) && task.getProcessingStatus().getValue().equals(currentTaskStatusFilter)) { remove = false; @@ -109,7 +109,7 @@ void filterListByTaskAndStatus() { } } if (remove) { - this.filteredList.remove(processDTO); + this.filteredList.remove(processInterface); } } @@ -131,9 +131,9 @@ public void filterList() { * * @return A list of projects for filter list */ - public Collection getProjectsForFiltering() { - HashMap projectsForFiltering = new HashMap<>(); - for (ProcessDTO process : this.resultList) { + public Collection getProjectsForFiltering() { + HashMap projectsForFiltering = new HashMap<>(); + for (ProcessInterface process : this.resultList) { projectsForFiltering.put(process.getProject().getId(), process.getProject()); } return projectsForFiltering.values(); @@ -144,10 +144,10 @@ public Collection getProjectsForFiltering() { * * @return A list of tasks for filter list */ - public Collection getTasksForFiltering() { - HashMap tasksForFiltering = new HashMap<>(); - for (ProcessDTO processDTO : this.resultList) { - for (TaskDTO currentTask : processDTO.getTasks()) { + public Collection getTasksForFiltering() { + HashMap tasksForFiltering = new HashMap<>(); + for (ProcessInterface processInterface : this.resultList) { + for (TaskInterface currentTask : processInterface.getTasks()) { tasksForFiltering.put(currentTask.getTitle(), currentTask); } } @@ -170,17 +170,17 @@ private void refreshFilteredList() { /** * Delete Process. * - * @param processDTO + * @param processInterface * process to delete. */ @Override - public void delete(ProcessDTO processDTO) { + public void delete(ProcessInterface processInterface) { try { - Process process = ServiceManager.getProcessService().getById(processDTO.getId()); + Process process = ServiceManager.getProcessService().getById(processInterface.getId()); if (process.getChildren().isEmpty()) { try { ProcessService.deleteProcess(process); - this.filteredList.remove(processDTO); + this.filteredList.remove(processInterface); } catch (DataException | IOException e) { Helper.setErrorMessage(ERROR_DELETING, new Object[] {ObjectType.PROCESS.getTranslationSingular() }, logger, e); @@ -213,9 +213,9 @@ public void setTaskStatusDownForSelection() { /** * Gets the filtered list. * - * @return a list of ProcessDTO + * @return a list of ProcessInterface */ - public List getFilteredList() { + public List getFilteredList() { return this.filteredList; } @@ -223,9 +223,9 @@ public List getFilteredList() { * Sets the filtered list. * * @param filteredList - * a list of ProcessDTO + * a list of ProcessInterface */ - public void setFilteredList(List filteredList) { + public void setFilteredList(List filteredList) { this.filteredList = filteredList; } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/UserForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/UserForm.java index 66d79e6170d..18d49dfa306 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/UserForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/UserForm.java @@ -54,7 +54,7 @@ import org.kitodo.data.database.enums.TaskStatus; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; -import org.kitodo.production.dto.ProjectDTO; +import org.kitodo.data.interfaces.ProjectInterface; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.filters.FilterMenu; import org.kitodo.production.forms.dataeditor.GalleryViewMode; @@ -563,10 +563,10 @@ public Map getMetadataLanguages() { * * @return list of projects available for assignment to the user */ - public List getProjects() { + public List getProjects() { try { return ServiceManager.getProjectService().findAllAvailableForAssignToUser(this.userObject) - .stream().sorted(Comparator.comparing(ProjectDTO::getTitle)).collect(Collectors.toList()); + .stream().sorted(Comparator.comparing(ProjectInterface::getTitle)).collect(Collectors.toList()); } catch (DataException e) { Helper.setErrorMessage(ERROR_LOADING_MANY, new Object[] {ObjectType.PROJECT.getTranslationPlural() }, logger, e); @@ -626,11 +626,11 @@ public void setPasswordToEncrypt(String passwordToEncrypt) { } /** - * Check and return whether given UserDTO 'user' is logged in. + * Check and return whether given UserInterface 'user' is logged in. * * @param user - * UserDTO to check - * @return whether given UserDTO is checked in + * UserInterface to check + * @return whether given UserInterface is checked in */ public static boolean checkUserLoggedIn(User user) { for (SecuritySession securitySession : ServiceManager.getSessionService().getActiveSessions()) { diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java index 762ede19314..7c0a7a9018b 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java @@ -50,13 +50,13 @@ import org.kitodo.data.database.beans.Template; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProcessInterface; import org.kitodo.exceptions.CommandException; import org.kitodo.exceptions.InvalidMetadataValueException; import org.kitodo.exceptions.NoSuchMetadataFieldException; import org.kitodo.exceptions.ProcessGenerationException; import org.kitodo.exceptions.RecordIdentifierMissingDetail; import org.kitodo.exceptions.RulesetNotFoundException; -import org.kitodo.production.dto.ProcessDTO; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.forms.BaseForm; import org.kitodo.production.helper.Helper; @@ -435,7 +435,7 @@ public void prepareProcess(int templateId, int projectId, String referringView, defaultConfigurationType = null; } if (Objects.nonNull(parentId) && parentId != 0) { - ProcessDTO parentProcess = ServiceManager.getProcessService().findById(parentId); + ProcessInterface parentProcess = ServiceManager.getProcessService().findById(parentId); RulesetManagementInterface rulesetManagement = ServiceManager.getRulesetService() .openRuleset(ServiceManager.getRulesetService().getById(parentProcess.getRuleset().getId())); Map allowedSubstructuralElements = rulesetManagement diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SelectProjectDialogView.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SelectProjectDialogView.java index 97f59cf7800..f3fabea722d 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SelectProjectDialogView.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SelectProjectDialogView.java @@ -27,7 +27,7 @@ import org.kitodo.data.database.beans.Project; import org.kitodo.data.database.beans.Template; import org.kitodo.data.database.exceptions.DAOException; -import org.kitodo.production.dto.TemplateDTO; +import org.kitodo.data.interfaces.TemplateInterface; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; import org.kitodo.production.services.ServiceManager; @@ -39,26 +39,26 @@ public class SelectProjectDialogView implements Serializable { private static final Logger logger = LogManager.getLogger(SelectProjectDialogView.class); private int selectedProjectId = 0; - private TemplateDTO templateDTO; + private TemplateInterface templateInterface; protected static final String ERROR_LOADING_ONE = "errorLoadingOne"; private static final String CREATE_PROCESS_PATH = "/pages/processFromTemplate.jsf?faces-redirect=true"; /** * Get template. * - * @return value of templateDTO + * @return value of templateInterface */ - public TemplateDTO getTemplate() { - return templateDTO; + public TemplateInterface getTemplate() { + return templateInterface; } /** - * Set templateDTO. + * Set templateInterface. * - * @param templateDTO as org.kitodo.production.dto.TemplateDTO + * @param templateInterface as org.kitodo.production.dto.TemplateInterface */ - public void setTemplateDTO(TemplateDTO templateDTO) { - this.templateDTO = templateDTO; + public void setTemplateInterface(TemplateInterface templateInterface) { + this.templateInterface = templateInterface; } /** @@ -86,12 +86,12 @@ public void setSelectedProjectId(int projectId) { */ public List getTemplateProjects() { try { - Template template = ServiceManager.getTemplateService().getById(this.templateDTO.getId()); + Template template = ServiceManager.getTemplateService().getById(this.templateInterface.getId()); return template.getProjects().stream().sorted(Comparator.comparing(Project::getTitle)) .collect(Collectors.toList()); } catch (DAOException e) { Helper.setErrorMessage(ERROR_LOADING_ONE, new Object[] {ObjectType.TEMPLATE.getTranslationSingular(), - this.templateDTO.getId()}, logger, e); + this.templateInterface.getId()}, logger, e); } return Collections.emptyList(); } @@ -103,20 +103,20 @@ public List getTemplateProjects() { * Display error message if the current template is not used in any project. */ public void createProcessFromTemplate() { - if (this.templateDTO.getProjects().size() == 1) { - this.selectedProjectId = this.templateDTO.getProjects().get(0).getId(); + if (this.templateInterface.getProjects().size() == 1) { + this.selectedProjectId = this.templateInterface.getProjects().get(0).getId(); } if (this.selectedProjectId > 0) { try { FacesContext context = FacesContext.getCurrentInstance(); String path = context.getExternalContext().getRequestContextPath() + CREATE_PROCESS_PATH - + "&templateId=" + this.templateDTO.getId() + "&projectId=" + this.selectedProjectId + + "&templateId=" + this.templateInterface.getId() + "&projectId=" + this.selectedProjectId + "&referrer=" + context.getViewRoot().getViewId(); context.getExternalContext().redirect(path); } catch (IOException e) { Helper.setErrorMessage(e.getLocalizedMessage()); } - } else if (templateDTO.getProjects().size() > 1) { + } else if (templateInterface.getProjects().size() > 1) { PrimeFaces.current().ajax().update("selectProjectDialog"); PrimeFaces.current().executeScript("PF('selectProjectDialog').show();"); } else { diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SelectTemplateDialogView.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SelectTemplateDialogView.java index c8fe74606f6..fa2e12b750e 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SelectTemplateDialogView.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/SelectTemplateDialogView.java @@ -19,8 +19,8 @@ import javax.faces.view.ViewScoped; import javax.inject.Named; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.TemplateDTO; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TemplateInterface; import org.kitodo.production.helper.Helper; import org.primefaces.PrimeFaces; @@ -29,7 +29,7 @@ public class SelectTemplateDialogView implements Serializable { private int selectedTemplateId = 0; - private ProjectDTO project; + private ProjectInterface project; protected static final String ERROR_LOADING_ONE = "errorLoadingOne"; private static final String CREATE_PROCESS_PATH = "/pages/processFromTemplate.jsf?faces-redirect=true"; private static final String MASSIMPORT_PATH = "/pages/massImport.jsf?faces-redirect=true"; @@ -40,16 +40,16 @@ public class SelectTemplateDialogView implements Serializable { * * @return value of project */ - public ProjectDTO getProject() { + public ProjectInterface getProject() { return project; } /** * Set project. * - * @param project as org.kitodo.production.dto.ProjectDTO + * @param project as org.kitodo.production.dto.ProjectInterface */ - public void setProject(ProjectDTO project) { + public void setProject(ProjectInterface project) { this.project = project; } @@ -65,7 +65,7 @@ public int getSelectedTemplateId() { /** * Set selectedTemplateId. * - * @param selectedTemplateId as org.kitodo.production.dto.TemplateDTO + * @param selectedTemplateId as org.kitodo.production.dto.TemplateInterface */ public void setSelectedTemplateId(int selectedTemplateId) { this.selectedTemplateId = selectedTemplateId; @@ -94,7 +94,7 @@ public void openMassImportForProject() { * Display error message if no template is configured for current project. */ public void checkForTemplates() { - List availableTemplates = this.project.getTemplates(); + List availableTemplates = this.project.getActiveTemplates(); if (availableTemplates.size() == 1) { this.selectedTemplateId = availableTemplates.get(0).getId(); } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java index ac258eebefe..f4beeb15e62 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/TitleRecordLinkTab.java @@ -36,7 +36,7 @@ import org.kitodo.data.database.beans.Process; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; -import org.kitodo.production.dto.ProcessDTO; +import org.kitodo.data.interfaces.ProcessInterface; import org.kitodo.production.helper.Helper; import org.kitodo.production.metadata.MetadataEditor; import org.kitodo.production.services.ServiceManager; @@ -307,14 +307,14 @@ public void searchForParentProcesses() { return; } try { - List processes = ServiceManager.getProcessService().findLinkableParentProcesses(searchQuery, + List processes = ServiceManager.getProcessService().findLinkableParentProcesses(searchQuery, createProcessForm.getProject().getId(), createProcessForm.getTemplate().getRuleset().getId()); if (processes.isEmpty()) { Helper.setMessage("createProcessForm.titleRecordLinkTab.searchButtonClick.noHits"); } indicationOfMoreHitsVisible = processes.size() > MAXIMUM_NUMBER_OF_HITS; possibleParentProcesses = new ArrayList<>(); - for (ProcessDTO process : processes.subList(0, Math.min(processes.size(), MAXIMUM_NUMBER_OF_HITS))) { + for (ProcessInterface process : processes.subList(0, Math.min(processes.size(), MAXIMUM_NUMBER_OF_HITS))) { possibleParentProcesses.add(new SelectItem(process.getId().toString(), process.getTitle())); } } catch (DataException e) { diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/AddDocStrucTypeDialog.java b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/AddDocStrucTypeDialog.java index 3e7d37b1815..12052a1a5d0 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/AddDocStrucTypeDialog.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/dataeditor/AddDocStrucTypeDialog.java @@ -45,10 +45,10 @@ import org.kitodo.data.database.beans.Process; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProcessInterface; import org.kitodo.exceptions.InvalidMetadataValueException; import org.kitodo.exceptions.NoSuchMetadataFieldException; import org.kitodo.exceptions.UnknownTreeNodeDataException; -import org.kitodo.production.dto.ProcessDTO; import org.kitodo.production.helper.Helper; import org.kitodo.production.metadata.InsertionPosition; import org.kitodo.production.metadata.MetadataEditor; @@ -631,7 +631,7 @@ public void search() { .getAllowedSubstructuralElements().keySet(); List ids = ServiceManager.getProcessService().findLinkableChildProcesses(processNumber, dataEditor.getProcess().getRuleset().getId(), allowedSubstructuralElements) - .stream().map(ProcessDTO::getId).collect(Collectors.toList()); + .stream().map(ProcessInterface::getId).collect(Collectors.toList()); if (ids.isEmpty()) { alert(Helper.getTranslation("dialogAddDocStrucType.searchButtonClick.noHits")); } diff --git a/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java b/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java index 34a9acd64ef..6725163879d 100644 --- a/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java +++ b/Kitodo/src/main/java/org/kitodo/production/helper/SearchResultGeneration.java @@ -24,7 +24,7 @@ import org.elasticsearch.search.sort.SortOrder; import org.kitodo.data.elasticsearch.index.type.enums.ProcessTypeField; import org.kitodo.data.exceptions.DataException; -import org.kitodo.production.dto.ProcessDTO; +import org.kitodo.data.interfaces.ProcessInterface; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.services.ServiceManager; @@ -60,16 +60,16 @@ public HSSFWorkbook getResult() { return getWorkbook(); } - private List getResultsWithFilter() { - List processDTOS = new ArrayList<>(); + private List getResultsWithFilter() { + List processInterfaces = new ArrayList<>(); try { - processDTOS = ServiceManager.getProcessService().findByQuery(getQueryForFilter(ObjectType.PROCESS), + processInterfaces = ServiceManager.getProcessService().findByQuery(getQueryForFilter(ObjectType.PROCESS), ServiceManager.getProcessService().sortById(SortOrder.ASC), true); } catch (DataException e) { logger.error(e.getMessage(), e); } - return processDTOS; + return processInterfaces; } /** @@ -121,25 +121,25 @@ private void insertRowData(HSSFSheet sheet) { Long numberOfExpectedProcesses = ServiceManager.getProcessService() .count(getQueryForFilter(ObjectType.PROCESS)); if (numberOfExpectedProcesses > elasticsearchLimit) { - List processDTOS; + List processInterfaces; int queriedIds = 0; while (numberOfProcessedProcesses < numberOfExpectedProcesses) { RangeQueryBuilder rangeQueryBuilder = new RangeQueryBuilder(ProcessTypeField.ID.toString()); rangeQueryBuilder.gte(queriedIds).lt(queriedIds + elasticsearchLimit); BoolQueryBuilder queryForFilter = getQueryForFilter(ObjectType.PROCESS); queryForFilter.must(rangeQueryBuilder); - processDTOS = ServiceManager.getProcessService().findByQuery(queryForFilter, + processInterfaces = ServiceManager.getProcessService().findByQuery(queryForFilter, ServiceManager.getProcessService().sortById(SortOrder.ASC), true); queriedIds += elasticsearchLimit; - for (ProcessDTO processDTO : processDTOS) { + for (ProcessInterface processDTO : processInterfaces) { prepareRow(rowCounter, sheet, processDTO); rowCounter++; } - numberOfProcessedProcesses += processDTOS.size(); + numberOfProcessedProcesses += processInterfaces.size(); } } else { - List resultsWithFilter = getResultsWithFilter(); - for (ProcessDTO processDTO : resultsWithFilter) { + List resultsWithFilter = getResultsWithFilter(); + for (ProcessInterface processDTO : resultsWithFilter) { prepareRow(rowCounter, sheet, processDTO); rowCounter++; } @@ -161,15 +161,15 @@ private void setRowHeader(HSSFSheet sheet) { rowHeader.createCell(7).setCellValue(Helper.getTranslation("Status")); } - private void prepareRow(int rowCounter, HSSFSheet sheet, ProcessDTO processDTO) { + private void prepareRow(int rowCounter, HSSFSheet sheet, ProcessInterface processInterface) { HSSFRow row = sheet.createRow(rowCounter); - row.createCell(0).setCellValue(processDTO.getTitle()); - row.createCell(1).setCellValue(processDTO.getId()); - row.createCell(2).setCellValue(processDTO.getCreationDate()); - row.createCell(3).setCellValue(processDTO.getNumberOfImages()); - row.createCell(4).setCellValue(processDTO.getNumberOfStructures()); - row.createCell(5).setCellValue(processDTO.getNumberOfMetadata()); - row.createCell(6).setCellValue(processDTO.getProject().getTitle()); - row.createCell(7).setCellValue(processDTO.getSortHelperStatus()); + row.createCell(0).setCellValue(processInterface.getTitle()); + row.createCell(1).setCellValue(processInterface.getId()); + row.createCell(2).setCellValue(processInterface.getCreationDate()); + row.createCell(3).setCellValue(processInterface.getNumberOfImages()); + row.createCell(4).setCellValue(processInterface.getNumberOfStructures()); + row.createCell(5).setCellValue(processInterface.getNumberOfMetadata()); + row.createCell(6).setCellValue(processInterface.getProject().getTitle()); + row.createCell(7).setCellValue(processInterface.getSortHelperStatus()); } } diff --git a/Kitodo/src/main/java/org/kitodo/production/model/LazyDTOModel.java b/Kitodo/src/main/java/org/kitodo/production/model/LazyDTOModel.java index 791a8268cc9..0f5e01aec83 100644 --- a/Kitodo/src/main/java/org/kitodo/production/model/LazyDTOModel.java +++ b/Kitodo/src/main/java/org/kitodo/production/model/LazyDTOModel.java @@ -32,8 +32,8 @@ import org.kitodo.data.elasticsearch.exceptions.CustomResponseException; import org.kitodo.data.elasticsearch.index.IndexRestClient; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.DataInterface; import org.kitodo.exceptions.FilterException; -import org.kitodo.production.dto.BaseDTO; import org.kitodo.production.services.data.FilterService; import org.kitodo.production.services.data.base.SearchDatabaseService; import org.primefaces.PrimeFaces; @@ -82,8 +82,8 @@ public Object getRowData(String rowKey) { @Override public Object getRowKey(Object inObject) { - if (inObject instanceof BaseDTO) { - BaseDTO dto = (BaseDTO) inObject; + if (inObject instanceof DataInterface) { + DataInterface dto = (DataInterface) inObject; return dto.getId(); } else if (inObject instanceof BaseBean) { BaseBean bean = (BaseBean) inObject; diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/BatchService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/BatchService.java index 84a422084d1..253d97777a5 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/BatchService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/BatchService.java @@ -31,13 +31,14 @@ import org.kitodo.data.elasticsearch.index.type.enums.BatchTypeField; import org.kitodo.data.elasticsearch.search.Searcher; import org.kitodo.data.exceptions.DataException; -import org.kitodo.production.dto.BatchDTO; +import org.kitodo.data.interfaces.BatchInterface; +import org.kitodo.production.dto.DTOFactory; import org.kitodo.production.helper.Helper; import org.kitodo.production.services.ServiceManager; import org.kitodo.production.services.data.base.TitleSearchService; import org.primefaces.model.SortOrder; -public class BatchService extends TitleSearchService { +public class BatchService extends TitleSearchService { private static volatile BatchService instance = null; private static final String BATCH = "batch"; @@ -150,18 +151,18 @@ public List> findByProcessTitle(String title) throws DataExc } @Override - public BatchDTO convertJSONObjectToDTO(Map jsonObject, boolean related) throws DataException { - BatchDTO batchDTO = new BatchDTO(); - batchDTO.setId(getIdFromJSONObject(jsonObject)); - batchDTO.setTitle(BatchTypeField.TITLE.getStringValue(jsonObject)); + public BatchInterface convertJSONObjectToInterface(Map jsonObject, boolean related) throws DataException { + BatchInterface batchInterface = DTOFactory.instance().newBatch(); + batchInterface.setId(getIdFromJSONObject(jsonObject)); + batchInterface.setTitle(BatchTypeField.TITLE.getStringValue(jsonObject)); if (!related) { - convertRelatedJSONObjects(jsonObject, batchDTO); + convertRelatedJSONObjects(jsonObject, batchInterface); } - return batchDTO; + return batchInterface; } - private void convertRelatedJSONObjects(Map jsonObject, BatchDTO batchDTO) throws DataException { - batchDTO.setProcesses(convertRelatedJSONObjectToDTO(jsonObject, BatchTypeField.PROCESSES.getKey(), + private void convertRelatedJSONObjects(Map jsonObject, BatchInterface batchInterface) throws DataException { + batchInterface.setProcesses(convertRelatedJSONObjectToInterface(jsonObject, BatchTypeField.PROCESSES.getKey(), ServiceManager.getProcessService())); } @@ -211,7 +212,7 @@ public String getLabel(Batch batch) { * * @return a readable label for the batch */ - public String getLabel(BatchDTO batch) { + public String getLabel(BatchInterface batch) { return Objects.nonNull(batch.getTitle()) ? batch.getTitle() : getNumericLabel(batch); } @@ -233,7 +234,7 @@ private String getNumericLabel(Batch batch) { * * @return a readable label for the batch */ - private String getNumericLabel(BatchDTO batch) { + private String getNumericLabel(BatchInterface batch) { return Helper.getTranslation(BATCH) + ' ' + batch.getId(); } diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/DocketService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/DocketService.java index 9ffaf758a9f..e8479d60b3e 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/DocketService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/DocketService.java @@ -27,13 +27,14 @@ import org.kitodo.data.elasticsearch.index.type.enums.DocketTypeField; import org.kitodo.data.elasticsearch.search.Searcher; import org.kitodo.data.exceptions.DataException; -import org.kitodo.production.dto.ClientDTO; -import org.kitodo.production.dto.DocketDTO; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.DocketInterface; +import org.kitodo.production.dto.DTOFactory; import org.kitodo.production.services.ServiceManager; import org.kitodo.production.services.data.base.ClientSearchService; import org.primefaces.model.SortOrder; -public class DocketService extends ClientSearchService { +public class DocketService extends ClientSearchService { private static volatile DocketService instance = null; @@ -80,7 +81,7 @@ public Long countResults(Map filters) throws DataException { } @Override - public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) + public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) throws DataException { return findByQuery(getDocketsForCurrentUserQuery(), getSortBuilder(sortField, sortOrder), first, pageSize, false); @@ -98,18 +99,18 @@ public List getAllForSelectedClient() { } @Override - public DocketDTO convertJSONObjectToDTO(Map jsonObject, boolean related) throws DataException { - DocketDTO docketDTO = new DocketDTO(); - docketDTO.setId(getIdFromJSONObject(jsonObject)); - docketDTO.setTitle(DocketTypeField.TITLE.getStringValue(jsonObject)); - docketDTO.setFile(DocketTypeField.FILE.getStringValue(jsonObject)); - - ClientDTO clientDTO = new ClientDTO(); - clientDTO.setId(DocketTypeField.CLIENT_ID.getIntValue(jsonObject)); - clientDTO.setName(DocketTypeField.CLIENT_NAME.getStringValue(jsonObject)); - - docketDTO.setClientDTO(clientDTO); - return docketDTO; + public DocketInterface convertJSONObjectToInterface(Map jsonObject, boolean related) throws DataException { + DocketInterface docketInterface = DTOFactory.instance().newDocket(); + docketInterface.setId(getIdFromJSONObject(jsonObject)); + docketInterface.setTitle(DocketTypeField.TITLE.getStringValue(jsonObject)); + docketInterface.setFile(DocketTypeField.FILE.getStringValue(jsonObject)); + + ClientInterface clientInterface = DTOFactory.instance().newClient(); + clientInterface.setId(DocketTypeField.CLIENT_ID.getIntValue(jsonObject)); + clientInterface.setName(DocketTypeField.CLIENT_NAME.getStringValue(jsonObject)); + + docketInterface.setClient(clientInterface); + return docketInterface; } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/FilterService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/FilterService.java index 7b3385a0d47..da006a8ea76 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/FilterService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/FilterService.java @@ -49,11 +49,13 @@ import org.kitodo.data.elasticsearch.search.Searcher; import org.kitodo.data.elasticsearch.search.enums.SearchCondition; import org.kitodo.data.exceptions.DataException; -import org.kitodo.production.dto.BaseDTO; -import org.kitodo.production.dto.FilterDTO; -import org.kitodo.production.dto.ProcessDTO; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.TaskDTO; +import org.kitodo.data.interfaces.DataFactoryInterface; +import org.kitodo.data.interfaces.DataInterface; +import org.kitodo.data.interfaces.FilterInterface; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TaskInterface; +import org.kitodo.production.dto.DTOFactory; import org.kitodo.production.enums.FilterString; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; @@ -64,7 +66,7 @@ /** * Service for Filter bean. */ -public class FilterService extends SearchService { +public class FilterService extends SearchService { private static final Logger logger = LogManager.getLogger(FilterService.class); private static volatile FilterService instance = null; @@ -138,11 +140,11 @@ List> findByValue(String value, boolean contains) throws Dat } @Override - public FilterDTO convertJSONObjectToDTO(Map jsonObject, boolean related) throws DataException { - FilterDTO filterDTO = new FilterDTO(); - filterDTO.setId(getIdFromJSONObject(jsonObject)); - filterDTO.setValue(FilterTypeField.VALUE.getStringValue(jsonObject)); - return filterDTO; + public FilterInterface convertJSONObjectToInterface(Map jsonObject, boolean related) throws DataException { + FilterInterface filterInterface = DTOFactory.instance().newFilter(); + filterInterface.setId(getIdFromJSONObject(jsonObject)); + filterInterface.setValue(FilterTypeField.VALUE.getStringValue(jsonObject)); + return filterInterface; } /** @@ -271,10 +273,10 @@ private BoolQueryBuilder buildTaskQuery(Boolean onlyOpenTasks, Boolean onlyUserA return limitToUserAssignedTasks(onlyOpenTasks, onlyUserAssignedTasks); } - Set collectIds(List dtos) { + Set collectIds(List dtos) { Set ids = new HashSet<>(); - for (BaseDTO processDTO : dtos) { - ids.add(processDTO.getId()); + for (DataInterface processInterface : dtos) { + ids.add(processInterface.getId()); } return ids; } @@ -550,9 +552,9 @@ private QueryBuilder createBatchIdFilter(String filter, ObjectType objectType, b if (objectType == ObjectType.PROCESS) { return createSetQuery("batches.id", filterValuesAsIntegers(filter, FilterString.BATCH), negate); } else if (objectType == ObjectType.TASK) { - List processDTOS = ServiceManager.getProcessService().findByQuery( + List processInterfaces = ServiceManager.getProcessService().findByQuery( createSetQuery("batches.id", filterValuesAsIntegers(filter, FilterString.BATCH), negate), true); - return createSetQuery(TaskTypeField.PROCESS_ID.getKey(), collectIds(processDTOS), negate); + return createSetQuery(TaskTypeField.PROCESS_ID.getKey(), collectIds(processInterfaces), negate); } return new BoolQueryBuilder(); } @@ -849,20 +851,20 @@ private QueryBuilder filterTaskDoneUser(String filter, ObjectType objectType) { /* * filtering by a certain done step, which the current user finished */ - /*List taskDTOS = new ArrayList<>(); + /*List taskInterfaces = new ArrayList<>(); String login = getFilterValueFromFilterString(filter, FilterString.TASKDONEUSER); try { Map user = ServiceManager.getUserService().findByLogin(login); - UserDTO userDTO = ServiceManager.getUserService().convertJSONObjectToDTO(user, false); - taskDTOS = userDTO.getProcessingTasks(); + UserInterface userInterface = ServiceManager.getUserService().convertJSONObjectToInterface(user, false); + taskInterfaces = userInterface.getProcessingTasks(); } catch (DataException e) { logger.error(e.getMessage(), e); } if (objectType == ObjectType.PROCESS) { - return createSetQuery("tasks.id", collectIds(taskDTOS), true); + return createSetQuery("tasks.id", collectIds(taskInterfaces), true); } else if (objectType == ObjectType.TASK) { - return createSetQuery("_id", collectIds(taskDTOS), true); + return createSetQuery("_id", collectIds(taskInterfaces), true); }*/ return new BoolQueryBuilder(); } @@ -962,8 +964,8 @@ private QueryBuilder getQueryAccordingToObjectTypeAndSearchInObject(ObjectType o private QueryBuilder getQueryAccordingToObjectTypeAndSearchInTask(ObjectType objectType, QueryBuilder query) throws DataException { if (objectType == ObjectType.PROCESS) { - List taskDTOS = ServiceManager.getTaskService().findByQuery(query, true); - return createSetQuery("tasks.id", collectIds(taskDTOS), true); + List taskInterfaces = ServiceManager.getTaskService().findByQuery(query, true); + return createSetQuery("tasks.id", collectIds(taskInterfaces), true); } else if (objectType == ObjectType.TASK) { return query; } @@ -975,8 +977,8 @@ private QueryBuilder getQueryAccordingToObjectTypeAndSearchInProcess(ObjectType if (objectType == ObjectType.PROCESS) { return query; } else if (objectType == ObjectType.TASK) { - List processDTOS = ServiceManager.getProcessService().findByQuery(query, true); - return createSetQuery(TaskTypeField.PROCESS_ID.getKey(), collectIds(processDTOS), true); + List processInterfaces = ServiceManager.getProcessService().findByQuery(query, true); + return createSetQuery(TaskTypeField.PROCESS_ID.getKey(), collectIds(processInterfaces), true); } return new BoolQueryBuilder(); } @@ -1096,14 +1098,14 @@ public List initProcessPropertyTitles() { * @return List of String objects containing the project */ public List initProjects() { - List projectsSortedByTitle = Collections.emptyList(); + List projectsSortedByTitle = Collections.emptyList(); try { projectsSortedByTitle = ServiceManager.getProjectService().findAllProjectsForCurrentUser(); } catch (DataException e) { Helper.setErrorMessage("errorInitializingProjects", logger, e); } - return projectsSortedByTitle.stream().map(ProjectDTO::getTitle).sorted().collect(Collectors.toList()); + return projectsSortedByTitle.stream().map(ProjectInterface::getTitle).sorted().collect(Collectors.toList()); } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java index 48fe88c3470..b43b5e4e8cd 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java @@ -77,6 +77,7 @@ import org.kitodo.data.database.enums.TaskStatus; import org.kitodo.data.database.exceptions.DAOException; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProcessInterface; import org.kitodo.exceptions.CatalogException; import org.kitodo.exceptions.CommandException; import org.kitodo.exceptions.ConfigException; @@ -89,7 +90,6 @@ import org.kitodo.exceptions.ProcessGenerationException; import org.kitodo.exceptions.RecordIdentifierMissingDetail; import org.kitodo.exceptions.UnsupportedFormatException; -import org.kitodo.production.dto.ProcessDTO; import org.kitodo.production.forms.createprocess.ProcessBooleanMetadata; import org.kitodo.production.forms.createprocess.ProcessDetail; import org.kitodo.production.forms.createprocess.ProcessFieldedMetadata; @@ -956,8 +956,8 @@ private Process loadParentProcess(Ruleset ruleset, int projectId, String parentI HashMap parentIDMetadata = new HashMap<>(); parentIDMetadata.put(identifierMetadata, parentId); try { - for (ProcessDTO processDTO : ServiceManager.getProcessService().findByMetadata(parentIDMetadata, true)) { - Process process = ServiceManager.getProcessService().getById(processDTO.getId()); + for (ProcessInterface processInterface : ServiceManager.getProcessService().findByMetadata(parentIDMetadata, true)) { + Process process = ServiceManager.getProcessService().getById(processInterface.getId()); if (Objects.isNull(process.getRuleset()) || Objects.isNull(process.getRuleset().getId())) { throw new ProcessGenerationException("Ruleset or ruleset ID of potential parent process " + process.getId() + " is null!"); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java index 3bd606fa88b..7b457e54ff7 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProcessService.java @@ -18,14 +18,6 @@ import static org.kitodo.data.database.enums.CorrectionComments.NO_OPEN_CORRECTION_COMMENTS; import static org.kitodo.data.database.enums.CorrectionComments.OPEN_CORRECTION_COMMENTS; -import com.itextpdf.text.Document; -import com.itextpdf.text.DocumentException; -import com.itextpdf.text.PageSize; -import com.itextpdf.text.Paragraph; -import com.itextpdf.text.Rectangle; -import com.itextpdf.text.pdf.PdfPTable; -import com.itextpdf.text.pdf.PdfWriter; - import java.io.File; import java.io.FileInputStream; import java.io.FilenameFilter; @@ -133,13 +125,14 @@ import org.kitodo.data.elasticsearch.index.type.enums.ProcessTypeField; import org.kitodo.data.elasticsearch.search.Searcher; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.BatchInterface; +import org.kitodo.data.interfaces.ProcessInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.PropertyInterface; +import org.kitodo.data.interfaces.TaskInterface; import org.kitodo.exceptions.InvalidImagesException; import org.kitodo.export.ExportMets; -import org.kitodo.production.dto.BatchDTO; -import org.kitodo.production.dto.ProcessDTO; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.PropertyDTO; -import org.kitodo.production.dto.TaskDTO; +import org.kitodo.production.dto.DTOFactory; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.enums.ProcessState; import org.kitodo.production.helper.Helper; @@ -173,7 +166,15 @@ import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -public class ProcessService extends ProjectSearchService { +import com.itextpdf.text.Document; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.PageSize; +import com.itextpdf.text.Paragraph; +import com.itextpdf.text.Rectangle; +import com.itextpdf.text.pdf.PdfPTable; +import com.itextpdf.text.pdf.PdfWriter; + +public class ProcessService extends ProjectSearchService { private static final FileService fileService = ServiceManager.getFileService(); private static final Logger logger = LogManager.getLogger(ProcessService.class); private static volatile ProcessService instance = null; @@ -383,7 +384,7 @@ public static LegacyMetadataTypeHelper getMetadataType(Process inProzess, String } @Override - public List loadData(int first, int pageSize, String sortField, + public List loadData(int first, int pageSize, String sortField, org.primefaces.model.SortOrder sortOrder, Map filters) throws DataException { return loadData(first, pageSize, sortField, sortOrder, filters, false, false); } @@ -400,7 +401,7 @@ public List loadData(int first, int pageSize, String sortField, * @return List of loaded processes * @throws DataException if processes cannot be loaded from search index */ - public List loadData(int first, int pageSize, String sortField, + public List loadData(int first, int pageSize, String sortField, org.primefaces.model.SortOrder sortOrder, Map filters, boolean showClosedProcesses, boolean showInactiveProjects) throws DataException { String filter = ServiceManager.getFilterService().parseFilterString(filters); @@ -591,9 +592,9 @@ List> findForCurrentSessionClient() throws DataException { * * @param metadata * key is metadata tag and value is metadata content - * @return list of ProcessDTO objects with processes for specific metadata tag + * @return list of ProcessInterface objects with processes for specific metadata tag */ - public List findByMetadata(Map metadata) throws DataException { + public List findByMetadata(Map metadata) throws DataException { return findByMetadata(metadata, false); } @@ -604,9 +605,9 @@ public List findByMetadata(Map metadata) throws Data * key is metadata tag and value is metadata content * @param exactMatch * online return exact matches - * @return list of ProcessDTO objects with processes for specific metadata tag + * @return list of ProcessInterface objects with processes for specific metadata tag */ - public List findByMetadata(Map metadata, boolean exactMatch) throws DataException { + public List findByMetadata(Map metadata, boolean exactMatch) throws DataException { String nameSearchKey = METADATA_SEARCH_KEY + ".name"; String contentSearchKey = METADATA_SEARCH_KEY + ".content"; if (exactMatch) { @@ -633,8 +634,8 @@ public List findByMetadata(Map metadata, boolean exa * @throws DataException * when there is an error on conversion */ - public List findByTitle(String title) throws DataException { - return convertJSONObjectsToDTOs(findByTitle(title, true), true); + public List findByTitle(String title) throws DataException { + return convertJSONObjectsToInterfaces(findByTitle(title, true), true); } /** @@ -642,11 +643,11 @@ public List findByTitle(String title) throws DataException { * * @param searchQuery * the query word or phrase - * @return a List of found ProcessDTOs + * @return a List of found ProcessInterfaces * @throws DataException * when accessing the elasticsearch server fails */ - public List findByAnything(String searchQuery) throws DataException { + public List findByAnything(String searchQuery) throws DataException { NestedQueryBuilder nestedQueryForMetadataContent = nestedQuery(METADATA_SEARCH_KEY, matchQuery(METADATA_SEARCH_KEY + ".content", searchQuery).operator(Operator.AND), ScoreMode.Total); NestedQueryBuilder nestedQueryForMetadataGroupContent = nestedQuery(METADATA_GROUP_SEARCH_KEY, @@ -770,7 +771,7 @@ private QueryBuilder getQueryProjectIsAssignedToSelectedClient(int id) { * @throws DataException * if the search engine fails */ - public List findLinkableChildProcesses(String searchInput, int rulesetId, + public List findLinkableChildProcesses(String searchInput, int rulesetId, Collection allowedStructuralElementTypes) throws DataException { BoolQueryBuilder query = new BoolQueryBuilder() @@ -778,10 +779,10 @@ public List findLinkableChildProcesses(String searchInput, int rules .should(new MatchQueryBuilder(ProcessTypeField.ID.getKey(), searchInput).lenient(true)) .should(new WildcardQueryBuilder(ProcessTypeField.TITLE.getKey(), "*" + searchInput + "*"))) .must(new MatchQueryBuilder(ProcessTypeField.RULESET.getKey(), rulesetId)); - List linkableProcesses = new LinkedList<>(); + List linkableProcesses = new LinkedList<>(); - List processDTOS = findByQuery(query, false); - for (ProcessDTO process : processDTOS) { + List processInterfaces = findByQuery(query, false); + for (ProcessInterface process : processInterfaces) { if (allowedStructuralElementTypes.contains(getBaseType(process.getId()))) { linkableProcesses.add(process); } @@ -807,7 +808,7 @@ public List findLinkableChildProcesses(String searchInput, int rules * @throws DataException * if the search engine fails */ - public List findLinkableParentProcesses(String searchInput, int projectId, int rulesetId) + public List findLinkableParentProcesses(String searchInput, int projectId, int rulesetId) throws DataException { BoolQueryBuilder processQuery = new BoolQueryBuilder() @@ -830,7 +831,7 @@ public List findLinkableParentProcesses(String searchInput, int proj * of property * @return list of JSON objects with processes for specific property */ - public List findByProperty(String title, String value) throws DataException { + public List findByProperty(String title, String value) throws DataException { return findByQuery(createPropertyQuery(title, value), true); } @@ -854,7 +855,7 @@ public QueryBuilder createPropertyQuery(String title, String value) { return nestedQuery(ProcessTypeField.PROPERTIES.toString(), pairQuery, ScoreMode.Total); } - List findByProjectIds(Set projectIds, boolean related) throws DataException { + List findByProjectIds(Set projectIds, boolean related) throws DataException { QueryBuilder query = createSetQuery("project.id", projectIds, true); return findByQuery(query, related); } @@ -896,139 +897,139 @@ public SortBuilder sortByCreationDate(SortOrder sortOrder) { } /** - * Convert list of DTOs to list of beans. + * Convert list of Interfaces to list of beans. * * @param dtos - * list of DTO objects + * list of Interface objects * @return list of beans */ - public List convertDtosToBeans(List dtos) throws DAOException { + public List convertDtosToBeans(List dtos) throws DAOException { List processes = new ArrayList<>(); - for (ProcessDTO processDTO : dtos) { - processes.add(getById(processDTO.getId())); + for (ProcessInterface processInterface : dtos) { + processes.add(getById(processInterface.getId())); } return processes; } @Override - public ProcessDTO convertJSONObjectToDTO(Map jsonObject, boolean related) throws DataException { - ProcessDTO processDTO = new ProcessDTO(); + public ProcessInterface convertJSONObjectToInterface(Map jsonObject, boolean related) throws DataException { + ProcessInterface processInterface = DTOFactory.instance().newProcess(); if (!jsonObject.isEmpty()) { - processDTO.setId(getIdFromJSONObject(jsonObject)); - processDTO.setTitle(ProcessTypeField.TITLE.getStringValue(jsonObject)); - processDTO.setWikiField(ProcessTypeField.WIKI_FIELD.getStringValue(jsonObject)); - processDTO.setCreationDate(ProcessTypeField.CREATION_DATE.getStringValue(jsonObject)); - processDTO.setSortHelperArticles(ProcessTypeField.SORT_HELPER_ARTICLES.getIntValue(jsonObject)); - processDTO.setSortHelperDocstructs(ProcessTypeField.SORT_HELPER_DOCSTRUCTS.getIntValue(jsonObject)); - processDTO.setSortHelperImages(ProcessTypeField.SORT_HELPER_IMAGES.getIntValue(jsonObject)); - processDTO.setSortHelperMetadata(ProcessTypeField.SORT_HELPER_METADATA.getIntValue(jsonObject)); - processDTO.setSortHelperStatus(ProcessTypeField.SORT_HELPER_STATUS.getStringValue(jsonObject)); - processDTO.setProcessBaseUri(ProcessTypeField.PROCESS_BASE_URI.getStringValue(jsonObject)); - processDTO.setHasChildren(ProcessTypeField.HAS_CHILDREN.getBooleanValue(jsonObject)); - processDTO.setParentID(ProcessTypeField.PARENT_ID.getIntValue(jsonObject)); - processDTO.setNumberOfImages(ProcessTypeField.NUMBER_OF_IMAGES.getIntValue(jsonObject)); - processDTO.setNumberOfMetadata(ProcessTypeField.NUMBER_OF_METADATA.getIntValue(jsonObject)); - processDTO.setNumberOfStructures(ProcessTypeField.NUMBER_OF_STRUCTURES.getIntValue(jsonObject)); - processDTO.setBaseType(ProcessTypeField.BASE_TYPE.getStringValue(jsonObject)); - processDTO.setLastEditingUser(ProcessTypeField.LAST_EDITING_USER.getStringValue(jsonObject)); - processDTO.setCorrectionCommentStatus(ProcessTypeField.CORRECTION_COMMENT_STATUS.getIntValue(jsonObject)); - processDTO.setHasComments(!ProcessTypeField.COMMENTS_MESSAGE.getStringValue(jsonObject).isEmpty()); - convertLastProcessingDates(jsonObject, processDTO); - convertTaskProgress(jsonObject, processDTO); + processInterface.setId(getIdFromJSONObject(jsonObject)); + processInterface.setTitle(ProcessTypeField.TITLE.getStringValue(jsonObject)); + processInterface.setWikiField(ProcessTypeField.WIKI_FIELD.getStringValue(jsonObject)); + processInterface.setCreationDate(ProcessTypeField.CREATION_DATE.getStringValue(jsonObject)); + processInterface.setSortHelperArticles(ProcessTypeField.SORT_HELPER_ARTICLES.getIntValue(jsonObject)); + processInterface.setSortHelperDocstructs(ProcessTypeField.SORT_HELPER_DOCSTRUCTS.getIntValue(jsonObject)); + processInterface.setSortHelperImages(ProcessTypeField.SORT_HELPER_IMAGES.getIntValue(jsonObject)); + processInterface.setSortHelperMetadata(ProcessTypeField.SORT_HELPER_METADATA.getIntValue(jsonObject)); + processInterface.setSortHelperStatus(ProcessTypeField.SORT_HELPER_STATUS.getStringValue(jsonObject)); + processInterface.setProcessBaseUri(ProcessTypeField.PROCESS_BASE_URI.getStringValue(jsonObject)); + processInterface.setHasChildren(ProcessTypeField.HAS_CHILDREN.getBooleanValue(jsonObject)); + processInterface.setParentID(ProcessTypeField.PARENT_ID.getIntValue(jsonObject)); + processInterface.setNumberOfImages(ProcessTypeField.NUMBER_OF_IMAGES.getIntValue(jsonObject)); + processInterface.setNumberOfMetadata(ProcessTypeField.NUMBER_OF_METADATA.getIntValue(jsonObject)); + processInterface.setNumberOfStructures(ProcessTypeField.NUMBER_OF_STRUCTURES.getIntValue(jsonObject)); + processInterface.setBaseType(ProcessTypeField.BASE_TYPE.getStringValue(jsonObject)); + processInterface.setLastEditingUser(ProcessTypeField.LAST_EDITING_USER.getStringValue(jsonObject)); + processInterface.setCorrectionCommentStatus(ProcessTypeField.CORRECTION_COMMENT_STATUS.getIntValue(jsonObject)); + processInterface.setHasComments(!ProcessTypeField.COMMENTS_MESSAGE.getStringValue(jsonObject).isEmpty()); + convertLastProcessingDates(jsonObject, processInterface); + convertTaskProgress(jsonObject, processInterface); List> jsonArray = ProcessTypeField.PROPERTIES.getJsonArray(jsonObject); - List properties = new ArrayList<>(); + List properties = new ArrayList<>(); for (Map stringObjectMap : jsonArray) { - PropertyDTO propertyDTO = new PropertyDTO(); + PropertyInterface propertyInterface = DTOFactory.instance().newProperty(); Object title = stringObjectMap.get(JSON_TITLE); Object value = stringObjectMap.get(JSON_VALUE); if (Objects.nonNull(title)) { - propertyDTO.setTitle(title.toString()); - propertyDTO.setValue(Objects.nonNull(value) ? value.toString() : ""); - properties.add(propertyDTO); + propertyInterface.setTitle(title.toString()); + propertyInterface.setValue(Objects.nonNull(value) ? value.toString() : ""); + properties.add(propertyInterface); } } - processDTO.setProperties(properties); + processInterface.setProperties(properties); if (!related) { - convertRelatedJSONObjects(jsonObject, processDTO); + convertRelatedJSONObjects(jsonObject, processInterface); } else { - ProjectDTO projectDTO = new ProjectDTO(); - projectDTO.setId(ProcessTypeField.PROJECT_ID.getIntValue(jsonObject)); - projectDTO.setTitle(ProcessTypeField.PROJECT_TITLE.getStringValue(jsonObject)); - projectDTO.setActive(ProcessTypeField.PROJECT_ACTIVE.getBooleanValue(jsonObject)); - processDTO.setProject(projectDTO); + ProjectInterface projectInterface = DTOFactory.instance().newProject(); + projectInterface.setId(ProcessTypeField.PROJECT_ID.getIntValue(jsonObject)); + projectInterface.setTitle(ProcessTypeField.PROJECT_TITLE.getStringValue(jsonObject)); + projectInterface.setActive(ProcessTypeField.PROJECT_ACTIVE.getBooleanValue(jsonObject)); + processInterface.setProject(projectInterface); } } - return processDTO; + return processInterface; } /** - * Parses last processing dates from the jsonObject and adds them to the processDTO bean. + * Parses last processing dates from the jsonObject and adds them to the processInterface bean. * * @param jsonObject the json object retrieved from elastic search - * @param processDTO the processDTO bean that will receive the processing dates + * @param processInterface the processInterface bean that will receive the processing dates */ - private void convertLastProcessingDates(Map jsonObject, ProcessDTO processDTO) throws DataException { + private void convertLastProcessingDates(Map jsonObject, ProcessInterface processInterface) throws DataException { String processingBeginLastTask = ProcessTypeField.PROCESSING_BEGIN_LAST_TASK.getStringValue(jsonObject); - processDTO.setProcessingBeginLastTask(Helper.parseDateFromFormattedString(processingBeginLastTask)); + processInterface.setProcessingBeginLastTask(Helper.parseDateFromFormattedString(processingBeginLastTask)); String processingEndLastTask = ProcessTypeField.PROCESSING_END_LAST_TASK.getStringValue(jsonObject); - processDTO.setProcessingEndLastTask(Helper.parseDateFromFormattedString(processingEndLastTask)); + processInterface.setProcessingEndLastTask(Helper.parseDateFromFormattedString(processingEndLastTask)); } /** - * Parses task progress properties from the jsonObject and adds them to the processDTO bean. + * Parses task progress properties from the jsonObject and adds them to the processInterface bean. * * @param jsonObject the json object retrieved from elastic search - * @param processDTO the processDTO bean that will receive the progress information + * @param processInterface the processInterface bean that will receive the progress information */ - private void convertTaskProgress(Map jsonObject, ProcessDTO processDTO) throws DataException { - processDTO.setProgressClosed(ProcessTypeField.PROGRESS_CLOSED.getDoubleValue(jsonObject)); - processDTO.setProgressInProcessing(ProcessTypeField.PROGRESS_IN_PROCESSING.getDoubleValue(jsonObject)); - processDTO.setProgressOpen(ProcessTypeField.PROGRESS_OPEN.getDoubleValue(jsonObject)); - processDTO.setProgressLocked(ProcessTypeField.PROGRESS_LOCKED.getDoubleValue(jsonObject)); - processDTO.setProgressCombined(ProcessTypeField.PROGRESS_COMBINED.getStringValue(jsonObject)); + private void convertTaskProgress(Map jsonObject, ProcessInterface processInterface) throws DataException { + processInterface.setProgressClosed(ProcessTypeField.PROGRESS_CLOSED.getDoubleValue(jsonObject)); + processInterface.setProgressInProcessing(ProcessTypeField.PROGRESS_IN_PROCESSING.getDoubleValue(jsonObject)); + processInterface.setProgressOpen(ProcessTypeField.PROGRESS_OPEN.getDoubleValue(jsonObject)); + processInterface.setProgressLocked(ProcessTypeField.PROGRESS_LOCKED.getDoubleValue(jsonObject)); + processInterface.setProgressCombined(ProcessTypeField.PROGRESS_COMBINED.getStringValue(jsonObject)); } - private void convertRelatedJSONObjects(Map jsonObject, ProcessDTO processDTO) throws DataException { + private void convertRelatedJSONObjects(Map jsonObject, ProcessInterface processInterface) throws DataException { int project = ProcessTypeField.PROJECT_ID.getIntValue(jsonObject); if (project > 0) { - processDTO.setProject(ServiceManager.getProjectService().findById(project, true)); + processInterface.setProject(ServiceManager.getProjectService().findById(project, true)); } int ruleset = ProcessTypeField.RULESET.getIntValue(jsonObject); if (ruleset > 0) { - processDTO.setRuleset(ServiceManager.getRulesetService().findById(ruleset, true)); + processInterface.setRuleset(ServiceManager.getRulesetService().findById(ruleset, true)); } - processDTO.setBatchID(getBatchID(processDTO)); - processDTO.setBatches(getBatchesForProcessDTO(jsonObject)); + processInterface.setBatchID(getBatchID(processInterface)); + processInterface.setBatches(getBatchesForProcessInterface(jsonObject)); // TODO: leave it for now - right now it displays only status - processDTO.setTasks(convertRelatedJSONObjectToDTO(jsonObject, ProcessTypeField.TASKS.getKey(), + processInterface.setTasks(convertRelatedJSONObjectToInterface(jsonObject, ProcessTypeField.TASKS.getKey(), ServiceManager.getTaskService())); } - private List getBatchesForProcessDTO(Map jsonObject) throws DataException { + private List getBatchesForProcessInterface(Map jsonObject) throws DataException { List> jsonArray = ProcessTypeField.BATCHES.getJsonArray(jsonObject); - List batchDTOList = new ArrayList<>(); + List batchInterfaceList = new ArrayList<>(); for (Map singleObject : jsonArray) { - BatchDTO batchDTO = new BatchDTO(); - batchDTO.setId(BatchTypeField.ID.getIntValue(singleObject)); - batchDTO.setTitle(BatchTypeField.TITLE.getStringValue(singleObject)); - batchDTOList.add(batchDTO); + BatchInterface batchInterface = DTOFactory.instance().newBatch(); + batchInterface.setId(BatchTypeField.ID.getIntValue(singleObject)); + batchInterface.setTitle(BatchTypeField.TITLE.getStringValue(singleObject)); + batchInterfaceList.add(batchInterface); } - return batchDTOList; + return batchInterfaceList; } /** * Check if process is assigned only to one batch. * - * @param batchDTOList + * @param list * list of batches for checkout * @return true or false */ - boolean isProcessAssignedToOnlyOneBatch(List batchDTOList) { - return batchDTOList.size() == 1; + boolean isProcessAssignedToOnlyOneBatch(List list) { + return list.size() == 1; } /** @@ -1194,15 +1195,15 @@ public URI getProcessDataDirectory(Process process, boolean forIndexingAll) { * Get process data directory. * Don't save it to the database, if it is for indexingAll. * - * @param processDTO - * processDTO to get the dataDirectory from + * @param processInterface + * processInterface to get the dataDirectory from * @return path */ - public String getProcessDataDirectory(ProcessDTO processDTO) { - if (Objects.isNull(processDTO.getProcessBaseUri())) { - processDTO.setProcessBaseUri(fileService.getProcessBaseUriForExistingProcess(processDTO)); + public String getProcessDataDirectory(ProcessInterface processInterface) { + if (Objects.isNull(processInterface.getProcessBaseUri())) { + processInterface.setProcessBaseUri(fileService.getProcessBaseUriForExistingProcess(processInterface)); } - return processDTO.getProcessBaseUri(); + return processInterface.getProcessBaseUri(); } /** @@ -1250,12 +1251,12 @@ public URI getProcessURI(Integer processId) { * * @return the batches the process is in */ - public String getBatchID(ProcessDTO process) { + public String getBatchID(ProcessInterface process) { if (process.getBatches().isEmpty()) { return null; } StringBuilder result = new StringBuilder(); - for (BatchDTO batch : process.getBatches()) { + for (BatchInterface batch : process.getBatches()) { if (result.length() > 0) { result.append(", "); } @@ -1299,12 +1300,12 @@ public List getCurrentTasks(Process process) { return currentTasks; } - private List getOpenTasks(ProcessDTO process) { + private List getOpenTasks(ProcessInterface process) { return process.getTasks().stream() .filter(t -> TaskStatus.OPEN.equals(t.getProcessingStatus())).collect(Collectors.toList()); } - private List getTasksInWork(ProcessDTO process) { + private List getTasksInWork(ProcessInterface process) { return process.getTasks().stream() .filter(t -> TaskStatus.INWORK.equals(t.getProcessingStatus())).collect(Collectors.toList()); } @@ -1313,17 +1314,17 @@ private List getTasksInWork(ProcessDTO process) { * Create and return String used as progress tooltip for a given process. Tooltip contains OPEN tasks and tasks * INWORK. * - * @param processDTO + * @param processInterface * process for which the tooltop is created * @return String containing the progress tooltip for the given process */ - public String createProgressTooltip(ProcessDTO processDTO) { - String openTasks = getOpenTasks(processDTO).stream() + public String createProgressTooltip(ProcessInterface processInterface) { + String openTasks = getOpenTasks(processInterface).stream() .map(t -> " - " + Helper.getTranslation(t.getTitle())).collect(Collectors.joining(NEW_LINE_ENTITY)); if (!openTasks.isEmpty()) { openTasks = Helper.getTranslation(TaskStatus.OPEN.getTitle()) + ":" + NEW_LINE_ENTITY + openTasks; } - String tasksInWork = getTasksInWork(processDTO).stream() + String tasksInWork = getTasksInWork(processInterface).stream() .map(t -> " - " + Helper.getTranslation(t.getTitle())).collect(Collectors.joining(NEW_LINE_ENTITY)); if (!tasksInWork.isEmpty()) { tasksInWork = Helper.getTranslation(TaskStatus.INWORK.getTitle()) + ":" + NEW_LINE_ENTITY + tasksInWork; @@ -1342,12 +1343,12 @@ public String createProgressTooltip(ProcessDTO processDTO) { /** * Get current task. * - * @param processDTO - * DTOobject + * @param processInterface + * Interfaceobject * @return current task */ - public TaskDTO getCurrentTaskDTO(ProcessDTO processDTO) { - for (TaskDTO task : processDTO.getTasks()) { + public TaskInterface getCurrentTaskInterface(ProcessInterface processInterface) { + for (TaskInterface task : processInterface.getTasks()) { if (task.getProcessingStatus().equals(TaskStatus.OPEN) || task.getProcessingStatus().equals(TaskStatus.INWORK)) { return task; @@ -1703,9 +1704,9 @@ public String getBaseType(Workpiece workpiece) { * cannot be found in the index) */ public String getBaseType(int processId) throws DataException { - ProcessDTO processDTO = findById(processId, true); - if (Objects.nonNull(processDTO)) { - return processDTO.getBaseType(); + ProcessInterface processInterface = findById(processId, true); + if (Objects.nonNull(processInterface)) { + return processInterface.getBaseType(); } return ""; } @@ -1717,8 +1718,8 @@ public String getBaseType(int processId) throws DataException { * List of process properties * @return List of filtered correction / solution messages */ - private List filterForCorrectionSolutionMessages(List lpe) { - List filteredList = new ArrayList<>(); + private List filterForCorrectionSolutionMessages(List lpe) { + List filteredList = new ArrayList<>(); if (lpe.isEmpty()) { return filteredList; @@ -1728,7 +1729,7 @@ private List filterForCorrectionSolutionMessages(List "Korrektur notwendig", "Korrektur durchgef\u00FChrt"); // filtering for correction and solution messages - for (PropertyDTO property : lpe) { + for (PropertyInterface property : lpe) { if (translationList.contains(property.getTitle())) { filteredList.add(property); } @@ -2165,17 +2166,17 @@ private String prepareKey(String key) { /** * Retrieve and return process property value of property with given name - * 'propertyName' from given ProcessDTO 'process'. + * 'propertyName' from given ProcessInterface 'process'. * * @param process - * the ProcessDTO object from which the property value is retrieved + * the ProcessInterface object from which the property value is retrieved * @param propertyName * name of the property for the property value is retrieved * @return property value if process has property with name 'propertyName', * empty String otherwise */ - public static String getPropertyValue(ProcessDTO process, String propertyName) { - for (PropertyDTO property : process.getProperties()) { + public static String getPropertyValue(ProcessInterface process, String propertyName) { + for (PropertyInterface property : process.getProperties()) { if (property.getTitle().equals(propertyName)) { return property.getValue(); } @@ -2187,10 +2188,10 @@ public static String getPropertyValue(ProcessDTO process, String propertyName) { * Calculate and return duration/age of given process as a String. * * @param process - * ProcessDTO object for which duration/age is calculated + * ProcessInterface object for which duration/age is calculated * @return process age of given process */ - public static String getProcessDuration(ProcessDTO process) { + public static String getProcessDuration(ProcessInterface process) { String creationDateTimeString = process.getCreationDate(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); LocalDateTime createLocalDate = LocalDateTime.parse(creationDateTimeString, formatter); @@ -2493,32 +2494,32 @@ public static CorrectionComments hasCorrectionComment(int processID) throws DAOE /** * Retrieve comments for the given process. * - * @param processDTO + * @param processInterface * process for which the tooltip is created * @return List containing comments of given process * * @throws DAOException thrown when process cannot be loaded from database */ - public List getComments(ProcessDTO processDTO) throws DAOException { - Process process = ServiceManager.getProcessService().getById(processDTO.getId()); + public List getComments(ProcessInterface processInterface) throws DAOException { + Process process = ServiceManager.getProcessService().getById(processInterface.getId()); return ServiceManager.getCommentService().getAllCommentsByProcess(process); } /** - * Check and return if child process for given ProcessDTO processDTO can be created via calendar or not. + * Check and return if child process for given ProcessInterface processInterface can be created via calendar or not. * - * @param processDTO ProcessDTO for which child processes may be created via calendar - * @return whether child processes for the given ProcessDTO can be created via the calendar or not + * @param processInterface ProcessInterface for which child processes may be created via calendar + * @return whether child processes for the given ProcessInterface can be created via the calendar or not * @throws DAOException if process could not be loaded from database * @throws IOException if ruleset file could not be read */ - public static boolean canCreateProcessWithCalendar(ProcessDTO processDTO) + public static boolean canCreateProcessWithCalendar(ProcessInterface processInterface) throws DAOException, IOException { Collection functionalDivisions; - if (Objects.isNull(processDTO.getRuleset())) { + if (Objects.isNull(processInterface.getRuleset())) { return false; } - Integer rulesetId = processDTO.getRuleset().getId(); + Integer rulesetId = processInterface.getRuleset().getId(); if (RULESET_CACHE_FOR_CREATE_FROM_CALENDAR.containsKey(rulesetId)) { functionalDivisions = RULESET_CACHE_FOR_CREATE_FROM_CALENDAR.get(rulesetId); } else { @@ -2527,24 +2528,24 @@ public static boolean canCreateProcessWithCalendar(ProcessDTO processDTO) .getFunctionalDivisions(FunctionalDivision.CREATE_CHILDREN_WITH_CALENDAR); RULESET_CACHE_FOR_CREATE_FROM_CALENDAR.put(rulesetId, functionalDivisions); } - return functionalDivisions.contains(processDTO.getBaseType()); + return functionalDivisions.contains(processInterface.getBaseType()); } /** - * Check and return if child process for given ProcessDTO processDTO can be created or not. + * Check and return if child process for given ProcessInterface processInterface can be created or not. * - * @param processDTO ProcessDTO for which child processes may be created - * @return whether child processes for the given ProcessDTO can be created via the calendar or not + * @param processInterface ProcessInterface for which child processes may be created + * @return whether child processes for the given ProcessInterface can be created via the calendar or not * @throws DAOException if process could not be loaded from database * @throws IOException if ruleset file could not be read */ - public static boolean canCreateChildProcess(ProcessDTO processDTO) throws DAOException, + public static boolean canCreateChildProcess(ProcessInterface processInterface) throws DAOException, IOException { Collection functionalDivisions; - if (Objects.isNull(processDTO.getRuleset())) { + if (Objects.isNull(processInterface.getRuleset())) { return false; } - Integer rulesetId = processDTO.getRuleset().getId(); + Integer rulesetId = processInterface.getRuleset().getId(); if (RULESET_CACHE_FOR_CREATE_CHILD_FROM_PARENT.containsKey(rulesetId)) { functionalDivisions = RULESET_CACHE_FOR_CREATE_CHILD_FROM_PARENT.get(rulesetId); } else { @@ -2553,7 +2554,7 @@ public static boolean canCreateChildProcess(ProcessDTO processDTO) throws DAOExc .getFunctionalDivisions(FunctionalDivision.CREATE_CHILDREN_FROM_PARENT); RULESET_CACHE_FOR_CREATE_CHILD_FROM_PARENT.put(rulesetId, functionalDivisions); } - return functionalDivisions.contains(processDTO.getBaseType()); + return functionalDivisions.contains(processInterface.getBaseType()); } /** @@ -2682,15 +2683,15 @@ public Map getProcessTaskStates(List processes) { /** * Get all tasks of given process which should be visible to the user. - * @param processDTO process as DTO object + * @param processInterface process as Interface object * @param user user to filter the tasks for - * @return List of filtered tasks as DTO objects + * @return List of filtered tasks as Interface objects */ - public List getCurrentTasksForUser(ProcessDTO processDTO, User user) { + public List getCurrentTasksForUser(ProcessInterface processInterface, User user) { Set userRoles = user.getRoles().stream() .map(Role::getId) .collect(Collectors.toSet()); - return processDTO.getTasks().stream() + return processInterface.getTasks().stream() .filter(task -> TaskStatus.OPEN.equals(task.getProcessingStatus()) || TaskStatus.INWORK.equals(task.getProcessingStatus())) .filter(task -> !task.getRoleIds().stream() .filter(userRoles::contains) @@ -2727,8 +2728,8 @@ public List getTemplateProcesses() throws DataException, DAOException { BoolQueryBuilder inChoiceListShownQuery = new BoolQueryBuilder(); MatchQueryBuilder matchQuery = matchQuery(ProcessTypeField.IN_CHOICE_LIST_SHOWN.getKey(), true); inChoiceListShownQuery.must(matchQuery); - for (ProcessDTO processDTO : ServiceManager.getProcessService().findByQuery(matchQuery, true)) { - templateProcesses.add(getById(processDTO.getId())); + for (ProcessInterface processInterface : ServiceManager.getProcessService().findByQuery(matchQuery, true)) { + templateProcesses.add(getById(processInterface.getId())); } templateProcesses.sort(Comparator.comparing(Process::getTitle)); return templateProcesses; diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java index 207c3210bb8..1356ed41968 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/ProjectService.java @@ -43,16 +43,17 @@ import org.kitodo.data.elasticsearch.index.type.enums.TemplateTypeField; import org.kitodo.data.elasticsearch.search.Searcher; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TemplateInterface; import org.kitodo.exceptions.ProjectDeletionException; -import org.kitodo.production.dto.ClientDTO; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.TemplateDTO; +import org.kitodo.production.dto.DTOFactory; import org.kitodo.production.helper.Helper; import org.kitodo.production.services.ServiceManager; import org.kitodo.production.services.data.base.ClientSearchService; import org.primefaces.model.SortOrder; -public class ProjectService extends ClientSearchService { +public class ProjectService extends ClientSearchService { private static volatile ProjectService instance = null; @@ -158,7 +159,7 @@ public List getAllForSelectedClient() { } @Override - public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) + public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) throws DataException { return findByQuery(getProjectsForCurrentUserQuery(), getSortBuilder(sortField, sortOrder), first, pageSize, false); @@ -172,69 +173,69 @@ public List loadData(int first, int pageSize, String sortField, Sort * user which is going to be edited * @return list of all matching projects */ - public List findAllAvailableForAssignToUser(User user) throws DataException { + public List findAllAvailableForAssignToUser(User user) throws DataException { return findAvailableForAssignToUser(user); } - private List findAvailableForAssignToUser(User user) throws DataException { + private List findAvailableForAssignToUser(User user) throws DataException { BoolQueryBuilder query = new BoolQueryBuilder(); for (Client client : user.getClients()) { query.should(createSimpleQuery(ProjectTypeField.CLIENT_ID.getKey(), client.getId(), true)); } - List projectDTOS = findByQuery(query, true); - List alreadyAssigned = new ArrayList<>(); + List projectInterfaces = findByQuery(query, true); + List alreadyAssigned = new ArrayList<>(); for (Project project : user.getProjects()) { - alreadyAssigned.addAll(projectDTOS.stream().filter(projectDTO -> projectDTO.getId().equals(project.getId())) + alreadyAssigned.addAll(projectInterfaces.stream().filter(projectInterface -> projectInterface.getId().equals(project.getId())) .collect(Collectors.toList())); } - projectDTOS.removeAll(alreadyAssigned); - return projectDTOS; + projectInterfaces.removeAll(alreadyAssigned); + return projectInterfaces; } @Override - public ProjectDTO convertJSONObjectToDTO(Map jsonObject, boolean related) throws DataException { - ProjectDTO projectDTO = new ProjectDTO(); - projectDTO.setId(getIdFromJSONObject(jsonObject)); - projectDTO.setTitle(ProjectTypeField.TITLE.getStringValue(jsonObject)); - projectDTO.setStartDate(ProjectTypeField.START_DATE.getStringValue(jsonObject)); - projectDTO.setEndDate(ProjectTypeField.END_DATE.getStringValue(jsonObject)); - projectDTO.setMetsRightsOwner(ProjectTypeField.METS_RIGTS_OWNER.getStringValue(jsonObject)); - projectDTO.setNumberOfPages(ProjectTypeField.NUMBER_OF_PAGES.getIntValue(jsonObject)); - projectDTO.setNumberOfVolumes(ProjectTypeField.NUMBER_OF_VOLUMES.getIntValue(jsonObject)); - projectDTO.setActive(ProjectTypeField.ACTIVE.getBooleanValue(jsonObject)); - ClientDTO clientDTO = new ClientDTO(); - clientDTO.setId(ProjectTypeField.CLIENT_ID.getIntValue(jsonObject)); - clientDTO.setName(ProjectTypeField.CLIENT_NAME.getStringValue(jsonObject)); - projectDTO.setClient(clientDTO); - projectDTO.setHasProcesses(ProjectTypeField.HAS_PROCESSES.getBooleanValue(jsonObject)); + public ProjectInterface convertJSONObjectToInterface(Map jsonObject, boolean related) throws DataException { + ProjectInterface projectInterface = DTOFactory.instance().newProject(); + projectInterface.setId(getIdFromJSONObject(jsonObject)); + projectInterface.setTitle(ProjectTypeField.TITLE.getStringValue(jsonObject)); + projectInterface.setStartDate(ProjectTypeField.START_DATE.getStringValue(jsonObject)); + projectInterface.setEndDate(ProjectTypeField.END_DATE.getStringValue(jsonObject)); + projectInterface.setMetsRightsOwner(ProjectTypeField.METS_RIGTS_OWNER.getStringValue(jsonObject)); + projectInterface.setNumberOfPages(ProjectTypeField.NUMBER_OF_PAGES.getIntValue(jsonObject)); + projectInterface.setNumberOfVolumes(ProjectTypeField.NUMBER_OF_VOLUMES.getIntValue(jsonObject)); + projectInterface.setActive(ProjectTypeField.ACTIVE.getBooleanValue(jsonObject)); + ClientInterface clientInterface = DTOFactory.instance().newClient(); + clientInterface.setId(ProjectTypeField.CLIENT_ID.getIntValue(jsonObject)); + clientInterface.setName(ProjectTypeField.CLIENT_NAME.getStringValue(jsonObject)); + projectInterface.setClient(clientInterface); + projectInterface.setHasProcesses(ProjectTypeField.HAS_PROCESSES.getBooleanValue(jsonObject)); if (!related) { - convertRelatedJSONObjects(jsonObject, projectDTO); + convertRelatedJSONObjects(jsonObject, projectInterface); } else { - projectDTO.setTemplates(getTemplatesForProjectDTO(jsonObject)); + projectInterface.setActiveTemplates(getTemplatesForProjectInterface(jsonObject)); } - return projectDTO; + return projectInterface; } - private List getTemplatesForProjectDTO(Map jsonObject) throws DataException { - List templateDTOS = new ArrayList<>(); + private List getTemplatesForProjectInterface(Map jsonObject) throws DataException { + List templateInterfaces = new ArrayList<>(); List> jsonArray = ProjectTypeField.TEMPLATES.getJsonArray(jsonObject); for (Map singleObject : jsonArray) { - TemplateDTO templateDTO = new TemplateDTO(); - templateDTO.setId(TemplateTypeField.ID.getIntValue(singleObject)); - templateDTO.setTitle(TemplateTypeField.TITLE.getStringValue(singleObject)); - templateDTOS.add(templateDTO); + TemplateInterface templateInterface = DTOFactory.instance().newTemplate(); + templateInterface.setId(TemplateTypeField.ID.getIntValue(singleObject)); + templateInterface.setTitle(TemplateTypeField.TITLE.getStringValue(singleObject)); + templateInterfaces.add(templateInterface); } - return templateDTOS.stream().filter(TemplateDTO::isActive).collect(Collectors.toList()); + return templateInterfaces.stream().filter(TemplateInterface::isActive).collect(Collectors.toList()); } - private void convertRelatedJSONObjects(Map jsonObject, ProjectDTO projectDTO) throws DataException { + private void convertRelatedJSONObjects(Map jsonObject, ProjectInterface projectInterface) throws DataException { // TODO: not clear if project lists will need it - projectDTO.setUsers(new ArrayList<>()); - projectDTO.setTemplates(convertRelatedJSONObjectToDTO(jsonObject, ProjectTypeField.TEMPLATES.getKey(), - ServiceManager.getTemplateService()).stream().filter(TemplateDTO::isActive).collect(Collectors.toList())); + projectInterface.setUsers(new ArrayList<>()); + projectInterface.setActiveTemplates(convertRelatedJSONObjectToInterface(jsonObject, ProjectTypeField.TEMPLATES.getKey(), + ServiceManager.getTemplateService()).stream().filter(TemplateInterface::isActive).collect(Collectors.toList())); } /** @@ -327,7 +328,7 @@ public QueryBuilder getProjectsForCurrentUserQuery() { * @return A list of all Projects assigned tot he current user * @throws DataException when elasticsearch query is failing */ - public List findAllProjectsForCurrentUser() throws DataException { + public List findAllProjectsForCurrentUser() throws DataException { return findByQuery(getProjectsForCurrentUserQuery(), false); } @@ -358,7 +359,7 @@ public String getProjectTitles(List projects) throws DataException { && ServiceManager.getSecurityAccessService().hasAuthorityToViewClientList()) { return projects.stream().map(Project::getTitle).collect(Collectors.joining(COMMA_DELIMITER)); } else { - List userProjectIds = findAllProjectsForCurrentUser().stream().map(ProjectDTO::getId) + List userProjectIds = findAllProjectsForCurrentUser().stream().map(ProjectInterface::getId) .collect(Collectors.toList()); return projects.stream().filter(project -> userProjectIds.contains(project.getId())).map(Project::getTitle) .collect(Collectors.joining(COMMA_DELIMITER)); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/RulesetService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/RulesetService.java index 6b015a653b6..778a8a9de09 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/RulesetService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/RulesetService.java @@ -39,16 +39,17 @@ import org.kitodo.data.elasticsearch.index.type.enums.RulesetTypeField; import org.kitodo.data.elasticsearch.search.Searcher; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ClientInterface; +import org.kitodo.data.interfaces.RulesetInterface; import org.kitodo.exceptions.RulesetNotFoundException; -import org.kitodo.production.dto.ClientDTO; -import org.kitodo.production.dto.RulesetDTO; +import org.kitodo.production.dto.DTOFactory; import org.kitodo.production.helper.Helper; import org.kitodo.production.helper.metadata.legacytypeimplementations.LegacyPrefsHelper; import org.kitodo.production.services.ServiceManager; import org.kitodo.production.services.data.base.ClientSearchService; import org.primefaces.model.SortOrder; -public class RulesetService extends ClientSearchService { +public class RulesetService extends ClientSearchService { private static final Logger logger = LogManager.getLogger(RulesetService.class); private static volatile RulesetService instance = null; @@ -96,7 +97,7 @@ public Long countResults(Map filters) throws DataException { } @Override - public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) + public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) throws DataException { return findByQuery(getRulesetsForCurrentUserQuery(), getSortBuilder(sortField, sortOrder), first, pageSize, false); @@ -114,20 +115,20 @@ public List getAllForSelectedClient() { } @Override - public RulesetDTO convertJSONObjectToDTO(Map jsonObject, boolean related) throws DataException { - RulesetDTO rulesetDTO = new RulesetDTO(); - rulesetDTO.setId(getIdFromJSONObject(jsonObject)); - rulesetDTO.setTitle(RulesetTypeField.TITLE.getStringValue(jsonObject)); - rulesetDTO.setFile(RulesetTypeField.FILE.getStringValue(jsonObject)); - rulesetDTO.setOrderMetadataByRuleset( + public RulesetInterface convertJSONObjectToInterface(Map jsonObject, boolean related) throws DataException { + RulesetInterface rulesetInterface = DTOFactory.instance().newRuleset(); + rulesetInterface.setId(getIdFromJSONObject(jsonObject)); + rulesetInterface.setTitle(RulesetTypeField.TITLE.getStringValue(jsonObject)); + rulesetInterface.setFile(RulesetTypeField.FILE.getStringValue(jsonObject)); + rulesetInterface.setOrderMetadataByRuleset( RulesetTypeField.ORDER_METADATA_BY_RULESET.getBooleanValue(jsonObject)); - ClientDTO clientDTO = new ClientDTO(); - clientDTO.setId(RulesetTypeField.CLIENT_ID.getIntValue(jsonObject)); - clientDTO.setName(RulesetTypeField.CLIENT_NAME.getStringValue(jsonObject)); + ClientInterface clientInterface = DTOFactory.instance().newClient(); + clientInterface.setId(RulesetTypeField.CLIENT_ID.getIntValue(jsonObject)); + clientInterface.setName(RulesetTypeField.CLIENT_NAME.getStringValue(jsonObject)); - rulesetDTO.setClientDTO(clientDTO); - return rulesetDTO; + rulesetInterface.setClient(clientInterface); + return rulesetInterface; } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/TaskService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/TaskService.java index 753b277cdbf..a3ea83e2903 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/TaskService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/TaskService.java @@ -51,12 +51,13 @@ import org.kitodo.data.elasticsearch.index.type.enums.TaskTypeField; import org.kitodo.data.elasticsearch.search.Searcher; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TaskInterface; +import org.kitodo.data.interfaces.UserInterface; import org.kitodo.exceptions.InvalidImagesException; import org.kitodo.exceptions.MediaNotFoundException; import org.kitodo.export.ExportDms; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.TaskDTO; -import org.kitodo.production.dto.UserDTO; +import org.kitodo.production.dto.DTOFactory; import org.kitodo.production.enums.GenerationMode; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; @@ -80,7 +81,7 @@ * functions on the task because the task itself is a database bean and * therefore may not include functionality. */ -public class TaskService extends ProjectSearchService { +public class TaskService extends ProjectSearchService { private static final Logger logger = LogManager.getLogger(TaskService.class); private static volatile TaskService instance = null; @@ -190,7 +191,7 @@ public List getAllForSelectedClient() { } @Override - public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) + public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters) throws DataException { return loadData(first, pageSize, sortField, sortOrder, filters, false, false, false, Arrays.asList(TaskStatus.OPEN, TaskStatus.INWORK)); @@ -210,7 +211,7 @@ public List loadData(int first, int pageSize, String sortField, SortOrd * @return List of loaded tasks * @throws DataException if tasks cannot be loaded from search index */ - public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters, + public List loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters, boolean onlyOwnTasks, boolean hideCorrectionTasks, boolean showAutomaticTasks, List taskStatus) throws DataException { @@ -299,31 +300,31 @@ public List findTaskTitlesDistinct() throws DataException, DAOException } @Override - public TaskDTO convertJSONObjectToDTO(Map jsonObject, boolean related) throws DataException { - TaskDTO taskDTO = new TaskDTO(); - taskDTO.setId(getIdFromJSONObject(jsonObject)); - taskDTO.setTitle(TaskTypeField.TITLE.getStringValue(jsonObject)); - taskDTO.setLocalizedTitle(getLocalizedTitle(taskDTO.getTitle())); - taskDTO.setOrdering(TaskTypeField.ORDERING.getIntValue(jsonObject)); + public TaskInterface convertJSONObjectToInterface(Map jsonObject, boolean related) throws DataException { + TaskInterface taskInterface = DTOFactory.instance().newTask(); + taskInterface.setId(getIdFromJSONObject(jsonObject)); + taskInterface.setTitle(TaskTypeField.TITLE.getStringValue(jsonObject)); + taskInterface.setLocalizedTitle(getLocalizedTitle(taskInterface.getTitle())); + taskInterface.setOrdering(TaskTypeField.ORDERING.getIntValue(jsonObject)); int taskStatus = TaskTypeField.PROCESSING_STATUS.getIntValue(jsonObject); - taskDTO.setProcessingStatus(TaskStatus.getStatusFromValue(taskStatus)); - taskDTO.setProcessingStatusTitle(Helper.getTranslation(taskDTO.getProcessingStatus().getTitle())); + taskInterface.setProcessingStatus(TaskStatus.getStatusFromValue(taskStatus)); + taskInterface.setProcessingStatusTitle(Helper.getTranslation(taskInterface.getProcessingStatus().getTitle())); int editType = TaskTypeField.EDIT_TYPE.getIntValue(jsonObject); - taskDTO.setEditType(TaskEditType.getTypeFromValue(editType)); - taskDTO.setEditTypeTitle(Helper.getTranslation(taskDTO.getEditType().getTitle())); - taskDTO.setProcessingTime(TaskTypeField.PROCESSING_TIME.getStringValue(jsonObject)); - taskDTO.setProcessingBegin(TaskTypeField.PROCESSING_BEGIN.getStringValue(jsonObject)); - taskDTO.setProcessingEnd(TaskTypeField.PROCESSING_END.getStringValue(jsonObject)); - taskDTO.setCorrection(TaskTypeField.CORRECTION.getBooleanValue(jsonObject)); - taskDTO.setTypeAutomatic(TaskTypeField.TYPE_AUTOMATIC.getBooleanValue(jsonObject)); - taskDTO.setTypeMetadata(TaskTypeField.TYPE_METADATA.getBooleanValue(jsonObject)); - taskDTO.setTypeImagesWrite(TaskTypeField.TYPE_IMAGES_WRITE.getBooleanValue(jsonObject)); - taskDTO.setTypeImagesRead(TaskTypeField.TYPE_IMAGES_READ.getBooleanValue(jsonObject)); - taskDTO.setBatchStep(TaskTypeField.BATCH_STEP.getBooleanValue(jsonObject)); - taskDTO.setRoleIds(convertJSONValuesToList(TaskTypeField.ROLES.getJsonArray(jsonObject))); - taskDTO.setRolesSize(TaskTypeField.ROLES.getSizeOfProperty(jsonObject)); - taskDTO.setCorrectionCommentStatus(TaskTypeField.CORRECTION_COMMENT_STATUS.getIntValue(jsonObject)); - convertTaskProjectFromJsonObjectToDTO(jsonObject, taskDTO); + taskInterface.setEditType(TaskEditType.getTypeFromValue(editType)); + taskInterface.setEditTypeTitle(Helper.getTranslation(taskInterface.getEditType().getTitle())); + taskInterface.setProcessingTime(TaskTypeField.PROCESSING_TIME.getStringValue(jsonObject)); + taskInterface.setProcessingBegin(TaskTypeField.PROCESSING_BEGIN.getStringValue(jsonObject)); + taskInterface.setProcessingEnd(TaskTypeField.PROCESSING_END.getStringValue(jsonObject)); + taskInterface.setCorrection(TaskTypeField.CORRECTION.getBooleanValue(jsonObject)); + taskInterface.setTypeAutomatic(TaskTypeField.TYPE_AUTOMATIC.getBooleanValue(jsonObject)); + taskInterface.setTypeMetadata(TaskTypeField.TYPE_METADATA.getBooleanValue(jsonObject)); + taskInterface.setTypeImagesWrite(TaskTypeField.TYPE_IMAGES_WRITE.getBooleanValue(jsonObject)); + taskInterface.setTypeImagesRead(TaskTypeField.TYPE_IMAGES_READ.getBooleanValue(jsonObject)); + taskInterface.setBatchStep(TaskTypeField.BATCH_STEP.getBooleanValue(jsonObject)); + taskInterface.setRoleIds(convertJSONValuesToList(TaskTypeField.ROLES.getJsonArray(jsonObject))); + taskInterface.setRolesSize(TaskTypeField.ROLES.getSizeOfProperty(jsonObject)); + taskInterface.setCorrectionCommentStatus(TaskTypeField.CORRECTION_COMMENT_STATUS.getIntValue(jsonObject)); + convertTaskProjectFromJsonObjectToInterface(jsonObject, taskInterface); /* * We read the list of the process but not the list of templates, because only process tasks @@ -332,35 +333,35 @@ public TaskDTO convertJSONObjectToDTO(Map jsonObject, boolean re */ int process = TaskTypeField.PROCESS_ID.getIntValue(jsonObject); if (process > 0 && !related) { - taskDTO.setProcess(ServiceManager.getProcessService().findById(process, true)); - taskDTO.setBatchAvailable(ServiceManager.getProcessService() - .isProcessAssignedToOnlyOneBatch(taskDTO.getProcess().getBatches())); + taskInterface.setProcess(ServiceManager.getProcessService().findById(process, true)); + taskInterface.setBatchAvailable(ServiceManager.getProcessService() + .isProcessAssignedToOnlyOneBatch(taskInterface.getProcess().getBatches())); } int processingUser = TaskTypeField.PROCESSING_USER_ID.getIntValue(jsonObject); if (processingUser > 0) { - UserDTO userDTO = new UserDTO(); - userDTO.setId(processingUser); - userDTO.setLogin(TaskTypeField.PROCESSING_USER_LOGIN.getStringValue(jsonObject)); - userDTO.setName(TaskTypeField.PROCESSING_USER_NAME.getStringValue(jsonObject)); - userDTO.setSurname(TaskTypeField.PROCESSING_USER_SURNAME.getStringValue(jsonObject)); - userDTO.setFullName(TaskTypeField.PROCESSING_USER_FULLNAME.getStringValue(jsonObject)); - taskDTO.setProcessingUser(userDTO); + UserInterface userInterface = DTOFactory.instance().newUser(); + userInterface.setId(processingUser); + userInterface.setLogin(TaskTypeField.PROCESSING_USER_LOGIN.getStringValue(jsonObject)); + userInterface.setName(TaskTypeField.PROCESSING_USER_NAME.getStringValue(jsonObject)); + userInterface.setSurname(TaskTypeField.PROCESSING_USER_SURNAME.getStringValue(jsonObject)); + userInterface.setFullName(TaskTypeField.PROCESSING_USER_FULLNAME.getStringValue(jsonObject)); + taskInterface.setProcessingUser(userInterface); } - return taskDTO; + return taskInterface; } /** - * Parses and adds properties related to the project of a task to the taskDTO. + * Parses and adds properties related to the project of a task to the taskInterface. * * @param jsonObject the jsonObject retrieved from the ElasticSearch index for a task - * @param taskDTO the taskDTO + * @param taskInterface the taskInterface */ - private void convertTaskProjectFromJsonObjectToDTO(Map jsonObject, TaskDTO taskDTO) throws DataException { - ProjectDTO projectDTO = new ProjectDTO(); - projectDTO.setId(TaskTypeField.PROJECT_ID.getIntValue(jsonObject)); - projectDTO.setTitle(TaskTypeField.PROJECT_TITLE.getStringValue(jsonObject)); - taskDTO.setProject(projectDTO); + private void convertTaskProjectFromJsonObjectToInterface(Map jsonObject, TaskInterface taskInterface) throws DataException { + ProjectInterface projectInterface = DTOFactory.instance().newProject(); + projectInterface.setId(TaskTypeField.PROJECT_ID.getIntValue(jsonObject)); + projectInterface.setTitle(TaskTypeField.PROJECT_TITLE.getStringValue(jsonObject)); + taskInterface.setProject(projectInterface); } private List convertJSONValuesToList(List> jsonObject) { diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/TemplateService.java b/Kitodo/src/main/java/org/kitodo/production/services/data/TemplateService.java index cdb2be13383..223f28b0232 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/TemplateService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/TemplateService.java @@ -42,18 +42,19 @@ import org.kitodo.data.elasticsearch.index.type.enums.TemplateTypeField; import org.kitodo.data.elasticsearch.search.Searcher; import org.kitodo.data.exceptions.DataException; +import org.kitodo.data.interfaces.ProjectInterface; +import org.kitodo.data.interfaces.TaskInterface; +import org.kitodo.data.interfaces.TemplateInterface; +import org.kitodo.data.interfaces.WorkflowInterface; import org.kitodo.exceptions.ProcessGenerationException; -import org.kitodo.production.dto.ProjectDTO; -import org.kitodo.production.dto.TaskDTO; -import org.kitodo.production.dto.TemplateDTO; -import org.kitodo.production.dto.WorkflowDTO; +import org.kitodo.production.dto.DTOFactory; import org.kitodo.production.enums.ObjectType; import org.kitodo.production.helper.Helper; import org.kitodo.production.services.ServiceManager; import org.kitodo.production.services.data.base.ClientSearchService; import org.primefaces.model.SortOrder; -public class TemplateService extends ClientSearchService { +public class TemplateService extends ClientSearchService { private static final Logger logger = LogManager.getLogger(TemplateService.class); private static volatile TemplateService instance = null; @@ -112,7 +113,7 @@ public List