[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at dev.open-bio.org
Sat Feb 10 01:52:57 UTC 2007


mwilkinson
Fri Feb  9 20:52:57 EST 2007
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory dev.open-bio.org:/tmp/cvs-serv7539/MOBY/Client

Modified Files:
	Service.pm 
Log Message:
added a new function to MOBY::Client::Central that allows the client to specify the queryIDs.  This is necesary if a client program needs to keep a maping between the input and the associated output.  I know, I know.  This should have been done years ago.  Sorry :-(
moby-live/Perl/MOBY/Client Service.pm,1.34,1.35
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Service.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Service.pm	2007/02/09 21:55:32	1.34
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Service.pm	2007/02/10 01:52:57	1.35
@@ -338,10 +338,107 @@
 	return $result;
 }
 
+
+=head2 enumerated_execute
+
+ Usage     :	$result = $Service->enumerated_execute(%args)
+ Function  :	execute the MOBY service using self-enumerated inputs
+ Returns   :	whatever the Service provides as output
+ Args      :	Input => %data
+ Comment   :    %data is a hash of single invocation inputs
+                the structure of %data is:
+				
+				$data{$queryID} = {articleName => $inputXML1, # for simples and parameters
+				                   articleNmae => [$inputXML2, $inputXML3], # for collections
+								   }
+                $inputXML is the actual XML of the Input object
+				for example <Object namespace="NCBI_gi" id="163483"/>
+				
+ a full example might be:
+				
+ $data{invocation1} = {id_to_match => "<Object namespace="GO" id="0003875"/>",
+                       id_list => ["<Object namespace="GO" id="0003875"/>,
+					               "<Object namespace="GO" id="0009984"/>,...
+								   ]
+						cutoff => "<Value>10</Value>"
+						}
+
+
+=cut
+
+
+
+sub enumerated_execute {
+  my ( $self, %args ) = @_;
+  die "ERROR:  expected Input to be a HASH ref "
+    unless ( ref( $args{Input} ) eq 'HASH' );
+  my %inputs = %{$args{Input}};
+# structure of %input is:
+#$input{qid} = {articleName => "<XML>",  # for simples
+#			   articleName2 => ["<XML>", "<XML>"], # for collections
+#			  }
+
+  my $data;
+  foreach my $qID( keys %inputs ) {
+    die "ERROR:  expected hashref {articleName => XML} for each queryID" unless ( ref($inputs{$qID}) eq 'HASH' );
+	my %articles = %{$inputs{$qID}};
+	$data .= "<moby:mobyData queryID='$qID'>";
+	foreach my $articleName(keys %articles){
+		my $XML = $articles{$articleName};
+		if (  ref( $XML ) ne 'ARRAY' ) {
+			$XML ||= "";
+			if ( $XML =~ /\<(moby\:|)Value\>/ ){
+				$data .= "<moby:Parameter moby:articleName='$articleName'>$XML</moby:Parameter>";
+			} else {
+				$data .= "<moby:Simple moby:articleName='$articleName'>\n$XML\n</moby:Simple>\n";
+			}
+		} elsif ( ref( $XML ) eq 'ARRAY' ) {
+			my @objs = @{$XML};
+			$data .= "<moby:Collection moby:articleName='$articleName'>\n";
+			foreach ( @objs ) {
+				$data .= "<moby:Simple>$_</moby:Simple>\n";
+			}
+			$data .= "</moby:Collection>\n";
+		}
+    }
+    $data .= "</moby:mobyData>\n";
+  }
+  ###################
+  #  this was added on January 19th, 2005 and may not work!
+  ###################
+  ###################
+  my $version = $self->smessageVersion();
+  $data = "<?xml version='1.0' encoding='UTF-8'?>
+	<moby:MOBY xmlns:moby='http://www.biomoby.org/moby' moby:smessageVersion='$version'>
+	      <moby:mobyContent>
+	          $data
+	      </moby:mobyContent>
+	</moby:MOBY>";  
+  my $METHOD = $self->serviceName;
+  &_LOG( %args, $METHOD );
+  my $response;
+
+	if ($self->category eq 'moby'){
+		eval { ( $response ) = $self->_soapService->$METHOD( $data ) };
+		if ($@) { die "Service execution failed: $@"}
+		else {return $response;} # the service execution failed then pass back ""
+	} elsif ($self->category eq 'post'){
+		my $response = $self->_executePOSTService(data => $data, method => $METHOD);
+		# currently SOAP::Lite does not execute POST WSDL, so we need to
+		# use LWP or something like that in the executePOSTService method
+		#eval { ( $response ) = $self->_soapService->$METHOD( $data ) };
+		unless ($response){ die "Service execution failed: $@"}
+		else {return $response;} # the service execution failed then pass back ""
+	}
+}
+
+
+
+
 =head2 methods
 
  Usage     :	$name = $Service->methods()
- Function  :	Internal method to retrieve all methods from a service
+ Function  :	retrieve all possible method calls for a given service
  Returns   :	listref of method names as strings
  Args      :	none
 




More information about the MOBY-guts mailing list