[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Mon Jul 25 20:55:35 UTC 2005


mwilkinson
Mon Jul 25 16:55:35 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi
In directory pub.open-bio.org:/tmp/cvs-serv21506/MOBY/Adaptor/moby/queryapi

Modified Files:
	mysql.pm 
Log Message:
more of the same.  Pass hashes instead of hashrefs, and avoid passing database ids

moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.32,1.33
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm	2005/07/25 20:14:35	1.32
+++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm	2005/07/25 20:55:35	1.33
@@ -302,9 +302,13 @@
     my ($self, %args) = @_;
     my $dbh = $self->dbh;
     my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid});
-    my $statement = "delete from simple_input where service_instance_lsid = ?";
-
-    $dbh->do( $statement, undef,($siid));
+    my ($collid) = $args{collection_input_id};
+    my $statement1; my $statement2;
+    $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?");
+    $collid && ($statement2 = "delete from simple_input where collection_input_id = ?");
+    
+    $siid && ($dbh->do( $statement1, undef,($siid)));
+    $collid && ($dbh->do($statement2, undef,($collid)));
     if ($dbh->err){
 	    return (1, $dbh->errstr);
     }
@@ -317,7 +321,7 @@
     my ($self, %args) = @_;
     my $dbh = $self->dbh;
     my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid});
-    my $result_ids = $adaptor->query_collection_input(service_instance_lsid => $self->lsid);
+    my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid);
 
     my $statement = "delete from simple_input where service_instance_lsid = ?";
 
@@ -381,86 +385,88 @@
 
 }
 
+# pass service_instance_id or collection_output_id
 sub delete_simple_output{
-	my ($self, @args) = @_;	
-	my $dbh = $self->dbh;
-	my $statement = "delete from simple_output ";
-	my @bindvalues = ();
-	($statement, @bindvalues) =_add_condition($statement, @args); 
-	$dbh->do( $statement,
-			  undef, @bindvalues );
-	if ($dbh->err){
-		return (1, $dbh->errstr);
-	}
-	else{
-		return 0;
-	}	
+    my ($self, %args) = @_;
+    my $dbh = $self->dbh;
+    my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid});
+    my ($collid) = $args{collection_output_id};
+    my $statement1; my $statement2;
+    $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?");
+    $collid && ($statement2 = "delete from simple_output where collection_input_id = ?");
+    
+    $siid && ($dbh->do( $statement1, undef,($siid)));
+    $collid && ($dbh->do($statement2, undef,($collid)));
+    if ($dbh->err){
+	    return (1, $dbh->errstr);
+    }
+    else{
+	    return 0;
+    }			  
 }	
 
+# pass service_instance_lsid
 sub query_secondary_input{
-	my ($self, @args) = @_;	
-	my $dbh = $self->dbh;
-	
-	my $statement = "select
-          secondary_input_id,
-          default_value,
-          maximum_value,
-          minimum_value,
-          enum_value,
-          datatype,
-          article_name,
-          service_instance_id
-          from secondary_input ";
-    my @bindvalues = (); 
-          
-	if  (@args > 0) 
- 	{
- 		($statement, @bindvalues) =_add_condition($statement, @args);
- 	}
- 	
- 	my $result = do_query($dbh, $statement, @bindvalues);
- 	return $result;	
+    my ($self, %args) = @_;	
+    my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid});
+    my $dbh = $self->dbh;
+    
+    my $statement = "select
+      secondary_input_id,
+      default_value,
+      maximum_value,
+      minimum_value,
+      enum_value,
+      datatype,
+      article_name,
+      service_instance_id
+      from secondary_input where service_instance_id = ?";    
+    my $result = do_query($dbh, $statement, ($siid));
+    return $result;	
 }
 
+# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid
 sub insert_secondary_input{
-	my ($self, @args) = @_;	
-	my $dbh = $self->dbh;		
-	$dbh->do(
-q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)},
-		undef,
-		(
-		   get_value('default_value', @args), get_value('maximum_value', @args),
-		   get_value('minimum_value', @args), get_value('enum_value', @args),
-		   get_value('datatype', @args),      get_value('article_name', @args),
-		   get_value('service_instance_id', @args),
-		)
-	);
-	return $dbh->{mysql_insertid};
+    my ($self, %args) = @_;	
+    my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid});
+    my $dbh = $self->dbh;		
+    $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)},
+	    undef,
+	    (
+	       $args{'default_value'}, $args{'maximum_value'},
+	       $args{'minimum_value'}, $args{'enum_value'},
+	       $args{'datatype'}, $args{'article_name'},$siid)
+    );
+    return $dbh->{mysql_insertid};
 }
 
+# pass service_instance_lsid
 sub delete_secondary_input{
-	my ($self, @args) = @_;	
-	my $dbh = $self->dbh;
-	my $statement = "delete from secondary_input ";
-	my @bindvalues = ();
-	($statement, @bindvalues) =_add_condition($statement, @args); 
-	$dbh->do( $statement,
-			  undef, @bindvalues );
-	
-	if ($dbh->err){
-		return (1, $dbh->errstr);
-	}
-	else{
-		return 0;
-	}	
+    my ($self, %args) = @_;
+    my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid});
+    my $dbh = $self->dbh;
+    my $statement = "delete from secondary_input where service_instance_lsid=?";
+
+    $dbh->do( $statement, undef, ($siid));    
+    if ($dbh->err){
+	    return (1, $dbh->errstr);
+    }
+    else{
+	    return 0;
+    }	
 }
 
-# query subroutine will selects all rows from object table
-sub query_object
-{
-	my ($self, @args) = @_;	
-	my $dbh = $self->dbh;
-	
+
+# receives argument "type", that may be either an LSID or a type term
+sub query_object {
+	my ($self, %args) = @_;
+	my $type = $args{type};
+	my $condition;
+	if ($type =~ /^urn\:lsid/){
+	    $condition = "where object_lsid = ?";
+	} else {
+	    $condition = "where object_type = ?";
+	}
 	my $statement = "select
           object_id,
           object_lsid,
@@ -468,15 +474,10 @@
           description,
           authority,
           contact_email
-          from object ";
-    my @bindvalues = (); 
-          
-	if  (@args > 0) 
- 	{
- 		($statement, @bindvalues) =_add_condition($statement, @args);
- 	}
- 	
- 	my $result = do_query($dbh, $statement, @bindvalues);
+          from object $condition";
+
+	my $dbh = $self->dbh; 	
+ 	my $result = do_query($dbh, $statement, ($type));
  	return $result;		
 }
 




More information about the MOBY-guts mailing list