Wiki

Clone wiki

ieeg / ExtensibleMetadata

Introduction

A major update to the IEEG codebase is support for "extensible metadata" with the goal that new data and metadata types can be checked into the IEEG codebase as plug-ins, without modification of the original source.

All such metadata will have both typed Java classes, as well as a JSON-style set of mechanisms for retrieving the hierarchical structure.

Details

PresentableMetadata

The core class for all serializable, presentable types is called PresentableMetadata. This has a variety of items that we expect each kind of metadata to include, such as:

  • getId() returns a unique ID for internal consumption
  • getFriendlyName() returns an English name for the item
  • getContentDescriptor() description of what's there
  • getCreationTime() when the entity was created, if available
  • getCreators() list of object creators, if available

Reserved (not yet supported) elements include: * getUserPermissions() * getRelevanceScore()

Note that PresentableMetadata subclasses SerializableMetadata, which in turn subclasses the base class BasicMetadata. The BasicMetadata class attempts to balance Java-style and JavaScript-style functionality.

  • Java classes are strongly typed and have fixed attributes. Such attributes can ordinarily be accessed via Reflections, but this is not available client-side in GWT.
  • JavaScript types are typically loosely typed and queriable. We provide a series of interfaces for querying the keys and types of data items, and for fetching items by key.
  • It is advised that you define a static map from keys to types and implement an interface to return the correspondences.
    • For now, we have types INT, DOUBLE, STRING, META (data), STRING_SET, and META_SET.

Making PresentableMetadata... actually Presentable in the MetdataBrowserPanel

By default, the MetadataBrowserPanel will render a PresentableMetadata item's name and nothing else. You'll want to make sure there is support for multiple columns of content. In some cases the PresentableMetadata may also have internal content that is page-able.

MetadataFormatter

The MetadataFormatter is responsible for returning the various elements to be rendered for the metadata: content for the columns, the image icon, star (Favorite) status, and pagination.

The interface is designed such that a single global MetadataFormatter exists for each kind of metadata, and that each of its methods can be called statically with the PresentableMetatdata item of interest as a parameter.

MetadataPresenter

If you would like to have special logic for handling "lazy" fetches from the server to retrieve data, you may need to implement the MetadataPresenter. This interface supports refresh, selection, removal of items, and so on.

As with MetadataFormatter, the interface is designed such that only one Formatter exists per PresentableMetadata type. Its methods are called with the target metadata as a parameter.

MetadataDrillDown

This is the handler for when an item in the viewer is "expanded" and needs its children to be fetched and returned.

A Major Gotcha, and a Solution

One major challenge in directly implementing MetadataFormatter etc. with your PresentableMetadata class is that this typically forces it to be client-side-only. If you include any GWT objects (e.g., image icon), this will not compile on the server-side.

On the other hand, you may want to have your metadata item shared between server- and client-side. To do this, you should define a static member variable for the MetadataPresenter and/or MetadataFormatter. Then in the MetadataFactory you can initialize these with a new (anonymous or client-side only) Formatter or Presenter that are matched up with your metadata.

The server side is mandated to NOT call getPresenter() or getFormatter(). Hence it's fine if these are set to null on that side.

Updated