1 # This file has been auto-generated only because it didn't exist.
2 # Feel free to modify it at will; it will not be overwritten automatically.
4 package SL::DB::CsvImportReport;
9 use SL::DB::MetaSetup::CsvImportReport;
10 use SL::DB::Manager::CsvImportReport;
12 __PACKAGE__->meta->add_relationships(
14 type => 'one to many',
15 class => 'SL::DB::CsvImportReportRow',
16 column_map => { id => 'csv_import_report_id' },
19 type => 'one to many',
20 class => 'SL::DB::CsvImportReportStatus',
21 column_map => { id => 'csv_import_report_id' },
25 __PACKAGE__->meta->initialize;
28 my ($self, %params) = @_;
32 for my $row_obj (@{ $params{rows} || $self->rows }) {
33 $folded_rows->{ $row_obj->row } ||= [];
34 $folded_rows->{ $row_obj->row }[ $row_obj->col ] = $row_obj->value;
41 my ($self, %params) = @_;
43 my $folded_status = {};
45 for my $status_obj (@{ $params{status} || $self->status }) {
46 $folded_status->{ $status_obj->row } ||= {};
47 $folded_status->{ $status_obj->row }{information} ||= [];
48 $folded_status->{ $status_obj->row }{errors} ||= [];
49 push @{ $folded_status->{ $status_obj->row }{ $status_obj->type } }, $status_obj->value;
55 # implementes cascade delete as per documentation
59 my $dbh = $self->db->dbh;
63 do_query($::form, $dbh, 'DELETE FROM csv_import_report_status WHERE csv_import_report_id = ?', $self->id);
64 do_query($::form, $dbh, 'DELETE FROM csv_import_report_rows WHERE csv_import_report_id = ?', $self->id);
65 do_query($::form, $dbh, 'DELETE FROM csv_import_reports WHERE id = ?', $self->id);
67 if ($self->profile_id) {
68 do_query($::form, $dbh, 'DELETE FROM csv_import_profile_settings WHERE csv_import_profile_id = ?', $self->profile_id);
69 do_query($::form, $dbh, 'DELETE FROM csv_import_profiles WHERE id = ?', $self->profile_id);