X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FCsvImportReport.pm;h=b3cdf3bf348f6fdd57696df0e2eda65e1c7afd40;hb=0e75a632271124a628dd600cb7eac739b595144d;hp=1271c56ae84515649ccd7b95e8dc22237f5550f5;hpb=5d74fd02daea21f5802cb4b5089408dd3bcc2031;p=kivitendo-erp.git diff --git a/SL/DB/CsvImportReport.pm b/SL/DB/CsvImportReport.pm index 1271c56ae..b3cdf3bf3 100644 --- a/SL/DB/CsvImportReport.pm +++ b/SL/DB/CsvImportReport.pm @@ -7,6 +7,7 @@ use strict; use SL::DBUtils; use SL::DB::MetaSetup::CsvImportReport; +use SL::DB::Manager::CsvImportReport; __PACKAGE__->meta->add_relationships( rows => { @@ -21,47 +22,34 @@ __PACKAGE__->meta->add_relationships( }, ); -__PACKAGE__->meta->make_manager_class; __PACKAGE__->meta->initialize; sub folded_rows { - my ($self) = @_; - - $self->_fold_rows unless $self->{folded_rows}; + my ($self, %params) = @_; - return $self->{folded_rows}; -} + my $folded_rows = {}; -sub folded_status { - my ($self) = @_; - - $self->_fold_status unless $self->{folded_status}; + for my $row_obj (@{ $params{rows} || $self->rows }) { + $folded_rows->{ $row_obj->row } ||= []; + $folded_rows->{ $row_obj->row }[ $row_obj->col ] = $row_obj->value; + } - return $self->{folded_status}; + $folded_rows; } -sub _fold_rows { - my ($self) = @_; +sub folded_status { + my ($self, %params) = @_; - $self->{folded_rows} = []; + my $folded_status = {}; - for my $row_obj (@{ $self->rows }) { - $self->{folded_rows}->[ $row_obj->row ] ||= []; - $self->{folded_rows}->[ $row_obj->row ][ $row_obj->col ] = $row_obj->value; + for my $status_obj (@{ $params{status} || $self->status }) { + $folded_status->{ $status_obj->row } ||= {}; + $folded_status->{ $status_obj->row }{information} ||= []; + $folded_status->{ $status_obj->row }{errors} ||= []; + push @{ $folded_status->{ $status_obj->row }{ $status_obj->type } }, $status_obj->value; } -} -sub _fold_status { - my ($self) = @_; - - $self->{folded_status} = []; - - for my $status_obj (@{ $self->status }) { - $self->{folded_status}->[ $status_obj->row ] ||= {}; - $self->{folded_status}->[ $status_obj->row ]{information} ||= []; - $self->{folded_status}->[ $status_obj->row ]{errors} ||= []; - push @{ $self->{folded_status}->[ $status_obj->row ]{ $status_obj->type } }, $status_obj->value; - } + $folded_status; } # implementes cascade delete as per documentation