LP1756564: Add sample data for the booking module
authorJane Sandberg <sandbej@linnbenton.edu>
Wed, 28 Mar 2018 20:58:20 +0000 (13:58 -0700)
committerGalen Charlton <gmc@equinoxinitiative.org>
Sat, 3 Aug 2019 16:18:44 +0000 (12:18 -0400)
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 <sandbej@linnbenton.edu>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/tests/datasets/sql/assets_booking.sql [new file with mode: 0644]
Open-ILS/tests/datasets/sql/bibs_booking.sql [new file with mode: 0644]
Open-ILS/tests/datasets/sql/booking_resources_types.sql [new file with mode: 0644]
Open-ILS/tests/datasets/sql/env_create.sql
Open-ILS/tests/datasets/sql/env_destroy.sql
Open-ILS/tests/datasets/sql/load_all.sql

diff --git a/Open-ILS/tests/datasets/sql/assets_booking.sql b/Open-ILS/tests/datasets/sql/assets_booking.sql
new file mode 100644 (file)
index 0000000..5acce72
--- /dev/null
@@ -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 (file)
index 0000000..7513654
--- /dev/null
@@ -0,0 +1,9 @@
+\set bib_tag '''IMPORT BOOKING'''
+
+INSERT INTO marcxml_import (tag, marc)
+VALUES (:bib_tag, '<record xmlns="http://www.loc.gov/MARC21/slim"><leader>00434crm a2200133Ki 4500</leader>
+<controlfield tag="005">20180321175835.0</controlfield>
+<controlfield tag="008">150922s2015    xxx1 en  d681  50072eng d</controlfield><datafield tag="024" ind1="1" ind2=" "><subfield code="a">681495007240</subfield></datafield><datafield tag="090" ind1=" " ind2=" "><subfield code="a">KOBO EREADER</subfield></datafield><datafield tag="245" ind1="0" ind2="0"><subfield code="a">Kobo Aura ONE ereader.</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">1 ereader : </subfield><subfield code="b"> electronic texts, digital files ; </subfield><subfield code="c"> 20 x 14 x 1 cm in case, </subfield><subfield code="e"> + power cord.</subfield></datafield><datafield tag="336" ind1=" " ind2=" "><subfield code="a">text </subfield><subfield code="b"> txt </subfield><subfield code="2"> rdacontent</subfield></datafield><datafield tag="338" ind1=" " ind2=" "><subfield code="a">object </subfield><subfield code="2"> rdacarrier</subfield></datafield><datafield tag="655" ind1=" " ind2="0"><subfield code="a">Electronic book readers.</subfield></datafield></record>'),
+(:bib_tag, '<record mlns="http://www.loc.gov/MARC21/slim"><leader>00395crm a2200121Ki 4500</leader>
+<controlfield tag="005">20180321175835.0</controlfield>
+<controlfield tag="008">150922s2015    xxx1 en  d681  50072eng d</controlfield><datafield tag="024" ind1="1" ind2=" "><subfield code="a">681495007240</subfield></datafield><datafield tag="090" ind1=" " ind2=" "><subfield code="a">TREETON LAPTOP</subfield></datafield><datafield tag="245" ind1="0" ind2="0"><subfield code="a">VeryPC Treeton Laptop.</subfield></datafield><datafield tag="300" ind1=" " ind2=" "><subfield code="a">1 laptop computer : </subfield><subfield code="b"> electronic texts, digital files ; </subfield><subfield code="c"> 21 x 27 x 7 cm in case, </subfield><subfield code="e"> + power cord.</subfield></datafield><datafield tag="338" ind1=" " ind2=" "><subfield code="a">object </subfield><subfield code="2"> rdacarrier</subfield></datafield><datafield tag="655" ind1=" " ind2="0"><subfield code="a">Laptop computers.</subfield></datafield></record>');
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 (file)
index 0000000..d259171
--- /dev/null
@@ -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');
index 07dae6d..9e8d955 100644 (file)
@@ -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;
 
index 9f69865..6169194 100644 (file)
@@ -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);
index ce89563..f1a20fc 100644 (file)
@@ -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