[MOBY-guts] biomoby commit
Dennis Wang
dwang at pub.open-bio.org
Mon Jul 18 16:53:04 UTC 2005
dwang
Mon Jul 18 12:53:04 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv16206/Perl/MOBY
Modified Files:
simple_input.pm collection_output.pm collection_input.pm
simple_output.pm secondary_input.pm service_instance.pm
Log Message:
SQL statements replaced by generic api subroutines.
Actual SQL exists in Moby::Adaptor::moby::queryapi::mysql.pm
moby-live/Perl/MOBY simple_input.pm,1.5,1.6 collection_output.pm,1.3,1.4 collection_input.pm,1.3,1.4 simple_output.pm,1.4,1.5 secondary_input.pm,1.2,1.3 service_instance.pm,1.11,1.12
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2004/11/18 17:41:14 1.5
+++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/18 16:53:03 1.6
@@ -100,11 +100,11 @@
$CONFIG ||= MOBY::Config->new; # exported by Config.pm
my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
my $id = $adaptor->insert_simple_input(
- object_type_uri => $self->object_type_uri,
- namespace_type_uris => $self->namespace_type_uris,
- article_name => $self->article_name,
- service_instance_id => $self->service_instance_id,
- collection_input_id => $self->collection_input_id,
+ {object_type_uri => $self->object_type_uri},
+ {namespace_type_uris => $self->namespace_type_uris},
+ {article_name => $self->article_name},
+ {service_instance_id => $self->service_instance_id},
+ {collection_input_id => $self->collection_input_id}
);
return $id;
}
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2004/11/18 17:41:14 1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/18 16:53:03 1.4
@@ -94,8 +94,8 @@
$CONFIG ||= MOBY::Config->new; # exported by Config.pm
my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
my $id = $adaptor->insert_collection_output(
- service_instance => $self->service_instance_id,
- article_name => $self->article_name, );
+ {service_instance => $self->service_instance_id},
+ {article_name => $self->article_name} );
return $id;
}
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2004/11/18 17:41:14 1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/18 16:53:03 1.4
@@ -95,8 +95,8 @@
$CONFIG ||= MOBY::Config->new; # exported by Config.pm
my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
my $id = $adaptor->insert_collection_input(
- service_instance => $self->service_instance_id,
- article_name => $self->article_name, );
+ {service_instance => $self->service_instance_id},
+ {article_name => $self->article_name} );
return $id;
}
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2004/11/18 17:41:15 1.4
+++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/18 16:53:03 1.5
@@ -99,11 +99,11 @@
$CONFIG ||= MOBY::Config->new; # exported by Config.pm
my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
my $id = $adaptor->insert_simple_output(
- object_type_uri => $self->object_type_uri,
- namespace_type_uris => $self->namespace_type_uris,
- article_name => $self->article_name,
- service_instance_id => $self->service_instance_id,
- collection_output_id => $self->collection_output_id,
+ {object_type_uri => $self->object_type_uri},
+ {namespace_type_uris => $self->namespace_type_uris},
+ {article_name => $self->article_name},
+ {service_instance_id => $self->service_instance_id},
+ {collection_output_id => $self->collection_output_id}
);
return $id;
}
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2004/11/18 17:41:14 1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 16:53:03 1.3
@@ -2,6 +2,7 @@
package MOBY::secondary_input;
use strict;
use Carp;
+use MOBY::Config;
use vars qw($AUTOLOAD @ISA);
=head1 NAME
@@ -110,18 +111,17 @@
sub WRITE {
my ($self) = @_;
- my $dbh = $self->_dbh;
- $dbh->do(
-q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)},
- undef,
- (
- $self->default_value, $self->maximum_value,
- $self->minimum_value, $self->enum_value,
- $self->datatype, $self->article_name,
- $self->service_instance_id,
- )
- );
- my $id = $dbh->{mysql_insertid};
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+ my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value},
+ {maximum_value => $self->maximum_value},
+ {minimum_value => $self->minimum_value},
+ {enum_value => $self->enum_value},
+ {datatype => $self->datatype},
+ {article_name => $self->article_name},
+ {service_instance_id => $self->service_instance_id});
+
+ my $id = $dbh->{$insertid};
return $id;
}
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/05/30 23:33:44 1.11
+++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 16:53:03 1.12
@@ -272,16 +272,16 @@
. $self->servicename;
my $id = $self->adaptor->insert_service_instance(
- category => $self->category,
- servicename => $self->servicename,
- service_type_uri => $self->service_type_uri,
- authority_id => $self->authority_id,
- url => $self->url,
- contact_email => $self->contact_email,
- authoritative => $self->authoritative,
- description => $self->description,
- signatureURL => $self->signatureURL,
- lsid => $service_lsid
+ {category => $self->category},
+ {servicename => $self->servicename},
+ {service_type_uri => $self->service_type_uri},
+ {authority_id => $self->authority_id},
+ {url => $self->url},
+ {contact_email => $self->contact_email},
+ {authoritative => $self->authoritative},
+ {description => $self->description},
+ {signatureURL => $self->signatureURL},
+ {lsid => $service_lsid}
);
$self->service_instance_id($id);
$self->{__exists__} = 1; # this service now exists
@@ -298,36 +298,29 @@
return undef;
}
$CONFIG ||= MOBY::Config->new;
- $dbh->do( q{delete from service_instance where service_instance_id = ?},
- undef, $self->service_instance_id );
- $dbh->do( q{delete from simple_input where service_instance_id = ?},
- undef, $self->service_instance_id );
- $dbh->do( q{delete from simple_output where service_instance_id = ?},
- undef, $self->service_instance_id );
- my $sth =
- $dbh->prepare(
-q{select collection_input_id from collection_input where service_instance_id = ?}
- );
- $sth->execute( $self->service_instance_id );
- while ( my ($id) = $sth->fetchrow_array ) {
- $dbh->do( q{delete from simple_input where collection_input_id = ?},
- undef, $id );
- }
- $sth =
- $dbh->prepare(
-q{select collection_output_id from collection_output where service_instance_id = ?}
- );
- $sth->execute( $self->service_instance_id );
- while ( my ($id) = $sth->fetchrow_array ) {
- $dbh->do( q{delete from simple_output where collection_output_id = ?},
- undef, $id );
- }
- $dbh->do( q{delete from collection_input where service_instance_id = ?},
- undef, $self->service_instance_id );
- $dbh->do( q{delete from collection_output where service_instance_id = ?},
- undef, $self->service_instance_id );
- $dbh->do( q{delete from secondary_input where service_instance_id=?},
- undef, $self->service_instance_id );
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
+ $adaptor->delete_service_instance({service_instance_id => $self->service_instance_id});
+ $adaptor->delete_simple_input({service_instance_id => $self->service_instance_id});
+ $adaptor->delete_simple_output({service_instance_id => $self->service_instance_id});
+
+ my $result = $adaptor->query_collection_input({service_instance_id => $self->service_instance_id});
+
+ foreach my $row (@$result) {
+ my $id = $row->{collection_input_id};
+ $adaptor->delete_simple_input({collection_input_id => $id});
+ }
+ $result = $adaptor->query_collection_output({service_instance_id => $self->service_instance_id});
+
+ foreach my $row (@$result) {
+ my $id = $row->{collection_output_id};
+
+ $adaptor->delete_simple_output({collection_output_id => $id});
+ }
+ $adaptor->delete_collection_input({service_instance_id => $self->service_instance_id});
+ $adaptor->delete_collection_output({service_instance_id => $self->service_instance_id});
+ $adaptor->delete_secondary_input({service_instance_id => $self->service_instance_id});
+
return 1;
}
@@ -338,18 +331,21 @@
sub service_instance_exists {
my ($self) = @_;
+ $CONFIG ||= MOBY::Config->new;
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
my $dbh = $self->dbh;
my $authority;
- my ($id) =
- $dbh->selectrow_array(
- q{select authority_id from authority where authority_uri = ?},
- undef, $self->authority_uri );
+
+ my $result = $adaptor->query_authority({authority_uri => $self->authority_uri});
+ my $row = shift(@$result);
+ my $id = $row->{authority_id};
+
return undef unless $id;
- my ($svc) = $dbh->selectrow_array(
-q{select service_instance_id from service_instance where authority_id = ? and servicename = ?},
- undef,
- ( $id, $self->servicename )
- );
+
+ $result = $adaptor->query_service_instance({authority_id => $id}, 'and', {servicename => $self->servicename});
+ $row = shift(@$result);
+ my $svc = $row->{service_instance_id};
+
return $svc;
}
@@ -358,10 +354,14 @@
my ($self) = @_;
my $dbh = $self->dbh;
my $authority;
- my ( $id, $name, $uri, $email ) = $dbh->selectrow_array(
-q{select authority_id, authority_common_name, authority_uri, contact_email from authority where authority_uri = ?},
- undef, $self->authority_uri
- );
+
+ my $result = $adaptor->query_authority({authority_uri => $self->authority_uri});
+ my $row = shift(@$result);
+ my $id = $row->{authority_id};
+ my $name = $row->{authority_common_name};
+ my $uri = $row->{authority_uri};
+ my $email = $row->{contact_email};
+
if ( defined $id ) {
$authority = MOBY::authority->new(
dbh => $self->dbh,
More information about the MOBY-guts
mailing list