Lines 20-25
use Try::Tiny;
Link Here
|
20 |
|
20 |
|
21 |
use base 'Koha::BackgroundJob'; |
21 |
use base 'Koha::BackgroundJob'; |
22 |
|
22 |
|
|
|
23 |
use Koha::Database; |
23 |
use C4::Matcher; |
24 |
use C4::Matcher; |
24 |
use C4::ImportBatch qw( |
25 |
use C4::ImportBatch qw( |
25 |
RecordsFromMARCXMLFile |
26 |
RecordsFromMARCXMLFile |
Lines 87-94
sub process {
Link Here
|
87 |
my $matcher_failed = 0; |
88 |
my $matcher_failed = 0; |
88 |
my $matcher_code = ""; |
89 |
my $matcher_code = ""; |
89 |
|
90 |
|
|
|
91 |
my $schema = Koha::Database->new->schema; |
90 |
try { |
92 |
try { |
91 |
my $schema = Koha::Database->new->schema; |
|
|
92 |
$schema->storage->txn_begin; |
93 |
$schema->storage->txn_begin; |
93 |
|
94 |
|
94 |
my ( $errors, $marcrecords ); |
95 |
my ( $errors, $marcrecords ); |
Lines 110-117
sub process {
Link Here
|
110 |
|
111 |
|
111 |
$self->size(scalar @$marcrecords)->store; |
112 |
$self->size(scalar @$marcrecords)->store; |
112 |
|
113 |
|
113 |
( $batch_id, $num_valid, $num_items, @import_errors ) = |
114 |
( $batch_id, $num_valid, $num_items, @import_errors ) = BatchStageMarcRecords( |
114 |
BatchStageMarcRecords( |
|
|
115 |
$record_type, $encoding, |
115 |
$record_type, $encoding, |
116 |
$marcrecords, $filename, |
116 |
$marcrecords, $filename, |
117 |
$marc_modification_template, $comments, |
117 |
$marc_modification_template, $comments, |
Lines 123-130
sub process {
Link Here
|
123 |
$job_progress /= 2; |
123 |
$job_progress /= 2; |
124 |
} |
124 |
} |
125 |
$self->progress( int($job_progress) )->store; |
125 |
$self->progress( int($job_progress) )->store; |
126 |
} |
126 |
} |
127 |
); |
127 |
); |
|
|
128 |
if( $num_valid ) { |
129 |
$self->set({ progress => $num_valid, size => $num_valid }); |
130 |
} else { # We must assume that something went wrong here |
131 |
$self->set({ progress => 0, status => 'failed' }); |
132 |
} |
128 |
|
133 |
|
129 |
if ($profile_id) { |
134 |
if ($profile_id) { |
130 |
my $ibatch = Koha::ImportBatches->find($batch_id); |
135 |
my $ibatch = Koha::ImportBatches->find($batch_id); |
Lines 155-162
sub process {
Link Here
|
155 |
} |
160 |
} |
156 |
catch { |
161 |
catch { |
157 |
warn $_; |
162 |
warn $_; |
|
|
163 |
$schema->storage->txn_rollback; |
158 |
die "Something terrible has happened!" |
164 |
die "Something terrible has happened!" |
159 |
if ( $_ =~ /Rollback failed/ ); # Rollback failed |
165 |
if ( $_ =~ /Rollback failed/ ); # TODO Check test: Rollback failed |
|
|
166 |
$self->set({ progress => 0, status => 'failed' }); |
160 |
}; |
167 |
}; |
161 |
|
168 |
|
162 |
my $report = { |
169 |
my $report = { |
Lines 190-197
sub enqueue {
Link Here
|
190 |
my ( $self, $args) = @_; |
197 |
my ( $self, $args) = @_; |
191 |
|
198 |
|
192 |
$self->SUPER::enqueue({ |
199 |
$self->SUPER::enqueue({ |
193 |
job_size => 0, # unknown for now |
200 |
job_size => 0, # TODO Unknown for now? |
194 |
job_args => $args |
201 |
job_args => $args, |
195 |
}); |
202 |
}); |
196 |
} |
203 |
} |
197 |
|
204 |
|
198 |
- |
|
|