Aquarium / Protocol developer / Associations

Data Association Documentation

This is the documentation for how to successfully use data associations to store data related to Items, Collections, Plans, and Operations.

See the API documentation for more details on the functions that Krill provides.


Table of Contents


Data Associations

Data may be associated with Item, Operation and Plan objects. This data should either be serializable as JSON (e.g., a hash), or be an Upload object.

Data associations are managed directly using the DataAssociation model. (The AssociationMap class is a wrapper for this model class, making associations easier to use, but hiding some details.)

Using an Item reference item as an example, the following methods are available:

Setting data

Getting data

Example

As an example, suppose item is an Item and upload is an Upload. Then one might do

item.associate(:row, 12).associate(:col, 14).associate(:image,{},u)
item.notes = "Hello"
item.append_notes " World"
item.associations # => [ row: 12, col: 14, image: {}, notes: "Hello World"]
item.get(:row) # => 12
item.upload(:image) # => <An Aquarium Upload ActiveRecord>