Skip to content

Commit

Permalink
Fix display of import dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
solth committed Nov 5, 2024
1 parent a04fd3b commit 31edbed
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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();");
}
}
}

Expand Down Expand Up @@ -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.
Expand All @@ -855,10 +830,14 @@ public Collection<RecordIdentifierMissingDetail> 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());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TempProcess> processes = ServiceManager.getImportService().processUploadedFile(createProcessForm);
createProcessForm.setCurrentImportConfiguration(importConfiguration);

if (!createProcessForm.getProcesses().isEmpty() && additionalImport) {
extendsMetadataTableOfMetadataTab(processes);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
xmlns:p="http://primefaces.org/ui">

<p:dialog widgetVar="fileUploadDialog"
id="fileUpload"
id="fileUploadDialog"
width="578"
modal="true"
visible="#{CreateProcessForm.defaultConfigurationType eq 'FILE_UPLOAD'}"
visible="#{false}"
appendTo="@(body)"
resizable="false">
<h3>#{msgs['newProcess.fileUpload.heading']}</h3>
Expand All @@ -49,7 +49,7 @@
</div>
</p:row>
</p:panelGrid>
<p:panelGrid rendered="#{CreateProcessForm.currentImportConfiguration ne null}">
<p:panelGrid>
<p:row>
<div>
<p:outputLabel for="additionalImport" value="#{msgs['newProcess.catalogueSearch.additionalImport']}"/>
Expand Down Expand Up @@ -77,6 +77,7 @@
id="fileUploadButton">
<p:commandButton id="close"
value="#{msgs.close}"
process="@this"
styleClass="secondary right"
icon="fa fa-times fa-lg"
iconPos="right"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
xmlns:p="http://primefaces.org/ui">

<p:dialog widgetVar="catalogSearchDialog"
id="catalogSearch"
id="catalogSearchDialog"
width="640"
modal="true"
appendTo="@(body)"
visible="#{CreateProcessForm.defaultConfigurationType eq 'OPAC_SEARCH'}"
visible="#{false}"
resizable="false">
<h3>#{msgs['newProcess.catalogueSearch.heading']}</h3>
<h:form id="catalogSearchForm"
Expand Down Expand Up @@ -133,6 +133,7 @@
update="editForm hitlist"/>
<p:commandButton id="cancel"
value="#{msgs.cancel}"
process="@this"
styleClass="secondary right"
icon="fa fa-times fa-lg"
iconPos="right"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
id="searchEditDialog"
width="578"
modal="true"
visible="#{CreateProcessForm.defaultConfigurationType eq 'PROCESS_TEMPLATE'}"
visible="#{false}"
appendTo="@(body)"
resizable="false">
<h3>#{msgs.processTemplate}</h3>
Expand Down Expand Up @@ -58,6 +58,7 @@
icon="fa fa-download" iconPos="right"/>
<p:commandButton id="close"
value="#{msgs.close}"
process="@this"
styleClass="secondary right"
icon="fa fa-times fa-lg"
iconPos="right"
Expand Down
4 changes: 3 additions & 1 deletion Kitodo/src/main/webapp/pages/processFromTemplate.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
<h:outputText value="#{msgs.createNewProcess} (#{msgs.template}: '#{CreateProcessForm.template.title}')"
styleClass="shortable"/>
</h3>

<p:button id="cancel"
value="#{msgs.cancel}"
onclick="setConfirmUnload(false);"
Expand All @@ -53,6 +52,7 @@
<p:menuitem id="opacSearch"
process="@this"
value="#{msgs['newProcess.catalogueSearch.heading']}"
actionListener="#{CreateProcessForm.setCurrentImportConfiguration(null)}"
action="#{CreateProcessForm.checkRulesetConfiguration()}"
disabled="#{empty CreateProcessForm.catalogImportDialog.importConfigurations}"
icon="fa fa-book"
Expand All @@ -63,6 +63,7 @@
<p:menuitem id="fileUpload"
process="@this"
value="#{msgs['newProcess.fileUpload.heading']}"
actionListener="#{CreateProcessForm.setCurrentImportConfiguration(null)}"
oncomplete="PF('fileUploadDialog').show();"
disabled="#{empty CreateProcessForm.fileUploadDialog.importConfigurations}"
icon="fa fa-upload"
Expand All @@ -73,6 +74,7 @@
<p:menuitem id="searchEdit"
process="@this"
value="#{msgs.processTemplate}"
actionListener="#{CreateProcessForm.setCurrentImportConfiguration(null)}"
oncomplete="PF('searchEditDialog').show();"
disabled="#{empty CreateProcessForm.searchDialog.processesForChoiceList}"
icon="fa fa-copy"
Expand Down

0 comments on commit 31edbed

Please sign in to comment.