Skip to main content

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

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.

Regards,
 Peter


-----Original Message-----
From: january-dev-bounces@xxxxxxxxxxx [mailto:january-dev-bounces@xxxxxxxxxxx] On Behalf Of Scott Lewis
Sent: 06 June 2017 16:48
To: january-dev@xxxxxxxxxxx
Subject: [january-dev] question about metadata

Howdy,

We've been using the January metadata APIs, and I have some questions.  
First some code:

We've added new metadata interfaces...e.g.

interface IIdMetadata extends IMetadata {

...

}

And have an implementing class e.g.:

class IdMetadata extends Metadata implements IIdMetadata {

...

}

We add metadata to a dataset:

dataset.addMetadata(new IdMetadata());

Then we access the metadata:

IIdMetadata id = dataset.getFirstMetadata(IIdMetadata.class);

All this works fine.

We have occasions, however, where we would like to be able to do the
following:

(redeclaration of above IdMetadata class):

class IdMetadata extends Metadata implements IIdMetadata, SomeOtherMetadata {

...

}

and then

SomeOtherMetadata som = dataset.getFirstMetadata(SomeOtherMetadata.class);

and have it return a non-null object (the instance that implements both IIdMetadata and SomeOtherMetadata).

In my current tests, this does not work.   The SomeOtherMetadata.class 
query returns null.   My question:   Is this behavior desired/intended?

Thanksinadvance,

Scott


_______________________________________________
january-dev mailing list
january-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/january-dev

-- 
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom



Back to the top