[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Fri Jul 29 18:58:45 UTC 2005


mwilkinson
Fri Jul 29 14:58:44 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Client
In directory pub.open-bio.org:/tmp/cvs-serv11340/MOBY/Client

Modified Files:
	Central.pm SimpleArticle.pm 
Log Message:
updated pod documentation for MOBY Central and MOBY Client Central.  MOBY Client Central now has ways of getting to the LSID for various things in the MOBY Central messages.  See pod for details.

moby-live/Perl/MOBY/Client Central.pm,1.106,1.107 SimpleArticle.pm,1.7,1.8
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2005/07/29 15:43:26	1.106
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm	2005/07/29 18:58:44	1.107
@@ -467,16 +467,17 @@
              an additional XML hash key that contains the actual XML containing
              the object definition as sent by MOBY Central (used for a visual
 			 overview, rather than parsing all of the hash keys)
-	objectType => "the name of the Object"
+    objectType => "the name of the Object"
+    objectLSID => "urn:lsid:..."
     description => "a human-readable description of the object"
     contactEmail => "your at email.address"
     authURI => "URI of the registrar of this object"
     Relationships => {
       relationshipType1 => [
-        [Object1, articleName],
-        [Object2, articleName]],
+        [Object1, articleName, lsid],
+        [Object2, articleName, lsid]],
       relationshipType2 => [
-        [Object1, articleName]]}
+        [Object1, articleName, lsid]]}
     XML => <....XML of object registration.../>
 
  Args      : objectType =>  the name or LSID URI for an object
@@ -545,14 +546,18 @@
 			next unless $_->nodeType == ELEMENT_NODE;
 			my $article =
 			  $_->getAttributeNode('articleName');  # may or may not have a name
+			my $rlsid =
+			  $_->getAttributeNode('lsid');  # may or may not have a name
 			if ($article) { $article = $article->getValue() }
+			if ($rlsid) { $rlsid = $rlsid->getValue() }
+			
 			my @child2 = $_->childNodes;
 			foreach (@child2) {
 
 				#print getNodeTypeName($_), "\t", $_->toString,"\n";
 				next unless $_->nodeType == TEXT_NODE;
 				push @{ $relationships{$relationshipType} },
-				  [ $_->toString, $article ];
+				  [ $_->toString, $article, $rlsid ];
 			}
 		}
 	}
@@ -1295,19 +1300,22 @@
 
 =head2 retrieveServiceNames
 
- Title     :	retrieveServiceNames
+ Title     :	retrieveServiceNames(%args)
  Usage     :	$names = $MOBY->retrieveServiceNames([$reg_name])
  Function  :	get a (redundant) list of all registered service names
                 (N.B. NOT service types!)
  Returns   :	hashref to the following hash
                 $names{$AuthURI} = [serviceName_1, serviceName_2, serviceName3...]
- Args      :	$reg_name:  name of registry you wish to retrieve from (optional) 
+ Args      :	registry => $reg_name:  name of registry you wish to retrieve from (optional)
+                as_lsid => $boolean: return service names as their corresponding LSID's (default off)
 
 =cut
 
 sub retrieveServiceNames {
-	my ($self) = shift;
-	my $reg = shift;
+	my ($self, %args) = shift;
+	my $reg = $args{registry};
+	my $aslsid = $args{as_lsid};
+	
 	$reg = $reg ? $reg : $self->default_MOBY_servername;
 	return undef unless ( $self->Connection($reg) );
 
@@ -1324,7 +1332,14 @@
 		  $names_list->get_node($x)->getAttributeNode('name')->getValue;
 		my $auth =
 		  $names_list->get_node($x)->getAttributeNode('authURI')->getValue;
-		push @{ $servicenames{$auth} }, $name;
+		my $lsid = $names_list->get_node($x)->getAttributeNode('lsid');
+		if ($lsid){
+		    $lsid = $lsid->getValue;
+		} else {
+		    $lsid = $name;
+		}
+		$lsid ||=$name;
+		push @{ $servicenames{$auth} }, $aslsid?$lsid:$name;
 	}
 	return \%servicenames;
 }
@@ -1362,18 +1377,20 @@
 
 =head2 retrieveServiceTypes
 
- Title     :	retrieveServiceTypes
+ Title     :	retrieveServiceTypes(%args)
  Usage     :	$types = $MOBY->retrieveServiceTypes([$reg_name])
  Function  :	get the list of all registered service types
  Returns   :	hashref of $types{$type} = $definition
