Commit 5a40123e authored by Leo Gordon's avatar Leo Gordon
Browse files

adding ResourceClass and ResourceClassAdaptor

parent 46e0ab00
......@@ -62,6 +62,7 @@ sub get_available_adaptors {
'AnalysisCtrlRule' => 'Bio::EnsEMBL::Hive::DBSQL::AnalysisCtrlRuleAdaptor',
'DataflowRule' => 'Bio::EnsEMBL::Hive::DBSQL::DataflowRuleAdaptor',
'ResourceDescription' => 'Bio::EnsEMBL::Hive::DBSQL::ResourceDescriptionAdaptor',
'ResourceClass' => 'Bio::EnsEMBL::Hive::DBSQL::ResourceClassAdaptor',
'JobMessage' => 'Bio::EnsEMBL::Hive::DBSQL::JobMessageAdaptor',
'NakedTable' => 'Bio::EnsEMBL::Hive::DBSQL::NakedTableAdaptor',
......
=pod
=head1 NAME
Bio::EnsEMBL::Hive::DBSQL::ResourceClassAdaptor
=head1 SYNOPSIS
$resource_class_adaptor = $db_adaptor->get_ResourceClassAdaptor;
$resource_class_adaptor = $resource_class_object->adaptor;
=head1 DESCRIPTION
Module to encapsulate all db access for persistent class ResourceClass.
There should be just one per application and database connection.
=head1 CONTACT
Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.
=cut
package Bio::EnsEMBL::Hive::DBSQL::ResourceClassAdaptor;
use strict;
use Bio::EnsEMBL::Hive::ResourceClass;
use base ('Bio::EnsEMBL::Hive::DBSQL::ObjectAdaptor');
sub default_table_name {
return 'resource_class';
}
sub default_insertion_method {
return 'INSERT_IGNORE';
}
sub object_class {
return 'Bio::EnsEMBL::Hive::ResourceClass';
}
1;
=pod
=head1 NAME
Bio::EnsEMBL::Hive::ResourceClass
=head1 SYNOPSIS
=head1 DESCRIPTION
A data container object (the only methods are getters/setters) that corresponds to a row in 'resource_class' table:
CREATE TABLE resource_class (
resource_class_id int(10) unsigned NOT NULL AUTO_INCREMENT, # unique internal id
name varchar(40) NOT NULL,
PRIMARY KEY(resource_class_id)
) ENGINE=InnoDB;
=head1 CONTACT
Please contact ehive-users@ebi.ac.uk mailing list with questions/suggestions.
=cut
package Bio::EnsEMBL::Hive::ResourceClass;
use strict;
use Scalar::Util ('weaken');
use Bio::EnsEMBL::Utils::Argument; # import 'rearrange()'
sub new {
my $class = shift @_;
my $self = bless {}, $class;
my ($adaptor, $dbID, $name) =
rearrange([qw(adaptor dbID name) ], @_);
$self->adaptor($adaptor) if(defined($adaptor));
$self->dbID($dbID);
$self->name($name);
return $self;
}
sub adaptor {
my $self = shift @_;
if(@_) {
$self->{'_adaptor'} = shift @_;
weaken $self->{'_adaptor'};
}
return $self->{'_adaptor'};
}
sub dbID {
my $self = shift @_;
if(@_) {
$self->{'_resource_class_id'} = shift @_;
}
return $self->{'_resource_class_id'};
}
sub name {
my $self = shift @_;
if(@_) {
$self->{'_name'} = shift @_;
}
return $self->{'_name'};
}
sub to_string {
my $self = shift @_;
return (ref($self).': '.join(', ', map { $_.'="'.$self->$_().'"' } qw(dbID name) ));
}
1;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment