ResourceDescription.pm 1.92 KB
Newer Older
Leo Gordon's avatar
Leo Gordon committed
1 2 3 4 5 6 7 8 9 10 11 12 13
=pod 

=head1 NAME

  Bio::EnsEMBL::Hive::ResourceDescription

=head1 SYNOPSIS

=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 (
14
        resource_class_id     int(10) unsigned NOT NULL,
15
        meadow_type           varchar(40) NOT NULL,
Leo Gordon's avatar
Leo Gordon committed
16
        parameters            varchar(255) DEFAULT '' NOT NULL,
17
        PRIMARY KEY(resource_class_id, meadow_type)
Leo Gordon's avatar
Leo Gordon committed
18 19 20 21 22 23 24 25 26 27 28
    ) ENGINE=InnoDB;

=head1 CONTACT

  Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.

=cut

package Bio::EnsEMBL::Hive::ResourceDescription;

use strict;
29 30
use Scalar::Util ('weaken');

31
use Bio::EnsEMBL::Utils::Argument ('rearrange');
Leo Gordon's avatar
Leo Gordon committed
32 33 34 35 36 37

sub new {
    my $class = shift @_;

    my $self = bless {}, $class;

38 39
    my ($adaptor, $resource_class_id, $meadow_type, $parameters) =
         rearrange([qw(adaptor resource_class_id meadow_type parameters) ], @_);
Leo Gordon's avatar
Leo Gordon committed
40 41

    $self->adaptor($adaptor) if(defined($adaptor));
42
    $self->resource_class_id($resource_class_id);
Leo Gordon's avatar
Leo Gordon committed
43 44 45 46 47 48
    $self->meadow_type($meadow_type);
    $self->parameters($parameters);

    return $self;
}

49

Leo Gordon's avatar
Leo Gordon committed
50 51 52 53 54
sub adaptor {
    my $self = shift @_;

    if(@_) {
        $self->{'_adaptor'} = shift @_;
55
        weaken $self->{'_adaptor'};
Leo Gordon's avatar
Leo Gordon committed
56
    }
57

Leo Gordon's avatar
Leo Gordon committed
58 59 60
    return $self->{'_adaptor'};
}

61

62
sub resource_class_id {
Leo Gordon's avatar
Leo Gordon committed
63 64 65
    my $self = shift @_;

    if(@_) {
66
        $self->{'_resource_class_id'} = shift @_;
Leo Gordon's avatar
Leo Gordon committed
67
    }
68
    return $self->{'_resource_class_id'};
Leo Gordon's avatar
Leo Gordon committed
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
}

sub meadow_type {
    my $self = shift @_;

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

sub parameters {
    my $self = shift @_;

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

89
sub toString {
Leo Gordon's avatar
Leo Gordon committed
90 91
    my $self = shift @_;

92
    return (ref($self).': '.join(', ', map { $_.'="'.$self->$_().'"' } qw(resource_class_id meadow_type parameters) ));
Leo Gordon's avatar
Leo Gordon committed
93 94 95 96
}

1;