ResourceDescription.pm 3.12 KB
Newer Older
Leo Gordon's avatar
Leo Gordon committed
1 2 3 4
=pod 

=head1 NAME

5
    Bio::EnsEMBL::Hive::ResourceDescription
Leo Gordon's avatar
Leo Gordon committed
6 7 8 9 10 11

=head1 DESCRIPTION

    A data container object (the only methods are getters/setters) that corresponds to a row in 'resource_description' table:

    CREATE TABLE resource_description (
12
        resource_class_id     int(10) unsigned NOT NULL,
13
        meadow_type           varchar(40) NOT NULL,
14 15 16
        submission_cmd_args     VARCHAR(255) NOT NULL DEFAULT '',
        worker_cmd_args         VARCHAR(255) NOT NULL DEFAULT '',

17
        PRIMARY KEY(resource_class_id, meadow_type)
Leo Gordon's avatar
Leo Gordon committed
18 19
    ) ENGINE=InnoDB;

20 21
=head1 LICENSE

22
    Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Matthieu Muffato's avatar
Matthieu Muffato committed
23
    Copyright [2016-2018] EMBL-European Bioinformatics Institute
24 25 26 27 28 29 30 31 32 33

    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.

Leo Gordon's avatar
Leo Gordon committed
34 35
=head1 CONTACT

36
    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
Leo Gordon's avatar
Leo Gordon committed
37 38 39

=cut

40

Leo Gordon's avatar
Leo Gordon committed
41 42 43
package Bio::EnsEMBL::Hive::ResourceDescription;

use strict;
44 45
use Scalar::Util ('weaken');

46
use Bio::EnsEMBL::Utils::Argument ('rearrange');
Leo Gordon's avatar
Leo Gordon committed
47 48 49 50 51 52

sub new {
    my $class = shift @_;

    my $self = bless {}, $class;

53 54
    my ($adaptor, $resource_class_id, $meadow_type, $submission_cmd_args, $worker_cmd_args) =
         rearrange([qw(adaptor resource_class_id meadow_type submission_cmd_args worker_cmd_args) ], @_);
Leo Gordon's avatar
Leo Gordon committed
55 56

    $self->adaptor($adaptor) if(defined($adaptor));
57
    $self->resource_class_id($resource_class_id);
Leo Gordon's avatar
Leo Gordon committed
58
    $self->meadow_type($meadow_type);
59 60
    $self->submission_cmd_args($submission_cmd_args);
    $self->worker_cmd_args($worker_cmd_args);
Leo Gordon's avatar
Leo Gordon committed
61 62 63 64

    return $self;
}

65

Leo Gordon's avatar
Leo Gordon committed
66 67 68 69 70
sub adaptor {
    my $self = shift @_;

    if(@_) {
        $self->{'_adaptor'} = shift @_;
71
        weaken $self->{'_adaptor'};
Leo Gordon's avatar
Leo Gordon committed
72
    }
73

Leo Gordon's avatar
Leo Gordon committed
74 75 76
    return $self->{'_adaptor'};
}

77

78
sub resource_class_id {
Leo Gordon's avatar
Leo Gordon committed
79 80 81
    my $self = shift @_;

    if(@_) {
82
        $self->{'_resource_class_id'} = shift @_;
Leo Gordon's avatar
Leo Gordon committed
83
    }
84
    return $self->{'_resource_class_id'};
Leo Gordon's avatar
Leo Gordon committed
85 86
}

87

Leo Gordon's avatar
Leo Gordon committed
88 89 90 91 92 93 94 95 96
sub meadow_type {
    my $self = shift @_;

    if(@_) {
        $self->{'_meadow_type'} = shift @_;
    }
    return $self->{'_meadow_type'};
}

97 98

sub submission_cmd_args {
Leo Gordon's avatar
Leo Gordon committed
99 100 101
    my $self = shift @_;

    if(@_) {
102
        $self->{'_submission_cmd_args'} = shift @_;
Leo Gordon's avatar
Leo Gordon committed
103
    }
104
    return $self->{'_submission_cmd_args'} || '';
Leo Gordon's avatar
Leo Gordon committed
105 106
}

107 108 109 110 111 112 113 114 115 116 117

sub worker_cmd_args {
    my $self = shift @_;

    if(@_) {
        $self->{'_worker_cmd_args'} = shift @_;
    }
    return $self->{'_worker_cmd_args'} || '';
}


118
sub toString {
Leo Gordon's avatar
Leo Gordon committed
119 120
    my $self = shift @_;

121
    return (ref($self).': '.join(', ', map { $_.'="'.$self->$_().'"' } qw(resource_class_id meadow_type submission_cmd_args worker_cmd_args) ));
Leo Gordon's avatar
Leo Gordon committed
122 123 124 125
}

1;