[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Mon Jul 14 21:17:13 UTC 2003
mwilkinson
Mon Jul 14 17:17:13 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv2031/MOBY
Modified Files:
CommonSubs.pm
Log Message:
added new subroutine to start dealing with Collection outputs. Added a service (untested so far) that outputs a collection of GO terms that are related to a keyword input
moby-live/Perl/MOBY CommonSubs.pm,1.8,1.9
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2003/07/14 20:05:27 1.8
+++ /home/repository/moby/moby-live/Perl/MOBY/CommonSubs.pm 2003/07/14 21:17:13 1.9
@@ -72,6 +72,7 @@
responseFooter
getInputArticles
getNodeContentWithArticle
+ collectionResponse
);
%EXPORT_TAGS =(all => [qw(
getSimpleArticleIDs
@@ -81,6 +82,7 @@
responseFooter
getInputArticles
getNodeContentWithArticle
+ collectionResponse
)]);
@@ -199,8 +201,6 @@
}
-
-
=head2 simpleResponse
name : simpleResponse
@@ -216,8 +216,6 @@
=cut
-
-
sub simpleResponse {
my ($data, $articleName) = @_; # articleName optional
if ($articleName) {
@@ -243,6 +241,61 @@
}
+=head2 collectionResponse
+
+ name : collectionResponse
+ function : wraps a set of articles in the appropriate queryResponse structure
+ usage : return responseHeader . &collectionResponse(\@objects, 'MyArticleName') . responseFooter;
+ args : (in order)
+ \@objects - (optional) a listref of MOBY Objects as raw XML
+ $article - (optional) an articeName for this article
+ 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 &collectionResponse() with no arguments.
+
+=cut
+
+
+sub collectionResponse {
+ my ($data, $articleName) = @_; # articleName optional
+ my $content = "";
+ unless (ref $data =~ /array/){ # we're expecting an arrayref as input data
+ return "<moby:queryResponse>
+ </moby:queryResponse>";
+ }
+
+ foreach (@{$data}){
+ if($_) {
+ $content .= "
+ <Simple>
+ $data
+ </Simple>
+ ";
+ } else {
+ $content .= "
+ <Simple>
+ </Simple>
+ ";
+ }
+ }
+ if ($articleName) {
+ return "
+ <moby:queryResponse>
+ <Collection articleName='$articleName'>
+ $content
+ </Collection>
+ </moby:queryResponse>
+ ";
+ } else {
+ return "
+ <moby:queryResponse>
+ <Collection>$content</Collection>
+ </moby:queryResponse>
+ ";
+ }
+}
+
+
=head2 responseHeader
More information about the MOBY-guts
mailing list