-
Notifications
You must be signed in to change notification settings - Fork 36
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
15 changed files
with
815 additions
and
34 deletions.
There are no files selected for viewing
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,74 @@ | ||
#!/usr/bin/env perl | ||
|
||
|
||
=head1 NAME | ||
AddDiscardedMetadataCvterm | ||
=head1 SYNOPSIS | ||
mx-run AddDiscardedMetadataCvterm [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 adds discarded_metadata stock_property cvterm | ||
This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable> | ||
=head1 AUTHOR | ||
Titima Tantikanjana <[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 AddDiscardedMetadataCvterm; | ||
|
||
use Moose; | ||
use Bio::Chado::Schema; | ||
use Try::Tiny; | ||
extends 'CXGN::Metadata::Dbpatch'; | ||
|
||
|
||
has '+description' => ( default => <<'' ); | ||
This patch adds the 'discarded_metadata' stock_property cvterm | ||
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 } ); | ||
|
||
print STDERR "INSERTING CV TERMS...\n"; | ||
|
||
$schema->resultset("Cv::Cvterm")->create_with({ | ||
name => 'discarded_metadata', | ||
cv => 'stock_property' | ||
}); | ||
|
||
print "You're done!\n"; | ||
} | ||
|
||
|
||
#### | ||
1; # | ||
#### |
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
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,75 @@ | ||
|
||
package CXGN::Stock::Seedlot::Discard; | ||
|
||
=head1 NAME | ||
CXGN::Stock::Seedlot::Discard | ||
=head1 DESCRIPTION | ||
Store and manage discarded seedlot metadata | ||
=head1 USAGE | ||
=head1 AUTHOR | ||
Titima Tantikanjana <[email protected]> | ||
=cut | ||
|
||
|
||
use Moose; | ||
use Data::Dumper; | ||
|
||
|
||
extends 'CXGN::JSONProp'; | ||
|
||
has 'person_id' => (isa => 'Int', is => 'rw'); | ||
has 'discard_date' => (isa => 'Str', is => 'rw'); | ||
has 'reason' => (isa => 'Str', is => 'rw'); | ||
|
||
|
||
sub BUILD { | ||
my $self = shift; | ||
my $args = shift; | ||
|
||
$self->prop_table('stockprop'); | ||
$self->prop_namespace('Stock::Stockprop'); | ||
$self->prop_primary_key('stockprop_id'); | ||
$self->prop_type('discarded_metadata'); | ||
$self->cv_name('stock_property'); | ||
$self->allowed_fields([ qw | person_id discard_date reason | ]); | ||
$self->parent_table('stock'); | ||
$self->parent_primary_key('stock_id'); | ||
|
||
$self->load(); | ||
} | ||
|
||
|
||
sub get_discard_details { | ||
my $self = shift; | ||
my $args = shift; | ||
my $schema = $self->bcs_schema(); | ||
my $seedlot_id = $self->parent_id(); | ||
my $type = $self->prop_type(); | ||
my $type_id = $self->_prop_type_id(); | ||
my $key_ref = $self->allowed_fields(); | ||
my @fields = @$key_ref; | ||
my @discard_details; | ||
my $discard_details_rs = $schema->resultset("Stock::Stockprop")->find({stock_id => $seedlot_id, type_id => $type_id}); | ||
if ($discard_details_rs) { | ||
my $details_json = $discard_details_rs->value(); | ||
my $detail_hash = JSON::Any->jsonToObj($details_json); | ||
foreach my $field (@fields){ | ||
push @discard_details, $detail_hash->{$field}; | ||
} | ||
print STDERR "DISCARDED DETAILS =".Dumper(\@discard_details)."\n"; | ||
} | ||
|
||
return \@discard_details; | ||
} | ||
|
||
|
||
|
||
1; |
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
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
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
Oops, something went wrong.