[MOBY-guts] biomoby commit
Dennis Wang
dwang at pub.open-bio.org
Fri Jul 15 16:39:11 UTC 2005
dwang
Fri Jul 15 12:39:11 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi
In directory pub.open-bio.org:/tmp/cvs-serv30067/Perl/MOBY/Adaptor/moby/queryapi
Modified Files:
mysql.pm
Log Message:
All subroutines in mysql.pm should take in array of hashes as arguments.
Delete tuple subroutines now returns 0 if successful or 1 if error
moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.12,1.13
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 21:55:36 1.12
+++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/15 16:39:11 1.13
@@ -228,10 +228,10 @@
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -278,10 +278,10 @@
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -342,10 +342,10 @@
$dbh->do( $statement,
undef, @bindvalues )
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -405,10 +405,10 @@
$dbh->do( $statement,
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -463,10 +463,10 @@
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -526,10 +526,10 @@
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -570,6 +570,24 @@
return $dbh->{mysql_insertid};
}
+sub delete_object_term2term{
+ my ($self, @args) = @_;
+ my $dbh = $self->dbh;
+
+ my $statement = "delete from object_term2term ";
+ my @bindvalues = ();
+ ($statement, @bindvalues) = add_condition($statement, @args);
+ $dbh->do( $statement,
+ undef, @bindvalues );
+
+ if (dbh->err){
+ return (1, dbh->errstr);
+ }
+ else{
+ return 0;
+ }
+}
+
# selects all the columns from service_instance table
# where is lsid?
sub query_service_instance {
@@ -642,10 +660,10 @@
$dbh->do( $statement,
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -742,10 +760,10 @@
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -789,10 +807,10 @@
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -868,10 +886,10 @@
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -906,10 +924,10 @@
undef, @bindvalues );
if (dbh->err){
- return (0, dbh->errstr);
+ return (1, dbh->errstr);
}
else{
- return 1;
+ return 0;
}
}
@@ -1163,12 +1181,39 @@
# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery()
# note: returns a reference to an array containing ARRAY references
sub getRelationship{
- my ($self, %args) = @_;
+ my ($self, @args) = @_;
my $dbh = $self->dbh;
+ my $direction = get_value('direction', @args);
+ my $ontology = get_value('ontology', @args);
+ my $term = get_value('term', @args);
+ my $relationship = get_value('relationship', @args);
my $defs;
- my $ontology = $args{ontology};
- unless ( defined $args{$relationship} ) {
+ if ( $direction eq 'root' ) {
+ unless ( defined $relationship ) {
+ $defs = $self->dbh->selectall_arrayref( "
+ select distinct s2.${ontology}_lsid, relationship_type from
+ ${ontology}_term2term as t2t,
+ $ontology as s1,
+ $ontology as s2
+ where
+ s1.${ontology}_id = t2t.${ontology}1_id and
+ s2.${ontology}_id = t2t.${ontology}2_id and
+ s1.${ontology}_lsid = ?", undef, $term ); # ")
+ } else {
+ $defs = $self->dbh->selectall_arrayref( "
+ select distinct s2.${ontology}_lsid, relationship_type from
+ ${ontology}_term2term as t2t,
+ $ontology as s1,
+ $ontology as s2
+ where
+ relationship_type = ? and
+ s1.${ontology}_id = t2t.${ontology}1_id and
+ s2.${ontology}_id = t2t.${ontology}2_id and
+ s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ")
+ }
+ } else {
+ unless ( defined $relationship ) {
$defs = $self->dbh->selectall_arrayref( "
select distinct s2.${ontology}_lsid, relationship_type from
${ontology}_term2term as t2t,
@@ -1177,7 +1222,7 @@
where
s1.${ontology}_id = t2t.${ontology}1_id and
s2.${ontology}_id = t2t.${ontology}2_id and
- s1.${ontology}_lsid = ?", undef, $args{lsid} ); # ")
+ s2.${ontology}_lsid = ?", undef, $term ); # ")
} else {
$defs = $self->dbh->selectall_arrayref( "
select distinct s2.${ontology}_lsid, relationship_type from
@@ -1188,8 +1233,9 @@
relationship_type = ? and
s1.${ontology}_id = t2t.${ontology}1_id and
s2.${ontology}_id = t2t.${ontology}2_id and
- s1.${ontology}_lsid = ?", undef, $args{$relationship}, $args{lsid} ); # ")
+ s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ")
}
+ }
return $defs;
}
More information about the MOBY-guts
mailing list