kitodo-production icon indicating copy to clipboard operation
kitodo-production copied to clipboard

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

Open andre-hohmann opened this issue 1 year ago • 2 comments

Describe the bug If processes are 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:

  • #4459

See also:

  • #6024

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:

  • https://github.com/kitodo/kitodo-production/issues/6024#issuecomment-2039310575

Release 3.6.2 - probably since 3.6.0

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome

Additional context

Internal METS file: Volume
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mets:mets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:kitodo="http://meta.kitodo.org/v1/" xmlns:mets="http://www.loc.gov/METS/">
    <mets:metsHdr CREATEDATE="2024-04-05T08:42:27.492+02:00" LASTMODDATE="2024-04-05T08:42:43.237+02:00">
        <mets:metsDocumentID>761641</mets:metsDocumentID>
    </mets:metsHdr>
    <mets:dmdSec ID="uuid-99903c58-9259-3db1-b4f1-b49635e37491">
        <mets:mdWrap>
            <mets:xmlData>
                <kitodo:kitodo>
                    <kitodo:metadata name="processTitle">GebuStPi1_1882036999_0006</kitodo:metadata>
                </kitodo:kitodo>
            </mets:xmlData>
        </mets:mdWrap>
    </mets:dmdSec>
    <mets:dmdSec ID="uuid-80257fd5-3312-3691-bd0a-4b5fe29a824f">
        <mets:mdWrap>
            <mets:xmlData>
                <kitodo:kitodo>
                    <kitodo:metadata name="NumberProcessTitle">0006</kitodo:metadata>
                    <kitodo:metadata name="CurrentNoSorting">060</kitodo:metadata>
                    <kitodo:metadata name="LegalNoteAndTermsOfUse">PDM1.0</kitodo:metadata>
                    <kitodo:metadata name="slub_ownerDigi">SLUB Dresden</kitodo:metadata>
                    <kitodo:metadata name="CatalogIDDigitalAnchor">1881717593</kitodo:metadata>
                    <kitodo:metadata name="TSL_ATS">GebuStPi1</kitodo:metadata>
                    <kitodo:metadata name="SizeSourcePrint">360 ungezählte Seiten</kitodo:metadata>
                    <kitodo:metadata name="TitleDocMainShort">Geburtsregister StA Pirna-Stadt 1882 - SAP P-I-XX-6</kitodo:metadata>
                    <kitodo:metadata name="shelfmarksource">SAP P-I-XX-6</kitodo:metadata>
                    <kitodo:metadata name="PublicationYearSorting">1882</kitodo:metadata>
                    <kitodo:metadata name="slub_script">fehlender_Schrifttyp</kitodo:metadata>
                    <kitodo:metadata name="docType">Volume</kitodo:metadata>
                    <kitodo:metadata name="CatalogIDDigital">1882036999</kitodo:metadata>
                    <kitodo:metadata name="DocLanguage">ger</kitodo:metadata>
                    <kitodo:metadata name="singleDigCollection">Saxonica</kitodo:metadata>
                    <kitodo:metadata name="slub_ownerOrig">ADAC</kitodo:metadata>
                    <kitodo:metadata name="singleDigCollection">LDP: Bestände des Archivverbundes Pirna</kitodo:metadata>
                    <kitodo:metadata name="PlaceOfProduction">Pirna</kitodo:metadata>
                    <kitodo:metadata name="PublicationYear">1882</kitodo:metadata>
                    <kitodo:metadata name="CurrentNo">[6]</kitodo:metadata>
                    <kitodo:metadata name="TitleDocMain">Geburtsregister StA Pirna-Stadt 1882 - SAP P-I-XX-6</kitodo:metadata>
                </kitodo:kitodo>
            </mets:xmlData>
        </mets:mdWrap>
    </mets:dmdSec>
    <mets:fileSec/>
    <mets:structMap TYPE="PHYSICAL">
        <mets:div ID="uuid-2f7b3c2e-65c5-4578-b026-865043bbcf89" DMDID="uuid-99903c58-9259-3db1-b4f1-b49635e37491"/>
    </mets:structMap>
    <mets:structMap TYPE="LOGICAL">
        <mets:div ID="uuid-29da839c-334e-4712-9f32-512e264565f4" DMDID="uuid-80257fd5-3312-3691-bd0a-4b5fe29a824f" TYPE="Volume" ORDERLABEL="Geburtsregister StA Pirna-Stadt 1882 - SAP P-I-XX-6" LABEL="Geburtsregister StA Pirna-Stadt 1882 - SAP P-I-XX-6"/>
    </mets:structMap>
    <mets:structLink/>
