Commit 9a1f8e72 authored by Leo Gordon's avatar Leo Gordon
Browse files

removed dependency on Core's DBSQL::BaseAdaptor and Storable by introducing...

removed dependency on Core's DBSQL::BaseAdaptor and Storable by introducing own lightweight Hive::Storable
parent 13b19b79
......@@ -41,7 +41,7 @@ use Bio::EnsEMBL::Utils::Argument ('rearrange');
use Bio::EnsEMBL::Hive::Utils ('stringify');
use base ( 'Bio::EnsEMBL::Storable', # inherit dbID(), adaptor() and new() methods
use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods
);
......
......@@ -44,7 +44,7 @@ use Bio::EnsEMBL::Hive::Utils ('stringify', 'destringify');
use Bio::EnsEMBL::Hive::DBSQL::AnalysisJobAdaptor;
use Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor;
use base ( 'Bio::EnsEMBL::Storable', # inherit dbID(), adaptor() and new() methods
use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods
'Bio::EnsEMBL::Hive::Params', # inherit param management functionality
);
......
......@@ -42,7 +42,7 @@ use Bio::EnsEMBL::Utils::Argument ('rearrange');
use Bio::EnsEMBL::Utils::Exception ('throw');
use Bio::EnsEMBL::Hive::Analysis;
use base ( 'Bio::EnsEMBL::Storable' ); # inherit dbID(), adaptor() and new() methods
use base ( 'Bio::EnsEMBL::Hive::Storable' ); # inherit dbID(), adaptor() and new() methods
## Minimum amount of time in msec that a worker should run before reporting
......
......@@ -39,8 +39,6 @@ use strict;
no strict 'refs'; # needed to allow AUTOLOAD create new methods
use DBI 1.6; # the 1.6 functionality is important for detecting autoincrement fields and other magic.
use base ('Bio::EnsEMBL::DBSQL::BaseAdaptor');
sub default_table_name {
die "Please define table_name either by setting it via table_name() method or by redefining default_table_name() in your adaptor class";
......@@ -68,6 +66,60 @@ sub default_input_column_mapping {
};
}
# ---------------------------------------------------------------------------
sub new {
my ( $class, $dbobj ) = @_;
my $self = bless {}, $class;
if ( !defined $dbobj || !ref $dbobj ) {
throw("Don't have a db [$dbobj] for new adaptor");
}
if ( ref($dbobj) =~ /DBConnection$/ ) {
$self->dbc($dbobj);
} elsif( UNIVERSAL::can($dbobj, 'dbc') ) {
$self->dbc( $dbobj->dbc );
$self->db( $dbobj );
} else {
throw("I was given [$dbobj] for a new adaptor");
}
return $self;
}
sub db {
my $self = shift @_;
if(@_) { # setter
$self->{_db} = shift @_;
}
return $self->{_db};
}
sub dbc {
my $self = shift @_;
if(@_) { # setter
$self->{_dbc} = shift @_;
}
return $self->{_dbc};
}
sub prepare {
my ( $self, $sql ) = @_;
# Uncomment next line to cancel caching on the SQL side.
# Needed for timing comparisons etc.
#$sql =~ s/SELECT/SELECT SQL_NO_CACHE/i;
return $self->dbc->prepare($sql);
}
sub overflow_limit {
my $self = shift @_;
......
......@@ -37,7 +37,7 @@ package Bio::EnsEMBL::Hive::DBSQL::MetaContainer;
use strict;
use Bio::EnsEMBL::Hive::Utils ('stringify', 'destringify');
use base ('Bio::EnsEMBL::Hive::DBSQL::NakedTableAdaptor', 'Bio::EnsEMBL::DBSQL::BaseMetaContainer');
use base ('Bio::EnsEMBL::Hive::DBSQL::NakedTableAdaptor');
sub default_table_name {
......
......@@ -59,7 +59,7 @@ use Bio::EnsEMBL::Utils::Exception ('throw');
use Bio::EnsEMBL::Hive::Utils ('stringify');
use Bio::EnsEMBL::Hive::DBSQL::AnalysisAdaptor;
use base ( 'Bio::EnsEMBL::Storable', # inherit dbID(), adaptor() and new() methods
use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods
);
......
......@@ -41,7 +41,7 @@ use strict;
use Bio::EnsEMBL::Utils::Argument ('rearrange');
use base ( 'Bio::EnsEMBL::Storable', # inherit dbID(), adaptor() and new() methods
use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods
);
......
=pod
=head1 NAME
Bio::EnsEMBL::Hive::Storable
=head1 SYNOPSIS
my $dbID = $storable_object->dbID();
my $adaptor = $storable_object->adaptor();
=head1 DESCRIPTION
Storable is a base class for anything that can be stored.
It provides two getters/setters: dbID() and adaptor().
=head1 LICENSE
Copyright [1999-2013] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.
=head1 CONTACT
Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.
=head1 APPENDIX
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
=cut
package Bio::EnsEMBL::Hive::Storable;
use strict;
use warnings;
use Bio::EnsEMBL::Utils::Argument qw(rearrange);
use Scalar::Util qw(weaken);
=head2 new
Arg [-ADAPTOR] : Bio::EnsEMBL::Hive::DBSQL::BaseAdaptor
Arg [-dbID] : database internal id
Caller : internal calls
Description : create a new Storable object
Returntype : Bio::EnsEMBL::Hive::Storable
Exceptions : Adaptor not a Bio::EnsEMBL::DBSQL::BaseAdaptor
Status : Stable
=cut
sub new {
my $caller = shift;
my $class = ref($caller) || $caller;
my $self = bless {}, $class;
my ($adaptor, $dbID) = rearrange(['ADAPTOR', 'dbID'], @_);
$self->dbID( $dbID ) if defined( $dbID );
$self->adaptor($adaptor) if defined( $adaptor );
return $self;
}
=head2 dbID
Arg [1] : int $dbID
Description: getter/setter for the database internal id
Returntype : int
Exceptions : none
Caller : general, set from adaptor on store
Status : Stable
=cut
sub dbID {
my $self = shift;
$self->{'dbID'} = shift if(@_);
return $self->{'dbID'};
}
=head2 adaptor
Arg [1] : Bio::EnsEMBL::DBSQL::BaseAdaptor $adaptor
Description: get/set for this objects Adaptor
Returntype : Bio::EnsEMBL::DBSQL::BaseAdaptor
Exceptions : none
Caller : general, set from adaptor on store
Status : Stable
=cut
sub adaptor {
my $self = shift;
if(@_) {
$self->{'adaptor'} = shift;
weaken( $self->{'adaptor'} ) if defined( $self->{'adaptor'} );
}
return $self->{'adaptor'};
}
1;
......@@ -89,7 +89,7 @@ use Bio::EnsEMBL::Hive::Utils::RedirectStack;
use Bio::EnsEMBL::Hive::Utils::Stopwatch;
use Bio::EnsEMBL::Hive::Utils ('stringify');
use base ( 'Bio::EnsEMBL::Storable', # inherit dbID(), adaptor() and new() methods
use base ( 'Bio::EnsEMBL::Hive::Storable', # inherit dbID(), adaptor() and new() methods
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment