[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Mon Jul 25 18:17:45 UTC 2005
mwilkinson
Mon Jul 25 14:17:45 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi
In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY/Adaptor/moby/queryapi
Modified Files:
mysql.pm
Log Message:
changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic
moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.29,1.30
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 17:50:02 1.29
+++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 18:17:44 1.30
@@ -97,7 +97,7 @@
}
-sub add_condition{
+sub _add_condition{
my ($statement, @params) = @_;
my @bindvalues = ();
my $condition = "where ";
@@ -161,41 +161,18 @@
}
}
}
-#
-#sub general_query{
-# my ($self, @args) = @_;
-# my $dbh = $self->dbh;
-# my $statement = get_value('statement', @args);
-# my $sth = $dbh->prepare($statement);
-# if (@args > 1)
-# {
-# my $bindvalues = get_value('bind_values', @args);
-# $sth->execute(@$bindvalues);
-# }
-# else {
-# $sth->execute;
-# }
-# my $result = $sth->fetchall_arrayref();
-# return $result;
-#}
-
+
+# this should NOT retun a collection ID... needs more work...
sub query_collection_input{
- my ($self, @args) = @_;
+ my ($self, %args) = @_;
my $dbh = $self->dbh;
+ my $serv_lsid = $args{'service_lsid'};
my $statement = "select
collection_input_id,
- article_name,
- service_instance_id
- from collection_input ";
- my @bindvalues = ();
-
- if (@args > 0)
- {
- ($statement, @bindvalues) = add_condition($statement, @args);
- }
-
- my $result = do_query($dbh, $statement, @bindvalues);
+ article_name
+ from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?";
+ my $result = do_query($dbh, $statement, [$serv_lsid]);
return $result;
}
@@ -213,7 +190,7 @@
my $dbh = $self->dbh;
my $statement = "delete from collection_input ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
@@ -239,7 +216,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -263,7 +240,7 @@
my $dbh = $self->dbh;
my $statement = "delete from collection_output ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
@@ -292,7 +269,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -328,7 +305,7 @@
my $dbh = $self->dbh;
my $statement = "delete from simple_input ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
if ($dbh->err){
@@ -355,7 +332,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -391,7 +368,7 @@
my $dbh = $self->dbh;
my $statement = "delete from simple_output ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
if ($dbh->err){
@@ -420,7 +397,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -448,7 +425,7 @@
my $dbh = $self->dbh;
my $statement = "delete from secondary_input ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
@@ -478,7 +455,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -512,7 +489,7 @@
my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........**********
# ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ********************
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
@@ -539,7 +516,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -567,7 +544,7 @@
my $statement = "delete from object_term2term ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
@@ -606,7 +583,7 @@
lsid
from service_instance ";
my @bindvalues;
- ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id}));
+ ($statement, @bindvalues) =_add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id}));
my $final = do_query($dbh, $statement, @bindvalues);
if (@$final[0]){return 1} else {return 0}
@@ -628,7 +605,7 @@
delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table
my @args;
while (my ($k, $v) = each %args){
- push @args, ({$k => $v}, "and"); # format for the add_condition subroutine
+ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine
}
if ($authority_id){
push @args, ({authority_id => $authority_id}) ;
@@ -650,7 +627,7 @@
lsid
from service_instance ";
my @bindvalues;
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
my $final = do_query($dbh, $statement, @bindvalues);
return $final;
}
@@ -693,7 +670,7 @@
my $dbh = $self->dbh;
my $statement = "delete from service_instance ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
if ($dbh->err){
@@ -719,7 +696,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -766,7 +743,7 @@
my @bindvalues = ();
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -792,7 +769,7 @@
my $dbh = $self->dbh;
my $statement = "delete from service ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
@@ -816,7 +793,7 @@
my @bindvalues = ();
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -839,7 +816,7 @@
my $dbh = $self->dbh;
my $statement = "delete from service_term2term ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
@@ -869,7 +846,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -892,7 +869,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -918,7 +895,7 @@
my $dbh = $self->dbh;
my $statement = "delete from namespace ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
@@ -944,7 +921,7 @@
if (@args > 0)
{
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
}
my $result = do_query($dbh, $statement, @bindvalues);
@@ -956,7 +933,7 @@
my $dbh = $self->dbh;
my $statement = "delete from namespace_term2term ";
my @bindvalues = ();
- ($statement, @bindvalues) = add_condition($statement, @args);
+ ($statement, @bindvalues) =_add_condition($statement, @args);
$dbh->do( $statement,
undef, @bindvalues );
More information about the MOBY-guts
mailing list