From 8b2546e3a7ac9938a0725dffeec25224c48061e8 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Wed, 21 Mar 2012 20:00:01 -0400 Subject: [PATCH] TPAC: Show preferred library copies only in consortial scope A refinement of the preferred library display: only when the user is at the consortial scope should the preferred library copies float to the top. At all other scopes, the preferred library copies will appear in their proper place in the org unit hierarchy (or not at all if outside of the chosen scope). Signed-off-by: Dan Scott Signed-off-by: Mike Rylander --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm | 8 -------- Open-ILS/src/sql/Pg/020.schema.functions.sql | 15 --------------- Open-ILS/src/sql/Pg/990.schema.unapi.sql | 6 +++++- .../sql/Pg/upgrade/XXXX.schema.unapi_limit_rank.sql | 21 +++++---------------- 4 files changed, 10 insertions(+), 40 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm index 62133c99f7..bc74bd19c8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm @@ -245,14 +245,6 @@ sub mk_copy_query { } } }; - if ($org != $pref_ou) { - $query->{from}->{acp}->{aou}->{filter}->{id}->{in}->{select}->{aou} = [{ - column => 'id', - transform => 'actor.org_unit_descendants_pref_lib', - result_field => 'id', - params => [$depth, $pref_ou] - }]; - } }; # Filter hidden items if this is the public catalog diff --git a/Open-ILS/src/sql/Pg/020.schema.functions.sql b/Open-ILS/src/sql/Pg/020.schema.functions.sql index 35afbcdb58..ca4306eb2e 100644 --- a/Open-ILS/src/sql/Pg/020.schema.functions.sql +++ b/Open-ILS/src/sql/Pg/020.schema.functions.sql @@ -152,21 +152,6 @@ CREATE OR REPLACE FUNCTION actor.org_unit_descendants( INT ) RETURNS SETOF actor ) SELECT ou.* FROM actor.org_unit ou JOIN descendant_depth USING (id); $$ LANGUAGE SQL ROWS 1; -CREATE OR REPLACE FUNCTION actor.org_unit_descendants_pref_lib ( - ou INT, - depth INT, - pref_ou INT -) RETURNS SETOF actor.org_unit AS $$ - SELECT ou.* FROM actor.org_unit_descendants($1, $2) AS ou - UNION - SELECT ou.* FROM actor.org_unit ou WHERE id = $3; -$$ LANGUAGE SQL STABLE ROWS 1; - -COMMENT ON FUNCTION actor.org_unit_descendants_pref_lib( INT, INT, INT) IS $$ -Returns the descendants by depth of the specified library, but adds the -preferred library if it is not contained in the set of descendants. -$$; - CREATE OR REPLACE FUNCTION actor.org_unit_descendants_distance( INT ) RETURNS TABLE (id INT, distance INT) AS $$ WITH RECURSIVE org_unit_descendants_distance(id, distance) AS ( SELECT $1, 0 diff --git a/Open-ILS/src/sql/Pg/990.schema.unapi.sql b/Open-ILS/src/sql/Pg/990.schema.unapi.sql index 45eca9f99d..ac33c667fa 100644 --- a/Open-ILS/src/sql/Pg/990.schema.unapi.sql +++ b/Open-ILS/src/sql/Pg/990.schema.unapi.sql @@ -20,7 +20,11 @@ RETURNS INTEGER AS $$ SELECT id, distance FROM actor.org_unit_descendants_distance($2) ) SELECT COALESCE( - (SELECT -10000 FROM actor.org_unit WHERE $1 = $3 AND id = $3), + (SELECT -10000 FROM actor.org_unit + WHERE $1 = $3 AND id = $3 AND $2 IN ( + SELECT id FROM actor.org_unit WHERE parent_ou IS NULL + ) + ), (SELECT distance FROM search_libs WHERE id = $1), 10000 ); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_limit_rank.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_limit_rank.sql index 5d71d972eb..768277746e 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_limit_rank.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.unapi_limit_rank.sql @@ -19,21 +19,6 @@ BEGIN; -- check whether patch can be applied SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); -CREATE OR REPLACE FUNCTION actor.org_unit_descendants_pref_lib ( - ou INT, - depth INT, - pref_ou INT -) RETURNS SETOF actor.org_unit AS $$ - SELECT ou.* FROM actor.org_unit_descendants($1, $2) AS ou - UNION - SELECT ou.* FROM actor.org_unit ou WHERE id = $3; -$$ LANGUAGE SQL STABLE ROWS 1; - -COMMENT ON FUNCTION actor.org_unit_descendants_pref_lib( INT, INT, INT) IS $$ -Returns the descendants by depth of the specified library, but adds the -preferred library if it is not contained in the set of descendants. -$$; - -- The simplest way to apply all of these changes is just to replace the unapi -- schema entirely -- the following is a copy of 990.schema.unapi.sql with -- the initial COMMIT in place in case the upgrade_deps_block_check fails; @@ -61,7 +46,11 @@ RETURNS INTEGER AS $$ SELECT id, distance FROM actor.org_unit_descendants_distance($2) ) SELECT COALESCE( - (SELECT -10000 FROM actor.org_unit WHERE $1 = $3 AND id = $3), + (SELECT -10000 FROM actor.org_unit + WHERE $1 = $3 AND id = $3 AND $2 IN ( + SELECT id FROM actor.org_unit WHERE parent_ou IS NULL + ) + ), (SELECT distance FROM search_libs WHERE id = $1), 10000 ); -- 2.11.0