# flesh and munge the copies
my $fleshed_copies = [];
- my ($copy, $copy_evt);
+ my $copy;
foreach my $copy_id ( @{ $copies } ) {
- ($copy, $copy_evt) = $U->fetch_copy($copy_id);
- return $copy_evt if $copy_evt;
+ $copy = $editor->search_asset_copy([
+ { id => $copy_id , deleted => 'f' },
+ {
+ join => {
+ acpm => {
+ type => 'left',
+ join => {
+ bmp => { type => 'left' }
+ }
+ }
+ },
+ flesh => 1,
+ flesh_fields => { acp => ['parts'] }
+ }
+ ])->[0];
+ return OpenILS::Event->new('ASSET_COPY_NOT_FOUND') if !$copy;
$copy->call_number( $volume );
$copy->circ_lib( $cn->owning_lib() );
$copy->ischanged( 't' );
return $evt;
}
+ # take care of the parts
+ for my $copy (@$fleshed_copies) {
+ my $parts = $copy->parts;
+ next unless $parts;
+ my $part_objs = [];
+ foreach my $part (@$parts) {
+ my $part_label = $part->label;
+ my $part_obj = $editor->search_biblio_monograph_part(
+ {
+ label=>$part_label,
+ record=>$cn->record
+ }
+ )->[0];
+ if (!$part_obj) {
+ $part_obj = Fieldmapper::biblio::monograph_part->new();
+ $part_obj->label( $part_label );
+ $part_obj->record( $cn->record );
+ unless($editor->create_biblio_monograph_part($part_obj)) {
+ return $editor->die_event if $editor->die_event;
+ }
+ }
+ push @$part_objs, $part_obj;
+ }
+ $copy->parts( $part_objs );
+ $copy->ischanged(1);
+ $evt = OpenILS::Application::Cat::AssetCommon->update_copy_parts($editor, $copy, 1); #delete_parts=1
+ return $evt if $evt;
+ }
+
$editor->commit;
$logger->info("copy to volume transfer successfully updated ".scalar(@$copies)." copies");
reset_hold_list($auth, $retarget_holds);
}
}
+ # record the difference between the destination bib and the present bib
+ my $same_bib = $vol->record == $rec;
+
# see if there is a volume at the destination lib that
# already has the requested label
my $existing_vol = $e->search_asset_call_number(
# regardless of what volume was used as the destination,
# update any copies that have moved over to the new lib
- my $copies = $e->search_asset_copy({call_number=>$vol->id, deleted => 'f'});
+ my $copies = $e->search_asset_copy([
+ { call_number => $vol->id , deleted => 'f' },
+ {
+ join => {
+ acpm => {
+ type => 'left',
+ join => {
+ bmp => { type => 'left' }
+ }
+ }
+ },
+ flesh => 1,
+ flesh_fields => { acp => ['parts'] }
+ }
+ ]);
# update circ lib on the copies - make this a method flag?
for my $copy (@$copies) {
$e->update_asset_copy($copy) or return $e->event;
}
+ # update parts if volume is moving bib records
+ if( !$same_bib ) {
+ for my $copy (@$copies) {
+ my $parts = $copy->parts;
+ next unless $parts;
+ my $part_objs = [];
+ foreach my $part (@$parts) {
+ my $part_label = $part->label;
+ my $part_obj = $e->search_biblio_monograph_part(
+ {
+ label=>$part_label,
+ record=>$rec
+ }
+ )->[0];
+
+ if (!$part_obj) {
+ $part_obj = Fieldmapper::biblio::monograph_part->new();
+ $part_obj->label( $part_label );
+ $part_obj->record( $rec );
+ unless($e->create_biblio_monograph_part($part_obj)) {
+ return $e->die_event if $e->die_event;
+ }
+ }
+ push @$part_objs, $part_obj;
+ }
+
+ $copy->parts( $part_objs );
+ $copy->ischanged(1);
+ $evt = OpenILS::Application::Cat::AssetCommon->update_copy_parts($e, $copy, 1); #delete_parts=1
+ return $evt if $evt;
+ }
+ }
+
# Now see if any empty records need to be deleted after all of this
for(@rec_ids) {
'FM_ACP_UNFLESHED_BATCH_RETRIEVE' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.batch.retrieve', 'secure' : false },
'FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.asset.copy.fleshed.batch.retrieve.authoritative', 'secure' : false },
'FM_ACP_FLESHED_BATCH_UPDATE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.asset.copy.fleshed.batch.update' },
+ 'FM_ACP_TRANSFER_COPIES_BATCH' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.transfer_copies_to_volume' },
'FM_ACP_COUNT' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.copy_count.staff', 'secure' : false },
'FM_ACP_COUNT.authoritative' : { 'app' : 'open-ils.search', 'method' : 'open-ils.search.biblio.record.copy_count.staff.authoritative', 'secure' : false },
'FM_ACPL_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_location.retrieve.all', 'secure' : false },
JSAN.use('util.functional');
- var copies = network.simple_request('FM_ACP_FLESHED_BATCH_RETRIEVE.authoritative', [ params.copy_ids ]);
-
- for (var i = 0; i < copies.length; i++) {
- copies[i].call_number( data.marked_volume );
- copies[i].circ_lib( params.owning_lib );
- copies[i].ischanged( 1 );
- }
-
var robj = network.simple_request(
- 'FM_ACP_FLESHED_BATCH_UPDATE',
- [ ses(), copies, true ],
+ 'FM_ACP_TRANSFER_COPIES_BATCH',
+ [ ses(), data.marked_volume , params.copy_ids ],
null,
{
'title' : $("catStrings").getString('staff.cat.util.transfer_copies.override_transfer_failure'),