Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

ModelSEED Store

Scott Devoid edited this page Jul 25, 2012 · 7 revisions

ModelSEED::Store

Authenticated storage interface layer

ABSTRACT

NOTE

For each function in the METHODS section, $ref is a ModelSEED::Reference object or a string that produces a valid ModelSEED::Reference object when the constructor for that class is called thusly:

my $ref = ModelSEED::Reference->new( ref => $str );

METHODS

new

my $Store = ModelSEED::Store->new(\%);
my $Store = ModelSEED::Store->new(%);

This initializes a Storage interface object. This accepts a hash or hash reference to configuration details:

auth

The authorization to use when accessing data, i.e. the user requesting data / objects. This is required and must be an instance of a class that implements the ModelSEED::Auth interface.

database

A reference to a ModelSEED::Database object. This is the base storage interface that the Store will use. If this is not provided, it will be initialized based on the contents of the ModelSEED::Configuration package.

Object Methods

These functions operate on ModelSEED::MS objects.

create

my $object = $Store->create("Biochemistry, { name => "Foo" });

This creates a ModelSEED::MS::Biochemistry object and returns it. It does not save the object, however, it does initialize the object with the "parent" pointing back at the $Store instance. This instance will be used if $object-save()> is called without another store object. It will also be used if the ModelSEED::MS object needs additional data.

has_object

my $bool = $Store->has_object($ref);

Returns true if the object matching the reference exists in the database. Otherwise returns false.

get_object

my $obj  = $Store->get_object($ref);

Returns an object for the reference if it exists. Otherwise, returns undef.

save_object

my $bool  = $Store->save_object($ref, $obj, $config);

Saves the object $obj using the reference $ref. Returns true if the save was successful, false otherwise. $config is an optional hash ref. This is passed to the save_data function ModelSEED::Database as $config. See the documentation of that function for details.

find_objects

TODO: Not implemented.

Data Methods

These functions operate on standard perl hashes. Each of these functions have the same calling conventions as the Object Methods functions, but with perl hashes instead of blessed ModelSEED::MS objects.

has_data

my $bool = $Store->has_data($ref);

get_data

my $data = $Store->get_data($ref);

save_data

my $bool = $Store->save_data($ref, $data, $config);

find_data

TODO: Not implemented.

Alias Methods

These functions manipulate aliases and read/write permissions on aliases. For deatails on usage, see the Alias Functions section of ModelSEED::Database

my \@aliases   = $Store->get_aliases($query);
my \@usernames = $Store->alias_viewers($ref);
my $username   = $Store->alias_owner($ref);
my $bool       = $Store->alias_public($ref);

my $success = $Store->add_viewer( $ref, $username );
my $success = $Store->revmove_viewer( $ref, $username );
my $success = $Store->set_public( $ref, $bool );