[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Wed Jul 27 14:19:42 UTC 2005
mwilkinson
Wed Jul 27 10:19:42 EDT 2005
Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi
In directory pub.open-bio.org:/tmp/cvs-serv28768/MOBY/Adaptor/moby/queryapi
Modified Files:
mysql.pm
Log Message:
ontological relationships not being properly deleted since objects no longer existed
moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.45,1.46
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:07:57 1.45
+++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:19:42 1.46
@@ -521,17 +521,14 @@
my $dbh = $self->dbh;
my $term = $args{type};
return 0 unless $term;
- my $statement = "delete from object where ";
- my $condition;
- if ($term =~ /^urn\:lsid/){
- $condition = " object_lsid = ?";
- } else {
- $condition = " object_type = ?";
- }
- $statement = $statement.$condition;
- $dbh->do( $statement,undef, ($term) );
+ my $result = $self->query_object(type => $term);
+ my $row = shift(@$result);
+ my $id = $row->{object_id};
+ my $lsid = $row->{object_lsid};
+ my $statement = "delete from object where object_lsid = ?";
+ $dbh->do( $statement,undef, ($lsid) );
- $self->_delete_object_term2term(type => $term);
+ $self->_delete_object_term2term(id => $id);
if ($dbh->err){
return (1, $dbh->errstr);
}
@@ -593,15 +590,11 @@
# SHOULD NOT BE DOCUMENTED IN THE API
sub _delete_object_term2term{
my ($self, %args) = @_;
- my $type = $args{type};
- return 0 unless $type;
- my $result = $self->query_object(type => $type);
- my $row = shift @$result;
- my $id = $row->object_id;
-
+ my $o1id = $args{id};
+ return 0 unless defined($o1id);
my $dbh = $self->dbh;
my $statement = "delete from object_term2term where object1_id=?";
- $dbh->do( $statement,undef, ($id));
+ $dbh->do( $statement,undef, ($o1id));
if ($dbh->err){
return (1, $dbh->errstr);
@@ -848,13 +841,18 @@
return $dbh->{mysql_insertid};
}
-# pass in service type as LSID (service_lsid)
+# pass in 'type' as LSID term or lsid
sub delete_service{
my ($self, %args) = @_;
+ my $type = $args{type};
+ my $result = $self->query_service(type => $type);
+ my $row = shift(@$result);
+ my $id = $row->{service_id};
+ my $lsid = $row->{service_lsid};
my $dbh = $self->dbh;
my $statement = "delete from service where service_lsid = ?";
- $dbh->do( $statement, undef, ($args{service_lsid}));
- $self->_delete_service_term2term;
+ $dbh->do( $statement, undef, ($args{lsid}));
+ $self->_delete_service_term2term(id => $id);
if ($dbh->err){
return (1, $dbh->errstr);
}
@@ -911,12 +909,8 @@
# NOT BE DOCUMENTED IN THE API.
sub _delete_service_term2term{
my ($self, %args) = @_;
- my $type = $args{type};
- return 0 unless $type;
- my $result = $self->query_service(type => $type);
- my $row = shift @$result;
- my $id = $row->service_id;
-
+ my $id = $args{id};
+ return 0 unless (defined($id));
my $dbh = $self->dbh;
my $statement = "delete from service_term2term where service1_id=?";
$dbh->do( $statement,undef, ($id));
@@ -1006,11 +1000,15 @@
# pass namesapce_lsid
sub delete_namespace{
my ($self, %args) = @_;
- my $lsid = $args{namespace_lsid};
+ my $type = $args{type};
+ my $result = $self->query_namespace(type => $type);
+ my $row = shift(@$result);
+ my $id = $row->{namespace_id};
+ my $lsid = $row->{namespace_lsid};
my $dbh = $self->dbh;
my $statement = "delete from namespace where namespace_lsid = ?";
$dbh->do( $statement, undef, ($lsid));
- $self->_delete_namespace_term2term;
+ $self->_delete_namespace_term2term(id => $id);
if ($dbh->err){
return (1, $dbh->errstr);
}
@@ -1041,12 +1039,8 @@
# PRIVATE, NOT PART OF API!
sub _delete_namespace_term2term{
my ($self, %args) = @_;
- my $type = $args{type};
- return 0 unless $type;
- my $result = $self->query_namespace(type => $type);
- my $row = shift @$result;
- my $id = $row->namespace_id;
-
+ my $id = $args{id};
+ return 0 unless defined($id);
my $dbh = $self->dbh;
my $statement = "delete from namespace_term2term where namespace1_id=?";
$dbh->do( $statement,undef, ($id));
More information about the MOBY-guts
mailing list