# COSMOS Developer's Guide

### Data Feeds

Each web component is associated with a set of data feeds that produces configuration and content data. Each data feed produces a specific JSON structure that is consumed by a particular web component.

The COSMOSUI infrastructure provides a framework to create data feeds. Developers are not obligated to utilize this mechanism and are free to create their own data feeds based on other server side frameworks and technologies. COSMOSUI defines a servlet that acts as a gate keeper to data feed requests. This servlet handles the HTTP request and delegates the request to an Outputter class. An Outputter class is a simple java bean that takes in an input map and produces a data feed.

Figure 1. Delegator Servlet

A request delegator servlet receives the request and instantiates a particular outputter that handles the request. The request delegator provides interfaces to deserialize the request into a set of parameters that the outputter understands. The request delegator also provides a global store in which outputters can save state data. Note that the outputters themselves are stateless and can only change the state of the store.

The following sections define the IOuputter, IParameters and IStore interfaces.

IOuputter

    /**
     * Provides data feeds
     */
    public interface IOutputter {

    	/**
    	 * A resolver class that will generate unique ids.  unique ids
    	 * may be required by the outputter to identify particular items in
    	 * the generated output.
    	 * @param idResolver id resolving class
    	 */
    	public abstract void setIdResolver(IIDResolver idResolver);

    	/**
    	 * Writes content to a PrintWriter.  An input map is passed to this method
    	 * that the render method will use to generate the data feed
    	 * @param output a PrintWriter that method will write to
    	 * @param input an input map that contains name value pairs
    	 * @throws Exception
    	 */
    	public abstract void render(PrintWriter output, IParameters input)	throws Exception;

    	/**
    	 * This method is called write after instantiating the outputer.  A persisted storage
    	 * object is passed that outputters can use to save state
    	 * @param store a persistent storage object
    	 * @param parameters an input map that contains name value pairs
    	 * @throws Exception
    	 */
    	public abstract void initalize(IStore store, IParameters parameters)	throws Exception;

    }

IParameters

    /**
     * Provides a list of name value map that is used by outputters as input
     * parameters.
     */
    public interface IParameters {
    	/**
    	 * Returns a parameter value with an associated key name
    	 * @param name - key name
    	 * @return value of the parameter
    	 */
    	public String getParameter(String name);
    }

IStore

    /**
     * Persistent storage used by outputters to save state
     */
    public interface IStore {
    	/**
    	 * Returns a value from the store with provided key name
    	 * @param name - key name
    	 * @return stored value
    	 */
    	public abstract Object getAttribute(String name);
    	/**
    	 * Stores a value with an associated key name
    	 * @param name - key name
    	 * @param value - value to store
    	 */
    	public abstract void setAttribute(String name, String value);
    }

Data Tagging

Data tagging is an important design notion in the COSMOS UI. Wikipedia provides a definition of meta data tagging.

COSMOS UI distinguishes two types of data tags.

- Data Tags
- Render Tags

Data tags

Data tags provide meta data information about the data. For example, consider the following JSON structure:

    [
      {type:'cpu', id:'23423511'},
      {type:'mouse' id:'23122'},
      {type:'os' id:'23122'}

    ]

The above information shows three resources that present a CPU, a mouse and an operating system. Data can be tagged in multiple ways. The following shows three options.

Option 1 - categorize data based on hardware/software

    [
      {type:'cpu', id:'23423511', tag:'hardware'},
      {type:'mouse' id:'23122', tag:'hardware'},
      {type:'os' id:'23122', tag:'software'}
    ]

Option 2 - categorize data based on resource type

    [
      {type:'cpu', id:'23423511', tag:'cpu'},
      {type:'mouse' id:'23122', tag:'mouse'},
      {type:'os' id:'23122', tag:'os'}
    ]

Note that option 3 uses nested tags to provide meta data information on the resource.

Option 3 - categorize data based on hardware/software and resource type

    [
      {type:'cpu', id:'23423511', tag:'hardware cpu'},
      {type:'mouse' id:'23122', tag:'hardware mouse'},
      {type:'os' id:'23122', tag:'software os'}
    ]

The COSMOS visualization uses this information to render the data. For example, different icons can be associated with a resource depending on the tag value. Furthermore, if the above data structure is rendered in a tree, the tree widget may show different popup menus when the user selects the node depending on the tag value.

The COSMOS visualizations reads these tags to determine how to render the information.

Render tags

Render tags provide meta data information describing how the data is rendered. Consider the case of a tree widget, table widget and another tree widget.

When the widgets are rendered in the COSMOS UI a tag is associated with each widget.

When data is rendered in each of these widgets, the widget tags the data with their tag value. Consider the following data:

    [
      {type:'cpu', id:'23423511', tag:'hardware'},
      {type:'mouse' id:'23122', tag:'hardware'},
      {type:'os' id:'23122', tag:'software'}
    ]

If this data is rendered in the tree widget with a tag value of tree1, the data is tagged as follows:

    [
      {type:'cpu', id:'23423511', tag:'tree1 hardware'},
      {type:'mouse' id:'23122', tag:'tree1 hardware'},
      {type:'os' id:'23122', tag:'tree1 software'}
    ]

Similarly, if this data is rendered in the table widget with a tag value of table the data is tagged as follows:

    [
      {type:'cpu', id:'23423511', tag:'table hardware'},
      {type:'mouse' id:'23122', tag:'table hardware'},
      {type:'os' id:'23122', tag:'table software'}
    ]

These types of rendering tags provides additional meta data information on the data. This is useful in cases where data is sent from one widget to another. For example, if the table widget receives data from two different widgets it may handle the data differently if the data comes from one widget as opposed to the other widget.

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]