Permalink
Browse files

perltidy

  • Loading branch information...
1 parent 56b22ef commit 38305b1db40c52cae7acc44edabc84e969b71e4f @sajp sajp committed Jul 27, 2012
Showing with 55 additions and 44 deletions.
  1. +55 −44 lib/LIMS2/Model/Plugin/Plate.pm
@@ -14,17 +14,18 @@ requires qw( schema check_params throw retrieve log trace );
sub list_plate_types {
my $self = shift;
- return [ $self->schema->resultset('PlateType')->search( {}, { order_by => { -asc => 'id' } } ) ];
+ return [
+ $self->schema->resultset('PlateType')->search( {}, { order_by => { -asc => 'id' } } ) ];
}
sub pspec_list_plates {
return {
species => { validate => 'existing_species' },
- plate_name => { validate => 'non_empty_string', optional => 1 },
+ plate_name => { validate => 'non_empty_string', optional => 1 },
plate_type => { validate => 'existing_plate_type', optional => 1 },
- page => { validate => 'integer', optional => 1, default => 1 },
- pagesize => { validate => 'integer', optional => 1, default => 15 }
- }
+ page => { validate => 'integer', optional => 1, default => 1 },
+ pagesize => { validate => 'integer', optional => 1, default => 15 }
+ };
}
sub list_plates {
@@ -35,7 +36,8 @@ sub list_plates {
my %search = ( 'me.species_id' => $validated_params->{species} );
if ( $validated_params->{plate_name} ) {
- $search{'me.name'} = { -like => '%' . sanitize_like_expr( $validated_params->{plate_name} ) . '%' };
+ $search{'me.name'}
+ = { -like => '%' . sanitize_like_expr( $validated_params->{plate_name} ) . '%' };
}
if ( $validated_params->{plate_type} ) {
@@ -44,8 +46,7 @@ sub list_plates {
my $resultset = $self->schema->resultset('Plate')->search(
\%search,
- {
- prefetch => [ 'created_by' ],
+ { prefetch => ['created_by'],
order_by => { -desc => 'created_at' },
page => $validated_params->{page},
rows => $validated_params->{pagesize}
@@ -90,8 +91,13 @@ sub create_plate {
my $validated_params = $self->check_params( $params, $self->pspec_create_plate );
my $plate = $self->schema->resultset('Plate')->create(
- { slice_def( $validated_params, qw( name species_id type_id description created_by_id created_at ) ) }
+ { slice_def(
+ $validated_params,
+ qw( name species_id type_id description created_by_id created_at )
+ )
+ }
);
+
# refresh object data from database, sets created_by value
# if it was set by database
$plate->discard_changes;
@@ -111,20 +117,22 @@ sub create_plate {
sub pspec_retrieve_plate {
return {
- name => { validate => 'plate_name', optional => 1, rename => 'me.name' },
- id => { validate => 'integer', optional => 1, rename => 'me.id' },
- type => { validate => 'existing_plate_type', optional => 1, rename => 'me.type_id' },
- species => { validate => 'existing_species', rename => 'me.species_id', optional => 1 },
+ name => { validate => 'plate_name', optional => 1, rename => 'me.name' },
+ id => { validate => 'integer', optional => 1, rename => 'me.id' },
+ type => { validate => 'existing_plate_type', optional => 1, rename => 'me.type_id' },
+ species => { validate => 'existing_species', rename => 'me.species_id', optional => 1 },
REQUIRE_SOME => { name_or_id => [ 1, qw( name id ) ] }
};
}
sub retrieve_plate {
my ( $self, $params ) = @_;
- my $validated_params = $self->check_params( $params, $self->pspec_retrieve_plate, ignore_unknown => 1 );
+ my $validated_params
+ = $self->check_params( $params, $self->pspec_retrieve_plate, ignore_unknown => 1 );
- return $self->retrieve( Plate => { slice_def $validated_params, qw( me.name me.id me.type_id me.species_id ) } );
+ return $self->retrieve(
+ Plate => { slice_def $validated_params, qw( me.name me.id me.type_id me.species_id ) } );
}
sub delete_plate {
@@ -137,7 +145,7 @@ sub delete_plate {
$self->delete_well( { id => $well->id } );
}
- $plate->search_related_rs( 'plate_comments' )->delete;
+ $plate->search_related_rs('plate_comments')->delete;
$plate->delete;
return;
}
@@ -151,14 +159,14 @@ sub pspec_set_plate_assay_complete {
sub set_plate_assay_complete {
my ( $self, $params ) = @_;
- my $validated_params = $self->check_params( $params, $self->pspec_set_plate_assay_complete, ignore_unknown => 1 );
+ my $validated_params = $self->check_params( $params, $self->pspec_set_plate_assay_complete,
+ ignore_unknown => 1 );
- my $plate = $self->retrieve_plate( $params );
+ my $plate = $self->retrieve_plate($params);
for my $well ( $plate->wells ) {
$self->set_well_assay_complete(
- {
- id => $well->id,
+ { id => $well->id,
completed_at => $validated_params->{completed_at}
}
);
@@ -179,9 +187,10 @@ sub pspec_create_plate_well {
sub create_plate_well {
my ( $self, $params, $plate ) = @_;
- my $validated_params = $self->check_params( $params, $self->pspec_create_plate_well, ignore_unknown => 1 );
+ my $validated_params
+ = $self->check_params( $params, $self->pspec_create_plate_well, ignore_unknown => 1 );
- my $parent_well_ids = $self->find_parent_well_ids( $params );
+ my $parent_well_ids = $self->find_parent_well_ids($params);
my %well_params = (
plate_name => $plate->name,
@@ -191,49 +200,52 @@ sub create_plate_well {
);
# the remaining params are specific to the process
- delete @{$params} {qw( well_name process_type )};
+ delete @{$params}{qw( well_name process_type )};
- $well_params{process_data} = $params;
- $well_params{process_data}{type} = $validated_params->{process_type};
- $well_params{process_data}{input_wells} = [ map{ { id => $_ } } @{ $parent_well_ids } ];
+ $well_params{process_data} = $params;
+ $well_params{process_data}{type} = $validated_params->{process_type};
+ $well_params{process_data}{input_wells} = [ map { { id => $_ } } @{$parent_well_ids} ];
$self->create_well( \%well_params, $plate );
}
sub pspec_find_parent_well_ids {
return {
- parent_plate => { validate => 'plate_name', optional => 1 },
- parent_well => { validate => 'well_name', optional => 1 },
- allele_plate => { validate => 'plate_name', optional => 1 },
- allele_well => { validate => 'well_name', optional => 1 },
- vector_plate => { validate => 'plate_name', optional => 1 },
- vector_well => { validate => 'well_name', optional => 1 },
- DEPENDENCY_GROUPS => { parent => [qw( parent_plate parent_well )] },
- DEPENDENCY_GROUPS => { vector => [qw( vector_plate vector_well )] },
- DEPENDENCY_GROUPS => { allele => [qw( allele_plate allele_well )] },
+ parent_plate => { validate => 'plate_name', optional => 1 },
+ parent_well => { validate => 'well_name', optional => 1 },
+ allele_plate => { validate => 'plate_name', optional => 1 },
+ allele_well => { validate => 'well_name', optional => 1 },
+ vector_plate => { validate => 'plate_name', optional => 1 },
+ vector_well => { validate => 'well_name', optional => 1 },
+ DEPENDENCY_GROUPS => { parent => [qw( parent_plate parent_well )] },
+ DEPENDENCY_GROUPS => { vector => [qw( vector_plate vector_well )] },
+ DEPENDENCY_GROUPS => { allele => [qw( allele_plate allele_well )] },
};
}
sub find_parent_well_ids {
my ( $self, $params ) = @_;
- my $validated_params = $self->check_params( $params, $self->pspec_find_parent_well_ids, ignore_unknown => 1 );
+ my $validated_params
+ = $self->check_params( $params, $self->pspec_find_parent_well_ids, ignore_unknown => 1 );
my @parent_well_ids;
if ( $params->{process_type} eq 'second_electroporation' ) {
push @parent_well_ids,
- $self->get_well_id( $validated_params->{allele_plate}, $validated_params->{allele_well} );
+ $self->get_well_id( $validated_params->{allele_plate},
+ $validated_params->{allele_well} );
push @parent_well_ids,
- $self->get_well_id( $validated_params->{vector_plate}, $validated_params->{vector_well} );
+ $self->get_well_id( $validated_params->{vector_plate},
+ $validated_params->{vector_well} );
- delete @{$params}
- {qw( allele_plate vector_plate allele_well vector_well )};
+ delete @{$params}{qw( allele_plate vector_plate allele_well vector_well )};
}
else {
push @parent_well_ids,
- $self->get_well_id( $validated_params->{parent_plate}, $validated_params->{parent_well} );
+ $self->get_well_id( $validated_params->{parent_plate},
+ $validated_params->{parent_well} );
delete @{$params}{qw( parent_plate parent_well )};
}
@@ -245,9 +257,8 @@ sub get_well_id {
my ( $self, $plate_name, $well_name ) = @_;
my $well = $self->retrieve_well(
- {
- plate_name => $plate_name,
- well_name => substr( $well_name, -3),
+ { plate_name => $plate_name,
+ well_name => substr( $well_name, -3 ),
}
);

0 comments on commit 38305b1

Please sign in to comment.