[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Mon Jul 25 17:23:36 UTC 2005
mwilkinson
Mon Jul 25 13:23:35 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby
In directory pub.open-bio.org:/tmp/cvs-serv20339/MOBY/Adaptor/moby
Modified Files:
queryapi.pm
Log Message:
starting to document the adaptor layer
moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/18 16:53:49 1.4
+++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:23:35 1.5
@@ -1,8 +1,85 @@
+#$Id$
package MOBY::Adaptor::moby::queryapi;
use strict;
use Carp;
use vars qw($AUTOLOAD);
+
+=head1 NAME
+
+MOBY::Adaptor::moby::queryapi - An interface definition for MOBY Central underlying data-stores
+
+=cut
+
+=head1 SYNOPSIS
+
+ use MOBY::Adaptor::moby::queryapi::mysql # implements this interface def
+ my $m = MOBY::Adaptor::moby::queryapi::mysql->new(
+ username => 'user',
+ password => 'pass',
+ dbname => 'mobycentral',
+ port => '3306',
+ sourcetype => 'DBD::mysql');
+ my $objectid = $m->insert_object(
+ {object_type => "MyObject"},
+ {description => "this represents a foo bar"},
+ {authority => "www.example.org"},
+ {contact_email, 'me at example.org'})
+
+
+=cut
+
+=head1 DESCRIPTION
+
+This is an interface definition. There is NO implementation in this module
+with the exception that certain calls to required parameters have get/setter
+functions in this module (that can be overridden)
+
+=head1 AUTHORS
+
+Mark Wilkinson markw_at_ illuminae dot com
+Dennis Wang oikisai _at_ hotmail dot com
+BioMOBY Project: http://www.biomoby.org
+
+
+=cut
+
+=head1 METHODS
+
+
+=head2 new
+
+ Title : new
+ Usage : my $MOBY = MOBY::Client::Central->new(Registries => \%regrefs)
+ Function : connect to one or more MOBY-Central
+ registries for searching
+ Returns : MOBY::Client::Central object
+ Args : Registries - optional.
+ Notes : Each registry must have a different
+
+
+=cut
+
+
+sub new {
+ my ($caller, %args) = @_;
+ my $caller_is_obj = ref($caller);
+ my $class = $caller_is_obj || $caller;
+
+ my $self = bless {}, $class;
+
+ foreach my $attrname ( $self->_standard_keys_a ) {
+ if (exists $args{$attrname} && defined $args{$attrname}) {
+ $self->{$attrname} = $args{$attrname} }
+ elsif ($caller_is_obj) {
+ $self->{$attrname} = $caller->{$attrname} }
+ else {
+ $self->{$attrname} = $self->_default_for($attrname) }
+ }
+ return $self;
+}
+
+
# Modified by Dennis
{
@@ -14,10 +91,11 @@
(
username => [undef, 'read/write'],
password => [undef, 'read/write'],
- dbname => [undef, 'read/write'],
- port => [undef, 'read/write'],
- proxy => [undef, 'read/write'],
- url => [undef, 'read/write'],
+ dbname => [undef, 'read/write'],
+ port => [undef, 'read/write'],
+ proxy => [undef, 'read/write'],
+ url => [undef, 'read/write'],
+ driver => [undef, 'read/write'],
);
#_____________________________________________________________
@@ -41,46 +119,155 @@
keys %_attr_data;
}
+=head2 username
+
+ Title : username
+ Usage : my $un = $API->username($arg)
+ Function : get/set username (if required)
+ Returns : String (username)
+ Args : String (username) - optional.
+
+=cut
+
+
sub username {
my ($self, $arg) = @_;
$self->{username} = $arg if defined $arg;
return $self->{username};
}
+
+=head2 password
+
+ Title : password
+ Usage : my $un = $API->password($arg)
+ Function : get/set password (if required)
+ Returns : String (password)
+ Args : String (password) - optional.
+
+=cut
+
sub password {
my ($self, $arg) = @_;
$self->{password} = $arg if defined $arg;
return $self->{password};
}
+
+=head2 dbname
+
+ Title : dbname
+ Usage : my $un = $API->dbname($arg)
+ Function : get/set dbname (if required)
+ Returns : String (dbname)
+ Args : String (dbname) - optional.
+
+=cut
+
sub dbname {
my ($self, $arg) = @_;
$self->{dbname} = $arg if defined $arg;
return $self->{dbname};
}
+
+=head2 port
+
+ Title : port
+ Usage : my $un = $API->port($arg)
+ Function : get/set port (if required)
+ Returns : String (port)
+ Args : String (port) - optional.
+
+=cut
+
+
sub port {
my ($self, $arg) = @_;
$self->{port} = $arg if defined $arg;
return $self->{port};
}
+
+=head2 proxy
+
+ Title : proxy
+ Usage : my $un = $API->proxy($arg)
+ Function : get/set proxy (if required)
+ Returns : String (proxy)
+ Args : String (proxy) - optional.
+
+=cut
+
sub proxy {
my ($self, $arg) = @_;
$self->{proxy} = $arg if defined $arg;
return $self->{proxy};
}
+
+
+=head2 sourcetype
+
+ Title : sourcetype
+ Usage : my $un = $API->sourcetype($arg)
+ Function : get/set string name of sourcetype (e.g. mySQL)
+ Returns : String (sourcetype)
+ Args : String (sourcetype) - optional.
+
+=cut
+
sub sourcetype {
my ($self, $arg) = @_;
$self->{sourcetype} = $arg if defined $arg;
return $self->{sourcetype};
}
+
+
+=head2 driver
+
+ Title : driver
+ Usage : my $un = $API->driver($arg)
+ Function : get/set string name of driver module (e.g. DBD::mySQL)
+ Returns : String (driver)
+ Args : String (driver) - optional.
+
+=cut
+
+ sub driver {
+ my ($self, $arg) = @_;
+ $self->{driver} = $arg if defined $arg;
+ return $self->{driver};
+ }
+
+
+=head2 url
+
+ Title : url
+ Usage : my $un = $API->url($arg)
+ Function : get/set url (if required)
+ Returns : String (url)
+ Args : String (url) - optional.
+
+=cut
+
sub url {
my ($self, $arg) = @_;
$self->{url} = $arg if defined $arg;
return $self->{url};
}
+
sub _implementation {
my ($self, $arg) = @_;
$self->{'_implementation'} = $arg if defined $arg;
return $self->{'_implementation'};
}
+
+=head2 dbh
+
+ Title : dbh
+ Usage : my $un = $API->dbh($arg)
+ Function : get/set database handle (if required)
+ Returns : Database handle in whatever object is appropriate for sourcetype
+ Args : Database handle in whatever object is appropriate for sourcetype
+
+=cut
+
sub dbh {
my ($self, $arg) = @_;
$self->{dbh} = $arg if defined $arg;
@@ -89,24 +276,6 @@
}
-sub new {
- my ($caller, %args) = @_;
- my $caller_is_obj = ref($caller);
- my $class = $caller_is_obj || $caller;
-
- my $self = bless {}, $class;
-
- foreach my $attrname ( $self->_standard_keys_a ) {
- if (exists $args{$attrname} && defined $args{$attrname}) {
- $self->{$attrname} = $args{$attrname} }
- elsif ($caller_is_obj) {
- $self->{$attrname} = $caller->{$attrname} }
- else {
- $self->{$attrname} = $self->_default_for($attrname) }
- }
- return $self;
-
-}
# general query subroutine
# parameters:
@@ -114,6 +283,18 @@
# bind_values - an array of values to be bound to the parameters
# returns:
# resultset - reference to an array containing ARRAY references
+
+=head2 dbh
+
+ Title : general_query
+ Usage : my $un = $API->general_query(@args)
+ Function : Execute a generic query on an underlying SQL-based data source
+ Returns : array of array-refs representing resulting rows
+ Args : String - sql statement
+ [String] - a set of bind values
+
+=cut
+
sub general_query{
die "general_query not implemented in adaptor\n";
}
More information about the MOBY-guts
mailing list