Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [january-dev] question about metadata

On 6/6/2017 9:51 AM, Peter.Chang@xxxxxxxxxxxxx wrote:
Hi Scott,

Executive summary: Do not extend IMetadata as it is an old interface; instead extend MetadataType but only to a single level.

Historically we had metadata then extended it repeatedly as a dataset could only hold a single metadata object. Stacking more interfaces becomes a burden for subsequent developers and stuffs metadata handling code full of tedious type checking clauses.

The issue you encountered is hinted at in the MetadataType interface: the implementation(s) of storing metadata does not handle sub-interfaces too well. The tests in MetadataTest demonstrate what can be achieved (by LazyDatasetBase.findMetadataTypeSubInterface).

The recommended way is to have separate metadata interfaces, and add or retrieve them separately.

Ok, so just so I understand by 'separate metadata interfaces' you mean that this won't/shouldn't work:

interface A extends MetadataType {
...
}

interface B extends MetadataType {
...
}

class Foo extends Metadata implements A, B {
...
}

Adding:
dataset.addMetadata(new Foo());
Retrieving
A = dataset.getFirstMetadata(A.class);
B = dataset.getFirstMetadata(B.class);

This is not expected to work. I've tested it out locally and this does not, in fact, work with January as it is.

Further you are saying that the recommended way would be to have two implementing classes (FooA implements A, FooB implements B), and call addMetadata with both object instances. Is that correct?

Thanks,

Scott



Back to the top