Skip to content

Boolean metadata is overwritten by ruleset presets #5689

Description

@solth

Describe the bug
Kitodo does not explicitly save negative or "false" values for boolean metadata to the meta.xml file of a process, but instead skips saving the metadata at all for values interpreted as false. I think this is meant to simplify the handling of boolean metadata. Unfortunately, this does produce some problems with boolean metadata and the configuration of rulesets. One such problem is that any preset for a boolean metadata in the ruleset is interpreted as true:

https://github.com/kitodo/kitodo-production/blob/836739862427bc69f8631d2d2cf87697c0891aa2/Kitodo-API/src/main/java/org/kitodo/api/dataeditor/rulesetmanagement/SimpleMetadataViewInterface.java#LL49C1-L51C6

So getBooleanDefaultValue actually just returns whether a preset is configured at all, not it's actual value.

The constructor of a boolean metadata uses this method to determine the value of the metadata if no value for this metadata was found in a processes meta.xml file:

https://github.com/kitodo/kitodo-production/blob/836739862427bc69f8631d2d2cf87697c0891aa2/Kitodo/src/main/java/org/kitodo/production/forms/createprocess/ProcessBooleanMetadata.java#LL50C3-L50C3

Since false boolean values are not saved to the meta.xml, this construction of a boolean metadata with value false when opening a process in the metadata editor falls back on the default values/presets defined in the ruleset in the lines quoted above. This leads to checkboxes for explicitely deactived metadata to always be checked again when opening a corresponding process in the metadata editor again.

To Reproduce
Steps to reproduce the behavior:

  1. Configure a boolean metadata in the ruleset with a non-empty preset, for example
        <key id="accessRestriction">
            <label>Zugriffsbeschränkung</label>
            <label lang="de">Zugriffsbeschränkung</label>
            <label lang="en">Access restriction</label>
            <codomain type="boolean"/>
            <option value="yes"/>
            <option value="no"/>
            <preset>no</preset>
        </key>
  1. Add a metadata of this type to a process in the metadata editor
  2. Deactivate the metadata, e.g. remove the check from the checkbox
  3. Save the process
  4. Re-open the process in the editor
  5. Observe that check has been re-applied

Expected behavior
Boolean metadata that has been explicitely saved as false e.g. "unchecked" should not be overwritten by potential presets in the ruleset.

Release
3.6.0-SNAPSHOT and prior

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions