6 FixDroneImageryPartialTemplates
10 mx-run FixDroneImageryPartialTemplates [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.
16 This patch fixes the drone imagery partial template storage info to contain a template name and the image_id.
17 This subclass uses L<Moose>. The parent class uses L<MooseX::Runnable>
22 =head1 COPYRIGHT & LICENSE
24 Copyright 2010 Boyce Thompson Institute for Plant Research
26 This program is free software; you can redistribute it and/or modify
27 it under the same terms as Perl itself.
32 package FixDroneImageryPartialTemplates
;
35 use Bio
::Chado
::Schema
;
36 use CXGN
::People
::Schema
;
38 use CXGN
::Genotype
::Search
;
40 extends
'CXGN::Metadata::Dbpatch';
43 has
'+description' => ( default => <<'' );
44 This patch fixes the drone imagery partial template storage info to contain a template name
and the image_id
.
56 print STDOUT
"Executing the patch:\n " . $self->name . ".\n\nDescription:\n ". $self->description . ".\n\nExecuted by:\n " . $self->username . " .";
58 print STDOUT
"\nChecking if this db_patch was executed before or if previous db_patches have been executed.\n";
60 print STDOUT
"\nExecuting the SQL commands.\n";
61 my $schema = Bio
::Chado
::Schema
->connect( sub { $self->dbh->clone } );
62 my $people_schema = CXGN
::People
::Schema
->connect( sub { $self->dbh->clone } );
64 my $manual_plot_polygon_template_partial = SGN
::Model
::Cvterm
->get_cvterm_row($schema, 'drone_run_band_plot_polygons_partial', 'project_property')->cvterm_id();
66 my $previous_plot_polygons_rs = $schema->resultset('Project::Projectprop')->search({type_id
=>$manual_plot_polygon_template_partial});
68 while (my $p = $previous_plot_polygons_rs->next) {
69 my @previous_stock_polygons = @
{decode_json
$p->value};
70 my @new_stock_polygons;
71 foreach (@previous_stock_polygons) {
72 push @new_stock_polygons, {
73 template_name
=> "NA",
79 my $drone_run_band_plot_polygons = $schema->resultset('Project::Projectprop')->update_or_create({
80 type_id
=>$manual_plot_polygon_template_partial,
81 project_id
=>$p->project_id(),
83 value
=> encode_json
(\
@new_stock_polygons)
90 print "You're done!\n";