From f1c2b6ef5573a04c8ea1f0ccf3e105d405b0cefc Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 30 Nov 2005 15:42:38 +0000 Subject: [PATCH] new "container" stuff ... where the buckets live git-svn-id: svn://svn.open-ils.org/ILS/trunk@2129 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Storage/CDBI.pm | 1 + .../Application/Storage/CDBI/container.pm | 65 +++++++++ .../Application/Storage/Driver/Pg/dbi.pm | 49 +++++++ .../OpenILS/Application/Storage/Publisher.pm | 1 + .../Storage/Publisher/container.pm | 6 + Open-ILS/src/sql/Pg/070.schema.container.sql | 131 ++++++++++++++++++ Open-ILS/src/sql/Pg/build-db.sh | 1 + 7 files changed, 254 insertions(+) create mode 100644 Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/container.pm create mode 100644 Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/container.pm create mode 100644 Open-ILS/src/sql/Pg/070.schema.container.sql diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm index 5c2dec843d..da41af8bc5 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI.pm @@ -12,6 +12,7 @@ use OpenILS::Application::Storage::CDBI::config; use OpenILS::Application::Storage::CDBI::metabib; use OpenILS::Application::Storage::CDBI::money; use OpenILS::Application::Storage::CDBI::permission; +use OpenILS::Application::Storage::CDBI::container; use JSON; use OpenSRF::Utils::Logger; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/container.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/container.pm new file mode 100644 index 0000000000..0611698e22 --- /dev/null +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/container.pm @@ -0,0 +1,65 @@ +package OpenILS::Application::Storage::CDBI::container; +our $VERSION = 1; + +#------------------------------------------------------------------------------- +package container; +use base qw/OpenILS::Application::Storage::CDBI/; +#------------------------------------------------------------------------------- +package container::user_bucket; +use base qw/container/; + +container::user_bucket->table( 'container_user_bucket' ); +container::user_bucket->columns( All => qw/id owner name/ ); + +#------------------------------------------------------------------------------- +package container::user_bucket_item; +use base qw/container/; + +container::user_bucket->table( 'container_user_bucket_item' ); +container::user_bucket->columns( All => qw/id bucket target_user/ ); + +#------------------------------------------------------------------------------- +package container::copy_bucket; +use base qw/container/; + +container::copy_bucket->table( 'container_copy_bucket' ); +container::copy_bucket->columns( All => qw/id owner name/ ); + +#------------------------------------------------------------------------------- +package container::copy_bucket_item; +use base qw/container/; + +container::copy_bucket->table( 'container_copy_bucket_item' ); +container::copy_bucket->columns( All => qw/id bucket target_copy/ ); + +#------------------------------------------------------------------------------- +package container::biblio_record_entry_bucket; +use base qw/container/; + +container::biblio_record_entry_bucket->table( 'container_biblio_record_entry_bucket' ); +container::biblio_record_entry_bucket->columns( All => qw/id owner name/ ); + +#------------------------------------------------------------------------------- +package container::biblio_record_entry_bucket_item; +use base qw/container/; + +container::biblio_record_entry_bucket->table( 'container_biblio_record_entry_bucket_item' ); +container::biblio_record_entry_bucket->columns( All => qw/id bucket target_biblio_record_entry/ ); + +#------------------------------------------------------------------------------- +package container::call_number_bucket; +use base qw/container/; + +container::call_number_bucket->table( 'container_call_number_bucket' ); +container::call_number_bucket->columns( All => qw/id owner name/ ); + +#------------------------------------------------------------------------------- +package container::call_number_bucket_item; +use base qw/container/; + +container::call_number_bucket->table( 'container_call_number_bucket_item' ); +container::call_number_bucket->columns( All => qw/id bucket target_call_number/ ); + + +1; + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm index 65ab7defaa..6ab2325299 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm @@ -1,4 +1,53 @@ { + + #------------------------------------------------------------------------------- + package container::user_bucket; + + container::user_bucket->table( 'container.user_bucket' ); + container::user_bucket->sequence( 'container.user_bucket_id_seq' ); + + #------------------------------------------------------------------------------- + package container::user_bucket_item; + + container::user_bucket->table( 'container.user_bucket_item' ); + container::user_bucket->sequence( 'container.user_bucket_item_id_seq' ); + + #------------------------------------------------------------------------------- + package container::copy_bucket; + + container::copy_bucket->table( 'container.copy_bucket' ); + container::copy_bucket->sequence( 'container.copy_bucket_id_seq' ); + + #------------------------------------------------------------------------------- + package container::copy_bucket_item; + + container::copy_bucket->table( 'container.copy_bucket_item' ); + container::copy_bucket->sequence( 'container.copy_bucket_item_id_seq' ); + + #------------------------------------------------------------------------------- + package container::call_number_bucket; + + container::call_number_bucket->table( 'container.call_number_bucket' ); + container::call_number_bucket->sequence( 'container.call_number_bucket_id_seq' ); + + #------------------------------------------------------------------------------- + package container::call_number_bucket_item; + + container::call_number_bucket->table( 'container.call_number_bucket_item' ); + container::call_number_bucket->sequence( 'container.call_number_bucket_item_id_seq' ); + + #------------------------------------------------------------------------------- + package container::biblio_record_entry_bucket; + + container::biblio_record_entry_bucket->table( 'container.biblio_record_entry_bucket' ); + container::biblio_record_entry_bucket->sequence( 'container.biblio_record_entry_bucket_id_seq' ); + + #------------------------------------------------------------------------------- + package container::biblio_record_entry_bucket_item; + + container::biblio_record_entry_bucket->table( 'container.biblio_record_entry_bucket_item' ); + container::biblio_record_entry_bucket->sequence( 'container.biblio_record_entry_bucket_item_id_seq' ); + #--------------------------------------------------------------------- package money::grocery; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm index e5a05f5d44..88f3379fd7 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher.pm @@ -348,6 +348,7 @@ use OpenILS::Application::Storage::Publisher::metabib; use OpenILS::Application::Storage::Publisher::authority; use OpenILS::Application::Storage::Publisher::money; use OpenILS::Application::Storage::Publisher::permission; +use OpenILS::Application::Storage::Publisher::container; '; if ($@) { diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/container.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/container.pm new file mode 100644 index 0000000000..fe60ee6336 --- /dev/null +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/container.pm @@ -0,0 +1,6 @@ +package OpenILS::Application::Storage::Publisher::container; +use base qw/OpenILS::Application::Storage/; +#use OpenILS::Application::Storage::CDBI::config; + + +1; diff --git a/Open-ILS/src/sql/Pg/070.schema.container.sql b/Open-ILS/src/sql/Pg/070.schema.container.sql new file mode 100644 index 0000000000..7dc026a52e --- /dev/null +++ b/Open-ILS/src/sql/Pg/070.schema.container.sql @@ -0,0 +1,131 @@ +DROP SCHEMA container CASCADE; + +BEGIN; +CREATE SCHEMA container; + +CREATE TABLE container.copy_bucket ( + id SERIAL PRIMARY KEY, + owner INT NOT NULL + REFERENCES actor.usr (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + name TEXT NOT NULL, + CONSTRAINT cb_name_once_per_owner UNIQUE (owner,name) +); + +CREATE TABLE container.copy_bucket_item ( + id SERIAL PRIMARY KEY, + bucket INT NOT NULL + REFERENCES container.copy_bucket (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + target_copy INT NOT NULL + REFERENCES asset."copy" (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + CONSTRAINT cb_cb_item_once_per_bucket UNIQUE (bucket,target_copy) +); + + + + +CREATE TABLE container.call_number_bucket ( + id SERIAL PRIMARY KEY, + owner INT NOT NULL + REFERENCES actor.usr (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + name TEXT NOT NULL, + CONSTRAINT cnb_name_once_per_owner UNIQUE (owner,name) +); + +CREATE TABLE container.call_number_bucket_item ( + id SERIAL PRIMARY KEY, + bucket INT NOT NULL + REFERENCES container.call_number_bucket (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + target_call_number INT NOT NULL + REFERENCES asset.call_number (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + CONSTRAINT cnb_item_once_per_bucket UNIQUE (bucket,target_call_number) +); + + + + +CREATE TABLE container.biblio_record_entry_bucket ( + id SERIAL PRIMARY KEY, + owner INT NOT NULL + REFERENCES actor.usr (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + name TEXT NOT NULL, + CONSTRAINT breb_name_once_per_owner UNIQUE (owner,name) +); + +CREATE TABLE container.biblio_record_entry_bucket_item ( + id SERIAL PRIMARY KEY, + bucket INT NOT NULL + REFERENCES container.biblio_record_entry_bucket (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + target_biblio_record_entry INT NOT NULL + REFERENCES biblio.record_entry (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + CONSTRAINT breb_item_once_per_bucket UNIQUE (bucket,target_biblio_record_entry) +); + + + + +CREATE TABLE container.user_bucket ( + id SERIAL PRIMARY KEY, + owner INT NOT NULL + REFERENCES actor.usr (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + name TEXT NOT NULL, + CONSTRAINT ub_name_once_per_owner UNIQUE (owner,name) +); + +CREATE TABLE container.user_bucket_item ( + id SERIAL PRIMARY KEY, + bucket INT NOT NULL + REFERENCES container.user_bucket (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + target_user INT NOT NULL + REFERENCES actor.usr (id) + ON DELETE CASCADE + ON UPDATE CASCADE + DEFERRABLE + INITIALLY DEFERRED, + CONSTRAINT ub_item_once_per_bucket UNIQUE (bucket,target_user) +); + +COMMIT; diff --git a/Open-ILS/src/sql/Pg/build-db.sh b/Open-ILS/src/sql/Pg/build-db.sh index 724f29407d..27c3f14597 100755 --- a/Open-ILS/src/sql/Pg/build-db.sh +++ b/Open-ILS/src/sql/Pg/build-db.sh @@ -11,6 +11,7 @@ PGUSER=$3 PGHOST=$1 PGDATABASE=$2 psql -f 011.schema.authority.sql PGUSER=$3 PGHOST=$1 PGDATABASE=$2 psql -f 020.schema.functions.sql PGUSER=$3 PGHOST=$1 PGDATABASE=$2 psql -f 030.schema.metabib.sql PGUSER=$3 PGHOST=$1 PGDATABASE=$2 psql -f 040.schema.asset.sql +PGUSER=$3 PGHOST=$1 PGDATABASE=$2 psql -f 070.schema.container.sql PGUSER=$3 PGHOST=$1 PGDATABASE=$2 psql -f 080.schema.money.sql PGUSER=$3 PGHOST=$1 PGDATABASE=$2 psql -f 090.schema.action.sql -- 2.43.2