Skip to content

Refactor mass import page to use base list view instead of base edit view#6983

Merged
solth merged 10 commits intokitodo:mainfrom
solth:refactor-mass-import-page
Apr 17, 2026
Merged

Refactor mass import page to use base list view instead of base edit view#6983
solth merged 10 commits intokitodo:mainfrom
solth:refactor-mass-import-page

Conversation

@solth
Copy link
Copy Markdown
Member

@solth solth commented Apr 13, 2026

Fixes #6805 by refactoring the mass import page so that it is not based upon the baseEditView.xhtml template anymore and thus can continue to use the required enctype="multipart/form-data"

@solth solth requested a review from thomaslow April 13, 2026 16:40
@BartChris
Copy link
Copy Markdown
Collaborator

also to check: #6883

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 13, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 14, 2026

also to check: #6883

@BartChris would you mind reviewing this pull request, with that particular issue in mind, as you worked on the mass import quite a lot yourself?

@solth solth added the import Import mappings and configurations label Apr 14, 2026
@solth solth requested review from BartChris and removed request for thomaslow April 14, 2026 11:52
Comment thread Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/massImportTab.xhtml Outdated
@BartChris
Copy link
Copy Markdown
Collaborator

When the uploaded csv file gets bigger i run into problems:

I uploaded a csv file with 453 rows:

image

When removing one of the red marked pseudo columns or when trying to switch the catalog the table is emptied:

image image

Comment thread Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/massImportTab.xhtml Outdated
@BartChris
Copy link
Copy Markdown
Collaborator

BartChris commented Apr 15, 2026

When uploading a bigger csv file the "Add metadata" dialog is just an empty dialog:

image

vs

image

Edit: OK the fix for this button is the same:

   <p:commandButton id="addMetadataColumn"
                                         title="#{msgs['dataEditor.addMetadata.newMetadata']}"
                                         disabled="#{MassImportForm.records.size() eq 0}"
                                         process="@this"
                                         partialSubmit="true"
                                         style="margin: 3px"
                                         icon="fa fa-plus"
                                         styleClass="secondary"
                                         action="#{MassImportForm.addMetadataDialog.prepareMetadataTypes()}"
                                         update="addMetadataDialog"
                                         oncomplete="PF('addMetadataDialog').show();"/>

@BartChris
Copy link
Copy Markdown
Collaborator

Maybe @henning-gerhardt can also check if his issue with the role settings is fixed, because the error always comes down to the number of elements edited.

@BartChris
Copy link
Copy Markdown
Collaborator

I just noticed that the problems i encountered also appear in 3.9.0.

@henning-gerhardt
Copy link
Copy Markdown
Collaborator

As we at SLUB did not use the mass import feature and all changes are only focused on mass import I don't think that this pull request is fixing #6805 in first place. The comments in #6805 are switching fast from the original issue to an other maybe related issue and so I don't think that the main issue is fixed with this changes here.

@henning-gerhardt
Copy link
Copy Markdown
Collaborator

henning-gerhardt commented Apr 15, 2026

I tried it again and #6805 is already fixed by some changes between December 2025 and April 2026. So this pull request is not really related to the original issue of #6805 but maybe still to the comments in #6805.

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 15, 2026

I tried it again and #6805 is already fixed by some changes between December 2025 and April 2026. So this pull request is not really related to the original issue of #6805 but maybe still to the comments in #6805.

Yes, exactly. The linked issue was already fixed by #6810, I think, and the necessity to refactor the mass import form resulted from the changes in that pull request.

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 15, 2026

@BartChris thanks a lot for your review and suggestions, which fixed the problems you reported. (I commited them manually instead of applying the suggestions via GitHub because some indentations seemed to be lost in the suggestions).

I also increased the sizeLimit to a hopefully more reasonble value (and rebased against the current main branch).

Would you mind checking the pull request again?

@solth solth force-pushed the refactor-mass-import-page branch from 3415193 to 1022eef Compare April 15, 2026 12:17
@solth solth requested a review from BartChris April 15, 2026 13:19
@solth solth force-pushed the refactor-mass-import-page branch from 1022eef to 0c08d89 Compare April 16, 2026 09:13
Comment thread Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/massImportTab.xhtml Outdated
@BartChris
Copy link
Copy Markdown
Collaborator

BartChris commented Apr 16, 2026

I noticed that the MassImport button to trigger the import is never activated. (Maybe because of the changes i suggested)

image

