Skip to content

Commit

Permalink
add create_plate_csv_upload method to model that calls create_plate d…
Browse files Browse the repository at this point in the history
…irectly, do not need to send plate data hash back to controller and have it call plate create
  • Loading branch information
sajp committed Aug 9, 2012
1 parent 95ef0c4 commit 0cb35a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/LIMS2/Model/Plugin/Plate.pm
Expand Up @@ -274,9 +274,10 @@ sub get_well_id {
return $well->id;
}

sub process_plate_data {
sub create_plate_csv_upload {
my ( $self, $params, $well_data_fh ) = @_;

#validation done of create_plate, not needed here
my %plate_data = map { $_ => $params->{$_} } qw( plate_name species plate_type description created_by );
$plate_data{name} = delete $plate_data{plate_name};
$plate_data{type} = delete $plate_data{plate_type};
Expand All @@ -292,7 +293,7 @@ sub process_plate_data {
}
$plate_data{wells} = $well_data;

return \%plate_data;
return $self->create_plate( \%plate_data );
}

## no critic(RequireFinalReturn)
Expand Down
6 changes: 2 additions & 4 deletions lib/LIMS2/WebApp/Controller/User/PlateUpload.pm
Expand Up @@ -59,7 +59,7 @@ sub plate_upload_complete :Path( '/user/plate_upload_complete' ) :Args(0) {

my $well_data = $c->request->upload('datafile');
unless ( $well_data ) {
$c->stash->{error_msg} = 'No well data';
$c->stash->{error_msg} = 'No csv file with well data specified';
$c->go( 'plate_upload_step2' );
}

Expand All @@ -76,13 +76,11 @@ sub plate_upload_complete :Path( '/user/plate_upload_complete' ) :Args(0) {
$params->{species} ||= $c->session->{selected_species};
$params->{created_by} = $c->user->name;

my $plate_data = $c->model('Golgi')->process_plate_data( $params, $well_data->fh );

my $plate;
$c->model('Golgi')->txn_do(
sub {
try{
$plate = $c->model('Golgi')->create_plate( $plate_data );
$plate = $c->model('Golgi')->create_plate_csv_upload( $params, $well_data->fh );
}
catch {
$c->stash->{error_msg} = 'Error encountered while creating plate: ' . $_;
Expand Down

0 comments on commit 0cb35a1

Please sign in to comment.