add missing object Bio::GeneticRelationship::Population
[sgn.git] / lib / CXGN / Location / LocationLookup.pm
blob64d593cc9ffcfcff590e4ac9c384d51baf2b79f5
1 package CXGN::Location::LocationLookup;
3 =head1 NAME
5 CXGN::Location::LocationLookup - a module to lookup geolocations by name.
8 =head1 USAGE
10 my $location_lookup = CXGN::Location::LocationLookup->new({ schema => $schema} );
13 =head1 DESCRIPTION
15 Looks up geolocations ("NaturalDiversity::NdGeolocation") by name. Provides the NaturalDiversity::NdGeolocation object when a geolocation 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 'location_name' => (isa => 'Str', is => 'rw', predicate => 'has_location_name', clearer => 'clear_location_name');
35 sub get_geolocation {
36 my $self = shift;
37 my $schema = $self->get_schema();
38 my $geolocation;
39 if (!$self->has_location_name()){
40 return;
42 $geolocation = $schema->resultset("NaturalDiversity::NdGeolocation")
43 ->find({
44 description => $self->get_location_name(),
45 });
46 return $geolocation;
50 #######
52 #######