Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 80e68986

Von Thomas Heck vor etwa 12 Jahren hinzugefügt

  • ID 80e689862cf717fce069820e64086bbfa80aeaec
  • Vorgänger 8b7b7701
  • Nachfolger 5fa7820b

Controller/CsvImport: file und worker verfügbar machen

Unterschiede anzeigen:

SL/Controller/CsvImport.pm
19 19

  
20 20
use Rose::Object::MakeMethods::Generic
21 21
(
22
 scalar => [ qw(type profile file all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen all_units
23
                import_status errors headers raw_data_headers info_headers data num_imported num_importable displayable_columns) ],
22
 scalar                  => [ qw(type profile file all_profiles all_charsets sep_char all_sep_chars quote_char all_quote_chars escape_char all_escape_chars all_buchungsgruppen all_units
23
                                 import_status errors headers raw_data_headers info_headers data num_imported num_importable displayable_columns file) ],
24
 'scalar --get_set_init' => [ qw(worker) ]
24 25
);
25 26

  
26 27
__PACKAGE__->run_before('check_auth');
......
172 173
    return $self->action_new;
173 174
  }
174 175

  
175
  my $worker = $self->create_worker($file);
176
  $self->file($file);
177

  
178
  my $worker = $self->worker();
179

  
176 180
  $worker->run;
177 181

  
178 182
  $self->num_imported(0);
......
253 257
  return "csv-import-" . $self->type . ".csv";
254 258
}
255 259

  
256
sub create_worker {
257
  my ($self, $file) = @_;
260
sub init_worker {
261
  my $self = shift;
262

  
263
  my @args = (controller => $self);
264

  
265
  if ( $self->file() ) {
266
    push(@args, file => $self->file());
267
  }
258 268

  
259
  return $self->{type} eq 'customers_vendors' ? SL::Controller::CsvImport::CustomerVendor->new(controller => $self, file => $file)
260
       : $self->{type} eq 'contacts'          ? SL::Controller::CsvImport::Contact->new(       controller => $self, file => $file)
261
       : $self->{type} eq 'addresses'         ? SL::Controller::CsvImport::Shipto->new(        controller => $self, file => $file)
262
       : $self->{type} eq 'parts'             ? SL::Controller::CsvImport::Part->new(          controller => $self, file => $file)
263
       : $self->{type} eq 'projects'          ? SL::Controller::CsvImport::Project->new(       controller => $self, file => $file)
269
  return $self->{type} eq 'customers_vendors' ? SL::Controller::CsvImport::CustomerVendor->new(@args)
270
       : $self->{type} eq 'contacts'          ? SL::Controller::CsvImport::Contact->new(@args)
271
       : $self->{type} eq 'addresses'         ? SL::Controller::CsvImport::Shipto->new(@args)
272
       : $self->{type} eq 'parts'             ? SL::Controller::CsvImport::Part->new(@args)
273
       : $self->{type} eq 'projects'          ? SL::Controller::CsvImport::Project->new(@args)
264 274
       :                                        die "Program logic error";
265 275
}
266 276

  
267 277
sub setup_help {
268 278
  my ($self) = @_;
269 279

  
270
  $self->create_worker->setup_displayable_columns;
280
  $self->worker->setup_displayable_columns;
271 281
}
272 282

  
273 283

  

Auch abrufbar als: Unified diff