Skip to content

Commit

Permalink
Merge pull request #3549 from solgenomics/bug/brapi-studies-fixes-add…
Browse files Browse the repository at this point in the history
…itions

bug/brapi studies fixes additions
  • Loading branch information
lukasmueller authored Jun 24, 2021
2 parents 807a054 + c1c0416 commit 2204960
Show file tree
Hide file tree
Showing 9 changed files with 526 additions and 334 deletions.
84 changes: 84 additions & 0 deletions db/00139/AddMiscellaneousTrialType.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env perl


=head1 NAME
AddMiscellaneousTrialType
=head1 SYNOPSIS
mx-run ThisPackageName [options] -H hostname -D dbname -u username [-F]
this is a subclass of L<CXGN::Metadata::Dbpatch>
see the perldoc of parent class for more details.
=head1 DESCRIPTION
This patch add a sytem cvterm that is used to store miscellaneous trial types for trials.
This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
=head1 AUTHOR
Chris Tucker<[email protected]>
=head1 COPYRIGHT & LICENSE
Copyright 2010 Boyce Thompson Institute for Plant Research
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=cut


package AddMiscellaneousTrialType;

use Moose;
use Try::Tiny;
use Bio::Chado::Schema;

extends 'CXGN::Metadata::Dbpatch';


has '+description' => ( default => <<'' );
This patch add a sytem cvterm that is used to store miscellaneous trial types for trials.
has '+prereq' => (
default => sub {
[],
},
);

sub patch {
my $self=shift;

print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
print STDOUT "\nExecuting the SQL commands.\n";

my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } );

my $coderef = sub {

my $new_cvterm = $schema->resultset("Cv::Cvterm")->create_with(
{
name => 'misc_trial',
definition => 'A trial type that holds any trial type',
cv => 'project_type',
});
};

try {
$schema->txn_do($coderef);

} catch {
die "Load failed! " . $_ . "\n" ;
};

print "You're done!\n";
}

####
1; #
####
2 changes: 1 addition & 1 deletion lib/CXGN/BrAPI/v2/ObservationUnits.pm
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ sub observationunits_store {
my $project = $self->bcs_schema->resultset("Project::Project")->find( { project_id => $trial_id });
my $design_prop = $project->projectprops->find( { 'type.name' => 'design' },{ join => 'type'}); #there should be only one design prop.
if (!$design_prop) {
return CXGN::BrAPI::JSONResponse->return_error($self->status, sprintf('Study doe not have a proper Study type.'));
return CXGN::BrAPI::JSONResponse->return_error($self->status, sprintf('Study does not have a proper Study type.'));
}
my $design_type = $design_prop->value;

Expand Down
Loading

0 comments on commit 2204960

Please sign in to comment.