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;
11 __PACKAGE__->meta->add_relationships(
13 type => 'one to many',
14 class => 'SL::DB::CsvImportReportRow',
15 column_map => { id => 'csv_import_report_id' },
18 type => 'one to many',
19 class => 'SL::DB::CsvImportReportStatus',
20 column_map => { id => 'csv_import_report_id' },
24 __PACKAGE__->meta->make_manager_class;
25 __PACKAGE__->meta->initialize;
30 $self->_fold_rows unless $self->{folded_rows};
32 return $self->{folded_rows};
38 $self->_fold_status unless $self->{folded_status};
40 return $self->{folded_status};
46 $self->{folded_rows} = [];
48 for my $row_obj (@{ $self->rows }) {
49 $self->{folded_rows}->[ $row_obj->row ] ||= [];
50 $self->{folded_rows}->[ $row_obj->row ][ $row_obj->col ] = $row_obj->value;
57 $self->{folded_status} = [];
59 for my $status_obj (@{ $self->status }) {
60 $self->{folded_status}->[ $status_obj->row ] ||= {};
61 $self->{folded_status}->[ $status_obj->row ]{information} ||= [];
62 $self->{folded_status}->[ $status_obj->row ]{errors} ||= [];
63 push @{ $self->{folded_status}->[ $status_obj->row ]{ $status_obj->type } }, $status_obj->value;
67 # implementes cascade delete as per documentation
71 my $dbh = $self->db->dbh;
75 do_query($::form, $dbh, 'DELETE FROM csv_import_report_status WHERE csv_import_report_id = ?', $self->id);
76 do_query($::form, $dbh, 'DELETE FROM csv_import_report_rows WHERE csv_import_report_id = ?', $self->id);
77 do_query($::form, $dbh, 'DELETE FROM csv_import_reports WHERE id = ?', $self->id);
79 if ($self->profile_id) {
80 do_query($::form, $dbh, 'DELETE FROM csv_import_profile_settings WHERE csv_import_profile_id = ?', $self->profile_id);
81 do_query($::form, $dbh, 'DELETE FROM csv_import_profiles WHERE id = ?', $self->profile_id);