From 31edbed49129ac98a751c4f81dde3de679810536 Mon Sep 17 00:00:00 2001 From: Arved Solth Date: Tue, 5 Nov 2024 16:52:22 +0100 Subject: [PATCH] Fix display of import dialogs --- .../createprocess/CreateProcessForm.java | 63 +++++++------------ .../forms/createprocess/FileUploadDialog.java | 3 - .../dialogs/fileUpload.xhtml | 7 ++- .../processFromTemplate/dialogs/import.xhtml | 5 +- .../dialogs/searchEdit.xhtml | 3 +- .../webapp/pages/processFromTemplate.xhtml | 4 +- 6 files changed, 33 insertions(+), 52 deletions(-) diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java index 888ea47847b..b7f2b7900e3 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java @@ -102,7 +102,6 @@ public class CreateProcessForm extends BaseForm implements MetadataTreeTableInte private int progress; private TempProcess currentProcess; private Boolean rulesetConfigurationForOpacImportComplete = null; - private String defaultConfigurationType; private ImportConfiguration currentImportConfiguration; static final int TITLE_RECORD_LINK_TAB_INDEX = 1; @@ -448,10 +447,8 @@ public void prepareProcess(int templateId, int projectId, String referringView, project = processGenerator.getProject(); template = processGenerator.getTemplate(); updateRulesetAndDocType(getMainProcess().getRuleset()); - if (Objects.nonNull(project) && Objects.nonNull(project.getDefaultImportConfiguration())) { - setDefaultImportConfiguration(project.getDefaultImportConfiguration()); - } else { - defaultConfigurationType = null; + if (Objects.nonNull(project)) { + currentImportConfiguration = project.getDefaultImportConfiguration(); } if (Objects.nonNull(parentId) && parentId != 0) { ProcessDTO parentProcess = ServiceManager.getProcessService().findById(parentId); @@ -467,42 +464,29 @@ public void prepareProcess(int templateId, int projectId, String referringView, titleRecordLinkTab.setChosenParentProcess(String.valueOf(parentId)); titleRecordLinkTab.chooseParentProcess(); if (Objects.nonNull(project.getDefaultChildProcessImportConfiguration())) { - setDefaultImportConfiguration(project.getDefaultChildProcessImportConfiguration()); - } else { - defaultConfigurationType = null; + currentImportConfiguration = project.getDefaultChildProcessImportConfiguration(); } if (setChildCount(titleRecordLinkTab.getTitleRecordProcess(), rulesetManagement, workpiece)) { updateRulesetAndDocType(getMainProcess().getRuleset()); } } processDataTab.prepare(); - showDefaultImportConfigurationDialog(); + showDialogForImportConfiguration(currentImportConfiguration); } } catch (ProcessGenerationException | DataException | DAOException | IOException e) { Helper.setErrorMessage(e.getLocalizedMessage(), logger, e); } } - private void showDefaultImportConfigurationDialog() { - if (ImportConfigurationType.OPAC_SEARCH.name().equals(defaultConfigurationType)) { - checkRulesetConfiguration(); - } else if (ImportConfigurationType.FILE_UPLOAD.name().equals(defaultConfigurationType)) { - PrimeFaces.current().executeScript("PF('fileUploadDialog').show()"); - } else if (ImportConfigurationType.PROCESS_TEMPLATE.name().equals(defaultConfigurationType)) { - PrimeFaces.current().executeScript("PF('searchEditDialog').show()"); - } - } - - private void setDefaultImportConfiguration(ImportConfiguration importConfiguration) { - defaultConfigurationType = importConfiguration.getConfigurationType(); - this.setCurrentImportConfiguration(importConfiguration); - if (ImportConfigurationType.OPAC_SEARCH.name().equals(importConfiguration.getConfigurationType())) { - PrimeFaces.current().ajax().update("catalogSearchDialog"); - } else if (ImportConfigurationType.PROCESS_TEMPLATE.name().equals(importConfiguration.getConfigurationType())) { - searchDialog.setOriginalProcess(importConfiguration.getDefaultTemplateProcess()); - PrimeFaces.current().ajax().update("searchEditDialog"); - } else if (ImportConfigurationType.FILE_UPLOAD.name().equals(importConfiguration.getConfigurationType())) { - PrimeFaces.current().ajax().update("fileUploadDialog"); + private void showDialogForImportConfiguration(ImportConfiguration importConfiguration) { + if (Objects.nonNull(importConfiguration)) { + if (ImportConfigurationType.OPAC_SEARCH.name().equals(importConfiguration.getConfigurationType())) { + PrimeFaces.current().executeScript("PF('catalogSearchDialog').show();"); + } else if (ImportConfigurationType.PROCESS_TEMPLATE.name().equals(importConfiguration.getConfigurationType())) { + PrimeFaces.current().executeScript("PF('searchEditDialog').show();"); + } else if (ImportConfigurationType.FILE_UPLOAD.name().equals(importConfiguration.getConfigurationType())) { + PrimeFaces.current().executeScript("PF('fileUploadDialog').show();"); + } } } @@ -829,15 +813,6 @@ public void checkRulesetConfiguration() { PrimeFaces.current().executeScript("PF('recordIdentifierMissingDialog').show();"); } } - - /** - * Get defaultConfigurationType. - * - * @return value of defaultConfigurationType - */ - public String getDefaultConfigurationType() { - return defaultConfigurationType; - } /** * Returns the details of the missing record identifier error. @@ -855,10 +830,14 @@ public Collection getDetailsOfRecordIdentifierMis */ public void setCurrentImportConfiguration(ImportConfiguration currentImportConfiguration) { this.currentImportConfiguration = currentImportConfiguration; - if (Objects.nonNull(currentImportConfiguration) && ImportConfigurationType.OPAC_SEARCH.name() - .equals(currentImportConfiguration.getConfigurationType())) { - this.catalogImportDialog.setImportDepth(ImportService.getDefaultImportDepth(currentImportConfiguration)); - this.catalogImportDialog.setSelectedField(ImportService.getDefaultSearchField(currentImportConfiguration)); + if (Objects.nonNull(currentImportConfiguration)) { + if (ImportConfigurationType.OPAC_SEARCH.name().equals(currentImportConfiguration.getConfigurationType())) { + catalogImportDialog.setImportDepth(ImportService.getDefaultImportDepth(currentImportConfiguration)); + catalogImportDialog.setSelectedField(ImportService.getDefaultSearchField(currentImportConfiguration)); + } + else if (ImportConfigurationType.PROCESS_TEMPLATE.name().equals(currentImportConfiguration.getConfigurationType())) { + searchDialog.setOriginalProcess(currentImportConfiguration.getDefaultTemplateProcess()); + } } } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/FileUploadDialog.java b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/FileUploadDialog.java index 35e7a9dcb77..b5252e7949a 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/FileUploadDialog.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/FileUploadDialog.java @@ -84,10 +84,7 @@ public void handleFileUpload(FileUploadEvent event) { private void processXmlString() throws UnsupportedFormatException, XPathExpressionException, ProcessGenerationException, URISyntaxException, IOException, ParserConfigurationException, SAXException, InvalidMetadataValueException, TransformerException, NoSuchMetadataFieldException, DAOException { - ImportConfiguration importConfiguration = createProcessForm.getCurrentImportConfiguration(); LinkedList processes = ServiceManager.getImportService().processUploadedFile(createProcessForm); - createProcessForm.setCurrentImportConfiguration(importConfiguration); - if (!createProcessForm.getProcesses().isEmpty() && additionalImport) { extendsMetadataTableOfMetadataTab(processes); } else { diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/processFromTemplate/dialogs/fileUpload.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/processFromTemplate/dialogs/fileUpload.xhtml index 076be5f076c..0469003941f 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/processFromTemplate/dialogs/fileUpload.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/processFromTemplate/dialogs/fileUpload.xhtml @@ -19,10 +19,10 @@ xmlns:p="http://primefaces.org/ui">

#{msgs['newProcess.fileUpload.heading']}

@@ -49,7 +49,7 @@ - +
@@ -77,6 +77,7 @@ id="fileUploadButton">

#{msgs['newProcess.catalogueSearch.heading']}

#{msgs.processTemplate}

@@ -58,6 +58,7 @@ icon="fa fa-download" iconPos="right"/> -