DataflowRuleAdaptor.pm 2.42 KB
Newer Older
1
=pod
2 3

=head1 NAME
Jessica Severin's avatar
Jessica Severin committed
4

5
    Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor 
6 7

=head1 SYNOPSIS
Jessica Severin's avatar
Jessica Severin committed
8

9 10
    $dataflow_rule_adaptor = $db_adaptor->get_DataflowRuleAdaptor;
    $dataflow_rule_adaptor = $dataflowRuleObj->adaptor;
11 12

=head1 DESCRIPTION
Jessica Severin's avatar
Jessica Severin committed
13

14 15 16 17 18
    Module to encapsulate all db access for persistent class DataflowRule.
    There should be just one per application and database connection.

=head1 LICENSE

19
    Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
nwillhoft's avatar
nwillhoft committed
20
    Copyright [2016-2021] EMBL-European Bioinformatics Institute
21 22 23 24 25 26 27 28 29

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License
    is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and limitations under the License.
30 31

=head1 CONTACT
Jessica Severin's avatar
Jessica Severin committed
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 36 37 38 39 40

=cut


package Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor;

use strict;
41
use warnings;
42
use Bio::EnsEMBL::Hive::Utils ('stringify');
43

44
use base ('Bio::EnsEMBL::Hive::DBSQL::ObjectAdaptor');
45 46


47 48 49 50 51
sub check_object_present_in_db_by_content {
    return 0;
}


52 53 54 55 56 57 58 59 60 61
sub default_table_name {
    return 'dataflow_rule';
}


sub object_class {
    return 'Bio::EnsEMBL::Hive::DataflowRule';
}


62 63 64 65 66 67 68 69
=head2 branch_name_2_code

Description: encodes a branch mnemonic name into numeric code

=cut

sub branch_name_2_code {

70 71 72 73 74
    shift @_ if(ref($_[0]));     # skip the first argument if it is an object, so it works both as a method and a subroutine

    my ($branch_name_or_code, $no_default) = @_;

    return ($no_default ? undef : 1) unless(defined($branch_name_or_code));
75

76
    my $branch_code = ($branch_name_or_code=~/^\-?\d+$/)
77 78 79 80 81 82 83
        ? $branch_name_or_code
        : {
            'MAIN'          =>  1,

            'ANYFAILURE'    =>  0,
            'MEMLIMIT'      => -1,
            'RUNLIMIT'      => -2,
84 85
        }->{$branch_name_or_code};
    return defined($branch_code) ? $branch_code : die "Could not map the branch_name '$branch_name_or_code' to the internal code";
86
}
87 88 89

1;