Merge pull request #5191 from solgenomics/topic/quality_control
[sgn.git] / lib / CXGN / BrAPI / v1 / Locations.pm
blob947dcd62ac230e39cfeee48427f51e186a546e72
1 package CXGN::BrAPI::v1::Locations;
3 use Moose;
4 use Data::Dumper;
5 use SGN::Model::Cvterm;
6 use CXGN::Trial;
7 use CXGN::BrAPI::Pagination;
8 use CXGN::BrAPI::JSONResponse;
10 extends 'CXGN::BrAPI::v1::Common';
12 sub search {
13 my $self = shift;
14 my $page_size = $self->page_size;
15 my $page = $self->page;
16 my $status = $self->status;
18 my $locations = CXGN::Trial::get_all_locations($self->bcs_schema);
19 my ($data_window, $pagination) = CXGN::BrAPI::Pagination->paginate_array($locations,$page_size,$page);
20 my @data;
21 foreach (@$data_window){
22 push @data, {
23 locationDbId => qq|$_->[0]|,
24 locationType=> $_->[8],
25 locationName=> $_->[1],
26 name=> $_->[1],
27 abbreviation=>$_->[9],
28 countryCode=> $_->[6],
29 countryName=> $_->[5],
30 latitude=>$_->[2],
31 longitude=>$_->[3],
32 altitude=>$_->[4],
33 instituteName=>'',
34 instituteAddress=>$_->[10],
35 additionalInfo=> $_->[7],
36 documentationURL=> undef
40 my %result = (data=>\@data);
41 my @data_files;
42 return CXGN::BrAPI::JSONResponse->return_success(\%result, $pagination, \@data_files, $status, 'Locations list result constructed');