sub fleshed_copy_update {
- my( $self, $conn, $auth, $copies, $delete_stats, $oargs ) = @_;
+ my( $self, $conn, $auth, $copies, $delete_stats, $oargs, $create_parts ) = @_;
return 1 unless ref $copies;
my( $reqr, $evt ) = $U->checkses($auth);
return $evt if $evt;
}
my $retarget_holds = [];
$evt = OpenILS::Application::Cat::AssetCommon->update_fleshed_copies(
- $editor, $oargs, undef, $copies, $delete_stats, $retarget_holds, undef);
+ $editor, $oargs, undef, $copies, $delete_stats, $retarget_holds, undef, $create_parts);
if( $evt ) {
$logger->info("fleshed copy update failed with event: ".OpenSRF::Utils::JSON->perl2JSON($evt));
my $editor = new_editor( requestor => $reqr, xact => 1 );
my $retarget_holds = [];
my $auto_merge_vols = $options->{auto_merge_vols};
+ my $create_parts = $options->{create_parts};
for my $vol (@$volumes) {
$logger->info("vol-update: investigating volume ".$vol->id);
if( $copies and @$copies and !$vol->isdeleted ) {
$_->call_number($vol->id) for @$copies;
$evt = $assetcom->update_fleshed_copies(
- $editor, $oargs, $vol, $copies, $delete_stats, $retarget_holds, undef);
+ $editor, $oargs, $vol, $copies, $delete_stats, $retarget_holds, undef, $create_parts);
return $evt if $evt;
}
}
# authoritative list for the copy. existing part maps not targeting
# these parts will be deleted from the DB
sub update_copy_parts {
- my($class, $editor, $copy, $delete_maps) = @_;
+ my($class, $editor, $copy, $delete_maps, $create_parts) = @_;
return undef if $copy->isdeleted;
return undef unless $copy->ischanged or $copy->isnew;
# if this link already exists in the DB, don't attempt to re-create it
next if( grep{$_->part == $incoming_part->id} @$maps );
+
+ if ($incoming_part->isnew) {
+ next unless $create_parts;
+ my $new_part = Fieldmapper::biblio::monograph_part->new();
+ $new_part->record( $incoming_part->record );
+ $new_part->label( $incoming_part->label );
+ $incoming_part = $editor->create_biblio_monograph_part($new_part)
+ or return $editor->event;
+ }
my $new_map = Fieldmapper::asset::copy_part_map->new();
# this does the actual work
sub update_fleshed_copies {
- my($class, $editor, $override, $vol, $copies, $delete_stats, $retarget_holds, $force_delete_empty_bib) = @_;
+ my($class, $editor, $override, $vol, $copies, $delete_stats, $retarget_holds, $force_delete_empty_bib, $create_parts) = @_;
$override = { all => 1 } if($override && !ref $override);
$override = { all => 0 } if(!ref $override);
$evt = $class->update_copy_stat_entries($editor, $copy, $delete_stats);
$copy->parts( $parts );
# probably okay to use $delete_stats here for simplicity
- $evt = $class->update_copy_parts($editor, $copy, $delete_stats);
+ $evt = $class->update_copy_parts($editor, $copy, $delete_stats, $create_parts);
return $evt if $evt;
}