Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
packages/LIMS2-Tasks/lib/LIMS2/Task/General/DeletePlate.pm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package LIMS2::Task::General::DeletePlate; | ||
|
||
use strict; | ||
use warnings FATAL => 'all'; | ||
|
||
use Moose; | ||
use namespace::autoclean; | ||
use Smart::Comments; | ||
|
||
extends qw( LIMS2::Task ); | ||
|
||
has plate_name => ( | ||
is => 'ro', | ||
isa => 'Str', | ||
traits => [ 'Getopt' ], | ||
cmd_flag => 'plate-name', | ||
required => 1 | ||
); | ||
|
||
override abstract => sub { | ||
"Delete a Plate and all its wells" | ||
}; | ||
|
||
sub execute { | ||
my ( $self, $opts, $args ) = @_; | ||
$self->log->debug('Deleting plate: ' . $self->plate_name ); | ||
|
||
$self->model->txn_do( | ||
sub { | ||
$self->model->delete_plate( { plate_name => $self->plate_name } ); | ||
unless ( $self->commit ) { | ||
warn "Rollback\n"; | ||
$self->model->txn_rollback; | ||
} | ||
} | ||
); | ||
} | ||
|
||
__PACKAGE__->meta->make_immutable; | ||
|
||
1; | ||
|
||
__END__ |