Lines 152-167
Process the job!
Link Here
|
152 |
sub process { |
152 |
sub process { |
153 |
my ( $self, $args ) = @_; |
153 |
my ( $self, $args ) = @_; |
154 |
|
154 |
|
155 |
my $job_type = $self->type; |
155 |
return {} if ref($self) ne 'Koha::BackgroundJob'; |
156 |
return $job_type eq 'batch_biblio_record_modification' |
156 |
|
157 |
? Koha::BackgroundJob::BatchUpdateBiblio->process($args) |
157 |
my $derived_class = $self->_derived_class; |
158 |
: $job_type eq 'batch_authority_record_modification' |
158 |
|
159 |
? Koha::BackgroundJob::BatchUpdateAuthority->process($args) |
159 |
$args ||= {}; |
160 |
: $job_type eq 'batch_biblio_record_deletion' |
160 |
|
161 |
? Koha::BackgroundJob::BatchDeleteBiblio->process($args) |
161 |
return $derived_class->process({job_id => $self->id, %$args}); |
162 |
: $job_type eq 'batch_authority_record_deletion' |
162 |
|
163 |
? Koha::BackgroundJob::BatchDeleteAuthority->process($args) |
|
|
164 |
: Koha::Exceptions::Exception->throw('->process called without valid job_type'); |
165 |
} |
163 |
} |
166 |
|
164 |
|
167 |
=head3 job_type |
165 |
=head3 job_type |
Lines 203-208
sub report {
Link Here
|
203 |
return $data_dump->{report}; |
201 |
return $data_dump->{report}; |
204 |
} |
202 |
} |
205 |
|
203 |
|
|
|
204 |
=head3 additional_report |
205 |
|
206 |
Build additional variables for the job detail view. |
207 |
|
208 |
=cut |
209 |
|
210 |
sub additional_report { |
211 |
my ( $self ) = @_; |
212 |
|
213 |
return {} if ref($self) ne 'Koha::BackgroundJob'; |
214 |
|
215 |
my $derived_class = $self->_derived_class; |
216 |
|
217 |
return $derived_class->additional_report({job_id => $self->id}); |
218 |
} |
219 |
|
206 |
=head3 cancel |
220 |
=head3 cancel |
207 |
|
221 |
|
208 |
Cancel a job. |
222 |
Cancel a job. |
Lines 214-219
sub cancel {
Link Here
|
214 |
$self->status('cancelled')->store; |
228 |
$self->status('cancelled')->store; |
215 |
} |
229 |
} |
216 |
|
230 |
|
|
|
231 |
sub _derived_class { |
232 |
my ( $self ) = @_; |
233 |
my $job_type = $self->type; |
234 |
return $job_type eq 'batch_biblio_record_modification' |
235 |
? Koha::BackgroundJob::BatchUpdateBiblio->new |
236 |
: $job_type eq 'batch_authority_record_modification' |
237 |
? Koha::BackgroundJob::BatchUpdateAuthority->new |
238 |
: $job_type eq 'batch_biblio_record_deletion' |
239 |
? Koha::BackgroundJob::BatchDeleteBiblio->new |
240 |
: $job_type eq 'batch_authority_record_deletion' |
241 |
? Koha::BackgroundJob::BatchDeleteAuthority->new |
242 |
: Koha::Exceptions::Exception->throw($job_type . ' is not a valid job_type') |
243 |
} |
244 |
|
217 |
sub _type { |
245 |
sub _type { |
218 |
return 'BackgroundJob'; |
246 |
return 'BackgroundJob'; |
219 |
} |
247 |
} |