From 0de38bf3674a1b1fc71848a1eeb958e669af2139 Mon Sep 17 00:00:00 2001 From: Matthias Ronge Date: Wed, 30 Oct 2024 07:46:48 +0100 Subject: [PATCH] Fix checkstyle (Kitodo - Core) --- .../org/kitodo/production/forms/IndexingForm.java | 6 +++++- .../kitodo/production/services/data/BeanQuery.java | 14 ++++++++++++++ .../services/data/UserSpecifiedFilterParser.java | 12 ++++++------ .../production/services/index/IndexingService.java | 3 ++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/IndexingForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/IndexingForm.java index 57a360e3a2f..e5ac6257582 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/IndexingForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/IndexingForm.java @@ -60,6 +60,9 @@ public class IndexingForm { } } + /** + * Sets the number of database objects. + */ public static void setNumberOfDatabaseObjects() { for (Entry entry : indexingRows.entrySet()) { long count = 0; @@ -186,7 +189,8 @@ public void startAllIndexing() { * @return the overall progress of the indexing process */ public int getAllIndexingProgress() { - long numerator = 0, denominator = 0; + long numerator = 0; + long denominator = 0; for (IndexingRow indexingRow : indexingRows.values()) { if (indexingRow.getIndexed() >= 0) { numerator += indexingRow.getIndexed(); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/BeanQuery.java b/Kitodo/src/main/java/org/kitodo/production/services/data/BeanQuery.java index 3a500c323eb..8fe2d3dacc4 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/BeanQuery.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/BeanQuery.java @@ -290,6 +290,13 @@ public void restrictToRoles(List roles) { restrictions.add(restriction.toString()); } + /** + * Adds search restrictions entered by the user in the filter input. + * + * @param filterString + * user input + * @see "https://github.com/kitodo/kitodo-production/wiki/Suche-und-Filter" + */ public void restrictWithUserFilterString(String filterString) { int userFilterCount = 0; for (var groupFilter : UserSpecifiedFilterParser.parse(filterString).entrySet()) { @@ -380,6 +387,13 @@ private void innerFormQuery(StringBuilder query) { } } + /** + * Returns the query parameters. + * + * @return the query parameters + * @throws IllegalStateException + * if index queries still need to be made for parameterization + */ public Map getQueryParameters() { if (!indexQueries.isEmpty()) { throw new IllegalStateException("index searches not yet performed"); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/data/UserSpecifiedFilterParser.java b/Kitodo/src/main/java/org/kitodo/production/services/data/UserSpecifiedFilterParser.java index e7be3750a03..c7e83becbff 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/data/UserSpecifiedFilterParser.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/data/UserSpecifiedFilterParser.java @@ -73,8 +73,9 @@ static List parseFilters(String filter) { } } else { // add characters but, no spaces at the beginning - if (tokenCollector.length() > 0 || glyph > ' ') + if (tokenCollector.length() > 0 || glyph > ' ') { tokenCollector.appendCodePoint(glyph); + } } } trimRight(tokenCollector); @@ -115,8 +116,9 @@ private static List parseParentheses(StringBuilder input) { } } else { // add characters but, no spaces at the beginning - if (tokenCollector.length() > 0 || glyph > ' ') + if (tokenCollector.length() > 0 || glyph > ' ') { tokenCollector.appendCodePoint(glyph); + } } } if (tokenCollector.length() > 0) { @@ -162,8 +164,7 @@ private static UserSpecifiedFilter parseQueryPart(StringBuilder item) { // index search return new IndexQueryPart(FilterField.MISC, item.toString()); } else { - // if there is a colon - // disassemble the string + // if there is a colon: disassemble the string String column = item.substring(0, colon).toLowerCase(); String value = item.substring(colon + 1); // is the first one a known search field? @@ -188,8 +189,7 @@ private static UserSpecifiedFilter parseQueryPart(StringBuilder item) { if (idSearch.matches()) { return new DatabaseQueryPart(filterField, idSearch.group(1), idSearch.group(2)); } else { - // if the search field allows an additional colon, then - // search for it + // if the search allows an additional colon, search for it if (filterField.isDivisible()) { // the field allows another colon: then search for it int anotherColon = value.indexOf(":"); diff --git a/Kitodo/src/main/java/org/kitodo/production/services/index/IndexingService.java b/Kitodo/src/main/java/org/kitodo/production/services/index/IndexingService.java index 786150f4083..df74ac1cf4b 100644 --- a/Kitodo/src/main/java/org/kitodo/production/services/index/IndexingService.java +++ b/Kitodo/src/main/java/org/kitodo/production/services/index/IndexingService.java @@ -12,7 +12,8 @@ package org.kitodo.production.services.index; import java.util.Collection; -import java.util.*; +import java.util.List; +import java.util.Objects; import java.util.concurrent.CompletionStage; import org.apache.logging.log4j.LogManager;