-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust metadata replacement #5800
Conversation
This fix is a functional change. Previously, with $meta.x variables only the first child was checked, and if this is empty, the variable is resolved on the top structure. With this change, the first grandchild is now also taken into account, which would result in a different output value in other constellations:
Before: $(meta.md) → “Foo” (firstchild has no ‘md’, so resolve from topstruct) Maybe fix like this: if (!allChildren.isEmpty()) {
allFirstchildValue = MetadataEditor.getMetadataValue(allChildren.get(0), variableFinder.group(5));
/*»*/ if (Objects.isNull(allFirstchildValue)) {
/*»*/ allFirstchildValue = determineReplacementForTopstruct(variableFinder, dollarSignIfToKeep);
/*»*/ }
if (Objects.isNull(allFirstchildValue)) {
List<LogicalDivision> firstChildChildren = allChildren.get(0).getChildren();
if (!firstChildChildren.isEmpty()) {
allFirstchildValue = MetadataEditor.getMetadataValue(firstChildChildren.get(0), variableFinder.group(5));
}
}
} This should maintain the original behaviour, and fix your problem as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment above
My intention was to look first into the first child and then in the first grandchild and if both locations are not returning an result look into the top element. But your code change suggestion is not working without an other needed change: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more little thing.
Kitodo/src/main/java/org/kitodo/production/helper/VariableReplacer.java
Outdated
Show resolved
Hide resolved
1a81ba2
to
34af646
Compare
fixes #5799