[open-ils-commits] r17612 - trunk/Open-ILS/src/perlmods/OpenILS/Application (senator)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Sep 12 14:32:38 EDT 2010
Author: senator
Date: 2010-09-12 14:32:33 -0400 (Sun, 12 Sep 2010)
New Revision: 17612
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
Log:
Serials: make it possible to predict issues for all dists at once, not just one
Also return events on failure in a few more places to gives users better clues
when things go wrong. More work is still ahead on this.
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm 2010-09-12 15:55:22 UTC (rev 17611)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Serial.pm 2010-09-12 18:32:33 UTC (rev 17612)
@@ -614,13 +614,39 @@
my $editor = OpenILS::Utils::CStoreEditor->new();
my $ssub_id = $args->{ssub_id};
+ my $all_dists = $args->{all_dists};
my $mfhd = MFHD->new(MARC::Record->new());
my $ssub = $editor->retrieve_serial_subscription([$ssub_id]);
my $scaps = $editor->search_serial_caption_and_pattern({ subscription => $ssub_id, active => 't'});
my $sdists = $editor->search_serial_distribution( [{ subscription => $ssub->id }, { flesh => 1,
- flesh_fields => {sdist => [ qw/ streams / ]}, limit => 1 }] ); #TODO: 'deleted' support?
+ flesh_fields => {sdist => [ qw/ streams / ]}, $all_dists ? () : (limit => 1) }] ); #TODO: 'deleted' support?
+ if ($all_dists) {
+ my $total_streams = 0;
+ foreach (@$sdists) {
+ $total_streams += scalar(@{$_->streams});
+ }
+ if ($total_streams < 1) {
+ $editor->disconnect;
+ # XXX TODO new event type
+ return new OpenILS::Event(
+ "BAD_PARAMS", note =>
+ "There are no streams to direct items. Can't predict."
+ );
+ }
+ }
+
+ unless (@$scaps) {
+ $editor->disconnect;
+ # XXX TODO new event type
+ return new OpenILS::Event(
+ "BAD_PARAMS", note =>
+ "There are no active caption-and-pattern objects associated " .
+ "with this subscription. Can't predict."
+ );
+ }
+
my @predictions;
my $link_id = 1;
foreach my $scap (@$scaps) {
@@ -644,9 +670,21 @@
);
if ($last_published->[0]) {
my $last_siss = $last_published->[0];
+ unless ($last_siss->holding_code) {
+ $editor->disconnect;
+ # XXX TODO new event type
+ return new OpenILS::Event(
+ "BAD_PARAMS", note =>
+ "Last issuance has no holding code. Can't predict."
+ );
+ }
$options->{predict_from} = _revive_holding($last_siss->holding_code, $caption_field, 1);
} else {
- #TODO: throw event (can't predict from nothing!)
+ $editor->disconnect;
+ # XXX TODO make a new event type instead of hijacking this one
+ return new OpenILS::Event(
+ "BAD_PARAMS", note => "No issuance from which to predict!"
+ );
}
}
push( @predictions, _generate_issuance_values($mfhd, $options) );
More information about the open-ils-commits
mailing list