</mets:mets>
Internal METS file: MultiVolumeWork
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mets:mets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:kitodo="http://meta.kitodo.org/v1/" xmlns:mets="http://www.loc.gov/METS/">
    <mets:metsHdr CREATEDATE="2024-04-05T08:42:27.947+02:00" LASTMODDATE="2024-04-05T09:34:46.016+02:00">
        <mets:metsDocumentID>761640</mets:metsDocumentID>
    </mets:metsHdr>
    <mets:dmdSec ID="uuid-b0af74b5-974a-3fdb-a57d-a8637f994331">
        <mets:mdWrap>
            <mets:xmlData>
                <kitodo:kitodo>
                    <kitodo:metadata name="processTitle">GebuStPi1_1882036999_0006</kitodo:metadata>
                </kitodo:kitodo>
            </mets:xmlData>
        </mets:mdWrap>
    </mets:dmdSec>
    <mets:dmdSec ID="uuid-ea9c1353-d1ac-357b-bc09-d3d0e3f18687">
        <mets:mdWrap>
            <mets:xmlData>
                <kitodo:kitodo>
                    <kitodo:metadata name="slub_ownerDigi">SLUB Dresden</kitodo:metadata>
                    <kitodo:metadata name="PublicationYear">[1876-1912]</kitodo:metadata>
                    <kitodo:metadata name="PublicationYearSorting">1876</kitodo:metadata>
                    <kitodo:metadata name="TitleDocMainShort">Geburtsregister des Standesamtes Pirna</kitodo:metadata>
                    <kitodo:metadata name="TSL_ATS">GebudeStP</kitodo:metadata>
                    <kitodo:metadata name="singleDigCollection">Saxonica</kitodo:metadata>
                    <kitodo:metadata name="DocLanguage">ger</kitodo:metadata>
                    <kitodo:metadata name="CatalogIDDigital">1881717593</kitodo:metadata>
                    <kitodo:metadata name="TitleDocMain">Geburtsregister des Standesamtes Pirna</kitodo:metadata>
                    <kitodo:metadata name="singleDigCollection">LDP: Bestände des Archivverbundes Pirna</kitodo:metadata>
                    <kitodo:metadata name="docType">MultiVolumeWork</kitodo:metadata>
                    <kitodo:metadata name="PlaceOfProduction">Pirna</kitodo:metadata>
                    <kitodo:metadataGroup name="ContributorCorporation">
                        <kitodo:metadata name="RoleCode">com</kitodo:metadata>
                        <kitodo:metadata name="NameMainUnit">Standesamt Pirna</kitodo:metadata>
                        <kitodo:metadata name="RoleText">ZusammenstellendeR</kitodo:metadata>
                        <kitodo:metadata name="DisplayForm">Standesamt Pirna</kitodo:metadata>
                    </kitodo:metadataGroup>
                </kitodo:kitodo>
            </mets:xmlData>
        </mets:mdWrap>
    </mets:dmdSec>
    <mets:fileSec/>
    <mets:structMap TYPE="PHYSICAL">
        <mets:div ID="uuid-7a04c807-b8a9-4921-b829-ad972e97688c" DMDID="uuid-b0af74b5-974a-3fdb-a57d-a8637f994331"/>
    </mets:structMap>
    <mets:structMap TYPE="LOGICAL">
        <mets:div ID="uuid-13793733-b06a-4c2e-b67f-6af6d7ad0443" DMDID="uuid-ea9c1353-d1ac-357b-bc09-d3d0e3f18687" TYPE="MultiVolumeWork" ORDER="1" ORDERLABEL="Geburtsregister des Standesamtes Pirna" LABEL="Geburtsregister des Standesamtes Pirna">
            <mets:div ID="uuid-1128615c-f372-4687-96e2-cd30b29730c9" ORDER="1">
                <mets:mptr LOCTYPE="OTHER" OTHERLOCTYPE="Kitodo.Production" xlink:href="database://?process.id=761641"/>
            </mets:div>
        </mets:div>
    </mets:structMap>
    <mets:structLink/>
</mets:mets>

andre-hohmann avatar Apr 05 '24 07:04 andre-hohmann

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.

andre-hohmann avatar Apr 05 '24 08:04 andre-hohmann

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);
        }
    }

BartChris avatar Apr 05 '24 15:04 BartChris