NAME

UMMF::UML::Export::Perl::Tangram::Storage - Tangram Storage bridge for UMMF generated Perl code.

SYNOPSIS

DESCRIPTION

This package provides tools for using Tangram Storage objects transparently with UMMF-generated Perl code.

USAGE

use UMMF::UML::Export::Perl::Tangram::Storage;

$cls->get('name' => 'foo');
$cls->get_or_new('name' => 'foo');
$cls->get_or_error('name' => 'foo');
$obj->__storage_insert();
$obj->__storage_erase();
$obj->__storage_update();

EXPORT

None exported.

TO DO

AUTHOR

Kurt Stephens, kstephens@users.sourceforge.net 2004/03/29

SEE ALSO

UMMF::UML::Export::Perl::Tangram

VERSION

$Revision: 1.19 $

METHODS

flush_get_cache

$storage->flush_get_cache(@cls);

Flushes the get cache for all classes in @cls.

$storage->flush_get_cache();

Flushes the entire get cache.

flush_cache

$storage->flush_cache();

Flushes the entire get cache and disassembles any objects in the storage's object cache that may have circular references.

This is typically done at the end of an interaction (i.e via CGI, etc.) in a server-type application.

connect_opts

my ($dsn, $user, $pass) = $storage->connect_opts();

Returns a list of parameters suitable for DBI->connect($dsn, $user, $pass).

set_dbh

$storage->set_dbh($dbh);

Sets a cached DBD connection, using connect_opts().

$dbh-disconnect> is not called from $storage-disconnect>.

dbh

my $dbh = $storage->dbh();

Returns a cached DBD connection, using connect_opts().

If $dbh was not specified by set_dbh, it is subject to $dbh->disconnect when $storage->disconnect is called.

insert

$self->insert(@objs);

Inserts all objects in @obj into the storage. Caching is flushed for all objects of the class of the objects inserted..

update

$self->update(@objs);

Updates all objects in @obj into the storage. Caching is flushed for all objects of the class of the objects inserted..

update_or_insert

$self->update_or_insert(@objs);

Updates all objects in @obj into the storage. Any objects which are not already inserted into the storage are inserted. Caching is flushed for all objects of the class of the objects inserted..

erase

$self->erase(@objs);

Erases all objects in @obj from the storage. Caching is flushed for all objects of the class of the objects erased.

load

my @objs = $self->load(@ids);

Loads all objects from storage via unique object ids.

id

my $id = $self->id($obj);
my @ids = $self->id(@objs);

Returns the unique id for the object in storage.

class

my $cls_expr = $self->class($cls);

Returns a new class expression that represents all objects in the storage that are of the class $cls.

select

my @objs = $self->select($cls_expr, $filter, @opts);

Returns all objects of $cls_expr that match $filter.

cursor

my $cursor = $self->cursor($cls_expr, $filter, @opts);

Returns an iterator of all objects of $cls_expr that match $filter.

count

my $count = $self->count($filter, @opts);

Returns the count of all objects that match $filter.

sum

my $sum = $storage->sum($expr, $filter);
my @sums = $storage->sum([$expr1, $expr2], $filter);

Returns the sum of all $expr values of all objects that match $filter.

disconnect

$storage->disconnect();

Flushes the get cache. Disconnects the underlying storage and any database connections.

DESTROY

Calls disconnect() upon GC.

get_all

my $objs = $self->get_all($cls, \%keys);
my @objs = $self->get_all($cls, \%keys);

Returns all matching object of class $cls that match %keys exactly.

get

my $objs = $self->get_all($cls, \%keys);

Returns one matching object of class $cls that match %keys exactly. If more than one object matches, an error is thrown via die(). Any object found is stored in a cache.

get_force

my $objs = $self->get_foce($cls, \%keys);

Returns one matching object of class $cls that match %keys exactly. If more than one object matches, an error is thrown via die(). No caching is used.

get_or_error

my $objs = $self->get_foce($cls, \%keys);

Returns one matching object of class $cls that match %keys exactly. If no object is found, an error is thrown via die(). Caching is used.

get_or_new

my $objs = $self->get_or_new($cls, \%keys, \%inits);

Returns one matching object of class $cls that match %keys exactly. If no object is found, a new object is created with the %keys and %inits and is inserted in the storage. Caching is used.

UML::__ObjectBase Methods

__storage_opts

my $hash = $cls->__storage_opts;

Returns the hash of storage options used when a new Storage objects is created by __storage.

__storage_set_opts_callback

sub conn_opt_callback
{
  my ($opts, $storage_conn_id) = @_;
  $opts->{'db'} = 'blahblah';
  ...;
}
$cls->__storage_set_opts_callback(\&func);

Sets the function to use when calling

__storage_set_conn_id

$cls->__storage_set_conn_id('some_connection_name');

Sets the current connection id to use for the remainder of the process. Returns the previous connection id.

__storage

my $storage = $cls_or_obj->__storage();

Returns the current Perl::Tangram::Storage object for $cls_or_obj for the current connection id. If a storage object has not been created for the current connection id, a new one is created using the initial options from __storage_opts().

__storage_disconnect

my $storage = $cls_or_obj->__storage_disconnect();

Disconnects the $cls_or_obj from its current Storage object. All object caches are flushed and the Storage object is dropped.

__storage_flush_cache

$cls_or_obj->__storage_flush_cache();

Flushes object caches in the current Storage object, if any. This is ideally done at the end of an interactive session.

__storage_update

$obj->__storage_update();

Shorthand for:

$obj->__storage->update($obj);

__storage_update_or_insert

$obj->__storage_update_or_insert();

Shorthand for:

$obj->__storage->update_or_insert($obj);

__storage_erase

$obj->__storage_erase;

Shorthand for:

$obj->__storage->erase($obj);

__storage_insert

$obj->__storage_insert();

Shorthand for:

$obj->__storage->insert($obj);

get_all

my @objs = $cls->get_all(%key);

Shorthand for:

$cls->__storage->get_all($cls, \%key);

get

my $obj = $cls->get_al(%key);

Shorthand for:

my $obj = $cls->__storage->get($cls, \%key);

get_or_error

my $obj = $cls->get_or_error(%key);

Shorthand for:

my $obj = $cls->__storage->get_or_error($cls, \%key);

get_or_new

my $obj = $cls->get_or_new(%key);

Shorthand for:

my $obj = $cls->__storage->get_or_new($cls, \%key);

get_or_init

my $obj = $cls->get_or_new(\%key, \%init);

Shorthand for:

my $obj = $cls->__storage->get_or_init($cls, \%key, \%init);

get_force

my $obj = $cls->get_force(%key);

Shorthand for:

my $obj = $cls->__storage->get_force($cls, \%key);