- Args      :	$reg_name:  name of registry you wish to retrieve from (optional) 
-
+ 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 retrieveServiceTypes {
-	my ($self) = shift;
-	my $reg = shift;
+	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) );
 
@@ -1387,6 +1404,12 @@
 	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;
 		for
 		  my $elem ( $types->get_node($x)->getElementsByTagName('Description') )
@@ -1397,29 +1420,29 @@
 			}
 		}
 		$desc =~ s/<!\[CDATA\[((?>[^\]]+))\]\]>/$1/gs;
-		$servicetypes{$type} = $desc;
+		$servicetypes{$as_lsid?$lsid:$type} = $desc;
 	}
 	return \%servicetypes;
 }
 
 =head2 retrieveObjectNames
 
- Title     :	retrieveObjectNames
+ Title     :	retrieveObjectNames(%args)
  Usage     :	$names = $MOBY->retrieveObjectNames([$reg_name])
  Function  :	get the list of all registered Object types
  Returns   :	hashref of hash:
                 $names{$name} = $definition
- Args      :	$reg_name:  name of registry you wish to retrieve from (optional) 
+ Args      :	registry => $reg_name:  name of registry you wish to retrieve from (optional)
+                as_lsid  => $boolean:  return $name as its correspnding LSID (default off)
 
 =cut
 
 sub retrieveObjectNames {
-	my ($self) = shift;
-	my $reg = shift;
+	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('retrieveObjectNames' => (@_))->paramsall;
 	my ($return) = $self->_call( $reg, 'retrieveObjectNames', "" );
 	my $parser = XML::LibXML->new();
 	my $doc     = $parser->parse_string($return);
@@ -1429,6 +1452,12 @@
 	for ( my $x = 1 ; $x <= $obnames->size() ; $x++ ) {
 		next unless $obnames->get_node($x)->nodeType == ELEMENT_NODE;
 		my $name = $obnames->get_node($x)->getAttributeNode('name')->getValue;
+		my $lsid = $obnames->get_node($x)->getAttributeNode('lsid');
+		if ($lsid){
+		    $lsid = $lsid->getValue;
+		} else {
+		    $lsid = $name;
+		}
 		my $desc;
 		for my $elem (
 			$obnames->get_node($x)->getElementsByTagName('Description') )
@@ -1439,29 +1468,30 @@
 			}
 		}
 		$desc =~ s/<!\[CDATA\[((?>[^\]]+))\]\]>/$1/gs;
-		$objectnames{$name} = $desc;
+		$objectnames{$as_lsid?$lsid:$name} = $desc;
 	}
 	return \%objectnames;
 }
 
 =head2 retrieveNamespaces
 
- Title     :	retrieveNamespaces
+ Title     :	retrieveNamespaces(%args)
  Usage     :	$ns = $MOBY->retrieveNamespaces([$reg_name])
  Function  :	get the list of all registered Namespace types
  Returns   :	hashref of hash:
                 $ns{$namespace} = $definition
- Args      :	$reg_name:  name of registry you wish to retrieve from (optional) 
+ 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) = shift;
-	my $reg = shift;
+	my ($self, %args) = shift;
+	my $reg = $args{registry};
 	$reg = $reg ? $reg : $self->default_MOBY_servername;
 	return undef unless ( $self->Connection($reg) );
-
-#	my $return = $self->SOAP_connection($reg)->call('retrieveNamespaces' => (@_))->paramsall;
+	my $as_lsid = $args{as_lsid};
+	
 	my ($return) = $self->_call( $reg, 'retrieveNamespaces', "" );
 	my $parser = XML::LibXML->new();
 	my $doc    = $parser->parse_string($return);
@@ -1471,6 +1501,12 @@
 	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;
 		for my $elem (
 			$namesp->get_node($x)->getElementsByTagName('Description') )
@@ -1482,28 +1518,29 @@
 			}
 		}
 		$desc =~ s/<!\[CDATA\[((?>[^\]]+))\]\]>/$1/gs;
-		$namespaces{$ns} = $desc;
+		$namespaces{$as_lsid?$lsid:$ns} = $desc;
 	}
 	return \%namespaces;
 }
 
 =head2 retrieveObject
 
- NOT YET IMPLEMENTED
  Title     :	retrieveObject
- Usage     :	$objects = $MOBY->retrieveObjectNames($reg, $name | "all")
+ Usage     :	$objects = $MOBY->retrieveObjectNames(%args)
  Function  :	get the object xsd
  Returns   :	hashref of hash:
                 $objects{$name} = $W3C_XML_Schema_string
