Skip to content

Commit

Permalink
Merge pull request kitodo#6186 from effective-webwork/massimport-tran…
Browse files Browse the repository at this point in the history
…slate-metadata-keys

Translate metadata keys in mass import record table header
  • Loading branch information
solth authored Aug 26, 2024
2 parents 56aa1c5 + 76d6dbb commit e68fd3c
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -133,14 +133,19 @@ 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) {
Helper.setErrorMessage(e);
}
}

private void updateMetadataKeys() {
metadataKeys = Arrays.stream(importedCsvHeaderLine.split(csvSeparator, -1)).map(String::trim)
.collect(Collectors.toList());
}

/**
* Add new CSV lines.
*/
Expand Down Expand Up @@ -215,7 +220,7 @@ private void importRecords(Map<String, Map<String, List<String>>> processMetadat
*/
public String getColumnHeader(Integer columnIndex) {
if (columnIndex < metadataKeys.size()) {
return metadataKeys.get(columnIndex);
return Helper.getTranslation(metadataKeys.get(columnIndex));
}
return "";
}
Expand Down

0 comments on commit e68fd3c

Please sign in to comment.