From 76d6dbb7f88b63f19fa7e9a5e2fdf8e5325df2b9 Mon Sep 17 00:00:00 2001 From: Arved Solth Date: Tue, 20 Aug 2024 13:21:06 +0200 Subject: [PATCH] Translate metadata keys in mass import record table header --- .../production/forms/massimport/MassImportForm.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/massimport/MassImportForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/massimport/MassImportForm.java index 19b8ec371b9..c406b373130 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/massimport/MassImportForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/massimport/MassImportForm.java @@ -110,7 +110,7 @@ public void handleFileUpload(FileUploadEvent event) { resetValues(); if (!csvLines.isEmpty()) { importedCsvHeaderLine = csvLines.get(0); - metadataKeys = new LinkedList<>(Arrays.asList(csvLines.get(0).split(csvSeparator, -1))); + updateMetadataKeys(); if (csvLines.size() > 1) { importedCsvLines = csvLines.subList(1, csvLines.size()); records = massImportService.parseLines(importedCsvLines, csvSeparator); @@ -133,7 +133,7 @@ private void resetValues() { * Event listender function called when user switches CSV separator character used to split text lines into cells. */ public void changeSeparator() { - metadataKeys = new LinkedList<>(Arrays.asList(importedCsvHeaderLine.split(csvSeparator, -1))); + updateMetadataKeys(); try { records = massImportService.parseLines(importedCsvLines, csvSeparator); } catch (IOException | CsvException e) { @@ -141,6 +141,11 @@ public void changeSeparator() { } } + private void updateMetadataKeys() { + metadataKeys = Arrays.stream(importedCsvHeaderLine.split(csvSeparator, -1)).map(String::trim) + .collect(Collectors.toList()); + } + /** * Add new CSV lines. */ @@ -215,7 +220,7 @@ private void importRecords(Map>> processMetadat */ public String getColumnHeader(Integer columnIndex) { if (columnIndex < metadataKeys.size()) { - return metadataKeys.get(columnIndex); + return Helper.getTranslation(metadataKeys.get(columnIndex)); } return ""; }