LP#1269911: Database elements of MVF and CRA

* Teach vandelay.marc21_physical_characteristics() to see all 007's

We use vandelay.marc21_physical_characteristics() to extract fixed
field data that lives in the 007.  Before this change, it would
only look at the first 007 in the record.  Now it will look at
all of them in turn, supporting configurations such as DVD+BluRay.

* Add intarray extension

We need intarray for GIN index support of integer arrays, which is
how we'll be storing the in-use record attribute value identifiers.

* Hidy hole in which to stick "uncontrolled" values

In order to make use of the massive speed increases provided by
intarray indexing, we need to use (you guessed it) integers.  But
uncontrolled record attributes are not necessarily (or even very
often) numbers.  We will store them in a table of unique (per
attribute) values, and use the id from that table in our intarray
indexing.  That id comes from a DECREMENTING serial that starts
at -1 and counts downward.  This avoids collision with the other
set of integers (the id from config.coded_value_map) that we will
use for controlled record attribute values.

* Add a multi flag for record attrs

We pre-coordinate which record attrs are allowed to be multi-valued
with this new bool.  Most can be, we set the default to true and
adjust the seed data for those that should be false (sorters and
fields in the leader).

* New intarray-focused attribute extraction

We rewrite the record attribute extraction to capture all the
record-supplied values for each attribute (where multi is true)
and store that list in the new (fkey-corrected) metabib.record_attr_vector_list
table.  Only filters make it into this table.

We also insert a parameter after the record id to accept a list of
record attributes we want to rewrite. This defaults to NULL to rewrite
all of them.

Sorters are stored in a new, separate table built specifically for them.

metabib.record_attr becomes a vew atop metabib.record_attr_vector_list
which expands the intarray stored therein into an hstore. For
multi=true attributes, only one will be returned through this view,
as is HSTORE's way, and which will be returned is undefined.  However
this view is only provided for the purpose of backward compat with
reports or other locally defined logic.

And, finally, baseline seed data

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911: Teach the IDL about MVF- and CRA-related structures

IDL link from ccvm => ccraed via composite_def field

IDL selector attribute for ccvm class

ccraed gets CUD actions

In conify/global/config/coded_value_map, if the selected attr type is
composite=true, show a link from each coded value to manage the
composite definition.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911: Teach QueryParser new tricks

QP Needs to be made aware of several new structures in the database.

First, we have added a new sort-supporting table called metabib.record_sorter
which holds values extracted by crad.sorter=true attrs.  This is used instead
of the mrd.attrs->"something" hstore composite.

Next, we teach QP how to convert from a list of user-supplied values across
many dynamic filters (based on crad) into an intarray query of ids extracted
from config.coded_value_map (in the case of controlled attributes) or
metabib.uncontrolled_record_attr_value (in the case of, you guessed it,
uncontrolled attributes).  This query is applied against the vlist column
of metabib.record_attr_vector_list, which is GIN indexed for speed.

Finally, metabib.record_attr is now a view over metabib.record_attr_vector_list
and is consequently going to be slow for general use.  We restrict
its inclusion in the core query to only the case of a during() filter
which requires access to the value of a bib's Date2 field.  For the
other common case, requiring access to the Date1 field, we instead
use the pubdate sort value now stored in metabib.record_sorter.  We
might consider making the specific sorter attribute used configurable
so that we can change the definition of pubdate down the road, but it
starts out (and generally stays) defined as equivalent to Date1.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911: Upgrade script for MVF and CRA

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911 composite attributes admin UI

New interface for managing composite record attribute definitions:

/eg/conify/global/config/composite_attr_entry_definition/<id>

The UI for a coded value map is accessed from an existing coded value
via a new "Manage" link column in the CCVM table.  The UI allows staff
to build tree-shaped boolean composite definitions for CCVMs in terms
of existing CCVMs.

Additionally, the record attribute definition UI now has a link from
each definition to the coded value map page for the attribute.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911: composite attributes: configurable "icons" attribute

Honor the configurable icon attribute within the TPAC.

Create a default set of icons, by copying from the existing icons,
which roughly map to the new "icon_format" record attribute
definition mappings.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911: TPAC generates format selector from icon_format attr

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1053397: removed extraneous MR formats global flag

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911: Release notes for Multi-valued Fields and Controlled Attributes

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911: Release notes for Composite Record Attributes

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1053397 IDL class mraf for metabib::record_attr_flat

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1053397 DB for metarecords unapi and holds

Schema for unapi metarecord access (unap.mmr()) and associated
components.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1053397 DB metarecord seed data

Seed data for representing the holdable formats for metarecords.  This
is a subset of the "icon_format" collection, excluding the electronic
resources.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1053397 TPAC metarecord search and holds UI

API, TPAC backend, and UI bits for TPAC metarecord searching and holds.

* Group Formats and Editions options in advanced search / searchbar
* MR holds placement form, allowing selected formats and languages
* MR holds targeting updated to work w/ new holdable formats composite
  definitions

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1053397 TPAC Metarecords release notes

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911 'large print book' is also a 'book'

Remove the item_form != d component of the "book" composite definition.
I think this more closely matches how humans would interpret it.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Conflicts:
	Open-ILS/src/sql/Pg/950.data.seed-values.sql

Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911 seed data SQL repairs

Products of merge conflict resolution with the mvf-cra branch.

* repaired syntax error
* removed some duplicate global flag entries

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1269911 global flag for opac format selector attribute

Adds a new config.global_flag for defining which record attribute the
OPAC will use to find formats for the format selector.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1053397 repair one-hit redirect logic for metarecords

* Only perform the single-hit redirect if there is only one metarecord
  search result and the MR only has a single constituent record.

* Repair the record id logic so the redirect jumps to the correct
  record.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
LP#1053397 apply org scope to metarecord attributes

When loading record attributes (cra, ccvm, etc.) for constituent
records, limit the attributes to those contained by records which have
holdings within the provided (search) scope.

With this, for example, a search at Branch 1 for metarecords will only
show format icons for constituent records that have holdings at BR1.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>