1 package SL::BackgroundJob::CsvImport;
5 use parent qw(SL::BackgroundJob::Base);
8 use SL::DB::CsvImportProfile;
9 use SL::SessionFile::Random;
12 my ($self_or_class, %params) = @_;
14 my $package = ref($self_or_class) || $self_or_class;
15 $package =~ s/SL::BackgroundJob:://;
17 my $profile = delete $params{profile} || SL::DB::CsvImportProfile->new;
18 my $result = delete $params{result} || SL::SessionFile::Random->new;
21 profile => { $profile->flatten },
22 result => $result->file_name,
26 my $job = SL::DB::BackgroundJob->new(
29 package_name => $package,
30 data => YAML::Dump(\%data),
37 my ($self, $db_obj) = @_;
39 if (!$self->{profile}) {
40 $self->{profile} = SL::DB::CsvImportProfile->new;
41 my $data = YAML::Load($db_obj->data);
43 $self->{profile}->set($_ => $data->{$_});
47 return $self->{profile};
52 $self->{db_obj} = shift;
62 my $c = SL::Controller::CsvImport->new;
63 $c->profile($self->{profile});
64 $c->test_and_import(test => $self->);
81 SL::Background::CsvImport - backend for automatic imports of csv data
86 use SL::BackgroundJob::CsvImport;
89 From a controller or external source:
91 my $job = SL::BackgroundJob::CsvImport->create_job(
104 Sven Schoeling E<lt>s.schoeling@linet-services.deE<gt>