I suppose we have to update it explicitely whenever we execute an action. I tested it with the catalogueSelect box and added massImportButtonForm to the list of to be updated components. Now the button is enabled after switching the catalog.

  <p:selectOneMenu id="catalogueSelect"
                                     disabled="#{not MassImportForm.firstColumnContainsRecordsIdentifier()}"
                                     required="#{not empty param['massImportButtonForm:importButton']}"
                                     converter="#{importConfigurationConverter}"
                                     value="#{MassImportForm.importConfigurationId}">
                        <f:selectItem itemValue="#{null}"
                                      itemLabel="-- #{msgs.selectCatalog} --"
                                      noSelectionOption="true"/>
                        <f:selectItems value="#{CreateProcessForm.catalogImportDialog.importConfigurations}"
                                       var="configuration"
                                       itemLabel="#{configuration.title}"
                                       itemValue="#{configuration}"/>
                        <p:ajax process="@this"
                                partialSubmit="true"
                                update="recordsForm massImportButtonForm"/>
                    </p:selectOneMenu>

@solth solth marked this pull request as draft April 16, 2026 14:11
@BartChris
Copy link
Copy Markdown
Collaborator

BartChris commented Apr 16, 2026

This is not directly related to the PR and can maybe be fixed later, but i am wondering if we should spam the screen with tons of messages for every imported row:

image

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 16, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 2 duplication

Metric Results
Complexity 0
Duplication 2

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 16, 2026

This is not directly related to the PR and can maybe be fixed later, but i am wondering if we should spam the screen with tons of messages for every imported row:

Yes, that's suboptimal, and yes, we should address that in a separate pull request.

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 17, 2026

@BartChris I get a FacesException when trying to edit cell contents from slightly larger CSV files (about 100 rows), which I cannot explain, yet. Maybe it has something to do with lazy loading additional entries, but I don't now for sure.

@solth solth force-pushed the refactor-mass-import-page branch from d2ae1ff to 8ddb6f9 Compare April 17, 2026 08:50
@BartChris
Copy link
Copy Markdown
Collaborator

@BartChris I get a FacesException when trying to edit cell contents from slightly larger CSV files (about 100 rows), which I cannot explain, yet. Maybe it has something to do with lazy loading additional entries, but I don't now for sure.

I do not get an error here (maybe you fixed that) but i also cannot edit and save the values (it keeps the old value). I would have to check if this ever worked on large tables.

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 17, 2026

I do not get an error here (maybe you fixed that) but i also cannot edit and save the values (it keeps the old value). I would have to check if this ever worked on large tables.

Yes, I was able to fix the problem with larger files by using the enctype="multipart/form-data" in the recordsForm, but editing CSV cells is currently not possible.

I tried updating the current row in

https://github.com/solth/kitodo-production/blob/c078685857381483bfff1233f0d19009c8d177da/Kitodo/src/main/webapp/WEB-INF/templates/includes/massImport/massImportTab.xhtml#L148

but that did not work, either.

@BartChris
Copy link
Copy Markdown
Collaborator

I do not get an error here (maybe you fixed that) but i also cannot edit and save the values (it keeps the old value). I would have to check if this ever worked on large tables.

Yes, I was able to fix the problem with larger files by using the enctype="multipart/form-data" in the recordsForm, but editing CSV cells is currently not possible.

Did this work in 3.8? I would say this is a Mass Import and values should be provided by the CSV in general, so i do not see it as a critical problem, if values cannot be edited directly in the UI.

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 17, 2026

Did this work in 3.8? I would say this is a Mass Import and values should be provided by the CSV in general, so i do not see it as a critical problem, if values cannot be edited directly in the UI.

Yes, it did work in 3.8. And in 3.9 it works as well. In main, the mass import is pretty broken right now, though, to the point where it is not usable at all. The pull request does improve things and restores usabilty in general, but not being able to edit uploaded data (in contrast editing manually entered rows without a CSV upload seems to work fine) still is quite a regression when compared to previous releases, in my opinion.

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 17, 2026

@BartChris as a temporary step I deactivated the option to edit datatable cells after uploading a CSV file, so that this feature is not offered in a broken state.

I would suggest to go ahead and merge this pull request if you don't find any other problems with it, to at least restore the basic functionality of the mass import again. Once we get cell editing working again we can reactivate it afterwards in a separate pull request. What do you think?

Copy link
Copy Markdown
Collaborator

@BartChris BartChris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i agree. The rest of the functionality works for me

@solth solth marked this pull request as ready for review April 17, 2026 14:46
@BartChris
Copy link
Copy Markdown
Collaborator

Hmm, right now i got a problem when starting the import i have not seen before although i suppose this is not connected to the PR:

