ensembl-hive  2.5
DataflowRuleAdaptor.pm
Go to the documentation of this file.
1 =pod
2 
3 =head1 NAME
4 
6 
7 =head1 SYNOPSIS
8 
9  $dataflow_rule_adaptor = $db_adaptor->get_DataflowRuleAdaptor;
10  $dataflow_rule_adaptor = $dataflowRuleObj->adaptor;
11 
12 =head1 DESCRIPTION
13 
14  Module to encapsulate all db access for persistent class DataflowRule.
15  There should be just one per application and database connection.
16 
17 =head1 LICENSE
18 
19  Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
20  Copyright [2016-2022] EMBL-European Bioinformatics Institute
21 
22  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
23  You may obtain a copy of the License at
24 
25  http://www.apache.org/licenses/LICENSE-2.0
26 
27  Unless required by applicable law or agreed to in writing, software distributed under the License
28  is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29  See the License for the specific language governing permissions and limitations under the License.
30 
31 =head1 CONTACT
32 
33  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
34 
35 =cut
36 
37 
38 package Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor;
39 
40 use strict;
41 use warnings;
42 use Bio::EnsEMBL::Hive::Utils ('stringify');
43 
44 use base ('Bio::EnsEMBL::Hive::DBSQL::ObjectAdaptor');
45 
46 
47 sub check_object_present_in_db_by_content {
48  return 0;
49 }
50 
51 
52 sub default_table_name {
53  return 'dataflow_rule';
54 }
55 
56 
57 sub object_class {
58  return 'Bio::EnsEMBL::Hive::DataflowRule';
59 }
60 
61 
62 =head2 branch_name_2_code
63 
64 Description: encodes a branch mnemonic name into numeric code
65 
66 =cut
67 
68 sub branch_name_2_code {
69 
70  shift @_ if(ref($_[0])); # skip the first argument if it is an object, so it works both as a method and a subroutine
71 
72  my ($branch_name_or_code, $no_default) = @_;
73 
74  return ($no_default ? undef : 1) unless(defined($branch_name_or_code));
75 
76  my $branch_code = ($branch_name_or_code=~/^\-?\d+$/)
77  ? $branch_name_or_code
78  : {
79  'MAIN' => 1,
80 
81  'ANYFAILURE' => 0,
82  'MEMLIMIT' => -1,
83  'RUNLIMIT' => -2,
84  }->{$branch_name_or_code};
85  return defined($branch_code) ? $branch_code : die "Could not map the branch_name '$branch_name_or_code' to the internal code";
86 }
87 
88 1;
89