[MOBY-guts] biomoby commit
Dennis Wang
dwang at pub.open-bio.org
Wed Jul 13 18:18:39 UTC 2005
dwang
Wed Jul 13 14:18:39 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv20813/Perl/MOBY
Modified Files:
Central.pm
Log Message:
1st commit by Dennis
moby-live/Perl/MOBY Central.pm,1.157,1.158
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.157
retrieving revision 1.158
diff -u -r1.157 -r1.158
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/08 18:57:00 1.157
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 18:18:39 1.158
@@ -470,6 +470,9 @@
=cut
sub deregisterObjectClass {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ( $pkg, $payload ) = @_;
my $OntologyServer = &_getOntologyServer( ontology => 'object' );
return &_error( "Message Format Incorrect", "" ) unless ($payload);
@@ -482,42 +485,14 @@
return &_error( "Object class $class does not exist", "" )
unless ($existingURI);
my $dbh = MOBY::central_db_connection->new()->dbh;
- my ($id) = $dbh->selectrow_array(
-q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?},
- undef, $existingURI
- );
- return &_error(
- "Object class $class is used by a service and may not be deregistered",
- ""
- )
- if ($id);
- ($id) = $dbh->selectrow_array(
-q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?},
- undef, $existingURI
- );
- return &_error(
- "Object class $class is used by a service and may not be deregistered",
- ""
- )
- if ($id);
- ($id) = $dbh->selectrow_array(
-q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?},
- undef, $existingURI
- );
- return &_error(
- "Object class $class is used by a service and may not be deregistered",
- ""
- )
- if ($id);
- ($id) = $dbh->selectrow_array(
-q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?},
- undef, $existingURI
- );
+
+ my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI});
return &_error(
"Object class $class is used by a service and may not be deregistered",
""
)
- if ($id);
+ if ($errormsg);
+
my ( $success2, $message2, $URI ) =
$OntologyServer->deleteObject( term => $class );
$success2 == 0 && return &_error( $message2, $URI );
@@ -767,6 +742,9 @@
=cut
sub deregisterServiceType {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ( $pkg, $payload ) = @_;
my $OntologyServer = &_getOntologyServer( ontology => 'service' );
return &_error( "Message Format Incorrect", "" ) unless ($payload);
@@ -781,10 +759,10 @@
return &_error( "Service Type $term does not exist in the ontology", "" )
unless ($existingURI);
my $dbh = MOBY::central_db_connection->new()->dbh;
- my ($id) = $dbh->selectrow_array(
-q{select service_instance.service_instance_id from service_instance where service_type_uri = ?},
- undef, $existingURI
- );
+
+ my $result = $adaptor->query_service_instance({service_type_uri => $existingURI});
+ my $id = @$result[0]->{service_instance_id};
+
return &_error( "A registered service depends on this service type", "" )
if ($id);
my ( $success2, $message2, $deleteURI ) =
@@ -924,6 +902,9 @@
=cut
sub deregisterNamespace {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ( $pkg, $payload ) = @_;
my $OntologyServer = &_getOntologyServer( ontology => 'namespace' );
return &_error( "Message Format Incorrect", "" ) unless ($payload);
@@ -936,71 +917,10 @@
return &_error( "Namespace Type $term does not exist", "" )
unless ($existingURI);
my $dbh = MOBY::central_db_connection->new->dbh;
- my $sth =
- $dbh->prepare(
-"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')"
- );
- $sth->execute;
-
- while ( my ( $id, $ns ) = $sth->fetchrow_array() ) {
- my @nss = split ",", $ns;
- foreach (@nss) {
- $_ =~ s/\s//g;
- return &_error(
-"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered",
- ""
- )
- if ( $_ eq $existingURI );
- }
- }
- $sth =
- $dbh->prepare(
-"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')"
- );
- $sth->execute;
- while ( my ( $id, $ns ) = $sth->fetchrow_array() ) {
- my @nss = split ",", $ns;
- foreach (@nss) {
- $_ =~ s/\s//g;
- return &_error(
-"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered",
- ""
- )
- if ( $_ eq $existingURI );
- }
- }
- $sth =
- $dbh->prepare(
-"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')"
- );
- $sth->execute;
- while ( my ( $id, $ns ) = $sth->fetchrow_array() ) {
- my @nss = split ",", $ns;
- foreach (@nss) {
- $_ =~ s/\s//g;
- return &_error(
-"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered",
- ""
- )
- if ( $_ eq $existingURI );
- }
- }
- $sth =
- $dbh->prepare(
-"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')"
- );
- $sth->execute;
- while ( my ( $id, $ns ) = $sth->fetchrow_array() ) {
- my @nss = split ",", $ns;
- foreach (@nss) {
- $_ =~ s/\s//g;
- return &_error(
-"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered",
- ""
- )
- if ( $_ eq $existingURI );
- }
- }
+ my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term});
+ return &_error( $errstr, "")
+ if ($err);
+
my ( $success2, $message2, $URI ) =
$OntologyServer->deleteNamespace( term => $term );
$success2 == 0 && return &_error( $message2, $URI );
@@ -1936,6 +1856,9 @@
=cut
sub findService {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ( $pkg, $payload ) = @_;
$debug && &_LOG("\nLOOKING FOR SERVICES\n");
my %findme = &_findServicePayload($payload);
@@ -1965,18 +1888,16 @@
$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}
- );
+ my $ids = $adaptor->query_service_instance({authoritative => $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]
+ $debug && &_LOG("found id $_->{service_instnace_id}\n");
+ ++$valid_service_ids{ $_->{service_instance_id}
}; # increment that particular id's count by one
}
}
@@ -2002,10 +1923,8 @@
$children_string .= ( join ',', map { "\'$_\'" } @children );
}
$children_string =~ s/\,$//;
- my $ids =
- $dbh->selectall_arrayref(
-"select service_instance_id from service_instance where service_type_uri in ($children_string)"
- );
+ my $ids = $adaptor->match_service_type_uri({service_type_uri => $children_string});
+
$debug
&& _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" );
foreach ( @{$ids} ) {
@@ -2018,26 +1937,24 @@
++$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} )
- );
+
+ my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}});
+ my $id = @$result[0]->{authority_id};
+
unless ($id) {
return &_serviceListResponse( $dbh, undef );
}
- my $ids = $dbh->selectall_arrayref(
-q{select service_instance_id from service_instance where authority_id=?},
- undef, $id
- );
+
+ my $ids = $adaptor->query_service_instance({authority_id => $id});
+
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]
+ $debug && &_LOG("found id $_->{service_instance_id}\n");
+ ++$valid_service_ids{ $_->{service_instance_id}
}; # increment that particular id's count by one
}
}
@@ -2046,18 +1963,17 @@
$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}
- );
+
+ my $ids = $adaptor->query_service_instance({servicename => $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]
+ $debug && &_LOG("found id $_->{service_instance_id}\n");
+ ++$valid_service_ids{ $_->{service_instance_id}
}; # increment that particular id's count by one
}
}
@@ -2066,19 +1982,17 @@
++$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} )
- );
+
+ my $ids = $adaptor->query_service_instance({category => 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]
+ $debug && &_LOG("found id $_->{service_instance_id}\n");
+ ++$valid_service_ids{ $_->{service_instance_id}
}; # increment that particular id's count by one
}
}
@@ -2086,19 +2000,9 @@
++$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");
- $kw =~ s/\*//g;
- $kw = $dbh->quote("%$kw%");
- $searchstring .= " OR description like $kw ";
- }
- $searchstring =~ s/OR//; # just the first one
- $debug && &_LOG("search $searchstring\n");
- my $ids =
- $dbh->selectall_arrayref(
-"select service_instance_id from service_instance where $searchstring"
- );
+
+ my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme});
+
unless ( scalar @{$ids} ) {
$debug
&& &_LOG(
@@ -2264,6 +2168,8 @@
}
sub _searchForSimple {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
# returns list of service_instance ID's
# that match this simple
@@ -2282,24 +2188,17 @@
$ancestor_string .= ( join ',', map { "\'$_\'" } @ancestors );
}
$ancestor_string =~ s/\,$//;
- my $query =
-"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL "
- ; # if service_instance_id is null then it must be a collection input.
- my $nsquery;
- foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's
- $nsquery .= " OR INSTR(namespace_type_uris, '$ns') ";
- }
- if ($nsquery) {
- $nsquery =~ s/OR//; # just the first
- $nsquery .= " OR namespace_type_uris IS NULL";
- $query .= " AND ($nsquery) ";
- }
+
+ my ($query, $result) = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs});
+
$debug && _LOG("\nQUERY $query\n");
my @valid_services;
- my $sth = $dbh->prepare($query);
- $sth->execute;
- while ( my ( $id, $nss ) = $sth->fetchrow_array )
- { # get the service instance ID and the namespaces that matched
+
+ foreach my $row (@$result)
+ {
+ # get the service instance ID and the namespaces that matched
+ my $id = $row->{service_instance_id};
+ my $nss = $row->{namespace_type_uris};
if ( $nss && scalar @{$namespaceURIs} )
{ # if this service cares about namespaces at all,
# and if namespaces were specified in the query,
@@ -2327,9 +2226,11 @@
#Eddie - converted
sub _searchForCollection {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ( $dbh, $node, $expand, $inout ) =
@_; # $node in this case is a Collection object
- my $query;
# luckily, we can return a redundant list of service id's and
# this will be cleaned up in the caller
@@ -2339,30 +2240,15 @@
next unless ( $simple->nodeName =~ /simple/i );
my ( $objectURI, $namespaceURIs ) =
&_extractObjectTypesAndNamespaces($simple);
- $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 INSTR(namespace_type_uris, '$ns') ";
- }
- if ($nsquery) {
- $nsquery =~ s/^\sOR//; # just the first
- $nsquery .= " OR namespace_type_uris IS NULL";
- $query .= " AND ($nsquery) "; # add the AND clause
- }
+
+ my ($query, $result) = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs});
+
$debug && &_LOG("QUERY: $query");
- my $sth = $dbh->prepare($query);
- $sth->execute;
- while ( my ( $id, $nss ) = $sth->fetchrow_array )
+
+ foreach my $row (@$result )
{ # get the service instance ID and the namespaces that matched
+ my $id = $row->{service_instance_id};
+ my $nss = $row->{namespace_type_uris};
if ( $nss && scalar @{$namespaceURIs} )
{ # if this service cares about namespaces at all,
# and if namespaces were specified in the query,
@@ -2582,13 +2468,17 @@
=cut
sub retrieveServiceProviders {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ($pkg) = @_;
my $dbh = MOBY::central_db_connection->new()->dbh;
- my $sth = $dbh->prepare("select distinct authority_uri from authority");
- $sth->execute;
+
+ my $result = $adaptor->getUniqueAuthorityURI();
+
my $providers = "<serviceProviders>\n";
- while ( my ($prov) = $sth->fetchrow_array ) {
- $providers .= "<serviceProvider name='$prov'/>\n";
+ foreach my $prov (@$result) {
+ $providers .= "<serviceProvider name='$prov->{authority_uri}'/>\n";
}
$providers .= "</serviceProviders>\n";
return $providers;
@@ -2612,16 +2502,15 @@
=cut
sub retrieveServiceNames {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ($pkg) = shift;
my $dbh = MOBY::central_db_connection->new()->dbh;
- my $sth =
- $dbh->prepare(
-"select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"
- );
- $sth->execute;
+ my $result = $adaptor->getServiceNames();
my $names = "<serviceNames>\n";
- while ( my ( $auth, $name ) = $sth->fetchrow_array ) {
- $names .= "<serviceName name='$name' authURI='$auth'/>\n";
+ foreach my $row (@$result) {
+ $names .= "<serviceName name='$row->{servicename}' authURI='$row->{authority_uri}'/>\n";
}
$names .= "</serviceNames>\n";
return $names;
@@ -3051,25 +2940,17 @@
*DUMP = \&DUMP_MySQL; # alias it for backward compatibility
sub _flatten {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
# from a given term, traverse the ontology
# and flatten it into a list of parent terms
my ( $dbh, $type, $term, $seen ) = @_;
- my $sth = $dbh->prepare( "
- select
- OE1.term
- from
- OntologyEntry as OE1,
- OntologyEntry as OE2,
- Term2Term as TT
- where
- ontologyentry2_id = OE2.id
- and ontologyentry1_id = OE1.id
- and relationship_type_id = $type
- and OE2.term = ?"
- );
- $sth->execute($term);
- while ( my ($term) = $sth->fetchrow_array ) {
+
+ my $result = $adaptor->getParentTerms({relationship_type_id => $type}, {term => $term});
+
+ foreach my $row (@$result) {
+ my $term = $row->{term};
next if ${$seen}{$term};
&_flatten( $dbh, $type, $term, $seen );
${$seen}{$term} = 1;
@@ -3232,12 +3113,17 @@
=cut
sub _traverseServiceDAG {
+
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ( $dbh, $serviceType, $sth_hash ) = @_;
my %sth = %{$sth_hash};
my %ServiceIDs;
- my $sth = $dbh->prepare( $sth{get_service_type_id} );
- $sth->execute($serviceType);
- my ($root_id) = $sth->fetchrow_array;
+
+ my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]});
+ my $row = shift(@$result);
+ my ($root_id) = @$row;
return undef unless $root_id;
# we have to do a traversal of the DAG here to get all child nodes...
@@ -3250,11 +3136,13 @@
next
if ( $ServiceIDs{$service} eq "tested" )
; # if it has been tested already then move on
- my $sth = $dbh->prepare( $sth{get_service_hierarchy_list} );
- $sth->execute($service); # execute the query for child nodes
+
+ my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} );
+ # execute the query for child nodes
$ServiceIDs{$service} = "tested"; # mark it as tested
- while ( my $new = $sth->fetchrow_array )
+ foreach my $row (@$result)
{ # now get each of the child nodes
+ my $new = @$row;
next
if ( defined $ServiceIDs{$new} )
; # if we have already heard about it then move on
@@ -3278,22 +3166,19 @@
=cut
sub _traverseObjectDAG {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ( $dbh, $objectType, $sth_hash, $dir ) = @_;
my %sth = %{$sth_hash};
my %ObjectIDs;
- my $sth = $dbh->prepare( $sth{get_object_type_id} );
- $sth->execute($objectType);
- my ($root_id) = $sth->fetchrow_array;
- return undef unless $root_id;
- if ( $dir eq "p" ) {
- $debug && &_LOG("getting parents");
- $sth = $dbh->prepare( $sth{get_object_parent_list} );
- }
- else {
- $debug && &_LOG("getting children");
- $sth = $dbh->prepare( $sth{get_object_child_list} );
- }
+ my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]});
+
+ my $row = shift (@$result);
+ my ($root_id) = @$row;
+ return undef unless $root_id;
+
# we have to do a traversal of the DAG here to get all child nodes...
# this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery...
$ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested
@@ -3304,10 +3189,22 @@
next
if ( $ObjectIDs{$object} eq "tested" )
; # if it has been tested already then move on
- $sth->execute($object); # execute the query for child nodes
+
+ my $result;
+ if ( $dir eq "p" ) {
+ $debug && &_LOG("getting parents");
+ $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]});
+ }
+ else {
+ $debug && &_LOG("getting children");
+ $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]});
+ }
+ # execute the query for child nodes
+
$ObjectIDs{$object} = "tested"; # mark it as tested
- while ( my $new = $sth->fetchrow_array )
+ foreach my $row (@$result)
{ # now get each of the child nodes
+ my $new = @$row;
next
if ( defined $ObjectIDs{$new} )
; # if we have already heard about it then move on
@@ -3461,56 +3358,28 @@
}
sub _serviceListResponse {
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
my ( $dbh, @ids ) = @_;
my $output = "";
- my $sth = $dbh->prepare(
- q{
- select
- category, url, servicename, service_type_uri, authority_id, description, authoritative, contact_email, signatureURL, lsid
- from service_instance where
- service_instance_id = ?}
- );
- my $sth_simple_in =
- $dbh->prepare(
-"select object_type_uri, namespace_type_uris, article_name from simple_input where service_instance_id=? and collection_input_id IS NULL"
- );
- my $sth_simple_out =
- $dbh->prepare(
-"select object_type_uri, namespace_type_uris, article_name from simple_output where service_instance_id=? and collection_output_id IS NULL"
- );
- my $sth_collection_ins =
- $dbh->prepare(
-"select collection_input_id, article_name from collection_input where service_instance_id=?"
- );
- my $sth_collection_outs =
- $dbh->prepare(
-"select collection_output_id, article_name from collection_output where service_instance_id=?"
- );
- my $sth_collection_in =
- $dbh->prepare(
-"select object_type_uri, namespace_type_uris, article_name from simple_input where service_instance_id IS NULL and collection_input_id =?"
- );
- my $sth_collection_out =
- $dbh->prepare(
-"select object_type_uri, namespace_type_uris, article_name from simple_output where service_instance_id IS NULL and collection_output_id =?"
- );
- my $sth_secondary_in =
- $dbh->prepare(
-"select default_value, maximum_value, minimum_value, enum_value, datatype, article_name from secondary_input where service_instance_id=?"
- );
my $OSobj = MOBY::OntologyServer->new( ontology => 'object' );
my $OSns = MOBY::OntologyServer->new( ontology => 'namespace' );
my $OSserv = MOBY::OntologyServer->new( ontology => 'service' );
foreach (@ids) {
- $sth->execute($_);
- my (
- $category, $url, $servicename,
- $service_type_uri, $authority_id, $desc,
- $authoritative, $email, $signatureURL,
- $lsid
- )
- = $sth->fetchrow_array;
+ my $result = $adaptor->query_service_instance({service_instance_id => $_});
+ my $category = @$result[0]->{category};
+ my $url = @$result[0]->{url};
+ my $servicename = @$result[0]->{servicename};
+ my $service_type_uri = @$result[0]->{service_type_uri};
+ my $authority_id = @$result[0]->{authority_id};
+ my $desc = @$result[0]->{description};
+ my $authoritative = @$result[0]->{authoritative};
+ my $email = @$result[0]->{contact_email};
+ my $signatureURL = @$result[0]->{signatureURL};
+ my $lsid = @$result[0]->{lsid};
+
if ( $desc =~ /<!\[CDATA\[((?>[^\]]+))\]\]>/ ) {
$desc = $1;
}
@@ -3519,10 +3388,9 @@
$signatureURL ||= "";
next unless ( $servicename && $authority_id );
my $service_type = $OSserv->getServiceCommonName($service_type_uri);
- my ($authURI) =
- $dbh->selectrow_array(
- q{select authority_uri from authority where authority_id=?},
- undef, $authority_id );
+
+ $result = $adaptor->query_authority({authority_id => $authority_id});
+ my $authURI = @$result[0]->{authority_uri};
$output .=
"\t<Service authURI='$authURI' serviceName='$servicename' lsid='$lsid'>\n";
$output .= "\t<serviceType>$service_type</serviceType>\n";
@@ -3533,11 +3401,15 @@
$output .= "\t<signatureURL>$signatureURL</signatureURL>\n";
$output .= "\t<URL>$url</URL>\n";
$output .= "\t<Input>\n";
- $sth_simple_in->execute($_);
-
- while ( my ( $objURI, $nsURI, $article ) =
- $sth_simple_in->fetchrow_array() )
+
+ $result = $adaptor->query_simple_input({service_instance_id => $_}, 'and', {collection_input_id => undef});
+
+ foreach my $row (@$result)
{
+ my $objURI = $row->{object_type_uri};
+ my $nsURI = $row->{namespace_type_uris};
+ my $article = $row->{article_name};
+
my $objName = $OSobj->getObjectCommonName($objURI);
$nsURI ||= "";
my @nsURIs = split ",", $nsURI;
@@ -3550,15 +3422,23 @@
}
$output .= "\t\t</Simple>\n";
}
+ $result = $adaptor->query_collection_input({service_instance => $_});
$sth_collection_ins->execute($_);
- while ( my ( $collid, $articlename ) =
- $sth_collection_ins->fetchrow_array )
+
+ foreach my $row (@$result)
{
- $output .= "\t\t<Collection articleName='$articlename'>\n";
- $sth_collection_in->execute($collid);
- while ( my ( $objURI, $nsURI, $article ) =
- $sth_collection_in->fetchrow_array() )
+ my $collid = $row->{collection_input_id};
+ my $articlename = $row->{article_name};
+
+ $output .= "\t\t<Collection articleName='$articlename'>\n";
+
+ my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, 'and', {collection_input_id => $collid});
+ foreach my $row2 (@$result2)
{
+ my $objURI = $row2->{object_type_uri};
+ my $nsURI = $row2->{namespace_type_uri};
+ my $article = $row2->{article_name};
+
my $objName = $OSobj->getObjectCommonName($objURI);
$nsURI ||= "";
my @nsURIs = split ",", $nsURI;
@@ -3576,57 +3456,68 @@
}
$output .= "\t</Input>\n";
$output .= "\t<Output>\n";
- $sth_simple_out->execute($_);
- while ( my ( $objURI, $nsURI, $article ) =
- $sth_simple_out->fetchrow_array() )
+
+ $result = query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef});
+
+ foreach my $row (@$result)
{
+ my $objURI = $row->{object_type_uri};
+ my $nsURI = $row->{namespace_type_uris};
+ my $article = $row->{article_name};
+
+ my $objName = $OSobj->getObjectCommonName($objURI);
+ $nsURI ||= "";
+ my @nsURIs = split ",", $nsURI;
+ $article ||= "";
+ $output .= "\t\t<Simple articleName='$article'>\n";
+ $output .= "\t\t\t<objectType>$objName</objectType>\n";
+ foreach my $ns (@nsURIs) {
+ my $NSname = $OSns->getNamespaceCommonName($ns);
+ $output .= "\t\t\t<Namespace>$NSname</Namespace>\n" if $NSname;
+ }
+ $output .= "\t\t</Simple>\n";
+ }
+
+ $result = query_collection_output({service_instance_id => $_});
+ foreach my $row (@$result)
+ {
+ my $collid = $row->{collection_output_id};
+ my $articlename = $row->{article_name};
+ $output .= "\t\t<Collection articleName='$articlename'>\n";
+
+ my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id = $collid});
+ foreach my $row2 (@$result2 )
+ {
+ my $objURI = $row2->{object_type_uri};
+ my $nsURI = $row2->{namespace_type_uris};
+ my $article = $row2->{article_name};
my $objName = $OSobj->getObjectCommonName($objURI);
$nsURI ||= "";
my @nsURIs = split ",", $nsURI;
$article ||= "";
- $output .= "\t\t<Simple articleName='$article'>\n";
- $output .= "\t\t\t<objectType>$objName</objectType>\n";
+ $output .= "\t\t\t<Simple articleName='$article'>\n";
+ $output .= "\t\t\t\t<objectType>$objName</objectType>\n";
foreach my $ns (@nsURIs) {
- my $NSname = $OSns->getNamespaceCommonName($ns);
- $output .= "\t\t\t<Namespace>$NSname</Namespace>\n" if $NSname;
- }
- $output .= "\t\t</Simple>\n";
- }
- $sth_collection_outs->execute($_);
- while ( my ( $collid, $articlename ) =
- $sth_collection_outs->fetchrow_array )
- {
- $output .= "\t\t<Collection articleName='$articlename'>\n";
- $sth_collection_out->execute($collid);
- while ( my ( $objURI, $nsURI, $article ) =
- $sth_collection_out->fetchrow_array() )
- {
- my $objName = $OSobj->getObjectCommonName($objURI);
- $nsURI ||= "";
- my @nsURIs = split ",", $nsURI;
- $article ||= "";
- $output .= "\t\t\t<Simple articleName='$article'>\n";
- $output .= "\t\t\t\t<objectType>$objName</objectType>\n";
- foreach my $ns (@nsURIs) {
- my $NSname = $OSns->getNamespaceCommonName($ns);
- $output .= "\t\t\t\t<Namespace>$NSname</Namespace>\n"
- if $NSname;
- }
- $output .= "\t\t\t</Simple>\n";
- }
- $output .= "\t\t</Collection>\n";
+ my $NSname = $OSns->getNamespaceCommonName($ns);
+ $output .= "\t\t\t\t<Namespace>$NSname</Namespace>\n"
+ if $NSname;
+ }
+ $output .= "\t\t\t</Simple>\n";
+ }
+ $output .= "\t\t</Collection>\n";
}
$output .= "\t</Output>\n";
$output .= "\t<secondaryArticles>\n";
- $sth_secondary_in->execute($_);
- while (
- my (
- $default_value, $maximum_value, $minimum_value,
- $enum_value, $datatype, $article_name
- )
- = $sth_secondary_in->fetchrow_array()
- )
+ $result = $adaptor->query_secondary_input({service_instance_id => $_});
+ foreach my $row (@$result)
{
+ my $default_value = $row->{default_value};
+ my $maximum_value = $row->{maximum_value};
+ my $minimum_value = $row->{minimum_value};
+ my $enum_value = $row->{enum_value};
+ my $datatype = $row->{datatype};
+ my $article_name = $row->{article_name};
+
$article_name ||= "";
$datatype ||= "";
$default_value ||= "";
More information about the MOBY-guts
mailing list