From a457813d632916c0d79ec38ffe4ddf2662f91002 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Fri, 6 Sep 2013 16:36:47 -0400 Subject: [PATCH] 'Opportunistic' Acq In-process Copy Overlay It is both normal and common to overlay brief acquisitions bib records with more complete records, and it is simple to create copies as part of the overlay process, but there is no *simple* way to have the imported copies overlay the acq copies. This code builds off the existing copy overlay code (which matches and overlays using specified IDs), but uses broader matching criteria. By selecting the new option, "Auto Overlay In-process Acquisitions Copies", the system will potentially overlay copies which: * have associated lineitem details (that is, they were created by the acquisitions process), and * that lineitem detail has the same owning_lib as the incoming copy's owning_lib * the current copy associated with that lineitem detail is "In process" Also, fix two small bugs, one which prevented overlay using the 'Available' status (change 'if $val' to 'if defined $val', since 'Available' is '0'), and another which prevented item overlay when selecting the match record manually (as_imported was null in the DB). Signed-off-by: Dan Wells Signed-off-by: Mike Rylander --- .../lib/OpenILS/Application/Vandelay.pm | 41 +++++++++++++++++-- Open-ILS/src/templates/vandelay/inc/queue.tt2 | 7 ++++ .../src/templates/vandelay/inc/upload.tt2 | 7 ++++ .../web/js/ui/default/vandelay/vandelay.js | 8 ++++ 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm index e7dbde788a..576623128f 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm @@ -1015,6 +1015,7 @@ sub import_record_list_impl { $logger->info("vl: $type direct overlay succeeded for queued rec ". "$rec_id and overlay target $overlay_target"); $imported = 1; + $rec->imported_as($overlay_target); } } else { @@ -1207,7 +1208,7 @@ sub import_record_list_impl { } # import the copies - import_record_asset_list_impl($conn, \@success_rec_ids, $requestor) if @success_rec_ids; + import_record_asset_list_impl($conn, \@success_rec_ids, $requestor, $args) if @success_rec_ids; $conn->respond({total => $$report_args{total}, progress => $$report_args{progress}}); return undef; @@ -1577,7 +1578,7 @@ sub retrieve_queue_summary { # Given a list of queued record IDs, imports all items attached to those records # -------------------------------------------------------------------------------- sub import_record_asset_list_impl { - my($conn, $rec_ids, $requestor) = @_; + my($conn, $rec_ids, $requestor, $args) = @_; my $roe = new_editor(xact=> 1, requestor => $requestor); @@ -1614,6 +1615,8 @@ sub import_record_asset_list_impl { # call number label for every copy per org per record. my $auto_callnumber = {}; + my $opp_acq_copy_overlay = $args->{opp_acq_copy_overlay}; + my @overlaid_copy_ids; for my $item_id (@$item_ids) { my $e = new_editor(requestor => $requestor, xact => 1); my $item = $e->retrieve_vandelay_import_item($item_id); @@ -1673,6 +1676,38 @@ sub import_record_asset_list_impl { respond_with_status($report_args); next; } + } elsif ($opp_acq_copy_overlay) { # we are going to "opportunistically" overlay received, in-process acq copies + # recv_time should never be null if the copy status is + # "In Process", so that is just a double-check + my $query = [ + { + "recv_time" => {"!=" => undef}, + "owning_lib" => $item->owning_lib, + "+acn" => {"record" => $rec->imported_as}, + "+acp" => {"status" => OILS_COPY_STATUS_IN_PROCESS} + }, + { + "join" => { + "acp" => { + "join" => "acn" + } + }, + "flesh" => 2, + "flesh_fields" => { + "acqlid" => ["eg_copy_id"], + "acp" => ["call_number"] + } + } + ]; + # don't overlay the same copy twice + $query->[0]{"+acp"}{"id"} = {"not in" => \@overlaid_copy_ids} if @overlaid_copy_ids; + if (my $acqlid = $e->search_acq_lineitem_detail($query)->[0]) { + $copy = $acqlid->eg_copy_id; + push(@overlaid_copy_ids, $copy->id); + } + } + + if ($copy) { # we found a copy to overlay # overlaying copies requires an extra permission if (!$e->allowed("IMPORT_OVERLAY_COPY", $copy->call_number->owning_lib)) { @@ -1743,7 +1778,7 @@ sub import_record_asset_list_impl { price circ_as_type alert_message opac_visible circ_modifier/) { my $val = $item->$_(); - $copy->$_($val) if $val and $val ne ''; + $copy->$_($val) if defined $val and $val ne ''; } # de-flesh for update diff --git a/Open-ILS/src/templates/vandelay/inc/queue.tt2 b/Open-ILS/src/templates/vandelay/inc/queue.tt2 index 0d8be970eb..d9118dc82a 100644 --- a/Open-ILS/src/templates/vandelay/inc/queue.tt2 +++ b/Open-ILS/src/templates/vandelay/inc/queue.tt2 @@ -249,6 +249,13 @@ + + [% l('Copy Import Actions') %] + + + [% l('Auto-overlay In-process Acquisition Copies') %] + + diff --git a/Open-ILS/src/templates/vandelay/inc/upload.tt2 b/Open-ILS/src/templates/vandelay/inc/upload.tt2 index bca673e4be..4db970d7b4 100644 --- a/Open-ILS/src/templates/vandelay/inc/upload.tt2 +++ b/Open-ILS/src/templates/vandelay/inc/upload.tt2 @@ -103,6 +103,13 @@ + + [% l('Copy Import Actions') %] + + + [% l('Auto-overlay In-process Acquisitions Copies') %] + + diff --git a/Open-ILS/web/js/ui/default/vandelay/vandelay.js b/Open-ILS/web/js/ui/default/vandelay/vandelay.js index 00f78e1b9b..41b9a99522 100644 --- a/Open-ILS/web/js/ui/default/vandelay/vandelay.js +++ b/Open-ILS/web/js/ui/default/vandelay/vandelay.js @@ -1241,6 +1241,7 @@ function vlHandleQueueItemsAction(action) { vlUploadFtMergeProfile.attr('value', vlUploadFtMergeProfile2.attr('value')); vlUploadQueueAutoOverlayBestMatch.attr('value', vlUploadQueueAutoOverlayBestMatch2.attr('value')); vlUploadQueueAutoOverlayBestMatchRatio.attr('value', vlUploadQueueAutoOverlayBestMatchRatio2.attr('value')); + vlUploadQueueAutoOverlayInprocessAcqCopies.attr('value', vlUploadQueueAutoOverlayInprocessAcqCopies2.attr('value')); // attr('value') and various other incantations won't let me set // the value on the checkedmultiselect, so we temporarily swap @@ -1271,6 +1272,8 @@ function vlHandleQueueItemsAction(action) { vlUploadQueueAutoOverlayBestMatch2.attr('value', false); vlUploadQueueAutoOverlayBestMatchRatio.attr('value', '0.0'); vlUploadQueueAutoOverlayBestMatchRatio2.attr('value', '0.0'); + vlUploadQueueAutoOverlayInprocessAcqCopies.attr('value', false); + vlUploadQueueAutoOverlayInprocessAcqCopies2.attr('value', false); // and... swap them back vlUploadTrashGroups2 = vlUploadTrashGroups; @@ -1351,6 +1354,11 @@ function vlImportRecordQueue(type, queueId, recList, onload) { options.match_quality_ratio = vlUploadQueueAutoOverlayBestMatchRatio.attr('value'); } + if(vlUploadQueueAutoOverlayInprocessAcqCopies.checked) { + options.opp_acq_copy_overlay = true; //"opp" for opportunistic + vlUploadQueueAutoOverlayInprocessAcqCopies.checked = false; + } + var profile = vlUploadMergeProfile.attr('value'); if(profile != null && profile != '') { options.merge_profile = profile; -- 2.43.2