ensembl-hive  2.5
NakedTable.pm
Go to the documentation of this file.
1 =pod
2 
3 =head1 NAME
4 
6 
7 =head1 DESCRIPTION
8 
9  A data container object that links together an adaptor, a table and a preferred insertion method (insert/insert-ignore/replace).
10  This object is generated from specially designed datalow URLs.
11 
12 =head1 LICENSE
13 
14  Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
15  Copyright [2016-2022] EMBL-European Bioinformatics Institute
16 
17  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
18  You may obtain a copy of the License at
19 
20  http://www.apache.org/licenses/LICENSE-2.0
21 
22  Unless required by applicable law or agreed to in writing, software distributed under the License
23  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24  See the License for the specific language governing permissions and limitations under the License.
25 
26 =head1 CONTACT
27 
28  Please subscribe to the Hive mailing list: http://listserver.ebi.ac.uk/mailman/listinfo/ehive-users to discuss Hive-related questions or to be notified of our updates
29 
30 =cut
31 
32 
33 package Bio::EnsEMBL::Hive::NakedTable;
34 
35 use strict;
36 use warnings;
37 
38 use base ( 'Bio::EnsEMBL::Hive::Storable' );
39 
40 
41 sub unikey { # override the default from Cacheable parent
42  return [ 'table_name' ];
43 }
44 
45 
46 sub table_name {
47  my $self = shift @_;
48 
49  if(@_) {
50  $self->{'_table_name'} = shift @_;
51  }
52  return $self->{'_table_name'};
53 }
54 
55 
56 sub insertion_method {
57  my $self = shift @_;
58 
59  if(@_) {
60  $self->{'_insertion_method'} = shift @_;
61  }
62  return $self->{'_insertion_method'} || 'INSERT_IGNORE';
63 }
64 
65 
66 sub url_query_params {
67  my ($self) = @_;
68 
69  return { # direct access to the actual (possibly missing) values
70  'table_name' => $self->table_name,
71  'insertion_method' => $self->{'_insertion_method'},
72  };
73 }
74 
75 
76 sub display_name {
77  my ($self) = @_;
78  return $self->table_name;
79 }
80 
81 
82 sub dataflow {
83  my ( $self, $output_ids, $emitting_job ) = @_;
84 
85  my $adaptor = $self->adaptor();
86  my @column_names = keys %{$self->adaptor->column_set};
87  my @rows = ();
88 
89  foreach my $output_id (@$output_ids) {
90  my %row_hash = ();
91  foreach my $column (@column_names) {
92  $row_hash{ $column } = $emitting_job->_param_possibly_overridden($column, $output_id);
93  }
94  push @rows, \%row_hash;
95  }
96  $adaptor->store( \@rows );
97 }
98 
99 
100 sub toString {
101  my $self = shift @_;
102 
103  return 'NakedTable('.$self->table_name.')';
104 }
105 
106 1;
107