return 1 unless ref $issuances;
my( $reqr, $evt ) = $U->checkses($auth);
return $evt if $evt;
- my $editor = new_editor(requestor => $reqr, xact => 1);
+ my $editor = new_editor(authtoken => $auth, requestor => $reqr, xact => 1);
my $override = $self->api_name =~ /override/;
my %found_ssub_ids;
_cleanse_dates($issuance, ['date_published']);
$evt = _update_siss( $editor, $override, $issuance );
}
+
+ last if $evt;
}
if( $evt ) {
sub _prepare_summaries {
my ($e, $issuances, $sdist, $type) = @_;
- my ($mfhd, $formatted_parts) = _summarize_contents($e, $issuances, $sdist);
+ my ($mfhd, $formatted_parts) = _summarize_contents($e, $issuances, $sdist, $type);
return $mfhd if $U->event_code($mfhd);
my $search_method = "search_serial_${type}_summary";
$cu_method = "create";
}
- $summary->generated_coverage(OpenSRF::Utils::JSON->perl2JSON($formatted_parts));
+ if (@$formatted_parts) {
+ $summary->generated_coverage(OpenSRF::Utils::JSON->perl2JSON($formatted_parts));
+ } else {
+ # we had no issuances or MFHD data for this type, so clear any
+ # generated data which may have existed before
+ $summary->generated_coverage('');
+ }
my $method = "${cu_method}_serial_${type}_summary";
return $e->die_event unless $e->$method($summary);
}
my $editor = shift;
my $issuances = shift;
my $sdist = shift;
+ my $type = shift;
# create or lookup MFHD record
my $mfhd;
}
my @formatted_parts;
- my @scap_fields_ordered = $mfhd->field('85[345]');
+ my @scap_fields_ordered = $mfhd->field($MFHD_TAGS_BY_NAME{$type});
foreach my $scap_field (@scap_fields_ordered) { #TODO: use generic MFHD "summarize" method, once available
my @updated_holdings;