seedlot upload with accession synonyms. seedlot upload works to update existing seedlots
[sgn.git] / lib / SGN / Controller / DocumentBrowser.pm
bloba5904613e50e8f30561ba987d8137928ae5b33fb
3 =head1 NAME
5 SGN::Controller::DocumentBrowser - a controller for viewing document browser page
7 =head1 DESCRIPTION
9 The document browser is a tool that allows the user to upload a tsv file. The file is archived so others can view it as well. Users can then search the file for text matches and the value from the first column can then be saved to a list.
11 =head1 AUTHOR
13 =cut
16 package SGN::Controller::DocumentBrowser;
18 use Moose;
19 use URI::FromHash 'uri';
21 BEGIN { extends 'Catalyst::Controller'; }
24 sub document_browser :Path('/tools/documents/') :Args(0) {
25 my $self = shift;
26 my $c = shift;
27 my $bcs_schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado');
29 my $user = $c->user();
30 if (!$user) {
31 $c->res->redirect( uri( path => '/solpeople/login.pl', query => { goto_url => $c->req->uri->path_query } ) );
32 return;
35 my @file_array;
36 my %file_info;
37 my $q = "SELECT file_id, m.create_date, p.sp_person_id, p.username, basename, dirname, filetype FROM metadata.md_files JOIN metadata.md_metadata as m using(metadata_id) JOIN sgn_people.sp_person as p ON (p.sp_person_id=m.create_person_id) WHERE filetype='document_browser' and m.obsolete = 0 ORDER BY file_id ASC";
38 my $h = $bcs_schema->storage()->dbh()->prepare($q);
39 $h->execute();
41 while (my ($file_id, $create_date, $person_id, $username, $basename, $dirname, $filetype) = $h->fetchrow_array()) {
42 $file_info{$file_id} = [$file_id, $create_date, $person_id, $username, $basename, $dirname, $filetype];
44 foreach (keys %file_info){
45 push @file_array, $file_info{$_};
48 $c->stash->{files} = \@file_array;
49 $c->stash->{template} = '/tools/document_browser.mas';