[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Mon Dec 17 18:50:27 UTC 2007


kawas
Mon Dec 17 13:50:27 EST 2007
Update of /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies
In directory dev.open-bio.org:/tmp/cvs-serv6446/Perl/MOBY/RDF/Ontologies

Modified Files:
	Services.pm 
Log Message:
added a flag to findService so that you can omit isAlive information when deemed necessary
moby-live/Perl/MOBY/RDF/Ontologies Services.pm,1.8,1.9
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Services.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Services.pm	2007/11/29 19:45:54	1.8
+++ /home/repository/moby/moby-live/Perl/MOBY/RDF/Ontologies/Services.pm	2007/12/17 18:50:27	1.9
@@ -57,6 +57,13 @@
 		authURI => 'bioinfo.icapture.ubc.ca' 
 	});
 	
+	# get unformatted RDF/XML for a bunch of services from a single provider without isAlive info
+	print $x->findService({ 
+		prettyPrint => 'no',
+		authURI => 'bioinfo.icapture.ubc.ca',
+		isAlive => 'no' 
+	});
+	
 	# get unformatted RDF/XML for all services
 	print $x->findService({ 
 		prettyPrint => 'no' 
@@ -176,9 +183,11 @@
  This routine consumes a hash as input with keys:
 	authURI: the service provider URI <optional>
 	serviceName: the name of a particular service <optional>
+	isAlive    : whether (yes) or not (no) to add isAlive information. Defaults to 'yes'.
 	prettyPrint: whether (yes) or not (no) to output 'pretty print' formatted XML. Defaults to 'yes'.
 
 #TODO should i add all parameters from findService here?
+
 =cut
 
 sub findService {
@@ -187,6 +196,7 @@
 	my $authURI = $hash->{authURI}     || '';
 	my $name    = $hash->{serviceName} || '';
 	my $prettyPrint = $hash->{prettyPrint} ? $hash->{prettyPrint} : 'yes';
+	my $addIsAlive = $hash->{isAlive} ? $hash->{isAlive} : 'yes';
 	my $services = [];
 	my $RegObject;
 
@@ -217,9 +227,9 @@
 		}
 
 	}
-	my $xml = $self->_createRDFModel( \@$services );
+	my $xml = $self->_createRDFModel( \@$services, $addIsAlive );
 	return new MOBY::RDF::Utils->prettyPrintXML( { xml => $xml } )
-	  unless $prettyPrint eq 'no';
+	  unless $prettyPrint =~ /no/i;
 	return $xml;
 }
 
@@ -235,7 +245,7 @@
 =cut
 
 sub _createRDFModel {
-	my ( $self, $services ) = @_;
+	my ( $self, $services, $addIsAlive ) = @_;
 
 	# set up an RDF model
 	my $storage      = new RDF::Core::Storage::Memory;
@@ -303,40 +313,42 @@
 							 new RDF::Core::Literal( $SI->name )
 						 )
 		);
-
-		# TODO get this value!
-		if ( $self->{is_alive_path} and -e $self->{is_alive_path} ) {
-			my $parser = XML::LibXML->new();
-			my $doc    =
-			  $parser->parse_file(
-								 $self->{is_alive_path} . '/isAliveStats.xml' );
-			my $value    = "true";
-			my $id       = $SI->authority . "," . $SI->name;
-			my @nodelist = $doc->getElementsByTagName("service");
-			for my $node (@nodelist) {
-				next unless ( $node->getAttribute('id') eq $id );
-				$value = $node->textContent;
-				last;
+		
+		do {
+			# add is alive information if necessary
+			if ( $self->{is_alive_path} and -e $self->{is_alive_path} ) {
+				my $parser = XML::LibXML->new();
+				my $doc    =
+				  $parser->parse_file(
+									 $self->{is_alive_path} . '/isAliveStats.xml' );
+				my $value    = "true";
+				my $id       = $SI->authority . "," . $SI->name;
+				my @nodelist = $doc->getElementsByTagName("service");
+				for my $node (@nodelist) {
+					next unless ( $node->getAttribute('id') eq $id );
+					$value = $node->textContent;
+					last;
+				}
+				$model->addStmt(
+						 new RDF::Core::Statement(
+							 $resource,
+							 $resource->new( MOBY::RDF::Predicates::FETA->isAlive ),
+							 new RDF::Core::Literal($value)
+						 )
+				);
+			} else {
+	
+				# by default, state the service is alive ...
+				$model->addStmt(
+						 new RDF::Core::Statement(
+							 $resource,
+							 $resource->new( MOBY::RDF::Predicates::FETA->isAlive ),
+							 new RDF::Core::Literal('true')
+						 )
+				);
 			}
-			$model->addStmt(
-					 new RDF::Core::Statement(
-						 $resource,
-						 $resource->new( MOBY::RDF::Predicates::FETA->isAlive ),
-						 new RDF::Core::Literal($value)
-					 )
-			);
-		} else {
-
-			# by default, state the service is alive ...
-			$model->addStmt(
-					 new RDF::Core::Statement(
-						 $resource,
-						 $resource->new( MOBY::RDF::Predicates::FETA->isAlive ),
-						 new RDF::Core::Literal('true')
-					 )
-			);
-		}
-
+		} unless $addIsAlive  =~ /no/i;
+		
 		# add the authoring statements
 		my $bnode = $node_factory->newResource;
 		$model->addStmt(




More information about the MOBY-guts mailing list