From: Bill Erickson Date: Fri, 15 Mar 2013 18:32:18 +0000 (-0400) Subject: Sample data : copy locations, location groups X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=abf5e3b50aec475f7afb1c278c1d68de72ffc5b5;p=working%2FEvergreen.git Sample data : copy locations, location groups Adds a pile of sample copy location and location groups to the sample data in Open-ILS/tests/datasets/sql. Samples are loaded as part of "load_all.sql" Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier --- diff --git a/Open-ILS/tests/datasets/sql/assets_extras.sql b/Open-ILS/tests/datasets/sql/assets_extras.sql new file mode 100644 index 0000000000..2efefb982d --- /dev/null +++ b/Open-ILS/tests/datasets/sql/assets_extras.sql @@ -0,0 +1,69 @@ +-- copy locations +-- copy location groups +-- copy stat cats +-- ... + +INSERT INTO asset.copy_location (owning_lib, name) VALUES +(4, 'Adult'), +(4, 'Young Adult'), +(4, 'Juvenile'), +(4, 'AV'), +(4, 'Children''s AV'), +(5, 'Western'), +(5, 'Young Adult'), +(5, 'Genealogy'), +(5, 'Local History'), +(6, 'Sci-Fi'), +(6, 'Biography'), +(6, 'Ninjas'), +(6, 'Young Adult'), +(7, 'Vampires'), +(7, 'Western'), +(7, 'Young Adult'), +(7, 'Sports'); + +-- non-holable +INSERT INTO asset.copy_location (owning_lib, name, holdable) VALUES +(4, 'New Arrivals', FALSE); + +-- non-holable, non-cirulcateable, non-visible +INSERT INTO asset.copy_location + (owning_lib, name, holdable, opac_visible, circulate) VALUES +(5, 'Display', FALSE, FALSE, FALSE), +(6, 'Display', FALSE, FALSE, FALSE), +(7, 'Display', FALSE, FALSE, FALSE); + + +-- copy location groups + +INSERT INTO asset.copy_location_group (name, owner) VALUES ('Sys1 Fiction', 2); + +INSERT INTO asset.copy_location_group_map (lgroup, location) + SELECT CURRVAL('asset.copy_location_group_id_seq'), id + FROM asset.copy_location WHERE owning_lib in (4, 5) + AND opac_visible; + +INSERT INTO asset.copy_location_group (name, owner) VALUES ('Sys2 Fiction', 2); + +INSERT INTO asset.copy_location_group_map (lgroup, location) + SELECT CURRVAL('asset.copy_location_group_id_seq'), id + FROM asset.copy_location WHERE owning_lib in (6, 7) + AND opac_visible; + +-- evenly distribute the copies across all of the copy locations. +-- there's probably a more effecient way, but this gets the job done + +DO $$ + DECLARE cur_loc INTEGER; + DECLARE cur_copy asset.copy%ROWTYPE; +BEGIN + cur_copy := evergreen.next_copy(0); + + WHILE cur_copy.id IS NOT NULL LOOP + FOR cur_loc IN SELECT id FROM asset.copy_location ORDER BY id LOOP + UPDATE asset.copy SET location = cur_loc WHERE id = cur_copy.id; + cur_copy := evergreen.next_copy(cur_copy.id); + EXIT WHEN cur_copy.id IS NULL; + END LOOP; + END LOOP; +END $$; diff --git a/Open-ILS/tests/datasets/sql/load_all.sql b/Open-ILS/tests/datasets/sql/load_all.sql index 22947fc0f7..c9f2da4164 100644 --- a/Open-ILS/tests/datasets/sql/load_all.sql +++ b/Open-ILS/tests/datasets/sql/load_all.sql @@ -49,6 +49,9 @@ INSERT INTO biblio.record_entry (marc, last_xact_id) -- load RDA copies, etc. \i assets_rda.sql +-- load copy-related data +\i assets_extras.sql + -- load sample patrons \i users_patrons_100.sql