ParameterMySQLServerProvider.pm
Go to the documentation of this file.
00001 
00002 =head1 LICENSE
00003 
00004 Copyright [2009-2016] EMBL-European Bioinformatics Institute
00005 
00006 Licensed under the Apache License, Version 2.0 (the "License");
00007 you may not use this file except in compliance with the License.
00008 You may obtain a copy of the License at
00009 
00010      http://www.apache.org/licenses/LICENSE-2.0
00011 
00012 Unless required by applicable law or agreed to in writing, software
00013 distributed under the License is distributed on an "AS IS" BASIS,
00014 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 See the License for the specific language governing permissions and
00016 limitations under the License.
00017 
00018 =cut
00019 
00020 =head1 CONTACT
00021 
00022   Please email comments or questions to the public Ensembl
00023   developers list at <dev@ensembl.org>.
00024 
00025   Questions may also be sent to the Ensembl help desk at
00026   <helpdesk@ensembl.org>.
00027 
00028 =cut
00029 
00030 =head1 NAME
00031 
00032 Bio::EnsEMBL::MetaData::DBSQL::MySQLServerProvider
00033 
00034 =head1 SYNOPSIS
00035 
00036   my $provider = Bio::EnsEMBL::MetaData::DBSQL::MySQLServerProvider->new();
00037   my $args = $provider->args_for_genome($info);
00038   my $dba = Bio::EnsEMBL::DBSQL::DBAdaptor->new(%$args);
00039 
00040 =head1 DESCRIPTION
00041 
00042 Provides specified DB argument for a supplied info object or division.
00043 
00044 Used internally by Bio::EnsEMBL::LookUp::RemoteLookUp
00045 
00046 =cut
00047 
00048 package Bio::EnsEMBL::MetaData::DBSQL::ParameterMySQLServerProvider;
00049 
00050 use strict;
00051 use warnings;
00052 
00053 use base 'Bio::EnsEMBL::MetaData::DBSQL::MySQLServerProvider';
00054 
00055 use Bio::EnsEMBL::Utils::Argument qw/rearrange/;
00056 
00057 =head1 CONSTRUCTOR
00058 =head2 new 
00059   Description: Creates a new provider object which returns the supplied arguments
00060   Arg [-HOST]       : Host containing DBAdaptors
00061   Arg [-PORT]       : Port  for DBAdaptors
00062   Arg [-USER]       : User for DBAdaptors
00063   Arg [-PASS]       : Password for DBAdaptors
00064   Returntype : Bio::EnsEMBL::MetaData::DBSQL::MySQLServerProvider
00065   Exceptions : none
00066   Caller     : internal
00067   Status     : Stable
00068 =cut
00069 
00070 sub new {
00071   my ( $class, @args ) = @_;
00072   my $self = $class->SUPER::new(@args);
00073   ( $self->{user}, $self->{pass}, $self->{host}, $self->{port} ) =
00074     rearrange( [ 'USER', 'PASS', 'HOST', 'PORT' ], @args );
00075   return $self;
00076 }
00077 
00078 =head1 METHODS
00079 =head2 args_for_genome
00080   Description: Return the host arguments to build a DBAdaptor for a supplied info object
00081   Argument   : Bio::EnsEMBL::MetaData::GenomeInfo
00082   Returntype : Hashref
00083   Exceptions : none
00084   Caller     : 
00085   Status     : Stable
00086 =cut
00087 
00088 sub args_for_genome {
00089   my ( $self, $info ) = @_;
00090   return $self->args_for_division( $info->division() );
00091 }
00092 
00093 =head2 args_for_division
00094   Description: Return the host arguments to build a DBAdaptor for a supplied division
00095   Argument   : String
00096   Returntype : Hashref
00097   Exceptions : none
00098   Caller     : 
00099   Status     : Stable
00100 =cut
00101 
00102 sub args_for_division {
00103   my ( $self, $division ) = @_;
00104   return { -USER => $self->{user},
00105            -HOST => $self->{host},
00106            -PORT => $self->{port},
00107            -PASS => $self->{pass} };
00108 }
00109 
00110 1;
00111