clean
[sgn.git] / lib / SGN / Controller / Phenotypes.pm
blob440fd660ccdb0aad3e53c71c7bd767e891a824ae
1 package SGN::Controller::Phenotypes;
3 =head1 NAME
5 SGN::Controller::Phenotypes - Catalyst controller for pages dealing with
6 phenotypes submission and associating them with project, experiments, and stock accessions.
8 =cut
10 use Moose;
11 use namespace::autoclean;
12 use YAML::Any qw/LoadFile/;
14 use URI::FromHash 'uri';
15 use List::Compare;
16 use File::Temp qw / tempfile /;
17 use File::Slurp;
18 use JSON::Any;
20 use CXGN::Chado::Stock;
21 use SGN::View::Stock qw/stock_link stock_organisms stock_types/;
24 BEGIN { extends 'Catalyst::Controller' }
25 with 'Catalyst::Component::ApplicationAttribute';
27 has 'schema' => (
28 is => 'rw',
29 isa => 'DBIx::Class::Schema',
30 lazy_build => 1,
32 sub _build_schema {
33 shift->_app->dbic_schema( 'Bio::Chado::Schema', 'sgn_chado' )
36 has 'default_page_size' => (
37 is => 'ro',
38 default => 20,
41 =head1 PUBLIC ACTIONS
43 =head2 submission_guidelines
45 Public path: /phenotype/submission_guide
47 Display the phenotype submission guidelines page
49 =cut
51 sub submission_guidelines :Path('/phenotype/submission_guide') Args(0) {
52 my ($self, $c) = @_;
53 $c->stash(template => '/phenotypes/submission_guide.mas');
57 sub delete_uploaded_phenotype_files : Path('/breeders/phenotyping/delete/') Args(1) {
58 my $self =shift;
59 my $c = shift;
60 my $json = new JSON;
61 my $file_id = shift;
62 my $decoded;
63 if ($file_id){
64 $decoded = $json->allow_nonref->utf8->decode($file_id);
66 #print STDERR Dumper($file_id);
67 print "File ID: $file_id\n";
68 my $dbh = $c->dbc->dbh();
69 my $h = $dbh->prepare("delete from metadata.md_files where file_id=?;");
70 $h->execute($decoded);
71 print STDERR "Layout deleted successfully.\n";
72 $c->response->redirect('/breeders/phenotyping');
76 return 1;