[MOBY-guts] biomoby commit

Eddie Kawas kawas at dev.open-bio.org
Fri Dec 21 15:41:19 UTC 2007


kawas
Fri Dec 21 10:41:19 EST 2007
Update of /home/repository/moby/moby-live/Perl/scripts
In directory dev.open-bio.org:/tmp/cvs-serv23703/Perl/scripts

Modified Files:
	RESOURCES 
Log Message:
added a feature where if you have something like the following:
MOBY-S/Objects/DNASequence
then rdf for DNASequence is returned.
moby-live/Perl/scripts RESOURCES,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/scripts/RESOURCES,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/scripts/RESOURCES	2007/12/17 18:55:22	1.3
+++ /home/repository/moby/moby-live/Perl/scripts/RESOURCES	2007/12/21 15:41:19	1.4
@@ -41,72 +41,115 @@
 my $useCache = 1;
 
 my $url = url( -relative => 1, -path_info => 1 );
-
+$url =~ s/%([\da-f][\da-f])/chr( hex($1) )/egi;
 my $form = new CGI;
 
-if ( $url =~ m/^RESOURCES\/MOBY\-S\/Objects$/ ) {
-
-	if ($useCache) {
-		my $x =
-		  MOBY::RDF::Ontologies::Cache::ObjectCache->new( cache => "$dir", );
-		$x = $x->get_rdf();
-		print $form->header('text/xml'), $x if $x;
-	} else {
+if ( $url =~ m/^RESOURCES\/MOBY\-S\/Objects(\/[A-Za-z0-9_\-]*)?$/ ) {
+	do {
+		if ($useCache) {
+			my $x =
+			  MOBY::RDF::Ontologies::Cache::ObjectCache->new( cache => "$dir",
+			  );
+			$x = $x->get_rdf();
+			print $form->header('text/xml'), $x if $x;
+		} else {
+			my $x = MOBY::RDF::Ontologies::Objects->new;
+			$x = $x->createAll();
+			print $form->header('text/xml'), $x if $x;
+		}
+	} unless $1;
+	do {
 		my $x = MOBY::RDF::Ontologies::Objects->new;
-		$x = $x->createAll();
-		print $form->header('text/xml'), $x if $x;
-	}
-} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Services$/ ) {
-	if ($useCache) {
-		my $x =
-		  MOBY::RDF::Ontologies::Cache::ServiceTypeCache->new( cache => "$dir", );
-		$x = $x->get_rdf();
-		print $form->header('text/xml'), $x if $x;
-	} else {
+		my $rdf = $x->createByName( { term => substr $1, 1 } );
+		print $form->header('text/xml'), $rdf if $rdf;
+	} if $1;
+
+} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Services(\/[A-Za-z0-9_\-]*)?$/ ) {
+	do {
+		if ($useCache) {
+			my $x =
+			  MOBY::RDF::Ontologies::Cache::ServiceTypeCache->new(
+															 cache => "$dir", );
+			$x = $x->get_rdf();
+			print $form->header('text/xml'), $x if $x;
+		} else {
+			my $x = MOBY::RDF::Ontologies::ServiceTypes->new;
+			$x = $x->createAll();
+			print $form->header('text/xml'), $x if $x;
+		}
+	} unless $1;
+	do {
 		my $x = MOBY::RDF::Ontologies::ServiceTypes->new;
-		$x = $x->createAll();
-		print $form->header('text/xml'), $x if $x;
-	}
-} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/ServiceInstances$/ ) {
-	my $x;
-
-	# shall we use the cache?
-	if ($useCache) {
-		$x =
-		  MOBY::RDF::Ontologies::Cache::ServiceCache->new( cache => "$dir", );
-		$x = $x->get_rdf();
-
-	} else {
-
-		# no cache
-		$x = MOBY::RDF::Ontologies::Services->new;
-		$x = $x->findService();
-
-	}
-
-	# output the RDF generated
-	print $form->header('text/xml'), $x if $x;
-
-	# say not implemented if an error occurs
-	do {
-		print $form->header('text/html');
-		$form->start_html( -title => 'unavailable', );
-		print h2( "not", "implemented" );
-		print end_html;
-	} unless $x;
-
-} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Namespaces$/ ) {
-	if ($useCache) {
-		my $x = MOBY::RDF::Ontologies::Cache::NamespaceCache->new( 
-															 cache => "$dir",
+		my $rdf = $x->createByName( { term => substr $1, 1 } );
+		print $form->header('text/xml'), $rdf if $rdf;
+	} if $1;
+} elsif ( $url =~
+m/^RESOURCES\/MOBY\-S\/ServiceInstances(\/[A-Za-z0-9_\-.]*,[A-Za-z0-9_\-]*)?$/
+  )
+{
+	my $string = $1 || "";
+	do {
+		my $x;
+
+		# shall we use the cache?
+		if ($useCache) {
+			$x =
+			  MOBY::RDF::Ontologies::Cache::ServiceCache->new( cache => "$dir",
+			  );
+			$x = $x->get_rdf();
+
+		} else {
+
+			# no cache
+			$x = MOBY::RDF::Ontologies::Services->new;
+			$x = $x->findService();
+
+		}
+
+		# output the RDF generated
+		print $form->header('text/xml'), $x if $x;
+
+		# say not implemented if an error occurs
+		do {
+			print $form->header('text/html');
+			$form->start_html( -title => 'unavailable', );
+			print h2( "not", "implemented" );
+			print end_html;
+		} unless $x;
+	} unless $string;
+	do {
+		my $x = MOBY::RDF::Ontologies::Services->new;    
+		my $sname = substr ($string, index($string, ',')+1);
+        my $prov  = substr ($string, 1, index($string, ',')-1);
+		# get pretty printed RDF/XML for one service
+		$x = $x->findService(
+						   {
+							 serviceName => $sname,
+							 authURI     =>  $prov,
+						   }
 		);
-		$x = $x->get_rdf();
 		print $form->header('text/xml'), $x if $x;
-	} else {
+	} if $string;
+
+} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Namespaces(\/[A-Za-z0-9_\-]*)?$/ ) {
+	do {
+		if ($useCache) {
+			my $x =
+			  MOBY::RDF::Ontologies::Cache::NamespaceCache->new(
+															 cache => "$dir", );
+			$x = $x->get_rdf();
+			print $form->header('text/xml'), $x if $x;
+		} else {
+			my $x = MOBY::RDF::Ontologies::Namespaces->new;
+			$x = $x->createAll();
+			print $form->header('text/xml'), $x if $x;
+		}
+	} unless $1;
+	do {
 		my $x = MOBY::RDF::Ontologies::Namespaces->new;
-		$x = $x->createAll();
-		print $form->header('text/xml'), $x if $x;
-	}
+		my $rdf = $x->createByName( { term => substr $1, 1 } );
+		print $form->header('text/xml'), $rdf if $rdf;
+	} if $1;
 } elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/FULL$/ ) {
 
 	print $form->header('text/html');




More information about the MOBY-guts mailing list