[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Tue Sep 27 16:19:21 UTC 2005


mwilkinson
Tue Sep 27 12:19:21 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv26197/MOBY/Client

Modified Files:
	Central.pm 
Log Message:
added two new methods to MOBY Client Central to extract the additional details from namespace and service retrieval

moby-live/Perl/MOBY/Client Central.pm,1.124,1.125
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2005/09/16 17:01:10	1.124
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2005/09/27 16:19:21	1.125
@@ -1236,7 +1236,6 @@
 	" . ( $SI->XML ) . "
 	</retrieveService>";
 
-#    my $return  = $self->SOAP_connection($reg)->call(retrieveService => ($message))->paramsall;
 	my ($return) = $self->_call( $reg, 'retrieveService', $message );
 	my $parser = XML::LibXML->new();
 	my $doc   = $parser->parse_string($return);
@@ -1292,7 +1291,7 @@
 
 =head2 retrieveServiceNames
 
- Usage     :	$names = $MOBY->retrieveServiceNames([$reg_name])
+ Usage     :	$names = $MOBY->retrieveServiceNames(%args)
  Function  :	get a (redundant) list of all registered service names
                 (N.B. NOT service types!)
  Returns   :	hashref to the following hash
@@ -1367,7 +1366,7 @@
 
 =head2 retrieveServiceTypes
 
- Usage     :	$types = $MOBY->retrieveServiceTypes([$reg_name])
+ Usage     :	$types = $MOBY->retrieveServiceTypes(%args)
  Function  :	get the list of all registered service types
  Returns   :	hashref of $types{$type} = $definition
  Args      :	registry => $reg_name:  name of registry you wish to retrieve from (optional)
@@ -1414,6 +1413,76 @@
 	return \%servicetypes;
 }
 
+
+=head2 retrieveServiceTypesFull
+
+ Usage     :	$types = $MOBY->retrieveServiceTypesFull(%args)
+ Function  :	get all details of all service types
+ Returns   :	hashref of $types{$type} = {definition => "definition",
+                                            authURI  => "authority.uri.here",
+					    contactEmail => "email at addy.here"}
+ Args      :	registry => $reg_name:  name of registry you wish to retrieve from (optional)
+                as_lsid  => $boolean:  return the $type as its corresponding LSID (defualt off)
+
+=cut
+
+
+sub retrieveServiceTypesFull {
+	my ($self, %args) = shift;
+	my $reg = $args{registry};
+	my $as_lsid = $args{as_lsid};
+	
+	$reg = $reg ? $reg : $self->default_MOBY_servername;
+	return undef unless ( $self->Connection($reg) );
+
+#	my $return = $self->SOAP_connection($reg)->call('retrieveServiceTypes' => (@_))->paramsall;
+	my ($return) = $self->_call( $reg, 'retrieveServiceTypes', "" );
+	my $parser = XML::LibXML->new();
+	my $doc   = $parser->parse_string($return);
+	my $root  = $doc->getDocumentElement;
+	my $types = $root->childNodes;
+	my %servicetypes;
+	for ( my $x = 1 ; $x <= $types->size() ; $x++ ) {
+		next unless $types->get_node($x)->nodeType == ELEMENT_NODE;
+		my $type = $types->get_node($x)->getAttributeNode('name')->getValue;
+		my $lsid = $types->get_node($x)->getAttributeNode('lsid');
+		if ($lsid){
+		    $lsid = $lsid->getValue;
+		} else {
+		    $lsid = $type;
+		}
+		my ($desc, $auth, $email);
+		for
+		  my $elem ( $types->get_node($x)->getElementsByTagName('Description') )
+		{
+			$desc = $elem->firstChild->toString;
+			if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
+				$desc = $1;
+			}
+		}
+		for
+		  my $elem ( $types->get_node($x)->getElementsByTagName('authURI') )
+		{
+			$auth = $elem->firstChild->toString;
+			if ( $auth =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
+				$auth = $1;
+			}
+		}
+		for
+		  my $elem ( $types->get_node($x)->getElementsByTagName('contactEmail') )
+		{
+			$emai = $elem->firstChild->toString;
+			if ( $email =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
+				$email = $1;
+			}
+		}
+		$desc =~ s/<!\[CDATA\[((?>[^\]]+))\]\]>/$1/gs;  # somehow these CDATA elements are nested sometimes???
+		$servicetypes{$as_lsid?$lsid:$type} = {Description => $desc, authURI => $auth, contactEmail => $email};
+	}
+	return \%servicetypes;
+}
+
+
 =head2 retrieveObjectNames
 
  Usage     :	$names = $MOBY->retrieveObjectNames([$reg_name])