- Args      :	$reg - name of MOBY Central you want to use (must pass undef otherwise)
-                $name - object name (from ontology) or "all" to get all objects
-
+ Args      :	registry => $reg - name of MOBY Central you want to use (must pass undef otherwise)
+                objectType => $name - object name (from ontology) or undef to get all objects
+		as_lsid => $boolean - return $name as its corresponding LSID (default off)
+    
 =cut
 
 sub retrieveObject {
-	my ($self)  = shift;
-	my ($reg)   = shift;
-	my $type    = shift;
+	my ($self, %args)  = shift;
+	my ($reg)   = $args{registry};
+	my $type    = $args{objectType};
+	my $as_lsid = $args{as_lsid};
 	my $message = "
 	<retrieveObject>
 		 <objectType>$type</objectType>
@@ -1511,7 +1548,6 @@
 	$reg = $reg ? $reg : $self->default_MOBY_servername;
 	return undef unless ( $self->Connection($reg) );
 
-#	my $return = $self->SOAP_connection($reg)->call('retrieveObject' => ($message))->paramsall;
 	my ($return) = $self->_call( $reg, 'retrieveObject', $message );
 	my $parser = XML::LibXML->new();
 	my $doc     = $parser->parse_string($return);
@@ -1521,6 +1557,12 @@
 	for ( my $x = 1 ; $x <= $objects->size() ; $x++ ) {
 		next unless $objects->get_node($x)->nodeType == ELEMENT_NODE;
 		my $name = $objects->get_node($x)->getAttributeNode('name')->getValue;
+		my $lsid = $objects->get_node($x)->getAttributeNode('lsid');
+		if ($lsid){
+		    $lsid = $lsid->getValue;
+		} else {
+		    $lsid = $name;
+		}
 		my $desc;
 		for my $elem ( $objects->get_node($x)->getElementsByTagName('Schema') )
 		{
@@ -1724,7 +1766,12 @@
 		my $Service       = $Services->get_node($x);
 		my $AuthURI       = $Service->getAttributeNode('authURI')->getValue;
 		my $servicename   = $Service->getAttributeNode('serviceName')->getValue;
-		#my $lsid   		  = $Service->getAttributeNode('lsid')->getValue;
+		my $lsid          = $Service->getAttributeNode('lsid');
+		if ($lsid){
+		    $lsid = $lsid->getValue;
+		} else {
+		    $lsid = "";
+		}
 		my $Type          = &_nodeTextContent( $Service, 'serviceType' );
 		my $authoritative = &_nodeTextContent( $Service, 'authoritative' );
 		my $contactEmail  = &_nodeTextContent( $Service, 'contactEmail' );
@@ -1788,7 +1835,7 @@
 			authority     => $AuthURI,
 			authoritative => $authoritative,
 			URL           => $URL,
-			#LSID		  => $lsid,
+			LSID		=> $lsid,
 			contactEmail  => $contactEmail,
 			name          => $servicename,
 			type          => $Type,

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm	2004/12/14 22:31:30	1.7
+++ /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm	2005/07/29 18:58:44	1.8
@@ -86,6 +86,17 @@
 
 =cut
 
+=head2 objectLSID
+
+ Title     :	objectLSID
+ Usage     :	$type = $SA->objectLSID($type)
+ Function  :	get/set LSID
+ Returns   :	string
+ Arguments :    (optional) string representing objectLSID to set
+
+=cut
+
+
 =head2 namespaces
 
  Title     :	namespaces
@@ -171,6 +182,7 @@
 	  (
 		articleName => [ undef, 'read/write' ],
 		objectType  => [ undef, 'read/write' ],
+		objectLSID  => [ undef, 'read/write' ],
 		namespaces => [ [], 'read/write' ],
 		id           => [ undef, 'read/write' ],
 		XML_DOM      => [ undef, 'read/write' ],
@@ -250,11 +262,15 @@
 	$self->articleName( "" );
 	$self->objectType( "" );
 	my $attr        = $dom->getAttributeNode( 'articleName' );
+	my $lsid        = $dom->getAttributeNode( 'lsid' );
 	my $articleName = "";
 	$articleName = $attr->getValue if $attr;
+        $lsid = $attr->getValue if $lsid;
+        
 	$self->articleName( $articleName )
 	  if $articleName
 	  ; # it may have already been set if this Simple is part of a Collection...
+        $self->objectLSID( $lsid) if $lsid;
 
 # fork here - it may be an instantiated object (coming from a service invocation/response)
 # or it may be a template object as in the SimpleArticle element of a registration call




More information about the MOBY-guts mailing list