image

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 17, 2026

Hmm, right now i got a problem when starting the import i have not seen before although i suppose this is not connected to the PR:

We should probably make sure it isn't. Perhaps you could test with the same case in the main branch?

I just noticed that the "Mass import" button still isn't activated immediately after uploading a CSV files that already contains all data (thus metadata of type documentType in the first column) and doesn't require catalog queries.

@BartChris
Copy link
Copy Markdown
Collaborator

I will check. Right now i suspect that this is again about external schema files i cannot resolve...

@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 17, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 2 duplication

Metric Results
Complexity 0
Duplication 2

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@BartChris
Copy link
Copy Markdown
Collaborator

BartChris commented Apr 17, 2026

Ok, after commenting out

validationService.validateMappingFiles(importConfiguration.getMappingFiles());

and deactivating validation here

private String importProcessAndReturnParentID(String recordId, LinkedList<TempProcess> allProcesses,
                                                  ImportConfiguration importConfiguration, int projectID,
                                                  int templateID, boolean isParentInRecord, String parentIdMetadata,
                                                  boolean validateAgainstXmlSchema)

it works. So this is not directly connected and about some validation issue.

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 17, 2026

It should be possible to deactivate XML validation of external data for an import configuration in general, so you don't have to tamper with the code to achieve that:

Bildschirmfoto 2026-04-17 um 17 07 58

@BartChris
Copy link
Copy Markdown
Collaborator

Same error on main, so definitely not connected!

@BartChris
Copy link
Copy Markdown
Collaborator

BartChris commented Apr 17, 2026

It should be possible to deactivate XML validation of external data for an import configuration in general, so you don't have to tamper with the code to achieve that:

In importProcessForMassImport the validation flag seems hardcoded and not influenced by the setting.

Edit:It seems to be additionally checked in convertDataRecordToInternal, sorry. But validateExternal is always true.

// validate external record against corresponding XML metadata schema(ta)
if (validateExternal && importConfiguration.getValidateExternalData()) {
           validationService.validateExternalRecord(xmlContent, importConfiguration, identifier);
}

But it seems like

// validate mapping files against xslt schema
validationService.validateMappingFiles(importConfiguration.getMappingFiles()); 

is always called. In my case i suppose the mapping file validation let the process fail.

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 17, 2026

In importProcessForMassImport the validation flag seems hardcoded and not influenced by the setting.

Good that we found this out so it can be fixed as well!

@solth
Copy link
Copy Markdown
Member Author

solth commented Apr 17, 2026

In importProcessForMassImport the validation flag seems hardcoded and not influenced by the setting.

Good that we found this out so it can be fixed as well!

Interestingly, the setting in the import configuration actually seemed to work for me.

When schema validation was activated in the configuration, I got the following result in mass import:

Bildschirmfoto 2026-04-17 um 17 40 59

After deactivating the schema validation in the configuration, though, the import of the same IDs from the same catalog interface was succesful:

Bildschirmfoto 2026-04-17 um 17 43 44

It seems the static parameter true in https://github.com/solth/kitodo-production/blob/e1fdd90482a14ce073dac77044db74c8a9e1884c/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java#L1577 does not actually control whether schema validation is applied during mass import or not 🤔

Maybe your import didn't really fail because of schema invalid metadata, but because the imported XML file or the import mapping XSLT did not contain valid XML to begin with?

@BartChris
Copy link
Copy Markdown
Collaborator

BartChris commented Apr 17, 2026

Maybe your import didn't really fail because of schema invalid metadata, but because the imported XML file or the import mapping XSLT did not contain valid XML to begin with?

I have to check deeper, but my investigations right now seem to indicate that is not the validation of the catalog entries which fails for me, but the validation of the mapping files. And the latter might come down to the well known problem of external schema files, which are maybe blocked for me.

https://github.com/solth/kitodo-production/blob/e1fdd90482a14ce073dac77044db74c8a9e1884c/Kitodo/src/main/java/org/kitodo/production/services/data/ImportService.java#L962

<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
<!--
An XSLT stylesheet may contain an in-line schema within an xsl:import-schema element,
so the Schema for schemas needs to be imported
-->
<xs:import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://www.w3.org/2001/XMLSchema.xsd"/>

Edit: OK, i get the same error in "normal" catalog import... will make an issue next week.

@solth solth merged commit cc93607 into kitodo:main Apr 17, 2026
6 checks passed
@solth solth deleted the refactor-mass-import-page branch April 17, 2026 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

import Import mappings and configurations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save button is not activated after change is made in edit mode

3 participants