[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Wed Jan 28 14:45:18 UTC 2009


kawas
Wed Jan 28 09:45:18 EST 2009
Update of /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers
In directory dev.open-bio.org:/tmp/cvs-serv16288/Perl/MOBY-Server/lib/MOBY/RDF/Parsers

Modified Files:
	ServiceParser.pm 
Log Message:
added a loop to parse out unit tests in those instances that more than one is defined
added code to parse out the datatype/namespace/servicetype term from a uri/lsid
moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers ServiceParser.pm,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers/ServiceParser.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers/ServiceParser.pm	2008/11/25 18:05:44	1.3
+++ /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/RDF/Parsers/ServiceParser.pm	2009/01/28 14:45:18	1.4
@@ -346,7 +346,7 @@
 					  );
 					if ( $$val[0] ) {
 						for my $uri (@$val) {
-							$param->addNamespace( $uri->getURI )
+							$param->addNamespace( $self->_unwrap_namespace( $uri->getURI ) )
 							  if $uri->getURI ne MOBY::RDF::Predicates::FETA
 								  ->parameterNamespace;
 						}
@@ -386,11 +386,12 @@
 									  )
 				  );
 				if ( $$val[0] ) {
-					$param->objectType( $$val[0]->getURI );
+					$param->objectType( $self->_unwrap_datatype($$val[0]->getURI) );
 				}
 
 				# add the param to the service
 				push @{ $instance->input }, $param;
+				$param = undef;
 			}
 			elsif ( $val eq MOBY::RDF::Predicates::FETA->collectionParameter ) {
 				my $param      = MOBY::Client::SimpleArticle->new();
@@ -416,7 +417,7 @@
 					  );
 					if ( $$val[0] ) {
 						for my $uri (@$val) {
-							$param->addNamespace( $uri->getURI )
+							$param->addNamespace( $self->_unwrap_namespace( $uri->getURI ) )
 							  if $uri->getURI ne MOBY::RDF::Predicates::FETA
 								  ->parameterNamespace;
 						}
@@ -456,12 +457,13 @@
 									  )
 				  );
 				if ( $$val[0] ) {
-					$param->objectType( $$val[0]->getURI );
+					$param->objectType( $self->_unwrap_datatype($$val[0]->getURI) );
 				}
 				$collection->addSimple($param);
 
 				# add the param to the service
 				push @{ $instance->input }, $collection;
+				$param = undef;
 			}
 			elsif ( $val eq MOBY::RDF::Predicates::FETA->secondaryParameter ) {
 				my $param = MOBY::Client::SecondaryArticle->new;
@@ -556,6 +558,7 @@
 
 				# add the secondary to the service
 				push @{ $instance->secondary }, $param;
+				$param = undef;
 			}
 		}
 
@@ -616,7 +619,7 @@
 					  );
 					if ( $$val[0] ) {
 						for my $uri (@$val) {
-							$param->addNamespace( $uri->getURI )
+							$param->addNamespace( $self->_unwrap_namespace( $uri->getURI ) )
 							  if $uri->getURI ne MOBY::RDF::Predicates::FETA
 								  ->parameterNamespace;
 						}
@@ -656,11 +659,12 @@
 									  )
 				  );
 				if ( $$val[0] ) {
-					$param->objectType( $$val[0]->getURI );
+					$param->objectType( $self->_unwrap_datatype($$val[0]->getURI) );
 				}
 
 				# add the param to the service
 				push @{ $instance->output }, $param;
+				$param = undef;
 			}
 			elsif ( $val eq MOBY::RDF::Predicates::FETA->collectionParameter ) {
 				my $param      = MOBY::Client::SimpleArticle->new();
@@ -686,12 +690,11 @@
 					  );
 					if ( $$val[0] ) {
 						for my $uri (@$val) {
-							$param->addNamespace( $uri->getURI )
+							$param->addNamespace( $self->_unwrap_namespace( $uri->getURI ) )
 							  if $uri->getURI ne MOBY::RDF::Predicates::FETA
 								  ->parameterNamespace;
 						}
 					}
-
 				}
 
 				# get the articlename
@@ -726,12 +729,13 @@
 									  )
 				  );
 				if ( $$val[0] ) {
-					$param->objectType( $$val[0]->getURI );
+					$param->objectType( $self->_unwrap_datatype($$val[0]->getURI) );
 				}
 				$collection->addSimple($param);
 
 				# add the param to the service
 				push @{ $instance->output }, $collection;
+				$param = undef;
 			}
 		}
 
@@ -767,6 +771,24 @@
 			}
 		}
 		$val = "" if ref($val) eq 'ARRAY';
+
+		# check if $SI->type is an lsid or uri
+		if ( $val =~ m/RESOURCES\/MOBY\-S\/Services(\/[A-Za-z0-9_\-]*)?$/ ) {
+
+			# uri is /Services/
+			$val = substr $1, 1 if $1;
+		}
+		elsif ( $val =~ m/RESOURCES\/MOBY\-S\/Services(\#[A-Za-z0-9_\-]*)?$/ ) {
+
+			# uri is /Services#
+			$val = substr $1, 1 if $1;
+		}
+		elsif ( $val =~ m/^urn\:lsid/i ) {
+
+			# uri is an lsid
+			my $lsid = LS::ID->new($val);
+			$val = $lsid->object if $lsid;
+		}
 		$instance->type( MOBY::RDF::Utils::trim($val) );
 
 		# dont need the performsTask node anymore
@@ -834,10 +856,9 @@
 			$unit->xpath( MOBY::RDF::Utils::trim($val) );
 
 			# set the unit test in the service
-			$instance->unitTest($unit);
+			push @{ $instance->unitTests }, $unit;
 
-			# should only be one ... so last;
-			last;
+			#$instance->unitTest($unit);
 		}
 
 		# this service is done ...
@@ -853,5 +874,35 @@
 
 }
 
+sub _unwrap_datatype {
+	my ($self, $uri) = @_;
+	
+	# process the objectType, i.e. check to see if it is an LSID, or uri, etc
+	if ( $uri =~ m/RESOURCES\/MOBY\-S\/Objects(\/[A-Za-z0-9_\-]*)?$/ ) {
+		$uri = substr $1, 1 if $1;
+	} elsif (
+		 $uri =~ m/RESOURCES\/MOBY\-S\/Objects(\#[A-Za-z0-9_\-]*)?$/ ) {
+		$uri = substr $1, 1 if $1;
+	} elsif ( $uri =~ m/^urn\:lsid/i ) {
+		my $lsid = LS::ID->new( $uri );
+		$uri =  $lsid->object if $lsid;
+	}
+	return $uri;
+}
+
+sub _unwrap_namespace {
+	my ($self, $n) = @_;
+	# get only the namespace name (strip from lsid or URI)
+	if ($n =~ m/RESOURCES\/MOBY\-S\/Namespaces(\/[A-Za-z0-9_\-]*)?$/) {
+		$n = substr $1, 1 if $1;
+	} elsif ($n =~ m/RESOURCES\/MOBY\-S\/Namespaces(\#[A-Za-z0-9_\-]*)?$/ ){
+		$n = substr $1, 1 if $1;
+	} elsif( $n =~ m/^urn\:lsid/i) {
+		my $lsid = LS::ID->new($n);
+		$n = $lsid->object if $lsid;
+	}
+	return $n;
+}
+
 1;
 __END__




More information about the MOBY-guts mailing list