View | Details | Raw Unified | Return to bug 29149
Collapse All | Expand All

(-)a/Koha/BackgroundJob.pm (-10 / +30 lines)
Lines 228-247 sub cancel { Link Here
228
    $self->status('cancelled')->store;
228
    $self->status('cancelled')->store;
229
}
229
}
230
230
231
=head2 Internal methods
232
233
=head3 _derived_class
234
235
=cut
236
231
sub _derived_class {
237
sub _derived_class {
232
    my ( $self ) = @_;
238
    my ( $self ) = @_;
233
    my $job_type = $self->type;
239
    my $job_type = $self->type;
234
    return $job_type eq 'batch_biblio_record_modification'
240
235
      ? Koha::BackgroundJob::BatchUpdateBiblio->new
241
    my $class = $self->type_to_class_mapping->{$job_type};
236
      : $job_type eq 'batch_authority_record_modification'
242
237
      ? Koha::BackgroundJob::BatchUpdateAuthority->new
243
    Koha::Exceptions::Exception->throw($job_type . ' is not a valid job_type')
238
      : $job_type eq 'batch_biblio_record_deletion'
244
        unless $class;
239
      ? Koha::BackgroundJob::BatchDeleteBiblio->new
245
240
      : $job_type eq 'batch_authority_record_deletion'
246
    return $class->new;
241
      ? Koha::BackgroundJob::BatchDeleteAuthority->new
247
}
242
      : Koha::Exceptions::Exception->throw($job_type . ' is not a valid job_type')
248
249
=head3 type_to_class_mapping
250
251
=cut
252
253
sub type_to_class_mapping {
254
    return {
255
        batch_authority_record_deletion     => 'Koha::BackgroundJob::BatchDeleteAuthority',
256
        batch_authority_record_modification => 'Koha::BackgroundJob::BatchUpdateAuthority',
257
        batch_biblio_record_deletion        => 'Koha::BackgroundJob::BatchDeleteBiblio',
258
        batch_biblio_record_modification    => 'Koha::BackgroundJob::BatchUpdateBiblio',
259
    };
243
}
260
}
244
261
262
=head3 _type
263
264
=cut
265
245
sub _type {
266
sub _type {
246
    return 'BackgroundJob';
267
    return 'BackgroundJob';
247
}
268
}
248
- 

Return to bug 29149