From 55391d6b02be357779ff2ff604da343d707e1a73 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Wed, 6 Oct 2021 13:25:56 +0200 Subject: [PATCH] #3408 improvements from the review --- .../forms/createprocess/ProcessDataTab.java | 6 +++--- .../production/process/TitleGenerator.java | 2 +- .../production/services/data/ImportService.java | 2 +- .../services/data/ProcessService.java | 17 ++++++++--------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDataTab.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDataTab.java index eedae06fb9f..51255d8093f 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDataTab.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessDataTab.java @@ -242,14 +242,14 @@ private String getTitleFromMetaXML(Process process) { } catch (IOException e) { logger.error(e.getMessage(), e); } - return null; + return StringUtils.EMPTY; } private String getTitleFromAncestors() { int processesSize = createProcessForm.getProcesses().size(); if (processesSize <= 1) { - return null; + return StringUtils.EMPTY; } List ancestors = createProcessForm.getProcesses().subList(1, processesSize); @@ -264,7 +264,7 @@ private String getTitleFromAncestors() { return ((MetadataEntry) metadataOptional.get()).getValue(); } } - return null; + return StringUtils.EMPTY; } /** diff --git a/Kitodo/src/main/java/org/kitodo/production/process/TitleGenerator.java b/Kitodo/src/main/java/org/kitodo/production/process/TitleGenerator.java index 80142fc1176..1e05d5d5726 100644 --- a/Kitodo/src/main/java/org/kitodo/production/process/TitleGenerator.java +++ b/Kitodo/src/main/java/org/kitodo/production/process/TitleGenerator.java @@ -161,7 +161,7 @@ public static String getValueOfMetadataID(String metadataID, List return ImportService.getProcessDetailValue(row); } } - return null; + return StringUtils.EMPTY; } private String evaluateAdditionalDetailsRows(String currentTitle, String currentAuthors, String token) 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 21153b2e7a2..42df13d0625 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 @@ -979,7 +979,7 @@ public static void createProcessTitle(TempProcess tempProcess, StructuralElementViewInterface docTypeView = rulesetManagementInterface .getStructuralElementView(docType, acquisitionStage, priorityList); String processTitle = docTypeView.getProcessTitle().orElse(""); - ProcessService.generateProcessTitleAndGetAtstsl(processDetails, + ProcessService.generateProcessTitle(processDetails, processTitle, tempProcess.getProcess()); } 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 0a885ce4480..d9e731fe820 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 @@ -169,6 +169,7 @@ import com.itextpdf.text.pdf.PdfPTable; import com.itextpdf.text.pdf.PdfWriter; + public class ProcessService extends ProjectSearchService { private final FileService fileService = ServiceManager.getFileService(); private static final Logger logger = LogManager.getLogger(ProcessService.class); @@ -2290,14 +2291,12 @@ private HashSet getProcessesLinkedInLogicalDivision( } /** - * Generate and set the title to process and gets the atstsl. - * - * @return String atstsl + * Generate and set the title to process. */ - public static String generateProcessTitleAndGetAtstsl(List processDetails, String titleDefinition, - Process process) throws ProcessGenerationException { - return generateProcessTitleAndGetAtstsl(processDetails, titleDefinition, process, - TitleGenerator.getValueOfMetadataID(TitleGenerator.TITLE_DOC_MAIN, processDetails)); + public static void generateProcessTitle(List processDetails, String titleDefinition, Process process) + throws ProcessGenerationException { + generateProcessTitleAndGetAtstsl(processDetails, titleDefinition, process, + TitleGenerator.getValueOfMetadataID(TitleGenerator.TITLE_DOC_MAIN, processDetails)); } /** @@ -2311,7 +2310,7 @@ public static String generateProcessTitleAndGetAtstsl(List proces public static String generateProcessTitleAndGetAtstsl(List processDetails, String titleDefinition, Process process, String title) throws ProcessGenerationException { TitleGenerator titleGenerator = new TitleGenerator(null, processDetails); - String newTitle = titleGenerator.generateTitle(titleDefinition, null, (Objects.nonNull(title) ? title : "")); + String newTitle = titleGenerator.generateTitle(titleDefinition, null, title); process.setTitle(newTitle); // atstsl is created in title generator and next used in tiff header generator return titleGenerator.getAtstsl(); @@ -2434,7 +2433,7 @@ public static void deleteSymlinksFromUserHomes(Task task) { } /** - * Get the note list from metadata file by the xpath. + * Get the node list from metadata file by the xpath. * * @param process * The process for which the metadata file is searched for