[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Thu Apr 29 22:28:03 UTC 2004


mwilkinson
Thu Apr 29 18:28:03 EDT 2004
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv23038/MOBY

Modified Files:
	CommonSubs.pm 
Log Message:
implementing API changes into CommonSubs.  It is only the messaging structure that has changed, so MOBY::Central and Clinet::Central did not need to be updated.  Testing this now...hopefully it will work

moby-live/Perl/MOBY CommonSubs.pm,1.45,1.46
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2004/04/14 20:10:35	1.45
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm	2004/04/29 22:28:03	1.46
@@ -254,7 +254,7 @@
                 2. queryID (undef for Secondary parameters)
                 3. $data - the data takes several forms
                          a. $article XML::DOM node for Simples
-                            <queryInput...>...</queryInput>
+                            <mobyData...>...</mobyData>
                          b. \@article XML:DOM nodes for Collections
                          c. $secondary XML::DOM node
 
@@ -264,10 +264,10 @@
 sub genericServiceInputParser {
     my ($message) = @_;  # get the incoming MOBY query XML
     my @inputs;           # set empty response
-    my @queries = getInputs($message);  # returns XML::DOM nodes <queryInput>...</queryInput>
+    my @queries = getInputs($message);  # returns XML::DOM nodes <mobyData>...</mobyData>
     
     foreach my $query(@queries){
-        my $queryID = getInputID($query);  # get the queryID attribute of the queryInput
+        my $queryID = getInputID($query);  # get the queryID attribute of the mobyData
         my @input_articles = getArticles($query); # get the Simple/Collection/Secondary articles making up this query <Simple>...</Simple> or <Collection>...</Collection> or <Parameter>...</Parameter>
         foreach my $input(@input_articles){       # input is a listref
            my ($articleName, $article) = @{$input}; # get the named article
@@ -304,7 +304,7 @@
             
             for example, the input message:
             
-                <queryInput queryID = '1'>
+                <mobyData queryID = '1'>
                     <Simple articleName='name1'>
                        <Object namespace=blah id=blah/>
                     </Simple>
@@ -312,7 +312,7 @@
                        <datatype>Float</datatype>
                        <default>10</default>
                     </Parameter>
-                </queryInput>
+                </mobyData>
 
             will become:
             (note that SIMPLE, COLLECTION, and SECONDARY are exported constants from this module)
@@ -330,7 +330,7 @@
             With inputs that have collections these are presented as a
             listref of Simple article DOM's.  So for the following message:
             
-                <queryInput>
+                <mobyData>
                     <Collection articleName='name1'>
                       <Simple>
                        <Object namespace=blah id=blah/>
@@ -343,7 +343,7 @@
                        <datatype>Float</datatype>
                        <default>10</default>
                     </Parameter>
-                </queryInput>
+                </mobyData>
 
             will become
             
@@ -361,11 +361,11 @@
 sub complexServiceInputParser {
     my ($message) = @_;  # get the incoming MOBY query XML
     my @inputs;           # set empty response
-    my @queries = getInputs($message);  # returns XML::DOM nodes <queryInput>...</queryInput>
+    my @queries = getInputs($message);  # returns XML::DOM nodes <mobyData>...</mobyData>
     my %input_parameters;  # $input_parameters{$queryID} = [
     
     foreach my $query(@queries){
-        my $queryID = getInputID($query);  # get the queryID attribute of the queryInput
+        my $queryID = getInputID($query);  # get the queryID attribute of the mobyData
         my @input_articles = getArticles($query); # get the Simple/Collection/Secondary articles making up this query <Simple>...</Simple> or <Collection>...</Collection> or <Parameter>...</Parameter>
         foreach my $input(@input_articles){       # input is a listref
            my ($articleName, $article) = @{$input}; # get the named article
@@ -386,12 +386,11 @@
 =head2 getArticles
 
  name     : getArticles
- function : get the Simple/Collection/Parameter articles for a single queryInput
-            or queryResponse node
+ function : get the Simple/Collection/Parameter articles for a single mobyData
  usage    : @articles = getArticles($XML)
  args     : raw XML or XML::DOM of a queryInput, mobyData, or queryResponse block (e.g. from getInputs)
- returns  : a list of listrefs; each listref is one component of the queryInput.
-            a single queryInput/Response may consist of one or more named or unnamed
+ returns  : a list of listrefs; each listref is one component of the queryInput or mobyData block
+            a single block may consist of one or more named or unnamed
             simple, collection, or parameter articles.
             The listref structure is thus [name, $ARTICLE_DOM]:
             
@@ -399,17 +398,17 @@
 
             generated from the following sample XML:
 
-                <queryInput>
+                <mobyData>
                     <Simple articleName='name1'>
                       <Object namespace=blah id=blah/>
                     </Simple>
-                </queryInput>
+                </mobyData>
         
     or  :  @articles = ['name1', $COLL_DOM], ['paramname1', $PARAM_DOM]
 
             generated from the following sample XML:
 
-                <queryInput>
+                <mobyData>
                     <Collection articleName='name1'>
                       <Simple>
                        <Object namespace=blah id=blah/>
@@ -422,7 +421,7 @@
                        <datatype>Float</datatype>
                        <default>10</default>
                     </Parameter>
-                </queryInput>
+                </mobyData>
 
 =cut
 
@@ -471,10 +470,10 @@
 sub genericServiceInputParserAsObject {
     my ($message) = @_;  # get the incoming MOBY query XML
     my @inputs;           # set empty response
-    my @queries = getInputs($message);  # returns XML::DOM nodes <queryInput>...</queryInput>
-    
+    my @queries = getInputs($message);  # returns XML::DOM nodes <mobyData>...</mobyData>
+
     foreach my $query(@queries){
-        my $queryID = getInputID($query);  # get the queryID attribute of the queryInput
+        my $queryID = getInputID($query);  # get the queryID attribute of the mobyData
         my @input_articles = getArticlesAsObjects($query); # get the Simple/Collection articles making up this query <Simple>...</Simple> or <Collection>...</Collection> or <Parameter>...</Parameter
         foreach my $article(@input_articles){       # input is a listref
             if ($article->isCollection){
@@ -621,16 +620,17 @@
 }
 
 
+
 =head2 simpleResponse
 
  name     : simpleResponse
- function : wraps a simple article in the appropriate queryResponse structure
+ function : wraps a simple article in the appropriate (mobyData) structure
  usage    : $resp .= &simpleResponse($object, 'MyArticleName', $queryID);
  args     : (in order)
             $object   - (optional) a MOBY Object as raw XML
             $article  - (optional) an articeName for this article
             $query    - (optional, but strongly recommended) the queryID value for the
-                        queryInput block to which you are responding
+                        mobyData block to which you are responding
  notes    : as required by the API you must return a response for every input.
             If one of the inputs was invalid, you return a valid (empty) MOBY
             response by calling &simpleResponse(undef, undef, $queryID) with no arguments.
@@ -647,19 +647,19 @@
     $articleName ||="";
     if ($articleName) {
         return "
-        <moby:queryResponse moby:queryID='$qID'>
+        <moby:mobyData moby:queryID='$qID'>
             <moby:Simple moby:articleName='$articleName'>$data</moby:Simple>
-        </moby:queryResponse>
+        </moby:mobyData>
         ";
     } elsif($data) {
         return "
-        <moby:queryResponse moby:queryID='$qID'>
+        <moby:mobyData moby:queryID='$qID'>
             <moby:Simple moby:articleName='$articleName'>$data</moby:Simple>
-        </moby:queryResponse>
+        </moby:mobyData>
         ";
     } else {
 	return "
-        <moby:queryResponse moby:queryID='$qID'/>
+        <moby:mobyData moby:queryID='$qID'/>
 	";
 	}
 }
@@ -671,7 +671,7 @@
         my $doc = $parser->parse($query);
         $query = $doc->getDocumentElement();
     }
-    return '' unless $query->getTagName =~/queryInput/;
+    return '' unless ($query->getTagName =~/queryInput/ || $query->getTagName =~/mobyData/);
     my $id = $query->getAttribute('queryID');
     $id ||= $query->getAttribute('moby:queryID');
     return $id;
@@ -681,12 +681,12 @@
 =head2 collectionResponse
 
  name     : collectionResponse
- function : wraps a set of articles in the appropriate queryResponse structure
+ function : wraps a set of articles in the appropriate mobyData structure
  usage    : return responseHeader . &collectionResponse(\@objects, 'MyArticleName', $queryID) . responseFooter;
  args     : (in order)
             \@objects - (optional) a listref of MOBY Objects as raw XML
             $article  - (optional) an articeName for this article
-            $queryID  - (optional, but strongly recommended) the queryInput ID
+            $queryID  - (optional, but strongly recommended) the mobyData ID
                         to which you are responding
  notes    : as required by the API you must return a response for every input.
             If one of the inputs was invalid, you return a valid (empty) MOBY
@@ -701,7 +701,7 @@
     $data ||=[];
     $qID ||= '';
     unless ((ref($data) =~ /array/i) && $data->[0]){  # we're expecting an arrayref as input data,and it must not be empty
-        return "<moby:queryResponse moby:queryID='$qID'/>";
+        return "<moby:mobyData moby:queryID='$qID'/>";
     }
 
     foreach (@{$data}){
@@ -717,17 +717,17 @@
     }
     if ($articleName) {
         return "
-        <moby:queryResponse moby:queryID='$qID'>
+        <moby:mobyData moby:queryID='$qID'>
             <moby:Collection moby:articleName='$articleName'>
                 $content
             </moby:Collection>
-        </moby:queryResponse>
+        </moby:mobyData>
         ";
     } else {
         return "
-        <moby:queryResponse moby:queryID='$qID'>
+        <moby:mobyData moby:queryID='$qID'>
             <moby:Collection moby:articleName='$articleName'>$content</moby:Collection>
-        </moby:queryResponse>
+        </moby:mobyData>
         ";
     }
 }
@@ -762,7 +762,7 @@
     $notes ||="";
     my $xml = "<?xml version='1.0' encoding='UTF-8'?>".
         "<moby:MOBY xmlns:moby='http://www.biomoby.org/moby' xmlns='http://www.biomoby.org/moby'>".
-        "<moby:Response moby:authority='$auth'>";
+        "<moby:mobyContent moby:authority='$auth'>";
     if ($notes){
         my $encodednotes = HTML::Entities::encode($notes);
         $xml .="<moby:serviceNotes>$encodednotes</moby:serviceNotes>";
@@ -786,7 +786,7 @@
 
 
 sub responseFooter {
-    return "</moby:Response></moby:MOBY>";
+    return "</moby:Content></moby:MOBY>";
 }
 
 
@@ -794,7 +794,7 @@
 =head2 getInputs
 
  name     : getInputs
- function : get the queryInput block(s) as XML::DOM nodes
+ function : get the mobyData block(s) as XML::DOM nodes
  usage    : @queryInputs = getInputArticles($XML)
  args     : the raw XML of a <MOBY> query, or an XML::DOM document
  returns  : a list of XML::DOM::Node's, each is a queryInput or mobyData block.
@@ -817,8 +817,8 @@
     my @queries;
 
     foreach my $querytag('queryInput', 'moby:queryInput', 'mobyData', 'moby:mobyData'){
-        my $x = $moby->getElementsByTagName($querytag);  # get the queryInput block
-        for (0..$x->getLength-1){ # there may be more than one queryInput per message
+        my $x = $moby->getElementsByTagName($querytag);  # get the mobyData block
+        for (0..$x->getLength-1){ # there may be more than one mobyData per message
             push @queries, $x->item($_);
         }
     }
@@ -860,11 +860,11 @@
 =head2 getArticlesAsObjects
 
  name     : DO NOT USE!!
- function : get the Simple/Collection articles for a single queryInput
+ function : get the Simple/Collection articles for a single mobyData
             or queryResponse node, rethrning them as SimpleArticle,
             SecondaryArticle, or ServiceInstance objects
  usage    : @articles = getArticles($XML)
- args     : raw XML or XML::DOM of a moby:queryInput, moby:queryResponse block
+ args     : raw XML or XML::DOM of a moby:mobyData block
  returns  :
 
 =cut
@@ -977,13 +977,13 @@
 
     my $x;
     foreach ('queryInput', 'moby:queryInput', 'mobyData', 'moby:mobyData'){
-        $x = $moby->getElementsByTagName($_);  # get the queryInput block
+        $x = $moby->getElementsByTagName($_);  # get the mobyData block
         last if $x->item(0);
     }
     return undef unless $x->item(0); # in case there was no match at all
     
     my @queries;
-    for (0..$x->getLength-1){ # there may be more than one queryInput per message
+    for (0..$x->getLength-1){ # there may be more than one mobyData per message
 		my @this_query;
         foreach my $child($x->item($_)->getChildNodes){ # there may be more than one Simple/Collection per input; iterate over them 
             next unless $child->getNodeType == ELEMENT_NODE; # ignore whitespace




More information about the MOBY-guts mailing list