Commit 2e01559e authored by Leo Gordon's avatar Leo Gordon
Browse files

switch MetaParameters to the common cache (from a simple hash)

parent d2e61710
......@@ -266,12 +266,12 @@ sub AUTOLOAD {
sub init_collections { # should not really belong to DBAdaptor, temporarily squatting here...
foreach my $AdaptorType ('MetaParameters', 'PipelineWideParameters') {
foreach my $AdaptorType ('PipelineWideParameters') {
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( {} );
}
foreach my $AdaptorType ('ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
foreach my $AdaptorType ('MetaParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( Bio::EnsEMBL::Hive::Utils::Collection->new() );
}
......@@ -281,13 +281,13 @@ sub init_collections { # should not really belong to DBAdaptor, temporarily squ
sub load_collections {
my $self = shift @_;
foreach my $AdaptorType ('MetaParameters', 'PipelineWideParameters') {
foreach my $AdaptorType ('PipelineWideParameters') {
my $adaptor = $self->get_adaptor( $AdaptorType );
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( $adaptor->fetch_param_hash() );
}
foreach my $AdaptorType ('ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
foreach my $AdaptorType ('MetaParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
my $adaptor = $self->get_adaptor( $AdaptorType );
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
$class->collection( Bio::EnsEMBL::Hive::Utils::Collection->new( $adaptor->fetch_all ) );
......@@ -298,7 +298,7 @@ sub load_collections {
sub save_collections {
my $self = shift @_;
foreach my $AdaptorType ('MetaParameters', 'PipelineWideParameters') {
foreach my $AdaptorType ('PipelineWideParameters') {
my $adaptor = $self->get_adaptor( $AdaptorType );
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
while( my ($hash_key,$hash_value) = each %{ $class->collection() } ) {
......@@ -307,11 +307,11 @@ sub save_collections {
}
}
foreach my $AdaptorType ('ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
foreach my $AdaptorType ('MetaParameters', 'ResourceClass', 'ResourceDescription', 'Analysis', 'AnalysisStats', 'AnalysisCtrlRule', 'DataflowRule') {
my $adaptor = $self->get_adaptor( $AdaptorType );
my $class = 'Bio::EnsEMBL::Hive::'.$AdaptorType;
foreach my $storable_object ( $class->collection()->list ) {
$adaptor->store_or_update_one( $storable_object );
$adaptor->store_or_update_one( $storable_object, $class->unikey() );
# warn "Stored/updated ".$storable_object->toString()."\n";
}
}
......
......@@ -45,27 +45,12 @@ sub default_table_name {
}
sub replace_pair {
my ($self, $meta_key, $meta_value) = @_;
$self->remove_all_by_meta_key($meta_key); # make sure the previous values are gone
return $self->store( { 'meta_key' => $meta_key, 'meta_value' => $meta_value } );
}
sub fetch_param_hash {
my $self = shift @_;
return $self->fetch_HASHED_FROM_meta_key_TO_meta_value();
}
sub get_value_by_key {
my ($self, $meta_key) = @_;
if( my $collection = Bio::EnsEMBL::Hive::MetaParameters->collection() ) {
return $collection->{ $meta_key };
return $collection->find_one_by( 'meta_key', $meta_key );
} else {
......
......@@ -33,6 +33,11 @@ package Bio::EnsEMBL::Hive::MetaParameters;
use strict;
use base ( 'Bio::EnsEMBL::Hive::Cacheable' );
sub unikey { # override the default from Cacheable parent
return [ 'meta_key' ];
}
1;
......@@ -455,8 +455,13 @@ sub add_objects_from_config {
my $self = shift @_;
warn "Adding hive_meta table entries ...\n";
my $hm_coll = Bio::EnsEMBL::Hive::MetaParameters->collection();
%$hm_coll = (%$hm_coll, %{$self->hive_meta_table()} );
my $new_meta_entries = $self->hive_meta_table();
while( my ($meta_key, $meta_value) = each %$new_meta_entries ) {
Bio::EnsEMBL::Hive::MetaParameters->add_new_or_update(
'meta_key' => $meta_key,
'meta_value' => $meta_value,
);
}
warn "Done.\n\n";
warn "Adding pipeline-wide parameters ...\n";
......
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