Skip to content

Commit

Permalink
Implement the interfaces on the services
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-ronge committed Apr 23, 2024
1 parent 8f7c641 commit ececb2a
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public List<Process> getSelectedProcesses() {
ProcessService processService = ServiceManager.getProcessService();
if (allSelected) {
try {
this.selectedProcessesOrProcessDTOs = processService.findByQuery(processService.getQueryForFilter(
this.isShowClosedProcesses(), isShowInactiveProjects(), getFilter())
.mustNot(processService.createSetQueryForIds(new ArrayList<>(excludedProcessIds))), false);
this.selectedProcessesOrProcessDTOs = processService.findSelectedProcesses(
this.isShowClosedProcesses(), isShowInactiveProjects(), getFilter(),
new ArrayList<>(excludedProcessIds));
} catch (DataException e) {
logger.error(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand All @@ -36,9 +37,11 @@
import org.kitodo.production.helper.Helper;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.TitleSearchService;
import org.kitodo.production.services.data.interfaces.DatabaseBatchServiceInterface;
import org.primefaces.model.SortOrder;

public class BatchService extends TitleSearchService<Batch, BatchInterface, BatchDAO> {
public class BatchService extends TitleSearchService<Batch, BatchInterface, BatchDAO>
implements DatabaseBatchServiceInterface {

private static volatile BatchService instance = null;
private static final String BATCH = "batch";
Expand Down Expand Up @@ -120,7 +123,7 @@ public List<Batch> loadData(int first, int pageSize, String sortField, SortOrder
* @param batches
* to remove
*/
public void removeAll(Iterable<Batch> batches) throws DataException {
public void removeAll(Collection<Batch> batches) throws DataException {
for (Batch batch : batches) {
remove(batch);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
import org.kitodo.production.dto.DTOFactory;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.ClientSearchService;
import org.kitodo.production.services.data.interfaces.DatabaseDocketServiceInterface;
import org.primefaces.model.SortOrder;

public class DocketService extends ClientSearchService<Docket, DocketInterface, DocketDAO> {
public class DocketService extends ClientSearchService<Docket, DocketInterface, DocketDAO>
implements DatabaseDocketServiceInterface {

private static volatile DocketService instance = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,14 @@
import org.kitodo.production.helper.Helper;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.SearchService;
import org.kitodo.production.services.data.interfaces.DatabaseFilterServiceInterface;
import org.primefaces.model.SortOrder;

/**
* Service for Filter bean.
*/
public class FilterService extends SearchService<Filter, FilterInterface, FilterDAO> {
public class FilterService extends SearchService<Filter, FilterInterface, FilterDAO>
implements DatabaseFilterServiceInterface {

private static final Logger logger = LogManager.getLogger(FilterService.class);
private static volatile FilterService instance = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
import org.kitodo.production.metadata.copier.DataCopier;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.ProjectSearchService;
import org.kitodo.production.services.data.interfaces.DatabaseProcessServiceInterface;
import org.kitodo.production.services.dataformat.MetsService;
import org.kitodo.production.services.file.FileService;
import org.kitodo.production.services.workflow.WorkflowControllerService;
Expand All @@ -175,7 +176,8 @@
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class ProcessService extends ProjectSearchService<Process, ProcessInterface, ProcessDAO> {
public class ProcessService extends ProjectSearchService<Process, ProcessInterface, ProcessDAO>
implements DatabaseProcessServiceInterface {
private static final FileService fileService = ServiceManager.getFileService();
private static final Logger logger = LogManager.getLogger(ProcessService.class);
private static volatile ProcessService instance = null;
Expand Down Expand Up @@ -823,6 +825,14 @@ public List<ProcessInterface> findLinkableParentProcesses(String searchInput, in
return findByQuery(query, false);
}

@Override
public List<ProcessInterface> findSelectedProcesses(boolean showClosedProcesses, boolean showInactiveProjects,
String filter, Collection<Integer> excludedProcessIds) throws DataException {
return findByQuery(getQueryForFilter(showClosedProcesses, showInactiveProjects, filter)
.mustNot(createSetQueryForIds(new ArrayList<>(excludedProcessIds))),
false);
}

/**
* Find processes by property.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@
import org.kitodo.production.helper.Helper;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.ClientSearchService;
import org.kitodo.production.services.data.interfaces.DatabaseProjectServiceInterface;
import org.primefaces.model.SortOrder;

public class ProjectService extends ClientSearchService<Project, ProjectInterface, ProjectDAO> {
public class ProjectService extends ClientSearchService<Project, ProjectInterface, ProjectDAO>
implements DatabaseProjectServiceInterface {

private static volatile ProjectService instance = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@
import org.kitodo.production.helper.metadata.legacytypeimplementations.LegacyPrefsHelper;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.ClientSearchService;
import org.kitodo.production.services.data.interfaces.DatabaseRulesetServiceInterface;
import org.primefaces.model.SortOrder;

public class RulesetService extends ClientSearchService<Ruleset, RulesetInterface, RulesetDAO> {
public class RulesetService extends ClientSearchService<Ruleset, RulesetInterface, RulesetDAO>
implements DatabaseRulesetServiceInterface {

private static final Logger logger = LogManager.getLogger(RulesetService.class);
private static volatile RulesetService instance = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
import org.kitodo.production.services.command.CommandService;
import org.kitodo.production.services.command.KitodoScriptService;
import org.kitodo.production.services.data.base.ProjectSearchService;
import org.kitodo.production.services.data.interfaces.DatabaseTaskServiceInterface;
import org.kitodo.production.services.file.SubfolderFactoryService;
import org.kitodo.production.services.image.ImageGenerator;
import org.kitodo.production.services.workflow.WorkflowControllerService;
Expand All @@ -82,7 +83,7 @@
* functions on the task because the task itself is a database bean and
* therefore may not include functionality.
*/
public class TaskService extends ProjectSearchService<Task, TaskInterface, TaskDAO> {
public class TaskService extends ProjectSearchService<Task, TaskInterface, TaskDAO> implements DatabaseTaskServiceInterface {

private static final Logger logger = LogManager.getLogger(TaskService.class);
private static volatile TaskService instance = null;
Expand Down Expand Up @@ -173,7 +174,7 @@ public Long countResults(Map filters) throws DataException {
return countResults(new HashMap<String, String>(filters), false, false, false, null);
}

public Long countResults(HashMap<String, String> filters, boolean onlyOwnTasks, boolean hideCorrectionTasks,
public Long countResults(Map<?, String> filters, boolean onlyOwnTasks, boolean hideCorrectionTasks,
boolean showAutomaticTasks, List<TaskStatus> taskStatus)
throws DataException {
return countDocuments(createUserTaskQuery(ServiceManager.getFilterService().parseFilterString(filters),
Expand Down Expand Up @@ -212,7 +213,7 @@ public List<TaskInterface> loadData(int first, int pageSize, String sortField, S
* @return List of loaded tasks
* @throws DataException if tasks cannot be loaded from search index
*/
public List<TaskInterface> loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map filters,
public List<TaskInterface> loadData(int first, int pageSize, String sortField, SortOrder sortOrder, Map<?, String> filters,
boolean onlyOwnTasks, boolean hideCorrectionTasks, boolean showAutomaticTasks,
List<TaskStatus> taskStatus)
throws DataException {
Expand Down Expand Up @@ -704,7 +705,7 @@ List<Map<String, Object>> findByProcessId(Integer id) throws DataException {
* of template
* @return list of JSON objects with tasks for specific template id
*/
List<Map<String, Object>> findByTemplateId(Integer id) throws DataException {
public List<Map<String, Object>> findByTemplateId(Integer id) throws DataException {
return findDocuments(getQueryForTemplate(id));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@
import org.kitodo.production.helper.Helper;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.ClientSearchService;
import org.kitodo.production.services.data.interfaces.DatabaseTemplateServiceInterface;
import org.primefaces.model.SortOrder;

public class TemplateService extends ClientSearchService<Template, TemplateInterface, TemplateDAO> {
public class TemplateService extends ClientSearchService<Template, TemplateInterface, TemplateDAO>
implements DatabaseTemplateServiceInterface {

private static final Logger logger = LogManager.getLogger(TemplateService.class);
private static volatile TemplateService instance = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
import org.kitodo.production.helper.Helper;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.base.ClientSearchService;
import org.kitodo.production.services.data.interfaces.DatabaseWorkflowServiceInterface;
import org.primefaces.model.SortOrder;

public class WorkflowService extends ClientSearchService<Workflow, WorkflowInterface, WorkflowDAO> {
public class WorkflowService extends ClientSearchService<Workflow, WorkflowInterface, WorkflowDAO>
implements DatabaseWorkflowServiceInterface {

private static volatile WorkflowService instance = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
import org.kitodo.data.database.exceptions.DAOException;
import org.kitodo.data.database.persistence.BaseDAO;
import org.kitodo.data.exceptions.DataException;
import org.kitodo.production.services.data.interfaces.SearchDatabaseServiceInterface;
import org.primefaces.model.SortOrder;

public abstract class SearchDatabaseService<T extends BaseBean, S extends BaseDAO<T>> {
public abstract class SearchDatabaseService<T extends BaseBean, S extends BaseDAO<T>>
implements SearchDatabaseServiceInterface<T> {

protected S dao;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface DatabaseBatchServiceInterface extends SearchDatabaseServiceInte
* <p>
* <b>Implementation Note:</b><br>
* The function must get all processes from each batch and delete the
* batches to be deleted in each process before, it deletes the batches.
* batches to be deleted in each process, before it deletes the batches.
*
* @param batches
* batches to delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand All @@ -27,6 +28,7 @@
import org.kitodo.data.exceptions.DataException;
import org.kitodo.data.interfaces.ProcessInterface;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.FilterService;
import org.kitodo.production.services.dataformat.MetsService;
import org.kitodo.production.services.file.FileService;
import org.primefaces.model.SortOrder;
Expand Down Expand Up @@ -303,8 +305,8 @@ default Long findNumberOfProcessesWithTitle(String title) throws DataException {
* @throws DataException
* if an error occurs
*/
List<Process> findSelectedProcesses(boolean showClosedProcesses, boolean showInactiveProjects, String filter,
Collection<Integer> excludedProcessIds) throws DataException;
List<ProcessInterface> findSelectedProcesses(boolean showClosedProcesses, boolean showInactiveProjects,
String filter, Collection<Integer> excludedProcessIds) throws DataException;

/**
* Determines the number of processes that match the specified filter
Expand Down Expand Up @@ -384,14 +386,14 @@ default int getNumberOfChildren(int processId) throws DAOException {
* @param process
* process for which the data record number should be placed in
* the processBaseUri field
* @return the record number in a URI object
* @return the record number
*/
/*
* Since the moment this was introduced, I've never understood why this
* exists. Nor why property processBaseUri exists at all. See #5856
*/
default URI getProcessDataDirectory(ProcessInterface process) {
return getProcessDataDirectory((Process) process, false);
default String getProcessDataDirectory(ProcessInterface process) {
return getProcessDataDirectory((Process) process, false).toString();
}

/**
Expand Down Expand Up @@ -429,8 +431,8 @@ default URI getProcessDataDirectory(Process process, boolean forIndexingAll) {
*
* <p>
* <b>API Note:</b><br>
* This function counts the data records for the client, for which the
* logged in user is currently working.
* This function returns the processes for the client, for which the logged
* in user is currently working.
*
* <p>
* <b>Implementation Requirements:</b><br>
Expand All @@ -448,8 +450,11 @@ default URI getProcessDataDirectory(Process process, boolean forIndexingAll) {
* @throws DataException
* if an error occurs
*/
List<ProcessInterface> getResultsWithFilter(String filter, boolean showClosedProcesses,
boolean showInactiveProjects) throws DataException;
default List<ProcessInterface> getResultsWithFilter(String filter, boolean showClosedProcesses,
boolean showInactiveProjects) throws DataException {
return loadData(0, Integer.MAX_VALUE, "id", SortOrder.ASCENDING,
Collections.singletonMap(FilterService.FILTER_STRING, filter), showClosedProcesses, showInactiveProjects);
}

/**
* Returns processes to be offered as templates in the selection list. If a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ default void removeFromIndex(Integer id, boolean forceRefresh) throws CustomResp
* @deprecated Does nothing anymore and can be deleted.
*/
@Deprecated
default void removeLooseIndexData(List<Integer> baseIndexedBeansId) {
default void removeLooseIndexData(List<Integer> baseIndexedBeansId) throws DataException, CustomResponseException {
}

/**
Expand Down

0 comments on commit ececb2a

Please sign in to comment.