[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Wed Jul 9 22:16:47 UTC 2003
mwilkinson
Wed Jul 9 18:16:47 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv972/Perl/MOBY
Modified Files:
Central.pm
Log Message:
MOBY::Central now is able to discover services with Collection Articles as part of their service signature
moby-live/Perl/MOBY Central.pm,1.92,1.93
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2003/07/04 16:12:37 1.92
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2003/07/09 22:16:47 1.93
@@ -1646,50 +1646,53 @@
return @ids;
}
sub _searchForCollection {
-
my ($dbh, $node, $expand, $inout)= @_; # $node in this case is a Collection object
my $query;
-#######################
-# return; # abort for the moment
-#######################
- #######################################
- # MARK START HERE
- #######################################
-
+ # luckily, we can return a redundant list of service id's and
+ # this will be cleaned up in the caller
+
+ my @validservices;
foreach my $simple($node->getChildNodes()){
next unless ($simple->getNodeType == ELEMENT_NODE);
next unless ($simple->getTagName =~ /simple/i);
my ($objectURI, $namespaceURIs) = &_extractObjectTypesAndNamespaces($simple);
- $query = "select c.service_instance_id, s.namespace_type_uris from simple_input as s, collection_input as c where s.collection_input_id IS NOT NULL and s.collection_input_id = c.collection_input_id AND object_type_uri = '$objectURI' ";
+ $query = "select
+ c.service_instance_id,
+ s.namespace_type_uris
+ from
+ simple_$inout as s,
+ collection_$inout as c
+ where
+ s.collection_${inout}_id IS NOT NULL
+ AND s.collection_${inout}_id = c.collection_${inout}_id
+ AND object_type_uri = '$objectURI' ";
my $nsquery;
foreach my $ns(@{$namespaceURIs}){ # namespaces are already URI's
$nsquery .=" OR namespace_type_uris like '%$ns%' ";
}
- if ($nsquery){$nsquery =~ s/OR//;} # just the first
- $query .= " AND ($nsquery) ";
+ if ($nsquery){
+ $nsquery =~ s/^\sOR//; # just the first
+ $query .= " AND ($nsquery) "; # add the AND clause
+ }
+
+ $debug && &_LOG("QUERY: $query");
my $sth = $dbh->prepare($query);
$sth->execute;
- my @valid_service_ids;
while (my ($id, $nss) = $sth->fetchrow_array){ # get the service instance ID and the namespaces that matched
- my @ns = split ",", $nss; # because of the database structure we have to re-test for *identity*, not just like%% similarity
- my %nshash = map {($_, 1)} @ns,@{$namespaceURIs}; #we're going to test identity by building a hash of namespaces as keys
- if (scalar(keys %nshash) < scalar(@ns)+scalar(@{$namespaceURIs})){ # if the number of keys is less than the sum of the number of keys goign into the hash, then one of them was identical
- push @valid_service_ids, $id; # and therefore it really is a match, and is valid
+ if (scalar @{$namespaceURIs}){ # if namespaces were specified, then validate the discovered service against this list
+ my @ns = split ",", $nss; # because of the database structure we have to re-test for *identity*, not just like%% similarity
+ my %nshash = map {($_, 1)} @ns,@{$namespaceURIs}; #we're going to test identity by building a hash of namespaces as keys
+ if (scalar(keys %nshash) < scalar(@ns)+scalar(@{$namespaceURIs})){ # if the number of keys is less than the sum of the number of keys goign into the hash, then one of them was identical
+ push @validservices, $id; # and therefore it really is a match, and is valid
+ }
+ } else { # if no namespace was specified, then all of them are valid
+ push @validservices, $id
}
}
- &_LOG("QUERY: $query");
}
- return;
-# if ($query){$query =~s/AND//;} # just the first
-# $debug && &_LOG("_searchForCollectedSimples QUERY = select distinct(collection_$inout"."id from simple_$inout where collection_$inout"."_id IS NOT NULL AND $query\n\n");
- #
- #my $collids = $dbh->selectall_arrayref("create temporary table select distinct(collection_$inout"."id from simple_$inout where collection_$inout"."_id IS NOT NULL AND $query");
- #my @result;
- #foreach (@{$collids}){
- # push @result, $_->[0];
- #}
+ return @validservices;
}
sub _findServicePayload {
More information about the MOBY-guts
mailing list