[MOBY-guts] biomoby commit
Dennis Wang
dwang at pub.open-bio.org
Wed Jul 13 21:53:12 UTC 2005
dwang
Wed Jul 13 17:53:12 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv22025/Perl/MOBY
Modified Files:
Central.pm OntologyServer.pm authority.pm
Log Message:
Moved all SQL statements in authority.pm and Central.pm to Moby::Adaptor::queryapi::mysql.pm
In its place are calls to routines in Moby::Adaptor::queryapi.pm
moby-live/Perl/MOBY Central.pm,1.158,1.159 OntologyServer.pm,1.49,1.50 authority.pm,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -r1.158 -r1.159
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 18:18:39 1.158
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 21:53:11 1.159
@@ -1928,8 +1928,8 @@
$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
}
}
@@ -2001,7 +2001,7 @@
$debug
&& _LOG("Keywords added; criterion count is now $criterion_count\n");
- my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme});
+ my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme});
unless ( scalar @{$ids} ) {
$debug
@@ -2013,8 +2013,8 @@
$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
}
}
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2004/12/14 20:47:04 1.49
+++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/13 21:53:12 1.50
@@ -191,19 +191,21 @@
# if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objecttype/)){
# return (1, "external ontology", $term);
# }
+ my $result;
if ( $term =~ /^urn\:lsid/ ) {
- $sth =
- $self->dbh->prepare(
-"select object_lsid, object_type, description, authority, contact_email from object where object_lsid = ?"
- );
+ $result = $adaptor->query_object({object_lsid => $term});
+
} else {
- $sth =
- $self->dbh->prepare(
-"select object_lsid, object_type, description, authority, contact_email from object where object_type = ?"
- );
+ $result = $adaptor->query_object({object_type => $term});
+
}
- $sth->execute($term);
- my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array;
+ my $row = shift(@$result);
+ my $lsid = $row->{object_lsid};
+ my $type = $row->{object_type};
+ my $desc = $row->{description};
+ my $auth = $row->{authority};
+ my $email = $row->{contact_email};
+
if ($lsid)
{ # if it is in there, then it has been discovered regardless of being foreign or not
return ( 1, $desc, $lsid );
@@ -263,20 +265,20 @@
? $args{'node'}
: $self->setURI( $args{'node'} );
unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) }
- my $sth;
+ my $result;
if ( $args{'node'} =~ /^urn\:lsid/ ) {
- $sth =
- $self->dbh->prepare(
-"select object_lsid, object_type, description, authority, contact_email from object where object_lsid = ?"
- );
+
+ $result = $adaptor->query_object({object_lsid => $term});
} else {
- $sth =
- $self->dbh->prepare(
-"select object_lsid, object_type, description, authority, contact_email from object where object_type = ?"
- );
+ $result = $adaptor->query_object({object_type => $term});
}
- $sth->execute($term);
- my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array;
+ my $row = shift(@$result);
+ my $lsid = $row->{object_lsid};
+ my $type = $row->{object_type};
+ my $desc = $row->{description};
+ my $auth = $row->{authority};
+ my $email = $row->{contact_email};
+
if ($lsid) { # if it is in there, then the object exists
return ( 0, "This term already exists: $lsid", $lsid );
}
@@ -284,15 +286,13 @@
$args{node} =~ s/^\s+(.*?)\s+$/$1/s;
$args{contact_email} =~ s/^\s+(.*?)\s+$/$1/s;
$args{authority} =~ s/^\s+(.*?)\s+$/$1/s;
- $self->dbh->do(
-q{insert into object (object_type, object_lsid, description, authority,contact_email) values (?,?,?,?,?)},
- undef,
- (
- $args{'node'}, $LSID, $args{'description'},
- $args{'authority'}, $args{'contact_email'}
- )
- );
- unless ( $self->dbh->{mysql_insertid} ) {
+
+ my $insertid = $adaptor->insert_object({object_type => $args{'node'}},
+ {object_lsid => $LSID},
+ {description => $args{'description'}},
+ {authority => $args{'authority'}},
+ {contact_email => $args{'contact_email'}});
+ unless ( $insertid ) {
return ( 0, "Object creation failed for unknown reasons", '' );
}
return ( 1, "Object creation succeeded", $LSID );
@@ -313,24 +313,28 @@
? $args{'node'}
: $self->getObjectURI($term);
unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) }
- my ( $id, $type, $lsid, $desc, $auth, $contact ) =
- $self->dbh->selectrow_array(
-q{select object_id, object_type, object_lsid, description, authority,contact_email from object where object_lsid = ?},
- undef, $LSID
- );
+ my $result = $adaptor->query_object({object_lsid => $LSID});
+ my $row = shift(@$result);
+ my $id = $row->{object_id};
+ my $type = $row->{object_type};
+ my $lsid = $row->{object_lsid};
+ my $desc = $row->{description};
+ my $auth = $row->{authority};
+ my $contact = $row->{contact_email};
+
unless ($id) { return ( 0, "Object doesn't exist in ontology", "" ) }
# my $OS = MOBY::OntologyServer->new(ontology => "relationship");
- my $sth =
- $self->dbh->prepare(
-q{select relationship_type, object_lsid, object2_articlename from object_term2term, object where object1_id = ? and object2_id = object_id}
- );
- $sth->execute($id);
+
+ $result = $adaptor->getObjectRelationships({object1_id => $id});
my %rel;
- while ( my ( $relationship_type, $objectlsid, $article ) =
- $sth->fetchrow_array )
+ foreach my $row (@$result)
{
- push @{ $rel{$relationship_type} }, [ $objectlsid, $article ];
+ my $relationship_type = $row->{relationship_type};
+ my $objectlsid = $row->{object_lsid};
+ my $article = $row->{object2_articlename};
+
+ push @{ $rel{$relationship_type} }, [ $objectlsid, $article ];
}
return {
objectType => $lsid,
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2004/11/18 17:41:14 1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/13 21:53:12 1.3
@@ -2,6 +2,7 @@
package MOBY::authority;
use strict;
use Carp;
+use MOBY::Config;
use vars qw($AUTOLOAD @ISA);
=head1 NAME
@@ -86,20 +87,21 @@
}
}
my $dbh = $self->dbh;
- my ( $authority_id, $common, $uri, $contact ) = $dbh->selectrow_array(
-q{select authority_id, authority_common_name,authority_uri,contact_email from authority where authority_uri = ?},
- undef, $self->authority_uri
- );
+ $CONFIG ||= MOBY::Config->new; # exported by Config.pm
+ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' );
+
+ my $result = $adaptor->query_authority({authority_uri => $self->authority_uri});
+ my $authority_id = @$result[0]->{authority_id};
+ my $common = @$result[0]->{authority_common_name};
+ my $uri = @$result[0]->{authority_uri};
+ my $contact = @$result[0]->{contact_email};
+
unless ($authority_id) {
- $dbh->do(
-q{insert into authority (authority_common_name, authority_uri, contact_email) values (?,?,?)},
- undef,
- (
- $self->authority_common_name, $self->authority_uri,
- $self->contact_email
- )
- );
- $self->authority_id( $dbh->{mysql_insertid} );
+ my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name},
+ {authority_uri => $self->authority_uri},
+ {contact_email => $self->contact_email});
+
+ $self->authority_id( $insertid );
} else {
$self->authority_id($authority_id);
}
More information about the MOBY-guts
mailing list