Skip to content

Commit

Permalink
fix for transplate date and multi trial upload file
Browse files Browse the repository at this point in the history
  • Loading branch information
darekbienkowski committed Dec 14, 2023
1 parent 9ae4885 commit ddc0c0a
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ sub _validate_with_plugin {
}

## TREATMENT CHECKS
my $treatment_col = 24;
my $treatment_col = 25;
foreach my $treatment_name (@treatment_names){
if($worksheet->get_cell($row,$treatment_col)){
my $apply_treatment = $worksheet->get_cell($row,$treatment_col)->value();
Expand Down Expand Up @@ -779,10 +779,17 @@ sub _parse_with_plugin {
$single_design{'breeding_program'} = $worksheet->get_cell($row,1)->value();
$single_design{'location'} = $location;
$single_design{'year'} = $worksheet->get_cell($row,3)->value();
$single_design{'transplanting_date'} = $worksheet->get_cell($row,4)->value();
# $single_design{'transplanting_date'} = $worksheet->get_cell($row,4)->value();
$single_design{'design_type'} = $worksheet->get_cell($row,5)->value();
$single_design{'description'} = $worksheet->get_cell($row,6)->value();


# for a moment transplanting_date is moves as not required but whole design of that features must be redone
# including use cases
if ($worksheet->get_cell($row,4)) {
$single_design{'transplanting_date'} = $worksheet->get_cell($row,4)->value();
}

if ($worksheet->get_cell($row,7)) { # get and save trial type cvterm_id using trial type name
my $trial_type_id = $trial_type_map{$worksheet->get_cell($row,7)->value()};
$single_design{'trial_type'} = $trial_type_id;
Expand Down Expand Up @@ -1050,7 +1057,7 @@ sub _parse_header {
if (!$year_head || $year_head ne 'year' ) {
push @error_messages, "Cell D1: year is missing from the header";
}
if (!$transplanting_date_head || $year_head ne 'year' ) {
if (!$transplanting_date_head || $transplanting_date_head ne 'transplanting_date' ) {
push @error_messages, "Cell E1: year is missing from the header";
}
if (!$design_type_head || $design_type_head ne 'design_type' ) {
Expand Down
4 changes: 4 additions & 0 deletions lib/CXGN/Trial/TrialCreate.pm
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ has 'field_size' => (isa => 'Num', is => 'rw', predicate => 'has_field_size', re
has 'plot_width' => (isa => 'Num', is => 'rw', predicate => 'has_plot_width', required => 0);
has 'plot_length' => (isa => 'Num', is => 'rw', predicate => 'has_plot_length', required => 0);
has 'planting_date' => (isa => 'Str', is => 'rw', predicate => 'has_planting_date', required => 0);
has 'transplanting_date' => (isa => 'Str', is => 'rw', predicate => 'has_transplanting_date', required => 0);
has 'harvest_date' => (isa => 'Str', is => 'rw', predicate => 'has_harvest_date', required => 0);
has 'operator' => (isa => 'Str', is => 'rw', predicate => 'has_operator', required => 1);
has 'trial_stock_type' => (isa => 'Str', is => 'rw', predicate => 'has_trial_stock_type', required => 0, default => 'accession');
Expand Down Expand Up @@ -398,6 +399,9 @@ sub save_trial {
if ($self->get_harvest_date()){ # here is local getter
$t->set_harvest_date($self->get_harvest_date); # here is Project.pm unusual setter with writing to db instead of object
}
if ($self->get_transplanting_date()){ # here is local getter
$t->set_transplanting_date($self->get_transplanting_date); # here is Project.pm unusual setter with writing to db instead of object
}

#link to the project
$nd_experiment->find_or_create_related('nd_experiment_projects',{project_id => $project->project_id()});
Expand Down
4 changes: 3 additions & 1 deletion lib/SGN/Controller/AJAX/Trial.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,9 @@ sub upload_multiple_trial_designs_file_POST : Args(0) {
if ($trial_design->{'harvest_date'}){
$trial_info_hash{harvest_date} = $trial_design->{'harvest_date'};
}

if ($trial_design->{'transplanting_date'}){
$trial_info_hash{transplanting_date} = $trial_design->{'transplanting_date'};
}
my $trial_create = CXGN::Trial::TrialCreate->new(\%trial_info_hash);
my $current_save = $trial_create->save_trial();

Expand Down
10 changes: 5 additions & 5 deletions mason/breeders_toolbox/trial/trial_details.mas
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ $latest_trial_activity => undef
<table class="table table-hover table-bordered">
<tr><td><b>Plot Width (m)</b></td>
<td>
<div id="trial_description">
<div id="plot_width">
% if ($plot_width) {
% print "$plot_width";
% } else {
Expand All @@ -229,7 +229,7 @@ $latest_trial_activity => undef
</tr>
<tr><td><b>Plot Length (m)</b></td>
<td>
<div id="trial_description">
<div id="plot_length">
% if ($plot_length) {
% print "$plot_length";
% } else {
Expand All @@ -240,7 +240,7 @@ $latest_trial_activity => undef
</tr>
<tr><td><b>Field Size (ha)</b></td>
<td>
<div id="trial_description">
<div id="field_size">
% if ($field_size) {
% print "$field_size";
% } else {
Expand All @@ -251,7 +251,7 @@ $latest_trial_activity => undef
</tr>
<tr><td><b>Trial Will Be Genotyped</b></td>
<td>
<div id="trial_description">
<div id="planned_to_be_genotyped">
% if ($field_trial_is_planned_to_be_genotyped) {
% print "$field_trial_is_planned_to_be_genotyped";
% } else {
Expand All @@ -262,7 +262,7 @@ $latest_trial_activity => undef
</tr>
<tr><td><b>Trial Will Be In Crosses</b></td>
<td>
<div id="trial_description">
<div id="planned_to_cross">
% if ($field_trial_is_planned_to_cross) {
% print "$field_trial_is_planned_to_cross";
% } else {
Expand Down
4 changes: 3 additions & 1 deletion mason/breeders_toolbox/trial/trial_upload_dialogs.mas
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ $design_types => ()
<b>Trials may be uploaded in an Excel file (.xls or .xlsx)</b>
<br />
<b>Multiple Trial Designs:</b>
<br />
<b>Header:</b>
<br>
The first row (header) must contain the following, which is an expansion of the single trial design header:
Expand Down Expand Up @@ -734,7 +735,7 @@ $design_types => ()
<li>breeding_program (The name of breeding program that managed the trial, must exist in the database.)</li>
<li>location (The <strong>name</strong> or <strong>abbreviation</strong> of the location where the trial was held, must exist in the database.)</li>
<li>year (The year the trial was held.)</li>
<li>transplanting_date(The transplanting_date of the trial was conducted.)<li>

<li>design_type (The shorthand for the design type, must exist in the database. Possible values include CRD (Completely Randomized Design), RCBD (Randomized Complete Block Design), RRC (Resolvable Row-Column), DRRC (Doubly-Resolvable Row-Column), ARC (Augmented Row-Column), Alpha (Alpha Lattice Design), Lattice (Lattice Design), Augmented (Augmented Design), MAD (Modified Augmented Design), greenhouse (undesigned Nursery/Greenhouse), splitplot (Split Plot), p-rep (Partially Replicated), Westcott (Westcott Design))</li>
<li>description (Additional text with any other relevant information about the trial.)</li>
<li>plot_name (Must be unique across entire database. It is often a concatenation of the trial name and the plot number.)</li>
Expand All @@ -750,6 +751,7 @@ $design_types => ()
<li>plot_length (plot length in meters)</li>
<li>field_size (field size in hectares)</li>
<li>planting_date (Date of Planting in YYYY-MM-DD format)</li>
<li>transplanting_date(The transplanting_date of the trial was conducted. Date in YYYY-MM-DD format))</li>
<li>harvest_date (Date of Harvest in YYYY-MM-DD format)</li>
<li>is_a_control (type 1 in this field if the plot is a control, otherwise 0 or leave blank. generally you will have accessions that are controls, so you should indicate the plots that that accession is in as a control.)</li>
<li>rep_number (replicate number, must be numeric)</li>
Expand Down
Binary file added t/data/trial/upload_multi_trail.xlsx
Binary file not shown.
Binary file added t/data/trial/upload_multi_trail_full.xlsx
Binary file not shown.
104 changes: 104 additions & 0 deletions t/selenium2/breeders/upload_multi_trial_file.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
use lib 't/lib';

use Test::More;
use SGN::Test::WWW::WebDriver;
use SGN::Test::Fixture;

my $f = SGN::Test::Fixture->new();
my $t = SGN::Test::WWW::WebDriver->new();


$t->while_logged_in_as("submitter", sub {

my %trail_3_data = (
year => "2017",
name => "test_trial_3",
planting_date => "[No Planting Date]",
transplanting_date => "[No Transplanting Date]",
harvest_date => "[No Harvest Date]",
file_name => "upload_multi_trail.xlsx"

);

my %trail_6_data = (
year => "2017",
name => "test_trial_6",
planting_date => "2017-May-01",
transplanting_date => "2017-September-10",
harvest_date => "2018-February-01",
file_name => "upload_multi_trail_full.xlsx"
);

for my $trail (\%trail_3_data, \%trail_6_data) {
sleep(1);

$t->get_ok('/breeders/trials');
sleep(3);

$t->find_element_ok("refresh_jstree_html", "name", "click on refresh_jstree_html ")->click();
sleep(5);

$t->find_element_ok("upload_trial_link", "name", "click on upload_trial_link ")->click();
sleep(2);

# SCREEN 1 /Intro/
$t->find_element_ok("next_step_upload_intro_button", "id", "click on next_step_upload_intro_button ")->click();
sleep(1);

# SCREEN 2 /File formating and upload/
$t->find_element_ok("upload_multiple_trial_designs_tab", "id", "choose a multiple trial design tab")->click();
sleep(1);


my $upload_input = $t->find_element_ok("multiple_trial_designs_upload_file", "id", "find multi trial file input");
my $filename = $f->config->{basepath} . "/t/data/trial/$trail->{file_name}";

$t->driver()->upload_file($filename);
$upload_input->send_keys($filename);
sleep(1);

# SUBMIT
$t->find_element_ok("multiple_trial_designs_upload_submit", "id", "submit upload file")->click();
sleep(20);

# CHECK IF SUBMIT SUCCESSFUL
$t->find_element_ok("upload_multiple_trials_success_messages", "id", "find success info");

$t->find_element_ok("upload_multiple_trials_success_button", "id", "find and clock success button")->click();
sleep(7);

# Check if added do db and if successfully
$t->find_element_ok("test", "partial_link_text", "check program in tree")->click();
sleep(3);

$t->find_element_ok("jstree-icon", "class", "view drop down for program")->click();
sleep(5);

$t->find_element_ok("$trail->{name}", "partial_link_text", "check program in tree")->click();
my $href_to_trial = $t->find_element_ok("//li[\@role='treeitem']//a[contains(text(),'$trail->{name}')]", 'xpath', 'find created cross and take link href')->get_attribute('href');
sleep(7);

$t->get_ok($href_to_trial);
sleep(5);

my $table_content = $t->find_element_ok('trial_year', 'id', 'find cell of table with year information')->get_attribute('innerHTML');
ok($table_content =~ /$trail->{year}/, "Verify info in the table: $trail->{year}");

$table_content = $t->find_element_ok('trial_name', 'id', 'find cell of table with trial name information')->get_attribute('innerHTML');
ok($table_content =~ /$trail->{name}/, "Verify info in the table: $trail->{name}");

$table_content = $t->find_element_ok('planting_date', 'id', 'find cell of table with planting date information')->get_attribute('innerHTML');
ok($table_content =~ /$trail->{planting_date}/, "Verify info in the table: $trail->{planting_date}");

$table_content = $t->find_element_ok('harvest_date', 'id', 'find cell of table with trial harvest date information')->get_attribute('innerHTML');
ok($table_content =~ /$trail->{harvest_date}/, "Verify info in the table: $trail->{harvest_date}");

$table_content = $t->find_element_ok('transplanting_date', 'id', 'find cell of table with trial transplanting date information')->get_attribute('innerHTML');
ok($table_content =~ /$trail->{transplanting_date}/, "Verify info in the table: $trail->{transplanting_date}");

$f->clean_up_db();
}
});

$t->driver->close();
done_testing();

0 comments on commit ddc0c0a

Please sign in to comment.