[open-ils-commits] r17718 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Sep 15 22:26:00 EDT 2010
Author: miker
Date: 2010-09-15 22:25:57 -0400 (Wed, 15 Sep 2010)
New Revision: 17718
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
Log:
teach open-ils.storage.serial.issuance.ranged_tree about "global" issuances
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm 2010-09-16 01:52:51 UTC (rev 17717)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/asset.pm 2010-09-16 02:25:57 UTC (rev 17718)
@@ -799,51 +799,64 @@
# XXX Since this is all we need in open-ils.storage for serial stuff ATM, just
# XXX putting it here instead of creating a whole new file.
sub issuance_ranged_tree {
- my $self = shift;
- my $client = shift;
- my $iss = shift;
- my $ou = shift;
- my $depth = shift || 0;
+ my $self = shift;
+ my $client = shift;
+ my $iss = shift;
+ my $ou = shift;
+ my $depth = shift || 0;
- my $ou_list =
- actor::org_unit
- ->db_Main
- ->selectcol_arrayref(
- 'SELECT id FROM actor.org_unit_descendants(?,?)',
- {},
- $ou,
- $depth
- );
+ my $ou_list =
+ actor::org_unit
+ ->db_Main
+ ->selectcol_arrayref(
+ 'SELECT id FROM actor.org_unit_descendants(?,?)',
+ {},
+ $ou,
+ $depth
+ );
- return undef unless ($ou_list and @$ou_list);
+ return undef unless ($ou_list and @$ou_list);
- $iss = serial::issuance->retrieve( $iss );
- return undef unless ($iss);
+ $iss = serial::issuance->retrieve( $iss );
+ return undef unless ($iss);
- my $issuance = $iss->to_fieldmapper;
- $issuance->items([]);
+ my $issuance = $iss->to_fieldmapper;
+ $issuance->items([]);
- for my $it ( $iss->items() ) {
- my $item = $it->to_fieldmapper;
+ # Now, gather issuances on the same bib, with the same label and date_published ...
+ my @subs = map { $_->id } serial::subscription->search( record_entry => $iss->subscription->record_entry->id );
- next if ($it->unit->deleted);
- next unless (grep { $it->unit->circ_lib eq $_ } @$ou_list);
+ my @similar_iss = serial::issuance->search_where(
+ subscription => \@subs,
+ label => $iss->label,
+ date_published => $iss->date_published
+ );
- my $unit = $it->unit->to_fieldmapper;
- $unit->status( $it->unit->status->to_fieldmapper );
- $unit->location( $it->unit->location->to_fieldmapper );
- $item->unit( $unit );
+ # ... and add all /their/ items to the target issuance
+ for my $i ( @similar_iss ) {
+ for my $it ( $i->items() ) {
+
+ next if ($it->unit->deleted);
+ next unless (grep { $it->unit->circ_lib eq $_ } @$ou_list);
+
+ my $unit = $it->unit->to_fieldmapper;
+ $unit->status( $it->unit->status->to_fieldmapper );
+ $unit->location( $it->unit->location->to_fieldmapper );
- push @{ $issuance->items }, $item;
- }
+ my $item = $it->to_fieldmapper;
+ $item->unit( $unit );
+
+ push @{ $issuance->items }, $item;
+ }
+ }
- return $issuance;
+ return $issuance;
}
__PACKAGE__->register_method(
- api_name => 'open-ils.storage.serial.issuance.ranged_tree',
- method => 'issuance_ranged_tree',
- argc => 1,
- api_level => 1,
+ api_name => 'open-ils.storage.serial.issuance.ranged_tree',
+ method => 'issuance_ranged_tree',
+ argc => 1,
+ api_level => 1,
);
sub merge_record_assets {
More information about the open-ils-commits
mailing list