fix typo.
[sgn.git] / db / 00084 / AddTreatmentCvterms.pm
blob5295fdfcbd0bd26fb3b6f20baa9ae3ea6ccaf737
1 #!/usr/bin/env perl
4 =head1 NAME
6 AddTreatmentCvterms.pm
8 =head1 SYNOPSIS
10 mx-run ThisPackageName [options] -H hostname -D dbname -u username [-F]
12 this is a subclass of L<CXGN::Metadata::Dbpatch>
13 see the perldoc of parent class for more details.
15 =head1 DESCRIPTION
16 This patch adds the necessary cvterms that are used for storing grafted stocks,
17 rootstock-scion stock_relationship, grafting_experiment ,and missing project types
20 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
22 =head1 AUTHOR
24 <nm529@cornell.edu>
26 =head1 COPYRIGHT & LICENSE
28 Copyright 2010 Boyce Thompson Institute for Plant Research
30 This program is free software; you can redistribute it and/or modify
31 it under the same terms as Perl itself.
33 =cut
36 package AddTreatmentCvterms;
38 use Moose;
39 use Bio::Chado::Schema;
40 use Try::Tiny;
41 extends 'CXGN::Metadata::Dbpatch';
44 has '+description' => ( default => <<'' );
45 Add missing cvterms for storing grafted stocks, and grafting experiments or projects
47 has '+prereq' => (
48 default => sub {
49 [],
54 sub patch {
55 my $self=shift;
57 print STDOUT "Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
59 print STDOUT "\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
61 print STDOUT "\nExecuting the SQL commands.\n";
62 my $schema = Bio::Chado::Schema->connect( sub { $self->dbh->clone } );
65 print STDERR "INSERTING CVTERMS...\n";
67 my $terms = {
68 'experiment_type' => [
69 'treatment_experiment',
71 'project_relationship' => [
72 'trial_treatment_relationship'
76 foreach my $t (keys %$terms){
77 foreach (@{$terms->{$t}}){
78 $schema->resultset("Cv::Cvterm")->create_with({
79 name => $_,
80 cv => $t
81 });
86 print "You're done!\n";
90 ####
91 1; #
92 ####