kitodo / kitodo-production

Kitodo.Production is a workflow management tool for mass digitization and is part of the Kitodo Digital Library Suite.
http://www.kitodo.org/software/kitodoproduction/
GNU General Public License v3.0
63 stars 63 forks source link

Wrong value for the metadata "processTitle" is created for MultiVolumeWork #6025

Closed andre-hohmann closed 4 months ago

andre-hohmann commented 5 months ago

Describe the bug If processes are created for a volume and a multivolume work, the metadata "processTitle" of the volume is assigned to both processes.

Probably, this is caused by:

See also:

To Reproduce Steps to reproduce the behavior:

  1. Create a process for a volume with the process for the multivolume work in Kitodo.Production 3.6.0 or a newer version
  2. Open the internal METS file of both processes
  3. See the same metadata "processTitle"

Expected behavior The correct process title should be assigned to both processes.

Probably, this must be analyzed more deeply. It seems there are more consequences:

Release 3.6.2 - probably since 3.6.0

Desktop (please complete the following information):

Additional context

Internal METS file: Volume ``` xml 761641 GebuStPi1_1882036999_0006 0006 060 PDM1.0 SLUB Dresden 1881717593 GebuStPi1 360 ungezählte Seiten Geburtsregister StA Pirna-Stadt 1882 - SAP P-I-XX-6 SAP P-I-XX-6 1882 fehlender_Schrifttyp Volume 1882036999 ger Saxonica ADAC LDP: Bestände des Archivverbundes Pirna Pirna 1882 [6] Geburtsregister StA Pirna-Stadt 1882 - SAP P-I-XX-6 ```
Internal METS file: MultiVolumeWork ``` xml 761640 GebuStPi1_1882036999_0006 SLUB Dresden [1876-1912] 1876 Geburtsregister des Standesamtes Pirna GebudeStP Saxonica ger 1881717593 Geburtsregister des Standesamtes Pirna LDP: Bestände des Archivverbundes Pirna MultiVolumeWork Pirna com Standesamt Pirna ZusammenstellendeR Standesamt Pirna ```
andre-hohmann commented 5 months ago

In my opinion, this is a severe problem, because inconsistent internal metadata is created, which

  1. probably must be corrected to achieve consistent internal metadata.
  2. could lead to unnecessary configuration efforts of the export XSLT to solve at least the most obvious problems.

@solth : According to @henning-gerhardt, i should inform you explicitly, because for me this is a blocker for the productive use of the affected versions in SLUB Dresden. Since I was informed about this behavior by Leipzig University Library, it seems to be relevant for other institutions as well.

BartChris commented 5 months ago

I suppose this issue arises because the title is derived from currentProcess, which represents the child process (in cases where the import was initiated by the child process) rather than the currently evaluated process. Therefore, the title for both processes is taken from the child.

https://github.com/kitodo/kitodo-production/blob/5be1123d509c4ca81515f5b7f1cb84e00e36ca4b/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/CreateProcessForm.java#L650-L655

The title should, instead, probably be derived from the processed tempProcess (first the volume, then the multi-volume work). The revised code could look like this:

 private void saveTempProcessMetadata(TempProcess tempProcess) {
        try (OutputStream out = ServiceManager.getFileService()
                .write(ServiceManager.getProcessService().getMetadataFileUri(tempProcess.getProcess()))) {
            Workpiece workpiece = tempProcess.getWorkpiece();
            workpiece.setId(tempProcess.getProcess().getId().toString());
            if (Objects.nonNull(rulesetManagement)) {
                setProcessTitleMetadata(workpiece, tempProcess.getProcess().getTitle());
            }
            ServiceManager.getMetsService().save(workpiece, out);
        } catch (IOException e) {
            Helper.setErrorMessage(e.getLocalizedMessage(), logger, e);
        }
    }

    private void setProcessTitleMetadata(Workpiece workpiece, String processTitle) {
        Collection<String> keysForProcessTitle = rulesetManagement.getFunctionalKeys(FunctionalMetadata.PROCESS_TITLE);
        if (!keysForProcessTitle.isEmpty()) {
            addAllowedMetadataRecursive(workpiece.getLogicalStructure(), keysForProcessTitle, processTitle);
            //addAllowedMetadataRecursive(workpiece.getPhysicalStructure(), keysForProcessTitle, processTitle);
        }
    }