Expose MetadataOnly through metadata APIs - #233
Conversation
MetadataOnly is an empty schema marker, so property-based metadata generation omitted it from MetadataRetrieve and MetadataStore. Generic metadata conversion consequently produced Pixels elements without any of the required BinData, TiffData, or MetadataOnly choices. Generate backward-compatible default presence accessors and implement them in the OME-XML, aggregate, and filtering stores. Copy the marker through MetadataConverter without relying on concrete model classes. Cover marker creation and removal, legacy default behavior, metadata wrappers, conversion, and validation of converted XML against OME 2016-06.
|
#234 fixes the cause of the CI failure. The CI failure here is unrelated to the changes. |
|
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/new-bioformats-cv7000-reader-fixing-old-one-quietly-inventing-data/122100/1 |
sbesson
left a comment
There was a problem hiding this comment.
From the perspective of the data model, exposing the MetadataOnly in the interfaces and implementations of the ome.xml.meta package makes sense and restores some parity with the existing API for TiffData or BinData. The proposal makes use of default implementations in interfaces and would constitute a backwards-compatible API addition.
Labelling this PR to have it included it in the nightly builds and check it does not cause any downstream regression.
From the API perspective, the biggest unknown from my side is about the type of object that should be used in the getter and setter methods. The proposal use Boolean while an alternative would be to use an ome.xml.model.MetadataOnly object.
Most methods in the ome.xml.meta interface are getting or setting element attributes so the mapping into data types is more straightforward. MetadataOnly is different as it has no attribute and unlike TiffData and BinData there can only be one instance per Pixels so methods like getMetadataOnlyCount() returning an integer feels unnecessary.
|
Thanks for the review! |
melissalinkert
left a comment
There was a problem hiding this comment.
I agree with the approach to accept/return a Boolean, as this is consistent with the existing MetadataStore API which does not accept or return OME model objects. In the unlikely case that MetadataOnly is ever expanded in the OME-XML schema, at worst we could deprecate these methods in favor of whatever matched the updated schema.
Hej,
While testing Bio-Formats memoization and diagnosing some other memoization problems which came up due to testing Java 25 build of ome/bioformats#4450 and its use of
MetadataOnly, the OME-XML schema failed validation after active memoization.The failure was initially addressed haphazardly by me in ome/bioformats#4459, but I traced the underlying conversion problem to
ome.xml.meta.MetadataConverter, making this anome-modelissue rather than a Bioformats-Memoizer-specific problem.OME 2016-06 requires each
Pixelselement to contain one ofBinData,TiffData, orMetadataOnly.Unlike the other alternatives,
MetadataOnlyis an empty marker element. The metadata code generator exposes values, attributes, references, and repeated entities throughMetadataRetrieveandMetadataStore, but it previously generated no API for this marker.Consequently,
MetadataConvertercould copy every ordinaryPixelsproperty while silently droppingMetadataOnly. The resulting OME-XML contained aPixelselement without any member of the required schema choice and was therefore invalid.Changes
Add generated presence accessors for the marker:
MetadataRetrieve#getPixelsMetadataOnly(int)MetadataStore#setPixelsMetadataOnly(Boolean, int)The getter returns:
truewhen the marker is presentfalsewhen it is absentnullwhen an implementation cannot determine its presenceBoth methods are interface defaults so existing third-party metadata
implementations remain compatible. The default getter returns
null, and thedefault setter is a no-op.
Implement the accessors in:
OMEXMLMetadataImplAggregateMetadataFilterMetadataOMEXMLMetadataImplcreates or removes the concrete marker according to theBoolean value.
MetadataConverternow copies the marker exclusively throughthe metadata interfaces, without depending on concrete OME model classes.
Tests
Add focused coverage for:
The branch passes all local tests.