From: Jane Sandberg Date: Wed, 28 Mar 2018 20:58:20 +0000 (-0700) Subject: LP1756564: Add sample data for the booking module X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6482ac76f9d92b4002267b0c525e3ee0ea80dca3;p=Evergreen.git LP1756564: Add sample data for the booking module This commit adds booking resources and resource types to Evergreen's sample data. Specifically, it includes four resource types: * meeting rooms (bookable by staff at BR1 and BR4) * phone chargers (bookable by staff at BR3, BR4, and BM1) * laptop computers (attached to a MARC record, bookable by staff at BR3) * e-readers (attached to a MARC record, bookable by staff at BR3) Signed-off-by: Jane Sandberg Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/tests/datasets/sql/assets_booking.sql b/Open-ILS/tests/datasets/sql/assets_booking.sql new file mode 100644 index 0000000000..5acce72f8e --- /dev/null +++ b/Open-ILS/tests/datasets/sql/assets_booking.sql @@ -0,0 +1,13 @@ +-- Create call numbers +SELECT evergreen.populate_call_number(6, 'EQUIPMENT-1', 'IMPORT BOOKING', 1); +SELECT evergreen.populate_call_number(6, 'EQUIPMENT-2', 'IMPORT BOOKING', 1); +SELECT evergreen.populate_call_number(6, 'EQUIPMENT-3', 'IMPORT BOOKING', 1); +SELECT evergreen.populate_call_number(6, 'EQUIPMENT-4', 'IMPORT BOOKING', 1); +SELECT evergreen.populate_call_number(6, 'EQUIPMENT-5', 'IMPORT BOOKING', 1); +SELECT evergreen.populate_call_number(9, 'TECH', 'IMPORT BOOKING', 1); + + +-- Create copies +SELECT evergreen.populate_copy(6, 6, 'EQUIP', 'EQUIPMENT'); +SELECT evergreen.populate_copy(9, 9, 'TECH', 'TECH'); + diff --git a/Open-ILS/tests/datasets/sql/bibs_booking.sql b/Open-ILS/tests/datasets/sql/bibs_booking.sql new file mode 100644 index 0000000000..7513654d1b --- /dev/null +++ b/Open-ILS/tests/datasets/sql/bibs_booking.sql @@ -0,0 +1,9 @@ +\set bib_tag '''IMPORT BOOKING''' + +INSERT INTO marcxml_import (tag, marc) +VALUES (:bib_tag, '00434crm a2200133Ki 4500 +20180321175835.0 +150922s2015 xxx1 en d681 50072eng d681495007240KOBO EREADERKobo Aura ONE ereader.1 ereader : electronic texts, digital files ; 20 x 14 x 1 cm in case, + power cord.text txt rdacontentobject rdacarrierElectronic book readers.'), +(:bib_tag, '00395crm a2200121Ki 4500 +20180321175835.0 +150922s2015 xxx1 en d681 50072eng d681495007240TREETON LAPTOPVeryPC Treeton Laptop.1 laptop computer : electronic texts, digital files ; 21 x 27 x 7 cm in case, + power cord.object rdacarrierLaptop computers.'); diff --git a/Open-ILS/tests/datasets/sql/booking_resources_types.sql b/Open-ILS/tests/datasets/sql/booking_resources_types.sql new file mode 100644 index 0000000000..d259171c14 --- /dev/null +++ b/Open-ILS/tests/datasets/sql/booking_resources_types.sql @@ -0,0 +1,28 @@ +-- Create booking resource types +INSERT INTO booking.resource_type(id, name, owner, catalog_item, transferable) +VALUES (555, 'Meeting room', 1, False, True), +(556, 'Phone charger', 3, False, True); + +-- Create booking resource types from MARC +SELECT evergreen.populate_booking_resource_type(6, 'IMPORT BOOKING'); + +-- Create booking resources +INSERT INTO booking.resource(owner, type, barcode) +VALUES (4, 555, 'ROOM1231'), +(4, 555, 'ROOM1232'), +(4, 555, 'ROOM1233' ), +(7, 555, 'ROOM2341'), +(7, 555, 'ROOM2342'), +(7, 555, 'ROOM2343'), +(7, 555, 'ROOM2344'), +(7, 555, 'ROOM2345'), +(7, 555, 'ROOM2346'), +(6, 556, 'IPHONE-CHARGER-01'), +(6, 556, 'IPHONE-CHARGER-02'), +(7, 556, 'ANDROID-CHARGER-01'), +(7, 556, 'IPHONE-CHARGER-03'), +(9, 556, 'IPHONE-CHARGER-04'), +(9, 556, 'IPHONE-CHARGER-05'); + +-- Create booking resources from item records +SELECT evergreen.populate_booking_resource('EQUIP'); diff --git a/Open-ILS/tests/datasets/sql/env_create.sql b/Open-ILS/tests/datasets/sql/env_create.sql index 07dae6d9ec..9e8d955915 100644 --- a/Open-ILS/tests/datasets/sql/env_create.sql +++ b/Open-ILS/tests/datasets/sql/env_create.sql @@ -226,4 +226,36 @@ $$ LANGUAGE PLPGSQL; +/** + * Create a booking resource type for all + * bib records with a specific last_xact_id +*/ +CREATE FUNCTION evergreen.populate_booking_resource_type + (ownlib INTEGER, bib_tag TEXT) +RETURNS void AS $$ + INSERT INTO booking.resource_type(name, owner, catalog_item, transferable, record) + SELECT TRIM (' ./' FROM (XPATH( + '//marc:datafield[@tag="245"]/marc:subfield[@code="a"]/text()', + marc::XML, + ARRAY[ARRAY['marc', 'http://www.loc.gov/MARC21/slim']] + ))[1]::TEXT), + $1, True, True, id + FROM biblio.record_entry + WHERE id > 0 AND last_xact_id = $2; +$$ LANGUAGE SQL; + +/** + * Make all items with barcodes that start + * with a certain substring bookable +*/ + +CREATE FUNCTION evergreen.populate_booking_resource + (barcode_start TEXT) +RETURNS void AS $$ + INSERT INTO booking.resource(owner, type, barcode) + SELECT circ_lib, resource_type.id, barcode FROM asset.copy + INNER JOIN asset.call_number on copy.call_number=call_number.id + INNER JOIN booking.resource_type on call_number.record=resource_type.record + WHERE barcode LIKE $1 || '%'; +$$ LANGUAGE SQL; diff --git a/Open-ILS/tests/datasets/sql/env_destroy.sql b/Open-ILS/tests/datasets/sql/env_destroy.sql index 9f69865f87..61691943c8 100644 --- a/Open-ILS/tests/datasets/sql/env_destroy.sql +++ b/Open-ILS/tests/datasets/sql/env_destroy.sql @@ -12,4 +12,5 @@ DROP FUNCTION evergreen.populate_circ (INTEGER, INTEGER, BIGINT, INTEGER, TEXT, TEXT, TEXT, BOOLEAN); DROP FUNCTION evergreen.populate_hold (TEXT, BIGINT, INTEGER, INTEGER, INTEGER, BOOLEAN, TIMESTAMP WITH TIME ZONE, TEXT); - +DROP FUNCTION evergreen.populate_booking_resource_type(INTEGER, TEXT); +DROP FUNCTION evergreen.populate_booking_resource(TEXT); diff --git a/Open-ILS/tests/datasets/sql/load_all.sql b/Open-ILS/tests/datasets/sql/load_all.sql index ce89563c46..f1a20fc3a6 100644 --- a/Open-ILS/tests/datasets/sql/load_all.sql +++ b/Open-ILS/tests/datasets/sql/load_all.sql @@ -80,6 +80,9 @@ DELETE FROM marcxml_import; -- load metarecord bibs \i bibs_mr.sql +-- load booking bibs +\i bibs_booking.sql + -- insert all loaded bibs into the biblio.record_entry in insert order INSERT INTO biblio.record_entry (marc, last_xact_id) SELECT marc, tag FROM marcxml_import ORDER BY id; @@ -87,6 +90,12 @@ INSERT INTO biblio.record_entry (marc, last_xact_id) -- load MR copies, etc. \i assets_mr.sql +-- load booking assets +\i assets_booking.sql + +-- load booking resource types and resources +\i booking_resources_types.sql + -- load survey data \i surveys.sql