[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Fri Jul 4 16:12:38 UTC 2003
mwilkinson
Fri Jul 4 12:12:37 EDT 2003
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv1841/MOBY
Modified Files:
Central.pm
Log Message:
service discovery was being thwarted by a bad return value from the keyword search. Also, the test script was searching for a service that should have failed, but it thought it shoudl succeed. This should solve the problem
moby-live/Perl/MOBY Central.pm,1.91,1.92
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2003/07/04 15:00:12 1.91
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2003/07/04 16:12:37 1.92
@@ -1401,6 +1401,7 @@
'expandServices' => $findme{expandServices},
'authoritative' => $findme{authoritative},
'category' => $findme{Category},
+ 'keywords' => $findme{keywords},
");
my %valid_service_ids;
@@ -1414,11 +1415,14 @@
my $dbh = MOBY::central_db_connection->new()->dbh;
if ($findme{authoritative}){
++$criterion_count;
+ $debug && _LOG("authoritative added; criterion count is now $criterion_count\n");
my $ids = $dbh->selectall_arrayref(q{select service_instance_id from service_instance where authoritative=?}, undef, $findme{authoritative});
unless (scalar @{$ids}){
return &_serviceListResponse($dbh,undef);
}
+ $debug && _LOG("services ".(join ',', @{$ids})." incrememted\n");
foreach (@{$ids}){
+ $debug && &_LOG("found id $_->[0]\n");
++$valid_service_ids{$_->[0]}; # increment that particular id's count by one
}
}
@@ -1429,6 +1433,8 @@
return &_serviceListResponse($dbh,undef);
}
++$criterion_count;
+ $debug && _LOG("serviceType added; criterion count is now $criterion_count\n");
+
my $children_string = "'$URI',";
if ($findme{'expandServices'}){
$debug && _LOG("Expanding Objects\n");
@@ -1439,12 +1445,16 @@
}
$children_string =~ s/\,$//;
my $ids = $dbh->selectall_arrayref("select service_instance_id from service_instance where service_type_uri in ($children_string)");
+ $debug && _LOG("services ".(join ',', @{$ids})." incrememted\n");
foreach (@{$ids}){
+ $debug && &_LOG("found id $_->[0]\n");
++$valid_service_ids{$_->[0]}; # increment that particular id's count by one
}
}
if ($findme{authURI}){
++$criterion_count;
+ $debug && _LOG("authURI added; criterion count is now $criterion_count\n");
+
my ($id) = $dbh->selectrow_array(q{select authority_id from authority where authority_uri = ? or authority_common_name = ?},undef,($findme{authURI}, $findme{authURI}));
unless ($id){
return &_serviceListResponse($dbh,undef);
@@ -1453,34 +1463,44 @@
unless (scalar @{$ids}){
return &_serviceListResponse($dbh,undef);
}
+ $debug && _LOG("services ".(join ',', @{$ids})." incrememted\n");
foreach (@{$ids}){
+ $debug && &_LOG("found id $_->[0]\n");
++$valid_service_ids{$_->[0]}; # increment that particular id's count by one
}
}
if ($findme{servicename}){
++$criterion_count;
+ $debug && _LOG("servicename added; criterion count is now $criterion_count\n");
+
my $ids = $dbh->selectall_arrayref(q{select service_instance_id from service_instance where servicename=?}, undef, $findme{servicename});
unless (scalar @{$ids}){
return &_serviceListResponse($dbh,undef);
}
+ $debug && _LOG("services ".(join ',', @{$ids})." incrememted\n");
foreach (@{$ids}){
+ $debug && &_LOG("found id $_->[0]\n");
++$valid_service_ids{$_->[0]}; # increment that particular id's count by one
}
}
$findme{category} = 'moby' unless $findme{category};
if ($findme{category}){
++$criterion_count;
+ $debug && _LOG("category added; criterion count is now $criterion_count\n");
+
my $ids = $dbh->selectall_arrayref(q{select service_instance_id from service_instance where category=?}, undef, lc($findme{category}));
unless (scalar @{$ids}){
return &_serviceListResponse($dbh,undef);
}
+ $debug && _LOG("services ".(join ',', @{$ids})." incrememted\n");
foreach (@{$ids}){
+ $debug && &_LOG("found id $_->[0]\n");
++$valid_service_ids{$_->[0]}; # increment that particular id's count by one
}
}
- $debug && &_LOG("KEYWORDS @{$findme{keywords}}\n");
if (scalar @{$findme{keywords}}){
++$criterion_count;
+ $debug && _LOG("Keywords added; criterion count is now $criterion_count\n");
my $searchstring;
foreach my $kw(@{$findme{keywords}}){
$debug && &_LOG("KEYWORD $kw\n");
@@ -1496,17 +1516,19 @@
$debug && &_LOG("found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n");
return &_serviceListResponse($dbh, undef);
}
+ $debug && _LOG("services ".(join ',', @{$ids})." incrememted\n");
foreach (@{$ids}){
$debug && &_LOG("found id $_->[0]\n");
-
++$valid_service_ids{$_->[0]}; # increment that particular id's count by one
}
}
if (scalar @{$findme{inputObjects}}){
++$criterion_count;
+ $debug && _LOG("inputObject added; criterion count is now $criterion_count\n");
my $obj = (shift @{$findme{inputObjects}});
my @si_ids;
@si_ids = &_searchForServicesWithArticle($dbh, "input", $obj, $findme{'expandObjects'}, '') if defined $obj;
+ $debug && _LOG("Initial Search For Services with INPUT Article found @si_ids\n");
my %instances;
# we need to do a join, without doing a join...
if (scalar @si_ids){
@@ -1515,6 +1537,7 @@
next unless $obj;
$debug && _LOG("FIRST: ", $dbh, "input", $obj, $findme{'expandObjects'}, '');
my @new_ids = &_searchForServicesWithArticle($dbh, "input", $obj, $findme{'expandObjects'}, ''); # get their service ids
+ $debug && _LOG("Subsequent Search For Services with INPUT Article found @new_ids\n");
my @good_ids;my %good_ids;
foreach my $id(@new_ids){ # check the new id set against the set we know is already valid
next unless defined $id;
@@ -1525,15 +1548,20 @@
}
}
# now %instances contains only valid ID numbers
+ $debug && _LOG("Final results incremented of search for INPUT: ".(join ',',(keys %instances))."\n");
+
foreach (keys %instances){
+ $debug && &_LOG("found id $_\n");
++$valid_service_ids{$_};
}
}
if (scalar @{$findme{outputObjects}}){
++$criterion_count;
+ $debug && _LOG("outputObject added; criterion count is now $criterion_count\n");
my $obj = (shift @{$findme{outputObjects}});
my @si_ids;
@si_ids = &_searchForServicesWithArticle($dbh, "output", $obj, '') if defined $obj;
+ $debug && _LOG("Initial Search For Services with OUTPUT Article found @si_ids\n");
my %instances;
# we need to do a join, without doing a join...
if (scalar @si_ids){
@@ -1541,6 +1569,7 @@
while (my $obj = shift(@{$findme{outputObjects}})){ # iterate through the rest of the objects
next unless $obj;
my @new_ids = &_searchForServicesWithArticle($dbh, "output", $obj,''); # get their service ids
+ $debug && _LOG("Subsequent Search For Services with OUTPUT Article found @new_ids\n");
my @good_ids;my %good_ids;
foreach my $id(@new_ids){ # check the new id set against the set we know is already valid
next unless defined $id;
@@ -1551,17 +1580,19 @@
}
}
# now %instances contains only valid ID numbers
+ $debug && _LOG("Final results incremented of search for OUTPUT: ".(join ',',(keys %instances))."\n");
foreach (keys %instances){
+ $debug && &_LOG("found id $_\n");
++$valid_service_ids{$_};
}
}
my @final;
while (my ($id, $freq) = each %valid_service_ids){
- #print "ID: $id FREQ:$freq\n";
+ $debug && _LOG("TALLY IS ID: $id FREQ:$freq\n CRITERION COUNT $criterion_count\n");
next unless $freq == $criterion_count; # has to have matched every criterion
push @final, $id;
}
-return &_serviceListResponse($dbh, @final);
+ return &_serviceListResponse($dbh, @final);
}
@@ -1607,11 +1638,12 @@
($nsquery) && ($query .=" AND ($nsquery) ");
$debug && _LOG("\nQUERY $query\n");
my $ids = $dbh->selectall_arrayref($query);
-# my @ids; # ?!? what the heck was this supposed to achieve?! Must have been late at night...
-# foreach (@{$nsref}){
-# push @ids, $_->[0];
-# }
- return @{$ids};
+ my @ids;
+ foreach (@{$ids}){
+ push @ids, $_->[0];
+ }
+ $debug && _LOG("Resulting IDs were ".(join ',', @ids)."\n");
+ return @ids;
}
sub _searchForCollection {
@@ -2495,7 +2527,7 @@
$debug && &_LOG("_nodeArrayContext received DOM: ", $DOM->toString,"\nsearching for node $node\n");
my @result;
my $x = $DOM->getElementsByTagName($node);
- return undef unless $x->item(0);
+ return @result unless $x->item(0);
my @child = $x->item(0)->getChildNodes;
foreach (@child){
next unless $_->getNodeType == ELEMENT_NODE;
@@ -2503,9 +2535,11 @@
foreach (@child2){
#print $_->getNodeTypeName, "\t", $_->toString,"\n";
next unless $_->getNodeType == TEXT_NODE;
+ next unless (length($_->toString) > 0);
push @result, $_->toString;
}
}
+ $debug && _LOG("_nodeArrayContent resulted in @result\n");
return @result;
}
More information about the MOBY-guts
mailing list