ACQ support for two-step vandelay imports

If a lineitm is loaded into a queue via ACQ+Vandelay and a later attempt
is made to load the record into the catalog via ACQ+Vandelay, the
attempt will fail, because ACQ+Vandelay treats all
not-yet-fully-imported lineitems as new to vandelay.  This change
inspects lineitems at vandelay processing time to determine if they are
already linked to a VL record or if a new one is needed.  It also
removes the requirement that a queue be provided when all records in
process are already linked to a VL record (which already lives in a
queue).

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Acq: New lineitems added to existing POs should inherit provider

Jeremy Miller of the Albany Public Library in Albany, OR, reports that
through the interface at
    Actions For This Record -> View/Place Orders
in the staff client, when you add a lineitem to an existing PO, the new
lineitem has a null value in the "provider" field, instead of inheriting
the expected value from the PO.

This causes problems for some Acquisitions workflows.

The feature containing the bug appeared in 2.2, and this fix for it can be
backported that far.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Changed the thawing of a hold to first update the hold record and then re-target.

When thawing a hold, originaly we were first re-targeting before actually saving the hold record. On items with large quantities, sometimes the hold would timeout on targetig before getting a chance to actually save. This patch moves things around to first save the hold record before attempting to retarget.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
TPAC: Make call number browse record links retain search lib

In addition to maintaining scope for the call number browse search
results, we also need to maintain the scope for the links for the call
number records in the results themselves (for example, the "retrieve
this record" link, or the "search for this author" link).

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Ben Shum <bshum@biblio.org>
Bug #1044721: QP handles explicit group+joiner badly

Although the following four queries should be equivalent:
  george  ||  fred
 (george) ||  fred
  george  || (fred)
 (george) || (fred)

The Pg QueryParser driver generates SQL queries that return different
numbers of results for each of those queries, with all desired results
appearing only with the first query. This seems to be because of the way
filters are added in the interface.

This patch adjusts the Search code in TPAC to add an explicit group
around the user-entered query, which enables the Pg QueryParser driver
to handle all four of the above queries properly.

This patch should also resolve the problems encountered with the patch
for bug #1040740, "Implicit ANDs should have higher precedence than
explicit ORs"

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Vandelay: Fix index-miss with MARC Imports using Match Sets

In some Postgres installations, an expression such as:

(value LIKE '13423488%' OR value LIKE '245425%') will use a btree index,
but

value LIKE ANY('{13423488%,245425%}'::TEXT[])

will not.

Missing such an index can make matching incoming bibs based on a field
that's present in most of your existing records terrifically slow.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Increase Overlay Speed for Standard Identifiers

Due to an inefficient query order and a confused query planner,
some overlay matching can end up going abysmally slow.  See LP
bug #1024095 for elaboration on the issue.

This commit reorders the joins as originally suggested by Lebbeous,
then adds a specific index to coax the query planner into making the
best choices.  The example index here only targets the 02x identifier
fields, so other tag/subfield/substring(value) indexes will likely
be necessary for maximum benefit when matching on other fields
(e.g. 010).

These changes combined with the previous commit which replaces 'LIKE
ANY' with 'LIKE (... OR ...)' has shown great promise in testing.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Upgrade bits for Vandelay Overlay Changes

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Revert "Bug #1044721: QP handles explicit group+joiner badly"

This reverts commit b77bb9943009b81042b4ef1a6ac33ec9e3e96dd7.

Unfortunately this had side effects that escaped our manual testing
processes.  Especially with facets as reported by Ben Shum.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Protect against fleshed circ_lib in legacy check_age_protect

Retrieving org settings with an org unit object as the context org unit
results in errors and dying.

This affects legacy scripts only.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Michael Peters <mrpeters@library.in.gov>
Enable 1-hit redirect for item barcode searches

Signed-off-by: Thomas Berezansky <tsbere@mvlc.org>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Merge remote-tracking branch 'upstream/rel_2_2' into rel_2_2
Fix reserves list to list all reserves and loan period. Tickets #157 and #152.