minor fixes
[sgn.git] / lib / CXGN / Trial / TrialLookup.pm
blobebb80df6f510e1b1ea16d501edfcdf6871cef906
1 package CXGN::Trial::TrialLookup;
3 =head1 NAME
5 CXGN::Trial::TrialLookup - a module to lookup geolocations by name.
8 =head1 USAGE
10 my $trial_lookup = CXGN::Trial::TrialLookup->new({ schema => $schema, trial_name => $trial_name} );
13 =head1 DESCRIPTION
15 Looks up trials ("Project::Project") by name. Provides the Project::Project object when a trial name matches.
17 =head1 AUTHORS
19 Jeremy D. Edwards (jde22@cornell.edu)
21 =cut
23 use Moose;
24 use MooseX::FollowPBP;
25 use Moose::Util::TypeConstraints;
26 use Try::Tiny;
28 has 'schema' => (
29 is => 'rw',
30 isa => 'DBIx::Class::Schema',
31 lazy_build => 1,
33 has 'trial_name' => (isa => 'Str', is => 'rw', predicate => 'has_trial_name', clearer => 'clear_trial_name');
35 sub get_trial {
36 my $self = shift;
37 my $schema = $self->get_schema();
38 my $trial;
39 if (!$self->has_trial_name()){
40 return;
42 my $trial_name = $self->get_trial_name;
43 $trial = $schema->resultset("Project::Project")
44 ->find({
45 name => $trial_name,
46 });
47 if (!$trial) {
48 print STDERR "The trial $trial_name was not found\n";
49 return;
51 return $trial;
55 #######
57 #######