Skip to content

Prevent error for undefined metadata groups#6997

Open
oliver-stoehr wants to merge 1 commit intokitodo:mainfrom
effective-webwork:fix-undefined-metadata-group
Open

Prevent error for undefined metadata groups#6997
oliver-stoehr wants to merge 1 commit intokitodo:mainfrom
effective-webwork:fix-undefined-metadata-group

Conversation

@oliver-stoehr
Copy link
Copy Markdown
Collaborator

Metadata keys not defined in the ruleset are displayed but marked with a warning sign. However, this does not apply to metadata groups not defined in the ruleset. In combination with metadata entries inside of an undefined group a stack trace can appear.

The cause seems to be a bug:
The method NestedKeyView.rowToView(AuxiliaryTableRow row) (NestedKeyView.java) uses the method isComplexKey() to determine whether a NestedKeyView or a KeyView should be created. Since this method always returns false for undefined keys, a KeyView is always created.

(For displaying a metadata entry as child of a group some fields of the group are accessed. This fails, when the group is undefined and thus handled as a simple metadata entry without the necessary fields.)

To address this, I added a check that verifies the actual type of metadata when the metadata key is undefined, and creates a NestedKeyView for metadata groups.

With this change undefined metadata groups can be displayed in the metadata editor and metadata import. They are marked with a warning sign like the metadata entries are:
Unknown metadata group and metadata entry in the metadata editor

Fixes #3762
Fixes #5217

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity · 0 duplication

Metric Results
Complexity 4
Duplication 0

View in Codacy

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE during import when import mapping and ruleset do not match Metadata editor crashes with metadata group not defined in the ruleset

1 participant