[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Fri Feb 21 04:10:25 UTC 2003


mwilkinson
Thu Feb 20 23:10:25 EST 2003
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv30440/MOBY/Client

Modified Files:
	Central.pm 
Log Message:
new function 'ISA' to ask MOBY Central for the parentage and container status of an object.  useful if a service passes you something you have never seen before.
moby-live/Perl/MOBY/Client Central.pm,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2003/02/21 00:15:44	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2003/02/21 04:10:25	1.4
@@ -1061,6 +1061,42 @@
 }
 
 
+
+sub ISA {
+	my ($self)= shift;
+	my ($obj) = shift;
+	my ($reg) = shift;
+	return undef unless $obj;
+	my $message = "
+	<ISA>
+	 <objectType>$obj</objectType>
+	</ISA>";
+
+	$reg =$reg?$reg:$self->default_MOBY_servername;
+	return undef unless ($self->SOAP_connection($reg));
+	my $return = $self->SOAP_connection($reg)->call('ISA' => ($message))->paramsall;
+	#<Relationships>
+	#   <objectType>QueryObject</objectType>
+	#   <ISA>
+	#	  <objectType>ParentObject</objectType>
+	#	  ...
+	#	  ...
+	#    </ISA>
+	#	<HASA>
+	#	  <objectType>ContainedObject</objectType>
+	#	  ...
+	#	  ...
+	#	</HASA>
+	#</Relationships>
+    my $parser = new XML::DOM::Parser;
+    my $doc = $parser->parse($return);
+    my $root = $doc->getDocumentElement;
+	my @ISAs = &_nodeArrayContent($doc, "ISA");
+	my @HASA = &_nodeArrayContent($doc, "HASA");
+    return (\@ISAs, \@HASA);
+}
+
+
 sub _parseServices {
     my ($self, $Registry, $XML) = @_;
     my $Parser = new XML::DOM::Parser;
@@ -1139,6 +1175,28 @@
     }
     return $content;
 }
+
+
+sub _nodeArrayContent {
+	# will get array content of all child $node from given $DOM
+	# regardless of depth!
+    my ($DOM, $node) = @_;
+	$debug && &_LOG("_nodeArrayContext received DOM:  ", $DOM->toString,"\nsearching for node $node\n");
+    my @result;
+    my $x = $DOM->getElementsByTagName($node);
+    my @child = $x->item(0)->getChildNodes;
+    foreach (@child){
+        next unless $_->getNodeType == ELEMENT_NODE;
+        my @child2 = $_->getChildNodes;
+        foreach (@child2){
+            #print $_->getNodeTypeName, "\t", $_->toString,"\n";
+            next unless $_->getNodeType == TEXT_NODE;
+            push @result, $_->toString;
+        }
+    }
+    return @result;
+}
+
 sub AUTOLOAD {
     no strict "refs";
     my ($self, $newval) = @_;



More information about the MOBY-guts mailing list