[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Mon Jul 25 22:10:26 UTC 2005


mwilkinson
Mon Jul 25 18:10:26 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi
In directory pub.open-bio.org:/tmp/cvs-serv22004/MOBY/Adaptor/moby/queryapi

Modified Files:
	mysql.pm 
Log Message:
how do you know when you have done too much Perl coding?  When you start to say %args like a pirate...  This change might break things badly- I need to do a join in a dynamically generated SQL statement.  It looks OK now.  mySQL is weird in that you have to specify table names in natural joins.  UGH

moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.36,1.37
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm	2005/07/25 21:52:25	1.36
+++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm	2005/07/25 22:10:26	1.37
@@ -608,7 +608,7 @@
 	my $authURI = $args{'authority_uri'};
 #	my $id = $args{'authority_id'};  # is it safe to remove this?  better be!
 #	unless ($id){
-	    my $result = $self->query_authority({authority_uri => $authURI});
+	    my $result = $self->query_authority(authority_uri => $authURI);
 	    return 0 unless @$result[0];
 	    my $id = @$result[0]->{authority_id};
 	    return 0 unless $id;
@@ -638,36 +638,36 @@
 	my $dbh = $self->dbh;
     	
 	my $authority_id;
-	if ($args{'authority_uri'}){ # need to transform URI to a row ID
-	    my $result = $self->query_authority({authority_uri => $args{'authority_uri'}});
-	    return 0 unless @$result[0];
-	    $authority_id = @$result[0]->{authority_id};
-	    return 0 unless $authority_id;
-	}	
-	delete $args{'authority_uri'};  # this can't be passed into the search since it doens't exist in the table
+	#if ($args{'authority_uri'}){ # need to transform URI to a row ID
+	#    my $result = $self->query_authority(authority_uri => $args{'authority_uri'});
+	#    return 0 unless @$result[0];
+	#    $authority_id = @$result[0]->{authority_id};
+	#    return 0 unless $authority_id;
+	#}	
+	#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
 	}
-	if ($authority_id){
-	    push @args, ({authority_id => $authority_id}) ;
-	} else {
-    	    pop @args;  # remove final "and"
-	}
+#	if ($authority_id){
+#	    push @args, ({authority_id => $authority_id}) ;
+#	} else {
+#    	    pop @args;  # remove final "and"
+#	}
 	
 	my $statement = "select
           service_instance_id,
           category,
           servicename,
           service_type_uri,
-          authority_id,
+          authority.authority_uri,
           url,
           contact_email,
           authoritative,
           description,
 		  signatureURL,
 		  lsid 
-          from service_instance ";
+          from service_instance left join authority on authority.authority_id ";
         my @bindvalues;
  	($statement, @bindvalues) =_add_condition($statement, @args);
  	my $final = do_query($dbh, $statement, @bindvalues);
@@ -712,14 +712,12 @@
 	return $id;
 }
 
+# pass service_instance_lsid
 sub delete_service_instance{
-	my ($self, @args) = @_;	
+	my ($self, %args) = @_;	
 	my $dbh = $self->dbh;
-	my $statement = "delete from service_instance ";
-	my @bindvalues = ();
-	($statement, @bindvalues) =_add_condition($statement, @args); 
-	$dbh->do( $statement,
-			  undef, @bindvalues );
+	my $statement = "delete from service_instance where lsid = ?";
+	$dbh->do( $statement,undef, ($args{service_instance_lsid}) );
 	if ($dbh->err){
 		return (1, $dbh->errstr);
 	}
@@ -729,8 +727,10 @@
 }
 	
 # Selects all columns
+# pass authority_uri
 sub query_authority {
-	my ($self, @args) = @_;	
+	my ($self, %args) = @_;
+	my $authURI = $args{authority_uri};
 	my $dbh = $self->dbh;
 	
 	my $statement = "select
@@ -738,15 +738,8 @@
           authority_common_name,
           authority_uri,
           contact_email
-          from authority ";
-    my @bindvalues = (); 
-          
-	if  (@args > 0) 
- 	{
- 		($statement, @bindvalues) =_add_condition($statement, @args);
- 	}
- 	
- 	my $result = do_query($dbh, $statement, @bindvalues);
+          from authority where authority_uri = ?";
+ 	my $result = do_query($dbh, $statement, ($authURI));
  	return $result;
 }
 




More information about the MOBY-guts mailing list