2 =head1 SGN::Controller::AJAX::HTMLSelect - a resource to dynamically obtain html selects for a number of widely used data types
8 get_breeding_program_select()
16 Lukas Mueller <lam87@cornell.edu>
20 package SGN
::Controller
::AJAX
::HTMLSelect
;
25 use CXGN
::BreedersToolbox
::Projects
;
26 use CXGN
::Page
::FormattingHelpers qw
| simple_selectbox_html simple_checkbox_html
|;
27 use Scalar
::Util qw
| looks_like_number
|;
31 use CXGN
::Trial
::Folder
;
32 use SGN
::Model
::Cvterm
;
33 use CXGN
::Chado
::Stock
;
34 use CXGN
::Stock
::Search
;
35 use CXGN
::Stock
::Seedlot
;
40 use URI
::Encode
qw(uri_encode uri_decode);
41 use Array
::Utils
qw(:all);
42 use CXGN
::Genotype
::GenotypingProject
;
44 BEGIN { extends
'Catalyst::Controller::REST' };
47 default => 'application/json',
49 map => { 'application/json' => 'JSON' },
53 sub get_location_select
: Path
('/ajax/html/select/locations') Args
(0) {
57 my $id = $c->req->param("id") || "location_select";
58 my $name = $c->req->param("name") || "location_select";
59 my $empty = $c->req->param("empty") || "";
60 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
62 my $locations = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id) } )->get_all_locations();
64 if ($empty) { unshift @
$locations, [ "", "Select Location" ] }
66 my $default = $c->req->param("default") || @
$locations[0]->[0];
68 my $html = simple_selectbox_html
(
71 choices
=> $locations,
74 $c->stash->{rest
} = { select => $html };
77 sub get_breeding_program_select
: Path
('/ajax/html/select/breeding_programs') Args
(0) {
81 my $id = $c->req->param("id") || "breeding_program_select";
82 my $name = $c->req->param("name") || "breeding_program_select";
83 my $empty = $c->req->param("empty") || "";
84 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
86 my $breeding_programs = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id) } )->get_breeding_programs();
88 my $default = $c->req->param("default") || @
$breeding_programs[0]->[0];
89 if ($empty) { unshift @
$breeding_programs, [ "", "Please select a program" ]; }
91 my $html = simple_selectbox_html
(
94 choices
=> $breeding_programs,
95 # selected => $default
97 $c->stash->{rest
} = { select => $html };
100 sub get_year_select
: Path
('/ajax/html/select/years') Args
(0) {
104 my $id = $c->req->param("id") || "year_select";
105 my $name = $c->req->param("name") || "year_select";
106 my $empty = $c->req->param("empty") || "";
107 my $auto_generate = $c->req->param("auto_generate") || "";
108 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
111 if ($auto_generate) {
112 my $next_year = 1901 + (localtime)[5];
113 my $oldest_year = $next_year - 50;
114 @years = sort { $b <=> $a } ($oldest_year..$next_year);
117 @years = sort { $b <=> $a } CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id) } )->get_all_years();
120 my $default = $c->req->param("default") || $years[1];
122 my $html = simple_selectbox_html
(
128 $c->stash->{rest
} = { select => $html };
131 sub get_trial_folder_select
: Path
('/ajax/html/select/folders') Args
(0) {
135 my $breeding_program_id = $c->req->param("breeding_program_id");
136 my $folder_for_trials = 1 ?
$c->req->param("folder_for_trials") eq 'true' : 0;
137 my $folder_for_crosses = 1 ?
$c->req->param("folder_for_crosses") eq 'true' : 0;
138 my $folder_for_genotyping_trials = 1 ?
$c->req->param("folder_for_genotyping_trials") eq 'true' : 0;
139 my $folder_for_genotyping_projects = 1 ?
$c->req->param("folder_for_genotyping_projects") eq 'true' : 0;
140 my $folder_for_tracking_activities = 1 ?
$c->req->param("folder_for_tracking_activities") eq 'true' : 0;
142 my $id = $c->req->param("id") || "folder_select";
143 my $name = $c->req->param("name") || "folder_select";
144 my $empty = $c->req->param("empty") || ""; # set if an empty selection should be present
146 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
148 my @folders = CXGN
::Trial
::Folder
->list({
149 bcs_schema
=> $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id),
150 breeding_program_id
=> $breeding_program_id,
151 folder_for_trials
=> $folder_for_trials,
152 folder_for_crosses
=> $folder_for_crosses,
153 folder_for_genotyping_trials
=> $folder_for_genotyping_trials,
154 folder_for_genotyping_projects
=> $folder_for_genotyping_projects,
155 folder_for_tracking_activities
=> $folder_for_tracking_activities
158 if (scalar(@folders)>0){
159 @folders = sort { $a->[1] cmp $b->[1] } @folders;
163 unshift @folders, [ 0, "None" ];
165 # print STDERR "FOLDERS =".Dumper(\@folders)."\n";
167 my $html = simple_selectbox_html
(
170 choices
=> \
@folders,
172 $c->stash->{rest
} = { select => $html };
175 sub get_trial_type_select
: Path
('/ajax/html/select/trial_types') Args
(0) {
178 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
179 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
181 my $id = $c->req->param("id") || "trial_type_select";
182 my $name = $c->req->param("name") || "trial_type_select";
183 my $empty = $c->req->param("empty") || ""; # set if an empty selection should be present
185 my @all_types = CXGN
::Trial
::get_all_project_types
($c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id));
187 my $crossing_trial_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'crossing_trial', 'project_type')->cvterm_id();
188 my $pollinating_trial_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'pollinating_trial', 'project_type')->cvterm_id();
189 my $genotyping_trial_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'genotyping_trial', 'project_type')->cvterm_id();
193 foreach my $type(@all_types){
194 if (($type->[0] != $crossing_trial_cvterm_id) && ($type->[0] != $pollinating_trial_cvterm_id) && ($type->[0] != $genotyping_trial_cvterm_id)){
199 # sort types alphabetically, case insensitive
201 #print STDERR "types before sort: ".Dumper(\@types);
203 @types = sort { uc($a->[1]) cmp uc($b->[1]) } @types;
205 #print STDERR "types after sort: ".Dumper(\@types);
208 unshift @types, [ '', "None" ];
211 my $default = $c->req->param("default") || $types[0]->[0];
213 my $html = simple_selectbox_html
(
219 $c->stash->{rest
} = { select => $html };
222 sub get_treatments_select
: Path
('/ajax/html/select/treatments') Args
(0) {
225 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
226 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
227 my $trial_id = $c->req->param("trial_id");
229 my $id = $c->req->param("id") || "treatment_select";
230 my $name = $c->req->param("name") || "treatment_select";
231 my $empty = $c->req->param("empty") || ""; # set if an empty selection should be present
233 my $trial = CXGN
::Trial
->new({ bcs_schema
=> $schema, trial_id
=> $trial_id });
234 my $data = $trial->get_treatments();
237 unshift @
$data, [ 0, "None" ];
239 my $html = simple_selectbox_html
(
244 $c->stash->{rest
} = { select => $html };
247 sub get_projects_select
: Path
('/ajax/html/select/projects') Args
(0) {
250 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
251 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
252 my $p = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $schema } );
253 my $breeding_program_id = $c->req->param("breeding_program_id");
254 my $breeding_program_name = $c->req->param("breeding_program_name");
255 my $get_field_trials = $c->req->param("get_field_trials");
256 my $get_crossing_trials = $c->req->param("get_crossing_trials");
257 my $get_genotyping_trials = $c->req->param("get_genotyping_trials");
258 my $get_genotyping_projects = $c->req->param("get_genotyping_projects");
259 my $get_tracking_activities_projects = $c->req->param("get_tracking_activities_projects");
260 my $include_analyses = $c->req->param("include_analyses");
261 my $excluded_plates_in_project_id = $c->req->param("excluded_plates_in_project_id");
263 my @genotyping_plate_ids;
264 if ($excluded_plates_in_project_id) {
265 my $plate_info = CXGN
::Genotype
::GenotypingProject
->new({
266 bcs_schema
=> $schema,
267 project_id
=> $excluded_plates_in_project_id
269 my $genotyping_plates = $plate_info->get_genotyping_plate_ids();
270 @genotyping_plate_ids = @
$genotyping_plates;
274 if (!$breeding_program_id && !$breeding_program_name) {
275 $projects = $p->get_breeding_programs();
276 } elsif ($breeding_program_id){
277 push @
$projects, [$breeding_program_id];
279 push @
$projects, [$schema->resultset('Project::Project')->find({name
=> $breeding_program_name})->project_id()];
282 my $id = $c->req->param("id") || "html_trial_select";
283 my $name = $c->req->param("name") || "html_trial_select";
284 my $size = $c->req->param("size");
285 my $empty = $c->req->param("empty") || "";
286 my $multiple = $c->req->param("multiple") || 0;
287 my $live_search = $c->req->param("live_search") || 0;
290 foreach my $project (@
$projects) {
291 my ($field_trials, $cross_trials, $genotyping_trials, $genotyping_projects, $field_management_factor_projects, $drone_run_projects, $drone_run_band_projects, $analyses_projects, $sampling_trial_projects, $transformation_projects, $tracking_activities_projects) = $p->get_trials_by_breeding_program($project->[0]);
292 if ($get_field_trials){
293 if ($field_trials && scalar(@
$field_trials)>0){
294 my @trials = sort { $a->[1] cmp $b->[1] } @
$field_trials;
295 push @projects, @trials;
298 if ($get_crossing_trials){
299 if ($cross_trials && scalar(@
$cross_trials)>0){
300 my @trials = sort { $a->[1] cmp $b->[1] } @
$cross_trials;
301 push @projects, @trials;
304 if ($get_genotyping_trials){
306 if ($genotyping_trials && scalar(@
$genotyping_trials)>0){
307 my @trials = sort { $a->[1] cmp $b->[1] } @
$genotyping_trials;
308 push @all_projects, @trials;
310 if ($excluded_plates_in_project_id && scalar(@genotyping_plate_ids)>0) {
311 print STDERR
"SUBSTRACTING..."."\n";
312 foreach my $project (@all_projects) {
313 next if ($project->[0] ~~ @genotyping_plate_ids);
314 push @projects, $project;
317 @projects = @all_projects;
320 if ($include_analyses) {
321 if ($analyses_projects && scalar(@
$analyses_projects)>0){
322 my @analyses = sort { $a->[1] cmp $b->[1] } @
$analyses_projects;
323 push @projects, @analyses;
326 if ($get_genotyping_projects){
327 if ($genotyping_projects && scalar(@
$genotyping_projects)>0){
328 my @g_projects = sort { $a->[1] cmp $b->[1] } @
$genotyping_projects;
329 push @projects, @g_projects;
332 if ($get_tracking_activities_projects){
333 if ($tracking_activities_projects && scalar(@
$tracking_activities_projects)>0){
334 my @g_projects = sort { $a->[1] cmp $b->[1] } @
$tracking_activities_projects;
335 push @projects, @g_projects;
340 # if ($empty) { unshift @projects, [ "", "Please select a trial" ]; }
342 if ($get_crossing_trials) {
343 unshift @projects, [ "", "Please select a crossing experiment" ];
344 } elsif ($get_genotyping_projects) {
345 unshift @projects, [ "", "Please select a genotyping project" ];
347 unshift @projects, [ "", "Please select a trial" ];
350 # print STDERR "PROJECTS =".Dumper(\@projects)."\n";
351 my $html = simple_selectbox_html
(
352 multiple
=> $multiple,
353 live_search
=> $live_search,
357 choices
=> \
@projects,
359 $c->stash->{rest
} = { select => $html };
362 sub get_trials_select
: Path
('/ajax/html/select/trials') Args
(0) {
365 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
366 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
367 my $p = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $schema } );
368 my $breeding_program_id = $c->req->param("breeding_program_id");
369 my $breeding_program_name = $c->req->param("breeding_program_name");
370 my $trial_name_values = $c->req->param("trial_name_values") || 0;
373 if (!$breeding_program_id && !$breeding_program_name) {
374 $projects = $p->get_breeding_programs();
375 } elsif ($breeding_program_id){
376 push @
$projects, [$breeding_program_id];
378 push @
$projects, [$schema->resultset('Project::Project')->find({name
=> $breeding_program_name})->project_id()];
381 my $id = $c->req->param("id") || "html_trial_select";
382 my $name = $c->req->param("name") || "html_trial_select";
383 my $size = $c->req->param("size");
384 my $empty = $c->req->param("empty") || "";
385 my $multiple = $c->req->param("multiple") || 0;
386 my $live_search = $c->req->param("live_search") || 0;
387 my $include_location_year = $c->req->param("include_location_year");
388 my $include_lists = $c->req->param("include_lists") || 0;
391 if ($include_lists) { push @trials, [ "", "----INDIVIDUAL TRIALS----" ]; }
392 foreach my $project (@
$projects) {
393 my ($field_trials, $cross_trials, $genotyping_trials) = $p->get_trials_by_breeding_program($project->[0]);
394 foreach (@
$field_trials) {
395 my $trial_id = $_->[0];
396 my $trial_name = $_->[1];
397 if ($include_location_year) {
398 my $trial = CXGN
::Trial
->new({bcs_schema
=> $schema, trial_id
=> $trial_id });
399 my $location_array = $trial->get_location();
400 my $year = $trial->get_year();
401 $trial_name .= " (".$location_array->[1]." $year)";
403 push @trials, [$trial_id, $trial_name];
406 if ($trial_name_values) {
409 push @trials_redef, [$_->[1], $_->[1]];
411 @trials = @trials_redef;
413 @trials = sort { $a->[1] cmp $b->[1] } @trials;
415 if ($include_lists) {
416 my $lists = CXGN
::List
::available_lists
($c->dbc->dbh(), $c->user()->get_sp_person_id());
417 my $public_lists = CXGN
::List
::available_public_lists
($c->dbc->dbh());
418 my $lt = CXGN
::List
::Transform
->new();
420 push @trials, ["", "----YOUR LISTS OF TRIALS----"];
421 foreach my $item (@
$lists) {
422 if ( @
$item[5] eq "trials" ) {
423 my $list = CXGN
::List
->new({ dbh
=>$c->dbc->dbh(), list_id
=> @
$item[0] });
424 my $list_elements = $list->retrieve_elements_with_ids(@
$item[0]);
425 my @list_element_names = map { $_->[1] } @
$list_elements;
426 my $transform = $lt->transform($schema, 'projects_2_project_ids', \
@list_element_names);
427 my @trial_ids = @
{$transform->{transform
}};
428 push @trials, [join(',', @trial_ids), @
$item[1] . ' (' . @
$item[3] . ' trials)'];
432 push @trials, ["", "----PUBLIC LISTS OF TRIALS----"];
433 foreach my $item (@
$public_lists) {
434 if ( @
$item[5] eq "trials" ) {
435 my $list = CXGN
::List
->new({ dbh
=>$c->dbc->dbh(), list_id
=> @
$item[0] });
436 my $list_elements = $list->retrieve_elements_with_ids(@
$item[0]);
437 my @list_element_names = map { $_->[1] } @
$list_elements;
438 my $transform = $lt->transform($schema, 'projects_2_project_ids', \
@list_element_names);
439 my @trial_ids = @
{$transform->{transform
}};
440 push @trials, [join(',', @trial_ids), @
$item[1] . ' (' . @
$item[3] . ' trials)'];
445 if ($empty) { unshift @trials, [ "", "Please select a trial" ]; }
447 my $html = simple_selectbox_html
(
448 multiple
=> $multiple,
449 live_search
=> $live_search,
455 $c->stash->{rest
} = { select => $html };
458 sub get_genotyping_trials_select
: Path
('/ajax/html/select/genotyping_trials') Args
(0) {
461 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
462 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
463 my $p = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $schema } );
464 my $breeding_program_id = $c->req->param("breeding_program_id");
465 my $breeding_program_name = $c->req->param("breeding_program_name");
468 if (!$breeding_program_id && !$breeding_program_name) {
469 $projects = $p->get_breeding_programs();
470 } elsif ($breeding_program_id){
471 push @
$projects, [$breeding_program_id];
473 push @
$projects, [$schema->resultset('Project::Project')->find({name
=> $breeding_program_name})->project_id()];
476 my $id = $c->req->param("id") || "html_trial_select";
477 my $name = $c->req->param("name") || "html_trial_select";
478 my $size = $c->req->param("size");
479 my $empty = $c->req->param("empty") || "";
480 my $multiple = $c->req->param("multiple") || 0;
481 my $live_search = $c->req->param("live_search") || 0;
484 foreach my $project (@
$projects) {
485 my ($field_trials, $cross_trials, $genotyping_trials) = $p->get_trials_by_breeding_program($project->[0]);
486 foreach (@
$genotyping_trials) {
490 @trials = sort { $a->[1] cmp $b->[1] } @trials;
492 if ($empty) { unshift @trials, [ "", "Please select a trial" ]; }
494 my $html = simple_selectbox_html
(
495 multiple
=> $multiple,
496 live_search
=> $live_search,
502 $c->stash->{rest
} = { select => $html };
505 sub get_label_data_source_types_select
: Path
('/ajax/html/select/label_data_source_types') Args
(0) {
509 my $id = $c->req->param("id") || "label_data_source_types_select";
510 my $name = $c->req->param("name") || "label_data_source_types_select";
512 ["any", "Any Data Type..."],
513 ["field_trials", "Field Trials"],
514 ["genotyping_plates", "Genotyping Plates"],
515 ["crossing_experiments", "Crossing Experiments"],
517 ["public_lists", "Public Lists"]
520 my $html = simple_selectbox_html
(
527 $c->stash->{rest
} = { select => $html };
530 sub get_label_data_source_select
: Path
('/ajax/html/select/label_data_sources') Args
(0) {
534 my $id = $c->req->param("id") || "label_data_sources_select";
535 my $name = $c->req->param("name") || "label_data_sources_select";
536 my $empty = $c->req->param("empty") || "";
537 my $live_search = $c->req->param("live_search") ?
'data-live-search="true"' : '';
538 my $default = $c->req->param("default") || 0;
539 my $type = $c->req->param("type");
541 my $user_id = $c->user()->get_object()->get_sp_person_id();
543 # my $all_lists = CXGN::List::all_types($c->dbc->dbh());
545 my $lists = CXGN
::List
::available_lists
($c->dbc->dbh(), $user_id );
546 my $public_lists = CXGN
::List
::available_public_lists
($c->dbc->dbh() );
548 my $p = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $c->dbic_schema("Bio::Chado::Schema", undef, $user_id) } );
549 my $projects = $p->get_breeding_programs();
551 my (@field_trials, @crossing_experiments, @genotyping_trials) = [];
552 foreach my $project (@
$projects) {
553 my ($field_trials, $crossing_experiments, $genotyping_trials) = $p->get_trials_by_breeding_program($project->[0]);
554 foreach (@
$field_trials) {
555 push @field_trials, $_;
557 foreach (@
$crossing_experiments) {
558 push @crossing_experiments, $_;
560 foreach (@
$genotyping_trials) {
561 push @genotyping_trials, $_;
566 if ( !defined $type || $type eq 'any' || $type eq 'field_trials' ) {
567 push @choices, '__Field Trials';
568 @field_trials = sort { $a->[1] cmp $b->[1] } @field_trials;
569 foreach my $trial (@field_trials) {
570 push @choices, $trial;
573 if ( !defined $type || $type eq 'any' || $type eq 'genotyping_plates' ) {
574 push @choices, '__Genotyping Plates';
575 @genotyping_trials = sort { $a->[1] cmp $b->[1] } @genotyping_trials;
576 foreach my $trial (@genotyping_trials) {
577 push @choices, $trial;
580 if ( !defined $type || $type eq 'any' || $type eq 'crossing_experiments' ) {
581 push @choices, '__Crossing Experiments';
582 @crossing_experiments = sort { $a->[1] cmp $b->[1] } @crossing_experiments;
583 foreach my $crossing_experiment (@crossing_experiments) {
584 push @choices, $crossing_experiment;
587 if ( !defined $type || $type eq 'any' || $type eq 'lists' ) {
588 push @choices, '__Lists';
589 foreach my $item (@
$lists) {
590 push @choices, [@
$item[0], @
$item[1]];
593 if ( !defined $type || $type eq 'any' || $type eq 'public_lists' ) {
594 push @choices, '__Public Lists';
595 foreach my $item (@
$public_lists) {
596 push @choices, [@
$item[0], @
$item[1]];
600 # print STDERR "Choices are:\n".Dumper(@choices);
602 if ($default) { unshift @choices, [ '', $default ]; }
604 my $html = simple_selectbox_html
(
607 choices
=> \
@choices,
608 params
=> $live_search,
609 selected_params
=> 'hidden'
612 $c->stash->{rest
} = { select => $html };
614 # sub get_trials_select : Path('/ajax/html/select/trials') Args(0) {
618 # my $id = $c->req->param("id") || "label_data_sources_select";
619 # my $name = $c->req->param("name") || "label_data_sources_select";
620 # my $empty = $c->req->param("empty") || "";
621 # my $live_search = $c->req->param("live_search") ? 'data-live-search="true"' : '';
622 # my $default = $c->req->param("default") || 0;
624 # my $lists = CXGN::List::available_lists($c->dbc->dbh(), $c->user(), 'plots');
625 # my $public_lists = CXGN::List::available_public_lists($c->dbc->dbh(), 'plots');
627 # my $projects = CXGN::BreedersToolbox::Projects->new( { schema => $c->dbic_schema("Bio::Chado::Schema") } )->get_breeding_programs();
629 # foreach my $project (@$projects) {
630 # my ($field_trials, $cross_trials, $genotyping_trials) = $projects->get_trials_by_breeding_program($project->[0]);
631 # foreach (@$field_trials) {
635 # @trials = sort { $a->[1] cmp $b->[1] } @trials;
638 # push @choices, '__Your Plot Lists';
639 # foreach my $item (@$lists) {
640 # push @choices, $item;
642 # push @choices, '__Public Plot Lists';
643 # foreach my $item (@$public_lists) {
644 # push @choices, $item;
646 # push @choices, '__Trials';
647 # foreach my $trial (@trials) {
648 # push @choices, $trial;
651 # print STDERR "Choices are:\n".Dumper(@choices);
653 # if ($default) { unshift @trials, [ '', $default ]; }
655 # my $html = simple_selectbox_html(
658 # choices => \@choices,
659 # params => $live_search
662 # $c->stash->{rest} = { select => $html };
665 sub get_stocks_select
: Path
('/ajax/html/select/stocks') Args
(0) {
668 my $params = _clean_inputs
($c->req->params);
669 my $names_as_select = $params->{names_as_select
}->[0] || 0;
671 my %stockprops_values;
672 if ($params->{organization_list
} && scalar(@
{$params->{organization_list
}})>0){
673 $stockprops_values{'organization'} = $params->{organization_list
};
675 if ($params->{pui_list
} && scalar(@
{$params->{pui_list
}})>0){
676 $stockprops_values{'PUI'} = $params->{pui_list
};
678 if ($params->{accession_number_list
} && scalar(@
{$params->{accession_number_list
}})>0){
679 $stockprops_values{'accession number'} = $params->{accession_number_list
};
682 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
684 my $stock_search = CXGN
::Stock
::Search
->new({
685 bcs_schema
=>$c->dbic_schema("Bio::Chado::Schema", "sgn_chado", $sp_person_id),
686 people_schema
=>$c->dbic_schema("CXGN::People::Schema", undef, $sp_person_id),
687 phenome_schema
=>$c->dbic_schema("CXGN::Phenome::Schema", undef, $sp_person_id),
688 match_type
=>$params->{match_type
}->[0],
689 match_name
=>$params->{match_type
}->[0],
690 uniquename_list
=>$params->{uniquename_list
},
691 genus_list
=>$params->{genus_list
},
692 species_list
=>$params->{species_list
},
693 stock_id_list
=>$params->{stock_id_list
},
694 organism_id
=>$params->{organism_id
}->[0],
695 stock_type_name
=>$params->{stock_type_name
}->[0],
696 stock_type_id
=>$params->{stock_type_id
}->[0],
697 owner_first_name
=>$params->{owner_first_name
}->[0],
698 owner_last_name
=>$params->{owner_last_name
}->[0],
699 trait_cvterm_name_list
=>$params->{trait_cvterm_name_list
},
700 minimum_phenotype_value
=>$params->{minimum_phenotype_value
}->[0],
701 maximum_phenotype_value
=>$params->{maximum_phenotype_value
}->[0],
702 trial_name_list
=>$params->{trial_name_list
},
703 trial_id_list
=>$params->{trial_id_list
},
704 breeding_program_id_list
=>$params->{breeding_program_id_list
},
705 location_name_list
=>$params->{location_name_list
},
706 year_list
=>$params->{year_list
},
707 stockprops_values
=>\
%stockprops_values,
708 limit
=>$params->{limit
}->[0],
709 offset
=>$params->{offset
}->[0],
713 my ($result, $records_total) = $stock_search->search();
714 #print STDERR Dumper $result;
715 my $id = $c->req->param("id") || "html_trial_select";
716 my $name = $c->req->param("name") || "html_trial_select";
717 my $multiple = defined($c->req->param("multiple")) ?
$c->req->param("multiple") : 1;
718 my $size = $c->req->param("size");
719 my $empty = $c->req->param("empty") || "";
720 my $data_related = $c->req->param("data-related") || "";
722 foreach my $r (@
$result) {
723 if ($names_as_select) {
724 push @stocks, [ $r->{uniquename
}, $r->{uniquename
} ];
726 push @stocks, [ $r->{stock_id
}, $r->{uniquename
} ];
729 @stocks = sort { $a->[1] cmp $b->[1] } @stocks;
731 if ($empty) { unshift @stocks, [ "", "Please select a stock" ]; }
733 my $html = simple_selectbox_html
(
734 multiple
=> $multiple,
739 data_related
=> $data_related
741 $c->stash->{rest
} = { select => $html };
744 sub get_seedlots_select
: Path
('/ajax/html/select/seedlots') Args
(0) {
747 my $accessions = $c->req->param('seedlot_content_accession_name') ?
[$c->req->param('seedlot_content_accession_name')] : [];
748 my $crosses = $c->req->param('seedlot_content_cross_name') ?
[$c->req->param('seedlot_content_cross_name')] : [];
749 my $seedlot_id = $c->req->param('seedlot_id') ?
$c->req->param('seedlot_id') : '';
750 my $search_breeding_program_name = $c->req->param('seedlot_breeding_program_name') ?
$c->req->param('seedlot_breeding_program_name') : '';
751 # my $search_location = $c->req->param('seedlot_location') ? $c->req->param('seedlot_location') : '';
752 # my $search_amount = $c->req->param('seedlot_amount') ? $c->req->param('seedlot_amount') : '';
753 # my $search_weight = $c->req->param('seedlot_weight') ? $c->req->param('seedlot_weight') : '';
754 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
756 my $exclude_discarded = $c->req->param('exclude_discarded') ?
$c->req->param('exclude_discarded') : '';
757 my $exclude_self = $c->req->param('exclude_self') ?
$c->req->param('exclude_self') : '';
758 my ($list, $records_total) = CXGN
::Stock
::Seedlot
->list_seedlots(
759 $c->dbic_schema("Bio::Chado::Schema", "sgn_chado", $sp_person_id),
760 $c->dbic_schema("CXGN::People::Schema", undef, $sp_person_id),
761 $c->dbic_schema("CXGN::Phenome::Schema", undef, $sp_person_id),
766 $search_breeding_program_name,
775 foreach my $sl (@
$list) {
777 breeding_program_id
=> $sl->{breeding_program_id
},
778 breeding_program_name
=> $sl->{breeding_program_name
},
779 seedlot_stock_id
=> $sl->{seedlot_stock_id
},
780 seedlot_stock_uniquename
=> $sl->{seedlot_stock_uniquename
},
781 location
=> $sl->{location
},
782 location_id
=> $sl->{location_id
},
783 count
=> $sl->{current_count
}
786 #print STDERR Dumper \@seedlots;
787 my $id = $c->req->param("id") || "html_trial_select";
788 my $name = $c->req->param("name") || "html_trial_select";
789 my $multiple = defined($c->req->param("multiple")) ?
$c->req->param("multiple") : 1;
790 my $size = $c->req->param("size");
791 my $empty = $c->req->param("empty") || "";
792 my $data_related = $c->req->param("data-related") || "";
794 foreach my $r (@seedlots) {
795 if ($exclude_discarded == 1) {
796 if ($exclude_self == 1) {
797 if (($r->{count
} ne 'DISCARDED') && ($seedlot_id != $r->{seedlot_stock_id
})) {
798 push @stocks, [ $r->{seedlot_stock_id
}, $r->{seedlot_stock_uniquename
} ];
801 if ($r->{count
} ne 'DISCARDED') {
802 if ($r->{seedlot_stock_id
} == $seedlot_id) {
803 push @stocks, [ $r->{seedlot_stock_id
}, 'unspecified'];
805 push @stocks, [ $r->{seedlot_stock_id
}, $r->{seedlot_stock_uniquename
} ];
810 push @stocks, [ $r->{seedlot_stock_id
}, $r->{seedlot_stock_uniquename
} ];
814 @stocks = sort { $a->[1] cmp $b->[1] } @stocks;
816 if ($empty) { unshift @stocks, [ "", "Please select a stock" ]; }
818 my $html = simple_selectbox_html
(
819 multiple
=> $multiple,
824 data_related
=> $data_related
826 $c->stash->{rest
} = { select => $html };
829 sub get_ontologies
: Path
('/ajax/html/select/trait_variable_ontologies') Args
(0) {
832 my $cvprop_type_names = $c->req->param("cvprop_type_name") ? decode_json
$c->req->param("cvprop_type_name") : ['trait_ontology', 'method_ontology', 'unit_ontology'];
833 my $use_full_trait_name = $c->req->param("use_full_trait_name") || 0;
835 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
837 my $observation_variables = CXGN
::BrAPI
::v1
::ObservationVariables
->new({
838 bcs_schema
=> $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id),
839 metadata_schema
=> $c->dbic_schema("CXGN::Metadata::Schema", undef, $sp_person_id),
840 phenome_schema
=>$c->dbic_schema("CXGN::Phenome::Schema", undef, $sp_person_id),
841 people_schema
=> $c->dbic_schema("CXGN::People::Schema", undef, $sp_person_id),
842 page_size
=> 1000000,
847 my $result = $observation_variables->observation_variable_ontologies({cvprop_type_names
=> $cvprop_type_names});
848 #print STDERR Dumper $result;
851 foreach my $o (@
{$result->{result
}->{data
}}) {
852 if ($use_full_trait_name) {
853 push @ontos, [$o->{description
}."|".$o->{ontologyName
}.":".$o->{ontologyDbxrefAccession
}, $o->{description
}."|".$o->{ontologyName
}.":".$o->{ontologyDbxrefAccession
} ];
855 push @ontos, [$o->{ontologyDbId
}, $o->{ontologyName
}." (".$o->{description
}.")" ];
859 my $id = $c->req->param("id") || "html_trial_select";
860 my $name = $c->req->param("name") || "html_trial_select";
861 my $data_related = $c->req->param("data-related") || "";
863 @ontos = sort { $a->[1] cmp $b->[1] } @ontos;
865 my $html = simple_checkbox_html
(
869 data_related
=> $data_related
871 $c->stash->{rest
} = { select => $html };
874 sub get_high_dimensional_phenotypes_protocols
: Path
('/ajax/html/select/high_dimensional_phenotypes_protocols') Args
(0) {
877 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
878 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
879 my $checkbox_name = $c->req->param('checkbox_name');
880 my $protocol_type = $c->req->param('high_dimensional_phenotype_protocol_type');
882 my $protocol_type_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, $protocol_type, 'protocol_type')->cvterm_id();
883 my $protocolprop_type_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'high_dimensional_phenotype_protocol_properties', 'protocol_property')->cvterm_id();
885 my $q = "SELECT nd_protocol.nd_protocol_id, nd_protocol.name, nd_protocol.description, nd_protocol.create_date, nd_protocolprop.value
887 JOIN nd_protocolprop USING(nd_protocol_id)
888 WHERE nd_protocol.type_id=$protocol_type_cvterm_id AND nd_protocolprop.type_id=$protocolprop_type_cvterm_id;";
889 my $h = $schema->storage->dbh()->prepare($q);
892 my $html = '<table class="table table-bordered table-hover" id="html-select-highdimprotocol-table"><thead><tr><th>Select</th><th>Protocol Name</th><th>Description</th><th>Create Date</th><th>Properties</th></tr></thead><tbody>';
894 while (my ($nd_protocol_id, $name, $description, $create_date, $props_json) = $h->fetchrow_array()) {
895 my $props = decode_json
$props_json;
896 $html .= '<tr><td><input type="checkbox" name="'.$checkbox_name.'" value="'.$nd_protocol_id.'"></td><td>'.$name.'</td><td>'.$description.'</td><td>'.$create_date.'</td><td>';
897 while (my($k,$v) = each %$props) {
898 if ($k ne 'header_column_details' && $k ne 'header_column_names') {
899 $html .= "$k: $v<br/>";
902 $html .= '</td></tr>';
904 $html .= "</tbody></table>";
906 $html .= "<script>jQuery(document).ready(function() { jQuery('#html-select-highdimprotocol-table').DataTable({ }); } );</script>";
908 $c->stash->{rest
} = { select => $html };
911 sub get_analytics_protocols
: Path
('/ajax/html/select/analytics_protocols') Args
(0) {
914 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
915 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
916 my $checkbox_name = $c->req->param('checkbox_name');
917 my $protocol_type = $c->req->param('analytics_protocol_type');
919 my $protocol_type_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, $protocol_type, 'protocol_type')->cvterm_id();
920 my $protocolprop_type_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'analytics_protocol_properties', 'protocol_property')->cvterm_id();
922 my $q = "SELECT nd_protocol.nd_protocol_id, nd_protocol.name, nd_protocol.description, nd_protocol.create_date, nd_protocolprop.value
924 JOIN nd_protocolprop USING(nd_protocol_id)
925 WHERE nd_protocol.type_id=$protocol_type_cvterm_id AND nd_protocolprop.type_id=$protocolprop_type_cvterm_id;";
926 my $h = $schema->storage->dbh()->prepare($q);
929 my $html = '<table class="table table-bordered table-hover" id="html-select-analyticsprotocol-table"><thead><tr><th>Select</th><th>Analytics Name</th><th>Description</th><th>Create Date</th><th>Properties</th></tr></thead><tbody>';
931 while (my ($nd_protocol_id, $name, $description, $create_date, $props_json) = $h->fetchrow_array()) {
932 my $props = decode_json
$props_json;
933 $html .= '<tr><td><input type="checkbox" name="'.$checkbox_name.'" value="'.$nd_protocol_id.'"></td><td>'.$name.'</td><td>'.$description.'</td><td>'.$create_date.'</td><td>';
934 while (my($k,$v) = each %$props) {
935 $html .= "$k: $v<br/>";
937 $html .= '</td></tr>';
939 $html .= "</tbody></table>";
941 $html .= "<script>jQuery(document).ready(function() { jQuery('#html-select-analyticsprotocol-table').DataTable({ }); } );</script>";
943 $c->stash->{rest
} = { select => $html };
946 sub get_sequence_metadata_protocols
: Path
('/ajax/html/select/sequence_metadata_protocols') Args
(0) {
949 my $checkbox_name = $c->req->param('checkbox_name');
950 my $data_type_cvterm_id = $c->req->param('sequence_metadata_data_type_id');
951 my $include_query_link = $c->req->param('include_query_link');
953 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
954 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
956 my $protocol_type_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'sequence_metadata_protocol', 'protocol_type')->cvterm_id();
957 my $protocolprop_type_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'sequence_metadata_protocol_properties', 'protocol_property')->cvterm_id();
959 # Only select protocols that have a type of 'sequence_metadata_protocol' and its protocolprop of 'sequence_metadata_type' is the same as the provided $data_type
960 my $q = "SELECT nd_protocol.nd_protocol_id, nd_protocol.name, nd_protocol.description, nd_protocolprop.value
962 JOIN nd_protocolprop USING(nd_protocol_id)
963 WHERE nd_protocol.type_id=$protocol_type_cvterm_id AND nd_protocolprop.type_id=$protocolprop_type_cvterm_id
964 AND (nd_protocolprop.value->>'sequence_metadata_type_id')::integer = $data_type_cvterm_id;";
965 my $h = $schema->storage->dbh()->prepare($q);
968 my $html = '<table class="table table-bordered table-hover" id="html-select-sdmprotocol-table-' . $data_type_cvterm_id . '">';
969 my $select_th = defined $checkbox_name ?
"<th>Select</th>" : "";
970 $html .= '<thead><tr>' . $select_th . '<th>Protocol Name</th><th>Description</th><th>Properties</th></tr></thead>';
973 while (my ($nd_protocol_id, $name, $description, $props_json) = $h->fetchrow_array()) {
975 # Decode the json props
976 my $props = decode_json
$props_json;
978 # Add link to protocol name, if requested
979 if ( $include_query_link ) {
980 $name = "<a href='/search/sequence_metadata?nd_protocol_id=$nd_protocol_id&reference_genome=" . $props->{'reference_genome'} . "'>$name</a>";
983 # Build the row of the table
984 my $select_td = defined $checkbox_name ?
'<td><input type="checkbox" name="'.$checkbox_name.'" value="'.$nd_protocol_id.'"></td>' : '';
985 $html .= '<tr>' . $select_td . '<td>'.$name.'</td><td>'.$description.'</td><td>';
987 my $type = $props->{'sequence_metadata_type'};
988 $type =~ s/ / /;
989 $html .= "<strong>Data Type:</strong> " . $type . "<br />";
990 $html .= "<strong>Reference Genome:</strong> " . $props->{'reference_genome'} . "<br />";
991 $html .= "<strong>Score:</strong> " . $props->{'score_description'} . "<br />";
992 $html .= "<strong>Attributes:</strong><br />";
994 my $attributes = $props->{'attribute_descriptions'};
995 $html .= "<table class='table table-striped' style='min-width: 300px'>";
996 $html .= "<thead><tr><th>Key</th><th>Description</th></tr></thead>";
997 while (my($k,$v) = each %$attributes) {
998 $html .= "<tr><td>$k</td><td>$v</td></tr>";
1000 $html .= "</table>";
1002 my $links = $props->{'links'};
1003 if ( defined $links ) {
1004 $html .= "<strong>Links:</strong><br />";
1005 $html .= "<table class='table table-striped' style='min-width: 300px'>";
1006 $html .= "<thead><tr><th>Title</th><th>URL Template</th></tr></thead>";
1007 while (my($k,$v) = each %$links) {
1008 $html .= "<tr><td>$k</td><td>$v</td></tr>";
1011 $html .= "</table>";
1013 $html .= '</td></tr>';
1016 $html .= "</tbody></table>";
1018 $html .= "<script>jQuery(document).ready(function() { jQuery('#html-select-sdmprotocol-table-" . $data_type_cvterm_id . "').DataTable({ }); } );</script>";
1020 $c->stash->{rest
} = { select => $html };
1023 sub get_trained_nirs_models
: Path
('/ajax/html/select/trained_nirs_models') Args
(0) {
1026 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1027 my $schema = $c->dbic_schema("Bio::Chado::Schema", $sp_person_id);
1028 my $checkbox_name = $c->req->param('checkbox_name');
1030 my $nirs_model_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'waves_nirs_spectral_predictions', 'protocol_type')->cvterm_id();
1031 my $model_properties_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'analysis_model_properties', 'protocol_property')->cvterm_id();
1033 my $model_q = "SELECT nd_protocol.nd_protocol_id, nd_protocol.name, nd_protocol.description, model_type.value
1035 JOIN nd_protocolprop AS model_type ON(nd_protocol.nd_protocol_id=model_type.nd_protocol_id AND model_type.type_id=$model_properties_cvterm_id)
1036 WHERE nd_protocol.type_id=$nirs_model_cvterm_id;";
1037 my $model_h = $schema->storage->dbh()->prepare($model_q);
1038 $model_h->execute();
1040 my $html = '<table class="table table-bordered table-hover" id="html-select-nirsmodel-table"><thead><tr><th>Select</th><th>Model Name</th><th>Description</th><th>Format</th><th>Trait</th><th>Algorithm</th></tr></thead><tbody>';
1042 while (my ($nd_protocol_id, $name, $description, $model_type) = $model_h->fetchrow_array()) {
1043 my $model_type_hash = decode_json
$model_type;
1044 my $selected_trait_name = $model_type_hash->{trait_name
};
1045 my $preprocessing_boolean = $model_type_hash->{preprocessing_boolean
};
1046 my $niter = $model_type_hash->{niter
};
1047 my $algorithm = $model_type_hash->{algorithm
};
1048 my $tune = $model_type_hash->{tune
};
1049 my $random_forest_importance = $model_type_hash->{random_forest_importance
};
1050 my $cross_validation = $model_type_hash->{cross_validation
};
1051 my $format = $model_type_hash->{format
};
1053 $html .= '<tr><td><input type="checkbox" name="'.$checkbox_name.'" value="'.$nd_protocol_id.'"></td><td>'.$name.'</td><td>'.$description.'</td><td>'.$format.'</td><td>'.$selected_trait_name.'</td><td>'.$algorithm.'</td></tr>';
1055 $html .= "</tbody></table>";
1057 $html .= "<script>jQuery(document).ready(function() { jQuery('#html-select-nirsmodel-table').DataTable({ }); } );</script>";
1059 $c->stash->{rest
} = { select => $html };
1062 sub get_trained_keras_cnn_models
: Path
('/ajax/html/select/trained_keras_cnn_models') Args
(0) {
1065 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1066 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
1068 my $keras_cnn_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'trained_keras_cnn_model', 'protocol_type')->cvterm_id();
1069 my $model_properties_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'analysis_model_properties', 'protocol_property')->cvterm_id();
1071 my $model_q = "SELECT nd_protocol.nd_protocol_id, nd_protocol.name, nd_protocol.description, model_type.value
1073 JOIN nd_protocolprop AS model_type ON(nd_protocol.nd_protocol_id=model_type.nd_protocol_id AND model_type.type_id=$model_properties_cvterm_id)
1074 WHERE nd_protocol.type_id=$keras_cnn_cvterm_id;";
1075 my $model_h = $schema->storage->dbh()->prepare($model_q);
1076 $model_h->execute();
1077 my @keras_cnn_models;
1078 while (my ($nd_protocol_id, $name, $description, $model_type) = $model_h->fetchrow_array()) {
1079 my $model_type_hash = decode_json
$model_type;
1080 my $trait_id = $model_type_hash->{variable_id
};
1081 my $trained_trait_name = $model_type_hash->{variable_name
};
1082 my $aux_trait_ids = $model_type_hash->{aux_trait_ids
} ?
$model_type_hash->{aux_trait_ids
} : [];
1083 $model_type = $model_type_hash->{model_type
};
1084 my $trained_image_type = $model_type_hash->{image_type
};
1086 my @aux_trait_names;
1087 if (scalar(@
$aux_trait_ids)>0) {
1088 foreach (@
$aux_trait_ids) {
1089 my $aux_trait_name = SGN
::Model
::Cvterm
::get_trait_from_cvterm_id
($schema, $_, 'extended');
1090 push @aux_trait_names, $aux_trait_name;
1092 $name .= " Aux Traits:".join(",", @aux_trait_names);
1094 push @keras_cnn_models, [$nd_protocol_id, $name];
1097 my $id = $c->req->param("id") || "html_keras_cnn_select";
1098 my $name = $c->req->param("name") || "html_keras_cnn_select";
1100 @keras_cnn_models = sort { $a->[1] cmp $b->[1] } @keras_cnn_models;
1102 my $html = simple_selectbox_html
(
1105 choices
=> \
@keras_cnn_models
1107 $c->stash->{rest
} = { select => $html };
1110 sub get_trained_keras_mask_r_cnn_models
: Path
('/ajax/html/select/trained_keras_mask_r_cnn_models') Args
(0) {
1113 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1114 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
1116 my $keras_mask_r_cnn_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'trained_keras_mask_r_cnn_model', 'protocol_type')->cvterm_id();
1117 my $model_properties_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'analysis_model_properties', 'protocol_property')->cvterm_id();
1119 my $model_q = "SELECT nd_protocol.nd_protocol_id, nd_protocol.name, nd_protocol.description, model_type.value
1121 JOIN nd_protocolprop AS model_type ON(nd_protocol.nd_protocol_id=model_type.nd_protocol_id AND model_type.type_id=$model_properties_cvterm_id)
1122 WHERE nd_protocol.type_id=$keras_mask_r_cnn_cvterm_id;";
1123 my $model_h = $schema->storage->dbh()->prepare($model_q);
1124 $model_h->execute();
1125 my @keras_cnn_models;
1126 while (my ($nd_protocol_id, $name, $description, $model_type) = $model_h->fetchrow_array()) {
1127 my $model_type_hash = decode_json
$model_type;
1129 push @keras_cnn_models, [$nd_protocol_id, $name];
1132 my $id = $c->req->param("id") || "html_keras_mask_r_cnn_select";
1133 my $name = $c->req->param("name") || "html_keras_mask_r_cnn_select";
1135 @keras_cnn_models = sort { $a->[1] cmp $b->[1] } @keras_cnn_models;
1137 my $html = simple_selectbox_html
(
1140 choices
=> \
@keras_cnn_models
1142 $c->stash->{rest
} = { select => $html };
1145 sub get_analysis_models
: Path
('/ajax/html/select/models') Args
(0) {
1148 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1149 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
1150 my $model_properties_cvterm_id = $c->req->param('nd_protocol_type') ? SGN
::Model
::Cvterm
->get_cvterm_row($schema, $c->req->param('nd_protocol_type'), 'protocol_property')->cvterm_id() : SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'analysis_model_properties', 'protocol_property')->cvterm_id();
1152 my $model_q = "SELECT nd_protocol.nd_protocol_id, nd_protocol.name, nd_protocol.description, model_type.value
1154 JOIN nd_protocolprop AS model_type ON(nd_protocol.nd_protocol_id=model_type.nd_protocol_id AND model_type.type_id=$model_properties_cvterm_id);";
1155 my $model_h = $schema->storage->dbh()->prepare($model_q);
1156 $model_h->execute();
1158 while (my ($nd_protocol_id, $name, $description, $model_type) = $model_h->fetchrow_array()) {
1159 my $model_type_hash = decode_json
$model_type;
1161 push @models, [$nd_protocol_id, $name];
1164 my $id = $c->req->param("id") || "html_model_select";
1165 my $name = $c->req->param("name") || "html_model_select";
1166 my $empty = $c->req->param("empty");
1168 @models = sort { $a->[1] cmp $b->[1] } @models;
1169 if ($empty) { unshift @models, [ "", "Please select a model" ]; }
1171 my $html = simple_selectbox_html
(
1176 $c->stash->{rest
} = { select => $html };
1179 sub get_imaging_event_vehicles
: Path
('/ajax/html/select/imaging_event_vehicles') Args
(0) {
1182 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1183 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
1185 my $imaging_vehicle_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'imaging_event_vehicle', 'stock_type')->cvterm_id();
1186 my $imaging_vehicle_properties_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'imaging_event_vehicle_json', 'stock_property')->cvterm_id();
1188 my $q = "SELECT stock.stock_id, stock.uniquename, stock.description, stockprop.value
1190 JOIN stockprop ON(stock.stock_id=stockprop.stock_id AND stockprop.type_id=$imaging_vehicle_properties_cvterm_id)
1191 WHERE stock.type_id=$imaging_vehicle_cvterm_id;";
1192 my $h = $schema->storage->dbh()->prepare($q);
1194 my @imaging_vehicles;
1195 while (my ($stock_id, $name, $description, $prop) = $h->fetchrow_array()) {
1196 my $prop_hash = decode_json
$prop;
1198 push @imaging_vehicles, [$stock_id, $name];
1201 my $id = $c->req->param("id") || "html_imaging_vehicle_select";
1202 my $name = $c->req->param("name") || "html_imaging_vehicle_select";
1204 @imaging_vehicles = sort { $a->[1] cmp $b->[1] } @imaging_vehicles;
1206 my $html = simple_selectbox_html
(
1209 choices
=> \
@imaging_vehicles
1211 $c->stash->{rest
} = { select => $html };
1214 sub get_traits_select
: Path
('/ajax/html/select/traits') Args
(0) {
1217 my $trial_ids = $c->req->param('trial_ids') || 'all';
1218 my $stock_id = $c->req->param('stock_id') || 'all';
1219 my $stock_type = $c->req->param('stock_type') ?
$c->req->param('stock_type') . 's' : 'none';
1220 my $data_level = $c->req->param('data_level') || 'all';
1221 my $trait_format = $c->req->param('trait_format');
1222 my $contains_composable_cv_type = $c->req->param('contains_composable_cv_type');
1223 my $select_format = $c->req->param('select_format') || 'html_select'; #html_select or component_table_select
1224 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1225 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
1226 my $multiple = $c->req->param('multiple');
1227 my $empty = $c->req->param('empty');
1228 my $select_all = $c->req->param('select_all');
1230 my $id = $c->req->param("id") || "html_trial_select";
1231 my $name = $c->req->param("name") || "html_trial_select";
1232 my $size = $c->req->param("size");
1234 if ($data_level eq 'all') {
1239 if (($trial_ids eq 'all') && ($stock_id eq 'all')) {
1240 my $bs = CXGN
::BreederSearch
->new( { dbh
=> $c->dbc->dbh() } );
1241 my $status = $bs->test_matviews($c->config->{dbhost
}, $c->config->{dbname
}, $c->config->{dbuser
}, $c->config->{dbpass
});
1242 unless ($status->{'success'}) {
1243 $c->stash->{rest
} = { select => '<center><p>Direct trait select is not currently available</p></center>'};
1246 my $query = $bs->metadata_query([ 'traits' ], {}, {});
1247 @traits = @
{$query->{results
}};
1248 #print STDERR "Traits: ".Dumper(@traits)."\n";
1249 } elsif (looks_like_number
($stock_id)) {
1250 my $stock = CXGN
::Chado
::Stock
->new($schema, $stock_id);
1251 my @trait_list = $stock->get_trait_list();
1252 foreach (@trait_list){
1253 my @val = ($_->[0], $_->[2]."|".$_->[1]);
1254 push @traits, \
@val;
1256 } elsif ($trial_ids ne 'all') {
1257 my @trial_ids = split ',', $trial_ids;
1258 my %unique_traits_ids;
1259 my %unique_traits_ids_count;
1260 my %unique_traits_ids_drone_project;
1261 foreach (@trial_ids){
1262 my $trial = CXGN
::Trial
->new({bcs_schema
=>$schema, trial_id
=>$_});
1263 my $traits_assayed = $trial->get_traits_assayed($data_level, $trait_format, $contains_composable_cv_type);
1264 foreach (@
$traits_assayed) {
1265 $unique_traits_ids{$_->[0]} = $_;
1267 push @
{$unique_traits_ids_drone_project{$_->[0]}}, $_->[5];
1270 $unique_traits_ids_count{$_->[0]} += $_->[3];
1274 if ($select_format eq 'component_table_select') {
1275 my $html = '<table class="table table-hover table-bordered" id="'.$id.'"><thead><th>Observation Variable Components</th><th>Select</th></thead><tbody>';
1276 my %unique_components;
1277 foreach (values %unique_traits_ids) {
1278 foreach my $component (@
{$_->[2]}) {
1279 $unique_components{$_->[0]}->{num_pheno
} = $_->[3];
1280 $unique_components{$_->[0]}->{imaging_project_id
} = $_->[4];
1281 $unique_components{$_->[0]}->{imaging_project_name
} = $_->[5];
1282 if ($component->{cv_type
} && $component->{cv_type
} eq $contains_composable_cv_type) {
1283 $unique_components{$_->[0]}->{contains_cv_type
} = $component->{name
};
1286 push @
{$unique_components{$_->[0]}->{cv_types
}}, $component->{name
};
1290 my %separated_components;
1291 while (my ($k, $v) = each %unique_components) {
1292 my $string_cv_types = join ',', @
{$v->{cv_types
}};
1293 push @
{$separated_components{$string_cv_types}}, [$k, $v->{contains_cv_type
}, $v->{num_pheno
}, $v->{imaging_project_id
}, $v->{imaging_project_name
}];
1295 foreach my $k (sort keys %separated_components) {
1296 my $v = $separated_components{$k};
1297 $html .= "<tr><td>".$k."</td><td>";
1299 $html .= "<input type='checkbox' name = '".$name."' value ='".$_->[0]."'";
1303 $html .= "> ".$_->[1]." (".$_->[2]." Phenotypes";
1304 if ($_->[3] && $_->[4]) {
1305 $html .= " From ".$_->[4];
1309 $html .= "</td></tr>";
1311 $html .= "</tbody></table>";
1312 $c->stash->{rest
} = { select => $html };
1315 elsif ($select_format eq 'component_table_multiseason_select') {
1316 my $html = '<table class="table table-hover table-bordered" id="'.$id.'"><thead><th>Observation Variable Components</th><th>Select</th></thead><tbody>';
1317 my %unique_components;
1318 foreach (values %unique_traits_ids) {
1319 foreach my $component (@
{$_->[2]}) {
1320 $unique_components{$_->[0]}->{num_pheno
} = $_->[3];
1321 $unique_components{$_->[0]}->{imaging_project_id
} = $_->[4];
1322 $unique_components{$_->[0]}->{imaging_project_name
} = $_->[5];
1323 if ($component->{cv_type
} && $component->{cv_type
} eq $contains_composable_cv_type) {
1324 $unique_components{$_->[0]}->{contains_cv_type
} = $component->{name
};
1327 push @
{$unique_components{$_->[0]}->{cv_types
}}, $component->{name
};
1331 my %separated_components;
1332 while (my ($k, $v) = each %unique_components) {
1333 my $string_cv_types = join ',', @
{$v->{cv_types
}};
1334 push @
{$separated_components{$string_cv_types}}, [$k, $v->{contains_cv_type
}, $v->{num_pheno
}, $v->{imaging_project_id
}, $v->{imaging_project_name
}];
1336 foreach my $k (sort keys %separated_components) {
1337 my $v = $separated_components{$k};
1338 $html .= "<tr><td>".$k."</td><td>";
1340 $html .= "<input type='checkbox' name = '".$name."' value ='".$_->[0]."'";
1344 $html .= "> ".$_->[1]." (".$_->[2]." Phenotypes";
1345 if ($_->[3] && $_->[4]) {
1346 $html .= " From ".$_->[4];
1350 $html .= "</td></tr>";
1352 $html .= "</tbody></table>";
1353 $c->stash->{rest
} = { select => $html };
1356 elsif ($select_format eq 'html_select') {
1357 foreach (values %unique_traits_ids) {
1359 my $phenotype_count = $unique_traits_ids_count{$_->[0]};
1360 if (exists($unique_traits_ids_drone_project{$_->[0]})) {
1361 my $imaging_project_names = join ',', @
{$unique_traits_ids_drone_project{$_->[0]}};
1362 $text .= " ($imaging_project_names $phenotype_count Phenotypes)";
1364 $text .= " (".$phenotype_count." Phenotypes)";
1366 push @traits, [$_->[0], $text];
1371 @traits = sort { $a->[1] cmp $b->[1] } @traits;
1372 if ($empty) { unshift @traits, [ "", "Please select a trait" ]; }
1374 my $html = simple_selectbox_html
(
1375 multiple
=> $multiple,
1378 choices
=> \
@traits,
1381 $c->stash->{rest
} = { select => $html };
1384 sub get_phenotyped_trait_components_select
: Path
('/ajax/html/select/phenotyped_trait_components') Args
(0) {
1387 my $trial_ids = $c->req->param('trial_ids');
1388 #my $stock_id = $c->req->param('stock_id') || 'all';
1389 #my $stock_type = $c->req->param('stock_type') . 's' || 'none';
1390 my $data_level = $c->req->param('data_level') || 'all';
1391 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1392 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
1393 my $composable_cvterm_format = $c->config->{composable_cvterm_format
};
1395 if ($data_level eq 'all') {
1399 my @trial_ids = split ',', $trial_ids;
1401 my @trait_components;
1402 foreach (@trial_ids){
1403 my $trial = CXGN
::Trial
->new({bcs_schema
=>$schema, trial_id
=>$_});
1404 push @trait_components, @
{$trial->get_trait_components_assayed($data_level, $composable_cvterm_format)};
1406 #print STDERR Dumper \@trait_components;
1407 my %unique_trait_components = map {$_->[0] => $_->[1]} @trait_components;
1408 my @unique_components;
1409 foreach my $id (keys %unique_trait_components){
1410 push @unique_components, [$id, $unique_trait_components{$id}];
1412 #print STDERR Dumper \@unique_components;
1414 my $id = $c->req->param("id") || "html_trait_component_select";
1415 my $name = $c->req->param("name") || "html_trait_component_select";
1417 my $html = simple_selectbox_html
(
1421 choices
=> \
@unique_components,
1423 $c->stash->{rest
} = { select => $html };
1426 sub get_composable_cvs_allowed_combinations_select
: Path
('/ajax/html/select/composable_cvs_allowed_combinations') Args
(0) {
1429 my $id = $c->req->param("id") || "html_composable_cvs_combinations_select";
1430 my $name = $c->req->param("name") || "html_composable_cvs_combinations_select";
1431 my $composable_cvs_allowed_combinations = $c->config->{composable_cvs_allowed_combinations
};
1432 my @combinations = split ',', $composable_cvs_allowed_combinations;
1434 foreach (@combinations){
1435 my @parts = split /\|/, $_; #/#
1436 push @select, [$parts[1], $parts[0]];
1438 my $html = simple_selectbox_html
(
1441 choices
=> \
@select,
1443 $c->stash->{rest
} = { select => $html };
1446 sub get_crosses_select
: Path
('/ajax/html/select/crosses') Args
(0) {
1449 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1450 my $schema = $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id);
1451 my $p = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $schema } );
1452 my $breeding_program_id = $c->req->param("breeding_program_id");
1453 my $breeding_program_name = $c->req->param("breeding_program_name");
1456 if (!$breeding_program_id && !$breeding_program_name) {
1457 $projects = $p->get_breeding_programs();
1458 } elsif ($breeding_program_id){
1459 push @
$projects, [$breeding_program_id];
1461 push @
$projects, [$schema->resultset('Project::Project')->find({name
=> $breeding_program_name})->project_id()];
1464 my $id = $c->req->param("id") || "html_trial_select";
1465 my $name = $c->req->param("name") || "html_trial_select";
1466 my $multiple = defined($c->req->param("multiple")) ?
$c->req->param("multiple") : 1;
1467 my $size = $c->req->param("size");
1469 foreach my $project (@
$projects) {
1470 my ($field_trials, $cross_trials, $genotyping_trials) = $p->get_trials_by_breeding_program($project->[0]);
1471 foreach (@
$cross_trials) {
1475 @crosses = sort @crosses;
1477 my $html = simple_selectbox_html
(
1478 multiple
=> $multiple,
1482 choices
=> \
@crosses,
1484 $c->stash->{rest
} = { select => $html };
1487 sub get_genotyping_protocol_select
: Path
('/ajax/html/select/genotyping_protocol') Args
(0) {
1491 my $id = $c->req->param("id") || "gtp_select";
1492 my $name = $c->req->param("name") || "genotyping_protocol_select";
1493 my $empty = $c->req->param("empty") || "";
1497 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1498 my $gt_protocols = CXGN
::BreedersToolbox
::Projects
->new( { schema
=> $c->dbic_schema("Bio::Chado::Schema", undef, $sp_person_id) } )->get_gt_protocols();
1500 if (@
$gt_protocols) {
1501 $default_gtp = $c->config->{default_genotyping_protocol
};
1502 %gtps = map { @
$_[1] => @
$_[0] } @
$gt_protocols;
1506 unshift@
$gt_protocols, ['', "Select a genotyping protocol"]
1509 my $html = simple_selectbox_html
(
1512 choices
=> $gt_protocols,
1513 selected
=> $gtps{$default_gtp}
1515 $c->stash->{rest
} = { select => $html };
1518 sub get_trait_components_select
: Path
('/ajax/html/select/trait_components') Args
(0) {
1523 my $cv_id = $c->req->param('cv_id');
1524 #print STDERR "cv_id = $cv_id\n";
1525 my $id = $c->req->param("id") || "component_select";
1526 my $name = $c->req->param("name") || "component_select";
1527 my $default = $c->req->param("default") || 0;
1528 my $multiple = $c->req->param("multiple") || 0;
1529 my $size = $c->req->param('size') || '5';
1531 my $dbh = $c->dbc->dbh();
1532 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1533 my $onto = CXGN
::Onto
->new( { schema
=> $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id) } );
1534 my @components = $onto->get_terms($cv_id);
1535 #print STDERR Dumper \@components;
1536 if ($default) { unshift @components, [ '', $default ]; }
1538 my $html = simple_selectbox_html
(
1540 multiple
=> $multiple,
1542 choices
=> \
@components,
1546 $c->stash->{rest
} = { select => $html };
1551 sub ontology_children_select
: Path
('/ajax/html/select/ontology_children') Args
(0) {
1552 my ($self, $c) = @_;
1553 my $parent_node_cvterm = $c->request->param("parent_node_cvterm");
1554 my $rel_cvterm = $c->request->param("rel_cvterm");
1555 my $rel_cv = $c->request->param("rel_cv");
1556 my $size = $c->req->param('size') || '5';
1557 my $value_format = $c->req->param('value_format') || 'ids';
1558 print STDERR
"Parent Node $parent_node_cvterm\n";
1560 my $select_name = $c->request->param("selectbox_name");
1561 my $select_id = $c->request->param("selectbox_id");
1562 my $selected = $c->req->param("selected");
1563 my $empty = $c->request->param("empty") || '';
1564 my $multiple = $c->req->param("multiple") || 0;
1566 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1567 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
1568 my $parent_node_cvterm_row = SGN
::Model
::Cvterm
->get_cvterm_row_from_trait_name($schema, $parent_node_cvterm);
1569 my $parent_node_cvterm_id;
1570 if ($parent_node_cvterm_row){
1571 $parent_node_cvterm_id = $parent_node_cvterm_row->cvterm_id();
1573 my $rel_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, $rel_cvterm, $rel_cv)->cvterm_id();
1575 my $ontology_children_ref = $schema->resultset("Cv::CvtermRelationship")->search({type_id
=> $rel_cvterm_id, object_id
=> $parent_node_cvterm_id})->search_related('subject');
1576 my @ontology_children;
1577 while (my $child = $ontology_children_ref->next() ) {
1578 my $cvterm_id = $child->cvterm_id();
1579 my $dbxref_info = $child->search_related('dbxref');
1580 my $accession = $dbxref_info->first()->accession();
1581 my $db_info = $dbxref_info->search_related('db');
1582 my $db_name = $db_info->first()->name();
1583 if ($value_format eq 'ids'){
1584 push @ontology_children, [$cvterm_id, $child->name."|".$db_name.":".$accession];
1586 if ($value_format eq 'names'){
1587 push @ontology_children, [$child->name."|".$db_name.":".$accession, $child->name."|".$db_name.":".$accession];
1591 @ontology_children = sort { $a->[1] cmp $b->[1] } @ontology_children;
1593 unshift @ontology_children, [ 0, "None" ];
1595 #print STDERR Dumper \@ontology_children;
1596 my $html = simple_selectbox_html
(
1597 name
=> $select_name,
1599 multiple
=> $multiple,
1600 choices
=> \
@ontology_children,
1601 selected
=> $selected
1603 $c->stash->{rest
} = { select => $html };
1606 sub all_ontology_terms_select
: Path
('/ajax/html/select/all_ontology_terms') Args
(0) {
1607 my ($self, $c) = @_;
1608 my $db_id = $c->request->param("db_id");
1609 my $size = $c->req->param('size') || '5';
1611 my $select_name = $c->request->param("selectbox_name");
1612 my $select_id = $c->request->param("selectbox_id");
1614 my $empty = $c->request->param("empty") || '';
1615 my $multiple = $c->req->param("multiple") || 0;
1616 my $exclude_top_term = $c->req->param("exclude_top_term") || 1;
1618 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1619 my $bcs_schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
1621 my $exclude_top_sql = '';
1622 if ($exclude_top_term) {
1623 $exclude_top_sql = " AND dbxref.accession != '0000000' ";
1627 my $q = "SELECT cvterm.cvterm_id, cvterm.name, cvterm.definition, db.name, db.db_id, dbxref.accession, count(cvterm.cvterm_id) OVER() AS full_count FROM cvterm JOIN dbxref USING(dbxref_id) JOIN db using(db_id) WHERE db_id=$db_id $exclude_top_sql ORDER BY cvterm.name;";
1628 my $sth = $bcs_schema->storage->dbh->prepare($q);
1630 while (my ($cvterm_id, $cvterm_name, $cvterm_definition, $db_name, $db_id, $accession, $count) = $sth->fetchrow_array()) {
1631 push @ontology_terms, [$cvterm_id, $cvterm_name."|".$db_name.":".$accession];
1634 #@ontology_terms = sort { $a->[1] cmp $b->[1] } @ontology_terms;
1636 unshift @ontology_terms, [ 0, "None" ];
1638 #print STDERR Dumper \@ontology_children;
1639 my $html = simple_selectbox_html
(
1640 name
=> $select_name,
1642 multiple
=> $multiple,
1643 choices
=> \
@ontology_terms,
1645 $c->stash->{rest
} = { select => $html };
1648 sub get_datasets_select
:Path
('/ajax/html/select/datasets') Args
(0) {
1651 my $checkbox_name = $c->request->param("checkbox_name") || 'dataset_select_checkbox';
1652 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1653 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
1654 my $people_schema = $c->dbic_schema("CXGN::People::Schema", undef, $sp_person_id);
1656 my $num = int(rand(1000));
1660 if ($user_id = $c->user->get_object()->get_sp_person_id()) {
1662 my $user_datasets = CXGN
::Dataset
->get_datasets_by_user(
1663 $c->dbic_schema("CXGN::People::Schema", undef, $sp_person_id),
1666 #print STDERR "Retrieved datasets: ".Dumper($user_datasets);
1668 foreach (@
$user_datasets) {
1669 my $dataset_id = $_->[0];
1670 my $dataset_name = $_->[1];
1671 my $dataset_description = $_->[2];
1673 my $ds = CXGN
::Dataset
->new({
1675 people_schema
=> $people_schema,
1676 sp_dataset_id
=> $dataset_id
1678 my $info = $ds->get_dataset_data();
1680 my $dataset_info = {
1682 name
=> $dataset_name,
1683 description
=> $dataset_description,
1687 push @datasets, $dataset_info;
1691 #print STDERR Dumper \@datasets;
1693 my $lt = CXGN
::List
::Transform
->new();
1694 my %transform_dict = (
1695 'plots' => 'stock_ids_2_stocks',
1696 'accessions' => 'stock_ids_2_stocks',
1697 'traits' => 'trait_ids_2_trait_names',
1698 'locations' => 'locations_ids_2_location',
1699 'plants' => 'stock_ids_2_stocks',
1700 'trials' => 'project_ids_2_projects',
1701 'trial_types' => 'cvterm_ids_2_cvterms',
1702 'breeding_programs' => 'project_ids_2_projects',
1703 'genotyping_protocols' => 'nd_protocol_ids_2_protocols'
1706 my $html = '<table class="table table-bordered table-hover" id="html-select-dataset-table-'.$num.'"><thead><tr><th>Select</th><th>Dataset Name</th><th>Contents</th></tr></thead><tbody>';
1707 foreach my $ds (@datasets) {
1708 $html .= '<tr><td><input type="checkbox" name="'.$checkbox_name.'" value="'.$ds->{id
}.'"></td><td><a href="/dataset/'.$ds->{id
}.'">'.$ds->{name
}.'</a></td><td>';
1710 $html .= '<table class="table-bordered"><thead><tr>';
1711 foreach my $cat (@
{$ds->{info
}->{category_order
}}) {
1712 $html .= '<th>'.ucfirst($cat).'</th>';
1714 $html .= '</tr></thead><tbody><tr>';
1715 foreach my $cat (@
{$ds->{info
}->{category_order
}}) {
1716 my $ids = $ds->{info
}->{categories
}->{$cat};
1719 if (exists($transform_dict{$cat})) {
1720 my $transform = $lt->transform($schema, $transform_dict{$cat}, $ids);
1721 @items = @
{$transform->{transform
}};
1724 if (defined($ids)) {
1729 $html .= "<td><div class='well well-sm'>";
1730 $html .= "<select class='form-control' multiple>";
1732 $html .= "<option value='$_' disabled>$_</option>";
1734 $html .= "</select>";
1735 $html .= "</td></div>";
1737 $html .= "</tr></tbody></table>";
1738 $html .= '</td></tr>';
1741 $html .= "</tbody></table>";
1743 $html .= "<script>jQuery(document).ready(function() { jQuery('#html-select-dataset-table-".$num."').DataTable({ 'lengthMenu': [[2, 4, 6, 8, 10, 25, 50, -1], [2, 4, 6, 8, 10, 25, 50, 'All']] }); } );</script>";
1745 $c->stash->{rest
} = { select => $html };
1748 sub get_datasets_intersect_select
: Path
('/ajax/html/select/datasets_intersect') Args
(0) {
1751 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1752 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
1753 my $people_schema = $c->dbic_schema('CXGN::People::Schema', undef, $sp_person_id);
1755 my $name = $c->req->param("name");
1756 my $id = $c->req->param("id");
1757 my $names_as_values = $c->req->param("names_as_values");
1758 my $empty = $c->req->param("empty") || "";
1760 my $dataset_param = $c->req->param("param");
1761 my $dataset_ids = decode_json
$c->req->param("dataset_ids");
1763 my $first_dataset_id = shift @
$dataset_ids;
1764 my $dataset_info = CXGN
::Dataset
->new({people_schema
=> $people_schema, schema
=> $schema, sp_dataset_id
=> $first_dataset_id})->get_dataset_data();
1765 my $i = $dataset_info->{categories
}->{$dataset_param} || [];
1767 my @intersect = @
$i;
1768 foreach my $dataset_id (@
$dataset_ids) {
1770 my $dataset_info = CXGN
::Dataset
->new({people_schema
=> $people_schema, schema
=> $schema, sp_dataset_id
=> $dataset_id})->get_dataset_data();
1771 my $j = $dataset_info->{categories
}->{$dataset_param} || [];
1772 @intersect = intersect
(@intersect, @
$j);
1775 # print STDERR Dumper @intersect;
1777 my $lt = CXGN
::List
::Transform
->new();
1778 my %transform_dict = (
1779 'plots' => 'stock_ids_2_stocks',
1780 'accessions' => 'stock_ids_2_stocks',
1781 'traits' => 'trait_ids_2_trait_names',
1782 'locations' => 'locations_ids_2_location',
1783 'plants' => 'stock_ids_2_stocks',
1784 'trials' => 'project_ids_2_projects',
1785 'trial_types' => 'cvterm_ids_2_cvterms',
1786 'breeding_programs' => 'project_ids_2_projects',
1787 'genotyping_protocols' => 'nd_protocol_ids_2_protocols'
1791 if (exists($transform_dict{$dataset_param})) {
1792 my $transform = $lt->transform($schema, $transform_dict{$dataset_param}, \
@intersect);
1793 @items = @
{$transform->{transform
}};
1798 foreach (@intersect) {
1799 if (!$names_as_values) {
1800 push @result, [$_, $items[$counter]];
1802 push @result, [$items[$counter], $items[$counter]];
1808 unshift @result, ['', "Select one"];
1811 my $html = simple_selectbox_html
(
1814 choices
=> \
@result,
1816 $c->stash->{rest
} = { select => $html };
1819 sub get_drone_imagery_parameter_select
: Path
('/ajax/html/select/drone_imagery_parameter_select') Args
(0) {
1822 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1823 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
1825 my $project_id = $c->req->param("field_trial_id");
1826 my $drone_run_parameter = $c->req->param("parameter");
1828 my $id = $c->req->param("id") || "drone_imagery_plot_polygon_select";
1829 my $name = $c->req->param("name") || "drone_imagery_plot_polygon_select";
1830 my $empty = $c->req->param("empty") || "";
1832 my $parameter_type_id;
1833 if ($drone_run_parameter eq 'plot_polygons') {
1834 $parameter_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_band_plot_polygons', 'project_property')->cvterm_id();
1836 elsif ($drone_run_parameter eq 'plot_polygons_separated') {
1837 $parameter_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_band_plot_polygons_separated', 'project_property')->cvterm_id();
1839 elsif ($drone_run_parameter eq 'image_cropping') {
1840 $parameter_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_band_cropped_polygon', 'project_property')->cvterm_id();
1843 $c->stash->{rest
} = { error
=> "Parameter not supported!" };
1847 my $project_relationship_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_on_field_trial', 'project_relationship')->cvterm_id();
1848 my $drone_run_band_project_relationship_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_band_on_drone_run', 'project_relationship')->cvterm_id();
1849 my $drone_imagery_plot_polygons_rs = $schema->resultset("Project::Projectprop")->search({
1850 'me.type_id' => $parameter_type_id,
1851 'project_relationship_subject_projects.type_id' => $drone_run_band_project_relationship_type_id,
1852 'project_relationship_subject_projects_2.type_id' => $project_relationship_type_id,
1853 'object_project_2.project_id' => $project_id
1854 },{join => {'project' => {'project_relationship_subject_projects' => {'object_project' => {'project_relationship_subject_projects' => 'object_project'}}}}, '+select' => ['project.name'], '+as' => ['project_name']});
1857 while (my $r = $drone_imagery_plot_polygons_rs->next) {
1858 push @result, [$r->projectprop_id, $r->get_column('project_name')];
1862 unshift @result, ['', "Select one"];
1865 my $html = simple_selectbox_html
(
1868 choices
=> \
@result,
1870 $c->stash->{rest
} = { select => $html };
1873 sub get_drone_imagery_drone_runs_with_gcps
: Path
('/ajax/html/select/drone_runs_with_gcps') Args
(0) {
1876 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1877 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
1879 my $id = $c->req->param("id") || "drone_imagery_drone_run_gcp_select";
1880 my $name = $c->req->param("name") || "drone_imagery_drone_run_gcp_select";
1881 my $empty = $c->req->param("empty") || "";
1883 my $field_trial_id = $c->req->param('field_trial_id');
1885 my $drone_run_field_trial_project_relationship_type_id_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_on_field_trial', 'project_relationship')->cvterm_id();
1886 my $drone_run_ground_control_points_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_ground_control_points', 'project_property')->cvterm_id();
1887 my $processed_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_standard_process_completed', 'project_property')->cvterm_id();
1889 my $q = "SELECT project.project_id, project.name
1891 JOIN projectprop AS gcps ON(project.project_id = gcps.project_id AND gcps.type_id=$drone_run_ground_control_points_type_id)
1892 JOIN projectprop AS processed ON(project.project_id = processed.project_id AND processed.type_id=$processed_cvterm_id)
1893 JOIN project_relationship ON(project.project_id=project_relationship.subject_project_id AND project_relationship.type_id=$drone_run_field_trial_project_relationship_type_id_cvterm_id)
1894 WHERE project_relationship.object_project_id=?;";
1895 my $h = $schema->storage->dbh()->prepare($q);
1896 $h->execute($field_trial_id);
1899 while( my ($project_id, $name) = $h->fetchrow_array()) {
1900 push @result, [$project_id, $name];
1904 unshift @result, ['', "Select one"];
1907 my $html = simple_selectbox_html
(
1910 choices
=> \
@result,
1912 $c->stash->{rest
} = { select => $html };
1915 sub get_drone_imagery_drone_runs
: Path
('/ajax/html/select/drone_runs') Args
(0) {
1918 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1919 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
1921 my $id = $c->req->param("id") || "drone_imagery_drone_run_select";
1922 my $name = $c->req->param("name") || "drone_imagery_drone_run_select";
1923 my $empty = $c->req->param("empty") || "";
1925 my $field_trial_id = $c->req->param('field_trial_id');
1927 my $drone_run_field_trial_project_relationship_type_id_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_on_field_trial', 'project_relationship')->cvterm_id();
1928 my $processed_cvterm_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_standard_process_completed', 'project_property')->cvterm_id();
1930 my $q = "SELECT project.project_id, project.name
1932 JOIN projectprop AS processed ON(project.project_id = processed.project_id AND processed.type_id=$processed_cvterm_id)
1933 JOIN project_relationship ON(project.project_id=project_relationship.subject_project_id AND project_relationship.type_id=$drone_run_field_trial_project_relationship_type_id_cvterm_id)
1934 WHERE project_relationship.object_project_id=?;";
1935 my $h = $schema->storage->dbh()->prepare($q);
1936 $h->execute($field_trial_id);
1939 while( my ($project_id, $name) = $h->fetchrow_array()) {
1940 push @result, [$project_id, $name];
1944 unshift @result, ['', "Select one"];
1947 my $html = simple_selectbox_html
(
1950 choices
=> \
@result,
1952 $c->stash->{rest
} = { select => $html };
1955 sub get_drone_imagery_plot_polygon_types
: Path
('/ajax/html/select/drone_imagery_plot_polygon_types') Args
(0) {
1958 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
1959 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
1961 my $names_as_select = $c->req->param("names_as_select") || 0;
1962 my $standard_process = $c->req->param("standard_process_type") || 'minimal';
1964 my $id = $c->req->param("id") || "drone_imagery_plot_polygon_type_select";
1965 my $name = $c->req->param("name") || "drone_imagery_plot_polygon_type_select";
1966 my $empty = $c->req->param("empty") || "";
1968 my $plot_polygon_image_types = CXGN
::DroneImagery
::ImageTypes
::get_all_project_md_image_observation_unit_plot_polygon_types
($schema);
1971 while (my($type_id, $o) = each %$plot_polygon_image_types) {
1972 my %standard_processes = map {$_ => 1} @
{$o->{standard_process
}};
1973 if (exists($standard_processes{$standard_process})) {
1974 $terms{$type_id} = $o;
1979 foreach my $type_id (sort keys %terms) {
1980 my $t = $terms{$type_id};
1981 if ($names_as_select) {
1982 push @result, [$t->{name
}, $t->{name
}];
1984 push @result, [$type_id, $t->{name
}];
1989 unshift @result, ['', "Select one"];
1992 my $html = simple_selectbox_html
(
1995 choices
=> \
@result,
1997 $c->stash->{rest
} = { select => $html };
2000 sub get_micasense_aligned_raw_images
: Path
('/ajax/html/select/micasense_aligned_raw_images') Args
(0) {
2003 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
2004 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
2006 my $drone_run_project_id = $c->req->param("drone_run_project_id");
2008 my $id = $c->req->param("id") || "drone_imagery_plot_polygon_type_select";
2009 my $name = $c->req->param("name") || "drone_imagery_plot_polygon_type_select";
2010 my $empty = $c->req->param("empty") || "";
2012 my $saved_image_stacks_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_raw_images_saved_micasense_stacks', 'project_property')->cvterm_id();
2013 my $saved_micasense_stacks_json = $schema->resultset("Project::Projectprop")->find({
2014 project_id
=> $drone_run_project_id,
2015 type_id
=> $saved_image_stacks_type_id
2017 my $saved_micasense_stacks;
2018 if ($saved_micasense_stacks_json) {
2019 $saved_micasense_stacks = decode_json
$saved_micasense_stacks_json->value();
2023 foreach (sort {$a <=> $b} keys %$saved_micasense_stacks) {
2024 my $image_ids_array = $saved_micasense_stacks->{$_};
2026 foreach (@
$image_ids_array) {
2027 push @image_ids, $_->{image_id
};
2029 my $image_ids_string = join ',', @image_ids;
2030 push @result, [$image_ids_string, $image_ids_string];
2034 unshift @result, ['', "Select one"];
2037 my $html = simple_selectbox_html
(
2040 choices
=> \
@result,
2042 $c->stash->{rest
} = { select => $html };
2045 sub get_micasense_aligned_raw_images_grid
: Path
('/ajax/html/select/micasense_aligned_raw_images_grid') Args
(0) {
2048 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
2049 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
2051 my $drone_run_project_id = $c->req->param("drone_run_project_id");
2053 my $id = $c->req->param("id") || "drone_imagery_micasense_stacks_grid_select";
2054 my $name = $c->req->param("name") || "drone_imagery_micasense_stacks_grid_select";
2056 my $saved_image_stacks_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_raw_images_saved_micasense_stacks', 'project_property')->cvterm_id();
2057 my $saved_micasense_stacks_json = $schema->resultset("Project::Projectprop")->find({
2058 project_id
=> $drone_run_project_id,
2059 type_id
=> $saved_image_stacks_type_id
2061 my $saved_micasense_stacks;
2062 if ($saved_micasense_stacks_json) {
2063 $saved_micasense_stacks = decode_json
$saved_micasense_stacks_json->value();
2066 my $manual_plot_polygon_template_partial = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_band_plot_polygons_partial', 'project_property')->cvterm_id();
2067 my $q = "SELECT value FROM projectprop WHERE project_id=? AND type_id=$manual_plot_polygon_template_partial;";
2068 my $h = $schema->storage->dbh->prepare($q);
2069 $h->execute($drone_run_project_id);
2072 my %unique_image_polygons;
2073 while (my ($value) = $h->fetchrow_array()) {
2075 my $partial_templates = decode_json
$value;
2076 foreach my $t (@
$partial_templates) {
2077 my $nir_image_id = $t->{image_id
};
2078 my $polygon = $t->{stock_polygon
};
2079 my $template_name = $t->{template_name
};
2080 push @
{$unique_image_polygons{$nir_image_id}}, {
2081 template_name
=> $template_name,
2082 stock_polygon
=> $polygon
2091 foreach (sort {$a <=> $b} keys %$saved_micasense_stacks) {
2092 my $image_ids_array = $saved_micasense_stacks->{$_};
2093 my $nir_image = $image_ids_array->[3];
2094 my $latitude = nearest
(0.00001,$nir_image->{latitude
});
2095 my $longitude = nearest
(0.00001,$nir_image->{longitude
});
2096 $longitudes{$longitude}++;
2097 $latitudes{$latitude}++;
2098 my @stack_image_ids;
2099 foreach (@
$image_ids_array) {
2100 push @stack_image_ids, $_->{image_id
};
2102 my $nir_image_id = $nir_image->{image_id
};
2103 my @template_strings;
2105 if ($unique_image_polygons{$nir_image_id}) {
2106 foreach (@
{$unique_image_polygons{$nir_image_id}}) {
2107 push @polygons, $_->{stock_polygon
};
2108 push @template_strings, $_->{template_name
};
2111 my $template_string = join ',', @template_strings;
2112 push @
{$gps_images{$latitude}->{$longitude}}, {
2113 nir_image_id
=> $nir_image_id,
2114 image_ids
=> \
@stack_image_ids,
2115 template_names
=> $template_string,
2116 polygons
=> \
@polygons
2119 # print STDERR Dumper \%longitudes;
2120 # print STDERR Dumper \%latitudes;
2122 my $html = "<table class='table table-bordered table-hover'><thead><tr><th>Latitudes</th>";
2123 foreach my $lon (sort {$a <=> $b} keys %longitudes) {
2124 $html .= "<th>".$lon."</th>";
2126 $html .= "</tr></thead><tbody>";
2127 foreach my $lat (sort {$a <=> $b} keys %latitudes) {
2128 $html .= "<tr><td>".$lat."</td>";
2129 foreach my $lon (sort {$a <=> $b} keys %longitudes) {
2131 if ($gps_images{$lat}->{$lon}) {
2132 foreach my $img_id_info (@
{$gps_images{$lat}->{$lon}}) {
2133 $html .= "<span class='glyphicon glyphicon-picture' name='".$name."' data-image_id='".$img_id_info->{nir_image_id
}."' data-image_ids='".encode_json
($img_id_info->{image_ids
})."' data-polygons='".uri_encode
(encode_json
($img_id_info->{polygons
}))."' ></span>";
2134 if ($img_id_info->{template_names
}) {
2135 $html .= "Templates: ".$img_id_info->{template_names
};
2143 $html .= "</tbody></table>";
2145 $c->stash->{rest
} = { select => $html };
2148 sub get_plot_polygon_templates_partial
: Path
('/ajax/html/select/plot_polygon_templates_partial') Args
(0) {
2151 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
2152 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
2154 my $drone_run_project_id = $c->req->param("drone_run_project_id");
2156 my $id = $c->req->param("id") || "drone_imagery_plot_polygon_template_partial_type_select";
2157 my $name = $c->req->param("name") || "drone_imagery_plot_polygon_template_partial_type_select";
2158 my $empty = $c->req->param("empty") || "";
2160 my $manual_plot_polygon_template_partial = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_band_plot_polygons_partial', 'project_property')->cvterm_id();
2161 my $q = "SELECT value FROM projectprop WHERE project_id=? AND type_id=$manual_plot_polygon_template_partial;";
2162 my $h = $schema->storage->dbh->prepare($q);
2163 $h->execute($drone_run_project_id);
2167 while (my ($value) = $h->fetchrow_array()) {
2169 my $partial_templates = decode_json
$value;
2170 foreach my $t (@
$partial_templates) {
2171 my $image_id = $t->{image_id
};
2172 my $polygon = $t->{polygon
};
2173 my $template_name = $t->{template_name
};
2174 $unique_results{$template_name.": ".scalar(keys %$polygon)." Plots"} = uri_encode
(encode_json
($polygon));
2179 while (my ($k, $v) = each %unique_results) {
2180 push @result, [$v, $k];
2184 unshift @result, ['', "Select one"];
2187 my $html = simple_selectbox_html
(
2190 choices
=> \
@result,
2192 $c->stash->{rest
} = { select => $html };
2195 sub get_plot_image_sizes
: Path
('/ajax/html/select/plot_image_sizes') Args
(0) {
2198 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
2199 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
2201 my $drone_run_project_id = $c->req->param("drone_run_project_id");
2203 my $id = $c->req->param("id") || "drone_imagery_plot_polygon_type_select";
2204 my $name = $c->req->param("name") || "drone_imagery_plot_polygon_type_select";
2205 my $empty = $c->req->param("empty") || "";
2207 my $images_search = CXGN
::DroneImagery
::ImagesSearch
->new({
2208 bcs_schema
=>$schema,
2209 drone_run_project_id_list
=>[$drone_run_project_id],
2211 my ($result, $total_count) = $images_search->search();
2215 foreach (@
$result) {
2216 my $image = SGN
::Image
->new( $schema->storage->dbh, $_->{image_id
}, $c );
2217 my $image_url = $image->get_image_url('original_converted');
2218 my $image_fullpath = $image->get_filename('original_converted', 'full');
2219 my @size = imgsize
($image_fullpath);
2220 my $str = join ',', @size;
2221 $unique_sizes{$str} = \
@size;
2224 while (my($str, $size) = each %unique_sizes) {
2225 push @result, [$str, $size->[0]." width and ".$size->[1]." height"];
2229 unshift @result, ['', "Select one"];
2232 my $html = simple_selectbox_html
(
2235 choices
=> \
@result,
2237 $c->stash->{rest
} = { select => $html };
2240 sub get_drone_imagery_drone_run_band
: Path
('/ajax/html/select/drone_imagery_drone_run_band') Args
(0) {
2243 my $sp_person_id = $c->user() ?
$c->user->get_object()->get_sp_person_id() : undef;
2244 my $schema = $c->dbic_schema('Bio::Chado::Schema', 'sgn_chado', $sp_person_id);
2246 my $drone_run_project_id = $c->req->param("drone_run_project_id");
2248 my $id = $c->req->param("id") || "drone_imagery_drone_run_band_select";
2249 my $name = $c->req->param("name") || "drone_imagery_drone_run_band_select";
2250 my $empty = $c->req->param("empty") || "";
2252 my $drone_run_band_project_relationship_type_id = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_band_on_drone_run', 'project_relationship')->cvterm_id();
2253 my $drone_imagery_drone_run_bands_rs = $schema->resultset("Project::Project")->search({
2254 'project_relationship_subject_projects.type_id' => $drone_run_band_project_relationship_type_id,
2255 'object_project.project_id' => $drone_run_project_id
2256 },{join => {'project_relationship_subject_projects' => 'object_project' }});
2259 while (my $r = $drone_imagery_drone_run_bands_rs->next) {
2260 push @result, [$r->project_id, $r->name];
2264 unshift @result, ['', "Select a drone run band"];
2267 my $html = simple_selectbox_html
(
2270 choices
=> \
@result,
2272 $c->stash->{rest
} = { select => $html };
2276 sub get_items_select
: Path
('/ajax/html/select/items') Args
(0) {
2279 my $params = _clean_inputs
($c->req->params);
2280 my $items = $params->{list_items
},
2281 my $size = $params->{size
};
2282 my $multiple = defined($c->req->param("multiple")) ?
$c->req->param("multiple") : 1;
2283 my $data_related = $c->req->param("data-related") || "";
2284 my $names_as_select = $params->{names_as_select
}->[0] || 0;
2285 my $id = $c->req->param("id") || "html_trial_select";
2286 my $name = $c->req->param("name") || "html_trial_select";
2288 my $html = simple_selectbox_html
(
2289 multiple
=> $multiple,
2292 data_related
=> $data_related,
2297 $c->stash->{rest
} = { select => $html };
2302 sub get_genotyping_facility_select
: Path
('/ajax/html/select/genotyping_facilities') Args
(0) {
2306 my $id = $c->req->param("id") || "facility_select";
2307 my $name = $c->req->param("name") || "facility_select";
2308 my $empty = $c->req->param("empty") || "";
2310 my $genotyping_facilities = $c->config->{genotyping_facilities
};
2311 my @facilities = split ',',$genotyping_facilities;
2313 if ($empty) { unshift @facilities, [ "", "Select Facility" ] }
2315 my $default = $c->req->param("default") || @facilities[0]->[0];
2317 my $html = simple_selectbox_html
(
2320 choices
=> \
@facilities,
2321 selected
=> $default
2323 $c->stash->{rest
} = { select => $html };
2328 no warnings
'uninitialized';
2330 foreach (keys %$params){
2331 my $values = $params->{$_};
2333 if (ref \
$values eq 'SCALAR'){
2334 push @
$ret_val, $values;
2335 } elsif (ref $values eq 'ARRAY'){
2338 die "Input is not a scalar or an arrayref\n";
2340 @
$ret_val = grep {$_ ne undef} @
$ret_val;
2341 @
$ret_val = grep {$_ ne ''} @
$ret_val;
2342 $_ =~ s/\[\]$//; #ajax POST with arrays adds [] to the end of the name e.g. germplasmName[]. since all inputs are arrays now we can remove the [].
2343 $params->{$_} = $ret_val;