2 package CXGN
::Trial
::Download
;
6 use Moose
::Util
::TypeConstraints
;
8 use File
::Basename qw
| basename dirname
|;
10 use CXGN
::List
::Validate
;
13 use CXGN
::Trial
::TrialLayout
;
14 use Spreadsheet
::WriteExcel
;
16 use CXGN
::List
::Transform
;
17 use CXGN
::People
::Person
;
20 with
'MooseX::Object::Pluggable';
24 isa
=> "Bio::Chado::Schema",
38 isa
=> 'DBIx::Class::Schema',
42 # can be provided for logging purposes
48 has
'trial_download_logfile' => (
53 ## defines the plugin with which the download will be processed
54 has
'format' => (isa
=> 'Str', is
=> 'ro', required
=> 1);
56 has
'data_level' => (isa
=> 'Str | Undef', is
=> 'ro', default => 'plots');
58 has
'sample_number' => (isa
=> 'Int | Undef', is
=> 'ro', default => 0);
60 has
'predefined_columns' => (isa
=> 'ArrayRef[HashRef] | Undef', is
=> 'ro');
62 has
'trait_list' => (isa
=> 'ArrayRef', is
=> 'rw', predicate
=> 'has_trait_list' );
64 has
'filename' => (isa
=> 'Str', is
=> 'ro',
65 predicate
=> 'has_filename',
69 has
'file_metadata' => (isa
=> 'Str', is
=> 'rw', predicate
=> 'has_file_metadata');
71 ## used when downloading phenotypes as either csv or xls.
72 has
'include_timestamp' => (isa
=> 'Bool', is
=> 'ro', default => 0);
77 $self->load_plugin($self->format());
83 # $self->load_plugin($self->format());
85 # return $self->plugin_verify();
91 # print STDERR "Format: ".$self->format()."\n";
93 # $self->load_plugin($self->format());
96 # die "The plugin specified (".$self->format().") for the download does not exist";
99 # my $error = $self->plugin_download();
104 sub trial_download_log
{
106 my $trial_id = shift;
109 if (! $self->user_id && !$self->trial_download_logfile()) {
113 print STDERR
"Note: set config variable trial_download_logfile to obtain a log of downloaded trials.\n";
116 my $now = DateTime
->now();
118 open (my $F, ">>", $self->trial_download_logfile()) || die "Can't open ".$self->trial_download_logfile();
119 my $username = CXGN
::People
::Person
->new($self->bcs_schema->storage->dbh(), $self->user_id())->get_username();
120 print $F join("\t", (
124 $now->year()."-".$now->month()."-".$now->day()." ".$now->hour().":".$now->minute()));