Commit f174a05a authored by Leo Gordon's avatar Leo Gordon
Browse files

hide the calls to URLFactory into the DBAdaptor's constructor

parent 969061b9
......@@ -36,10 +36,24 @@ Bio::EnsEMBL::Hive::DBSQL::DBAdaptor
package Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use strict;
use Bio::EnsEMBL::Utils::Argument;
use Bio::EnsEMBL::Hive::URLFactory;
use base ('Bio::EnsEMBL::DBSQL::DBAdaptor');
sub new {
my ($class, @args) = @_;
my ($url) = rearrange(['URL'], @args);
if($url) {
return Bio::EnsEMBL::Hive::URLFactory->fetch($url) || die "Unable to connect to '$url'\n";
} else {
return $class->SUPER::new(@args);
}
}
sub hive_use_triggers { # getter only, not setter
my $self = shift @_;
......@@ -74,5 +88,5 @@ sub get_available_adaptors {
);
return \%pairs;
}
1;
......@@ -7,7 +7,6 @@ use Getopt::Long;
use Bio::EnsEMBL::Hive::Utils ('script_usage', 'destringify');
use Bio::EnsEMBL::Hive::Utils::Config;
use Bio::EnsEMBL::Hive::URLFactory;
use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::Queen;
use Bio::EnsEMBL::Hive::Valley;
......@@ -126,7 +125,7 @@ sub main {
Bio::EnsEMBL::Registry->load_all($self->{'reg_conf'});
$self->{'dba'} = Bio::EnsEMBL::Registry->get_DBAdaptor($self->{'reg_alias'}, 'hive');
} elsif($self->{'url'}) {
$self->{'dba'} = Bio::EnsEMBL::Hive::URLFactory->fetch($self->{'url'}) || die("Unable to connect to $self->{'url'}\n");
$self->{'dba'} = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new(-url => $self->{'url'});
} else {
print "\nERROR : Connection parameters (url or reg_conf+reg_alias) need to be specified\n\n";
script_usage(1);
......
......@@ -8,7 +8,6 @@ use warnings;
use Getopt::Long;
use Pod::Usage;
use Bio::EnsEMBL::Hive::URLFactory;
use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::Utils::Graph;
......@@ -56,7 +55,7 @@ sub _process_options {
Bio::EnsEMBL::Registry->load_all($self->{'reg_conf'});
$self->{dba} = Bio::EnsEMBL::Registry->get_DBAdaptor($self->{'reg_alias'}, 'hive');
} elsif($self->{url}) {
$self->{dba} = Bio::EnsEMBL::Hive::URLFactory->fetch($self->{url}) || die("Unable to connect to $self->{url}\n");
$self->{dba} = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new(-url => $self->{url});
} else {
pod2usage({
-message => 'ERROR: Connection parameters (url or reg_conf+reg_alias) need to be specified',
......
......@@ -6,7 +6,7 @@ use strict;
use warnings;
use Getopt::Long;
use Bio::EnsEMBL::Hive::URLFactory;
use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Hive::Utils ('script_usage');
main();
......@@ -33,7 +33,7 @@ sub main {
script_usage(1);
}
my $dba = Bio::EnsEMBL::Hive::URLFactory->fetch( $url ) || die "Unable to connect to pipeline database '$url'\n";
my $dba = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new(-url => $url );
my $dbc = $dba->dbc();
warn "Creating the 'lsf_report' table if it doesn't exist...\n";
......
......@@ -66,7 +66,7 @@ if($reg_alias) {
$url =~ s/\$(\{(\w+)\})/defined($ENV{$2})?"$ENV{$2}":"\$$1"/eg;
$url =~ s/\$((\w+))/defined($ENV{$2})?"$ENV{$2}":"\$$1"/eg;
$DBA = Bio::EnsEMBL::Hive::URLFactory->fetch($url) or die "Unable to connect to '$url'\n";
$DBA = Bio::EnsEMBL::Hive::DBSQL::DBAdaptor->new(-url => $url);
} else {
print "\nERROR : Connection parameters (url or reg_conf+reg_alias) need to be specified\n\n";
script_usage(1);
......
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