[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Thu Jul 21 16:37:35 UTC 2005


mwilkinson
Thu Jul 21 12:37:35 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv29120/MOBY

Modified Files:
	Central.pm service_instance.pm 
Log Message:
updating the service discovery code to be in-line with the new adaptor API

moby-live/Perl/MOBY Central.pm,1.163,1.164 service_instance.pm,1.19,1.20
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -r1.163 -r1.164
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm	2005/07/20 17:12:20	1.163
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm	2005/07/21 16:37:35	1.164
@@ -22,7 +22,7 @@
 use MOBY::secondary_input;
 use MOBY::central_db_connection;
 use MOBY::Config;
-use MOBY::Client::Central;
+#use MOBY::Client::Central;
 
 #use MOBY::RDF::ServiceInstanceRDF;
 #use RDF::Core;
@@ -762,7 +762,7 @@
 	  unless ($existingURI);
 	my $dbh = MOBY::central_db_connection->new()->dbh;
 	
-	my $result = $adaptor->query_service_instance({service_type_uri => $existingURI});
+	my $result = $adaptor->query_service({service_type_uri => $existingURI});
 	my $row = shift(@$result);
 	my $id = $row->{service_instance_id};
 	
@@ -1888,7 +1888,13 @@
 		$debug
 		  && _LOG(
 			"authoritative added; criterion count is now $criterion_count\n");
-		my $ids = $adaptor->query_service_instance({authoritative => $findme{authoritative}});
+		my $ids = _extract_ids($adaptor->query_service_instance({authoritative => $findme{authoritative}}));
+		
+		
+		
+		###  MARK - we need to extract ids at each step...
+		
+		
 		
 		unless ( scalar @{$ids} ) {
 			return &_serviceListResponse( $dbh, undef );
@@ -1923,7 +1929,7 @@
 			$children_string .= ( join ',', map { "\'$_\'" } @children );
 		}
 		$children_string =~ s/\,$//;
-		my $ids = $adaptor->match_service_type_uri({service_type_uri => $children_string});
+		my $ids = _extract_ids($adaptor->match_service_type_uri({service_type_uri => $children_string}));
 		
 		$debug
 		  && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
@@ -1946,7 +1952,7 @@
 			return &_serviceListResponse( $dbh, undef );
 		}
 
-		my $ids = $adaptor->query_service_instance({authority_id => $id});
+		my $ids = _extract_ids($adaptor->query_service_instance({authority_id => $id}));
 
 		unless ( scalar @{$ids} ) {
 			return &_serviceListResponse( $dbh, undef );
@@ -1965,7 +1971,7 @@
 		  && _LOG(
 			"servicename added; criterion count is now $criterion_count\n");
 
-		my $ids = $adaptor->query_service_instance({servicename => $findme{servicename}});
+		my $ids = _extract_ids($adaptor->query_service_instance({servicename => $findme{servicename}}));
 
 		unless ( scalar @{$ids} ) {
 			return &_serviceListResponse( $dbh, undef );
@@ -1984,7 +1990,7 @@
 		$debug
 		  && _LOG("category added; criterion count is now $criterion_count\n");
 
-		my $ids = $adaptor->query_service_instance({category => lc( $findme{category}) });
+		my $ids = _extract_ids($adaptor->query_service_instance({category => lc( $findme{category}) }));
 	
 		unless ( scalar @{$ids} ) {
 			return &_serviceListResponse( $dbh, undef );
@@ -2003,6 +2009,7 @@
 		  && _LOG("Keywords added; criterion count is now $criterion_count\n");
 		  
 		my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme});
+		$ids = _extract_ids($ids);  # this is the hash-list that comes back from do_query
 		  
 		unless ( scalar @{$ids} ) {
 			$debug
@@ -2146,6 +2153,20 @@
 	return &_serviceListResponse( $dbh, @final );
 }
 
+sub _extract_ids {
+	my ($linehash) = @_;
+	# ths data comes from the do_query of the mysql call
+	#  -->  [{...}]
+	my @lines = @$linehash;
+	return [] unless scalar(@lines);
+	my @ids;
+	foreach (@lines){
+		my $id = $_->{service_instance_id};
+		push @ids, $id;
+	}
+	return \@ids
+}
+
 #Eddie - converted
 sub _searchForServicesWithArticle {
 	my ( $dbh, $inout, $node, $expand, $coll ) = @_;
@@ -2190,9 +2211,8 @@
 	}
 	$ancestor_string =~ s/\,$//;
 	
-	my ($query, $result) = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs});
+	my $result = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs});
 
-	$debug && _LOG("\nQUERY $query\n");
 	my @valid_services;
 	
 	foreach my $row (@$result)
@@ -2242,10 +2262,8 @@
 		my ( $objectURI, $namespaceURIs ) =
 		  &_extractObjectTypesAndNamespaces($simple);
 
-		my ($query, $result) = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs});
+		my $result = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs});
 
-		$debug && &_LOG("QUERY: $query");
-	
 		foreach my $row (@$result )
 		{    # get the service instance ID and the namespaces that matched
 		    my $id = $row->{service_instance_id};
@@ -3392,7 +3410,7 @@
 		my $service_type = $OSserv->getServiceCommonName($service_type_uri);
 
 		$result = $adaptor->query_authority({authority_id => $authority_id});
-		my $row = shift(@$result);
+		$row = shift(@$result);
 		my $authURI = $row->{authority_uri};		 
 		$output .=
 "\t<Service authURI='$authURI' serviceName='$servicename' lsid='$lsid'>\n";

===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm	2005/07/20 22:49:05	1.19
+++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm	2005/07/21 16:37:35	1.20
@@ -186,16 +186,6 @@
 			$self->{$attrname} = $self->_default_for($attrname);
 		}
 	}
-
-	#    		category => $Category,
-	#		servicename => $serviceName,
-	#		service_type => $serviceType,
-	#		authority_uri => $AuthURI,
-	#		url => $URL,
-	#		contact_email => $contactEmail,
-	#		authoritative => $authoritativeService,
-	#		description => $desc,
-	#
 	return undef unless $self->authority_uri;
 	return undef unless $self->servicename;
 
@@ -222,9 +212,8 @@
 		  ? $self->service_type_uri( $self->service_type )
 		  : $self->service_type_uri($servicetypeURI);
 	}
-	my $existing_services = $self->adaptor->query_service_instance(
-								      servicename => $self->servicename,
-								      authority_uri => $self->authority_uri);
+	my $existing_services = $self->adaptor->query_service_instance({servicename => $self->servicename},"and",
+								      {authority_uri => $self->authority_uri});
 	my $existing_service = shift(@$existing_services);
 	if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did
 		$self->service_instance_id( $existing_service->{'serviceid'} );
@@ -316,15 +305,9 @@
 	my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
 	my $dbh = $self->dbh;
 	my $authority;
-	
-	my $result = $adaptor->query_authority({authority_uri => $self->authority_uri});
+
+	my $result = $adaptor->query_service_existence(authority_uri => $self->authority_uri, servicename => $self->servicename);
 	my $row = shift(@$result);
-	my $id = $row->{authority_id};
-	
-	return undef unless $id;
-	
-	$result = $adaptor->query_service_instance({authority_id => $id}, 'and', {servicename => $self->servicename});
-	$row = shift(@$result);
 	my $svc = $row->{service_instance_id};
 	
 	return $svc;




More information about the MOBY-guts mailing list