1 package SGN
::Controller
::Phenotypes
;
5 SGN::Controller::Phenotypes - Catalyst controller for pages dealing with
6 phenotypes submission and associating them with project, experiments, and stock accessions.
11 use namespace
::autoclean
;
12 use YAML
::Any qw
/LoadFile/;
14 use URI
::FromHash
'uri';
16 use File
::Temp qw
/ tempfile /;
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';
29 isa
=> 'DBIx::Class::Schema',
33 shift->_app->dbic_schema( 'Bio::Chado::Schema', 'sgn_chado' )
36 has
'default_page_size' => (
43 =head2 submission_guidelines
45 Public path: /phenotype/submission_guide
47 Display the phenotype submission guidelines page
51 sub submission_guidelines
:Path
('/phenotype/submission_guide') Args
(0) {
53 $c->stash(template
=> '/phenotypes/submission_guide.mas');
57 sub delete_uploaded_phenotype_files
: Path
('/breeders/phenotyping/delete/') Args
(1) {
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 my $h = $dbh->prepare("
71 DROP TABLE IF EXISTS temp;
72 CREATE TEMP TABLE temp AS
73 SELECT nd_experiment_id, nd_experiment_md_files_id, phenotype_id FROM metadata.md_files JOIN phenome.nd_experiment_md_files USING(file_id) JOIN nd_experiment_phenotype USING (nd_experiment_id) WHERE file_id=?;
74 DELETE FROM phenome.nd_experiment_md_files WHERE nd_experiment_md_files_id IN (SELECT nd_experiment_md_files_id FROM temp);
75 DELETE FROM nd_experiment where nd_experiment_id IN (SELECT nd_experiment_id FROM temp);
76 DELETE FROM phenotype where phenotype_id IN (SELECT phenotype_id FROM temp);
78 my $h2 = $dbh->prepare("UPDATE metadata.md_metadata SET obsolete = 1 where metadata_id IN (SELECT metadata_id from metadata.md_files where file_id=?);");
79 $h->execute($decoded);
80 $h2->execute($decoded);
81 print STDERR
"Phenotype file successfully made obsolete (AKA deleted).\n";
82 $c->response->redirect('/breeders/phenotyping');