Skip to content
adunofaiur edited this page May 31, 2014 · 3 revisions

Table of Contents

MetadataViewModel

MetadataViewModels are held in an object called metadataFields. In order to display metadata in a custom interface, your application must be able to parse these objects for metadata. See MICE.buildMetadatatable for an example.

MetadataLoader.render()

The simplest way to get displayable metadata is to call MetadataLoader.render(). MetadataLoader.render() accepts four or five parameters:

1. renderer - a function built by the user to display metadata gathered by the MetadataLoader. After creating a MetadataViewModel, MetadataLoader will call the renderer, supplying it with the task and metadataFields parameters. See MICE.render in mice.js for an example.

2. container - an HTML node to render metadata in. This container can be accessed in your rendered function by calling task.visual.

3. url - the target webpage's url

4. isRoot - a boolean flag that communicates whether the metadata being requested is the parent of other metadata in container'. When in doubt, set to true.

5. clipping - an optional metadata clipping. If you already have parsed metadata to render, pass it in here.

API Documentation

Loading Metadata and Meta-Metadata

SEMANTIC_SERVICE_URL
  • The base URL to the BigSemantics web service. By default, this points to the service hosted at the Interface Ecology Lab. Alternatively, you can check out the BigSemanticsService project, host your own instance of the service, and points this variable to it so that the library can use it.
MetadataLoader.getMetadata(url, callback)
  • Extracts metadata for the given URL from the service, and call the callback function when it is ready. The passed in callback function should accept one parameter which is the extracted metadata, as an object.
  • The extracted metadata objects are also called "documents". All extracted metadata objects will be placed in a document collection.
MetadataLoader.getMmdByUrl(url, callback)
  • Loads the meta-metadata wrapper for the given URL from the service, and call the callback function when it is ready. The passed in callback function should accept one parameter which is the corresponding meta-metadata object, as an object.
MetadataLoader.getMmdByName(name, callback)
  • Loads the meta-metadata wrapper with the given name from the service, and call the callback function when it is ready. The passed in callback function should accept one parameter which is the corresponding meta-metadata object, as an object.
MetadataLoader.clearDocumentCollection()
  • Clears the collection of documents (metadata objects) that have been loaded or rendered.

Preparing Metadata for Presentation

MetadataLoader.isRenderedDocument(url)
  • Checks if a given URL has been rendered already. This can be useful if you want to avoid presenting encountered documents repeatedly to the user. Returns true if the document has been encountered, otherwise false.
MetadataLoader.isFieldVisible(mmdField, metadata, url, parentField)
  • Checks if a metadata field should be rendered or not. It uses not only the field value, but also the associated presentation rules, types of the field, and the encompassing field to determine. Returns true if the field should be rendered, otherwise false.
MetadataLoader.getMetadataViewModel(parentField, mmdKids, metadata, depth ,child_value_as_label, taskUrl)
Constructs and returns a MetadataViewModel object, which recursively integrates extracted metadata and the corresponding meta-metadata wrapper.
MetadataLoader.hasVisibleMetadata(viewModelFields)
  • Checks if a set of MetadataViewModel objects contain contents that need to be rendered. This can be useful when the application needs to skip rendering empty containers. Returns true if there are contents that should be rendered, otherwise false.

Utility functions

MetadataLoader.getImageSource(viewModel)
  • Extracts the source URL of an image from its MetadataViewModel object.
MetadataLoader.toDisplayCase(s)
  • Converts a type or field name from underscore_separated_format to Display Ready Forms.
MetadataLoader.cleanText(s)
  • Cleans newlines and other control characters from the input string.
Clone this wiki locally