@@ -1463,7 +1532,7 @@
 
 =head2 retrieveNamespaces
 
- Usage     :	$ns = $MOBY->retrieveNamespaces([$reg_name])
+ Usage     :	$ns = $MOBY->retrieveNamespaces(%args)
  Function  :	get the list of all registered Namespace types
  Returns   :	hashref of hash:
                 $ns{$namespace} = $definition
@@ -1511,6 +1580,78 @@
 	return \%namespaces;
 }
 
+=head2 retrieveNamespacesFull
+
+ Usage     :	$ns = $MOBY->retrieveNamespaces(%args)
+ Function  :	get all details about all namespaces
+ Returns   :	hashref of hash:
+                $ns{$namespace} = {Definition => $definition,
+		                   authURI => $authority,
+				   contactEmail => $email} 
+ Args      :	registry => $reg_name:  name of registry you wish to retrieve from (optional)
+                as_lsid  => $boolean:  retrieve $namespace as its corresponding LSID (default off)
+
+=cut
+
+sub retrieveNamespaces {
+	my ($self, %args) = shift;
+	my $reg = $args{registry};
+	$reg = $reg ? $reg : $self->default_MOBY_servername;
+	return undef unless ( $self->Connection($reg) );
+	my $as_lsid = $args{as_lsid};
+	
+	my ($return) = $self->_call( $reg, 'retrieveNamespaces', "" );
+	my $parser = XML::LibXML->new();
+	my $doc    = $parser->parse_string($return);
+	my $root   = $doc->getDocumentElement;
+	my $namesp = $root->childNodes;
+	my %namespaces;
+	for ( my $x = 1 ; $x <= $namesp->size() ; $x++ ) {
+		next unless $namesp->get_node($x)->nodeType == ELEMENT_NODE;
+		my $ns = $namesp->get_node($x)->getAttributeNode('name')->getValue;
+		my $lsid = $namesp->get_node($x)->getAttributeNode('lsid');
+		if ($lsid){
+		    $lsid = $lsid->getValue;
+		} else {
+		    $lsid = $ns;
+		}
+		my ($desc, $auth, $email);
+		for my $elem (
+			$namesp->get_node($x)->getElementsByTagName('Description') )
+		{
+			$desc = $elem->firstChild;
+			$desc = $desc ? $desc->toString : "";
+			$desc ||="";
+			if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
+				$desc = $1;
+			}
+		}
+		for my $elem (
+			$namesp->get_node($x)->getElementsByTagName('authURI') )
+		{
+			$auth = $elem->firstChild;
+			$auth = $auth ? $auth->toString : "";
+			$auth ||="";
+			if ( $auth =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
+				$auth = $1;
+			}
+		}
+		for my $elem (
+			$namesp->get_node($x)->getElementsByTagName('contactEmail') )
+		{
+			$email = $elem->firstChild;
+			$email = $email ? $email->toString : "";
+			$email ||="";
+			if ( $email =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
+				$email = $1;
+			}
+		}
+		$namespaces{$as_lsid?$lsid:$ns} = {Description => $desc, authURI => $auth, contactEmail => $email};
+	}
+	return \%namespaces;
+}
+
+
 =head2 retrieveObject
 
  Usage     :	$objects = $MOBY->retrieveObjectNames(%args)




More information about the MOBY-guts mailing list