From: Fredric T Parks Date: Wed, 19 Feb 2014 00:01:48 +0000 (-0800) Subject: Made requested structural changes to the keyword storage and retreaval X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=24af5ac72bf215fffafa5ed108012a805ca835f6;p=working%2FEvergreen.git Made requested structural changes to the keyword storage and retreaval I made the changes requested on Launch Pad, So the table uses existing localization functionality Signed-off-by: Fredrick T Parks modified: Open-ILS/examples/fm_IDL.xml modified: Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm modified: Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm deleted: Open-ILS/src/sql/Pg/upgrade/XXXX.data.seed_boolean_keyword_table.sql deleted: Open-ILS/src/sql/Pg/upgrade/XXXX.function.retrieve_keywords_by_locale.sql deleted: Open-ILS/src/sql/Pg/upgrade/XXXX.schema.boolean_keyword_table.sql new file: Open-ILS/src/sql/Pg/upgrade/XXXX.schema.config_strings.sql --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 3e829535bf..92eee236e1 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -993,6 +993,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm index bdbbf33183..5653f2fa03 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/metabib.pm @@ -3206,11 +3206,12 @@ sub query_parser_fts_wrapper { _initialize_parser($parser) unless $parser->initialization_complete; #If this is a boolean search set the human readable operators - if(exists $args{"_boolean"}) { - $operators = retreave_boolean_keywords($args{"_boolean"}); - - foreach my $op (keys %{$operators}){ - $parser->operator($op, $operators->{$op}); + if($args{"_boolean"} eq 'true') { + for my $op ( @{ new_editor->search_config_strings( {purpose => {like => 'bool-op-%'}} ) } ) { + my $key = $op->purpose; + #strip off the purpose prefix leaving just the operator + $key =~ s/^bool-op-//; + $parser->operator( $key, $op->string ); } } @@ -3334,40 +3335,5 @@ __PACKAGE__->register_method( cachable => 1, ); -sub retreave_boolean_keywords { - my $cache = OpenSRF::Utils::Cache->new; - my $locale = shift; - my $operators; - - #Reformat locale abreveation [en_us -> en-US] - $locale =~ s/(\w\w)_(\w\w)/$1\-\U$2\E/g; - - #Check cache for localization valuse for the current locale - $operators = $cache->get_cache("boolsearchlocale.${locale}"); - - #unless there is a cached set of values load from disk and add to cache - unless (defined($operators)){ - #there are no operators in the cache so load from the DB - $operators = {}; - my $editor = new_editor; - my $results = $editor->json_query({from => ["config.retrieve_keywords_by_locale", $locale]}); - - foreach my $result (@{$results}){ - $operators->{$result->{operator}} = $result->{keyword}; - } - - $cache->put_cache("boolsearchlocale.${locale}", $operators); - } - - #if operators is still empty default to basic english keywords - if (!defined($operators)){ - $operators->{"and"} = " and "; - $operators->{"or"} = " or "; - $operators->{"disallowed"} = " not "; - } - - return $operators; -} - 1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index c19e570892..ada36d2ee5 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -400,7 +400,7 @@ sub load_rresults { #if this is a boolean search add flag so operators can be set later if($cgi->param("_boolean")) { - $args->{"_boolean"} = $ctx->{locale}; + $args->{"_boolean"} = 'true'; } if ($tag_circs) { diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.seed_boolean_keyword_table.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.seed_boolean_keyword_table.sql deleted file mode 100644 index 17af847132..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.seed_boolean_keyword_table.sql +++ /dev/null @@ -1,7 +0,0 @@ -INSERT INTO config.boolean_keyword (translation, operator, keyword) - VALUES ( 'en-US', 'and', ' and '), - ( 'en-US', 'or', ' or '), - ( 'en-US', 'disallowed', ' not '), - ( 'fr-CA', 'and', ' et '), - ( 'fr-CA', 'or', ' ou '), - ( 'fr-CA', 'disallowed', ' pas '); diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.retrieve_keywords_by_locale.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.retrieve_keywords_by_locale.sql deleted file mode 100644 index 36df9a3710..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.retrieve_keywords_by_locale.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE OR REPLACE FUNCTION config.retrieve_keywords_by_locale(locale text) - RETURNS TABLE( operator text, keyword text ) AS -$BODY$ -BEGIN - - RETURN QUERY - SELECT bk.operator, bk.keyword FROM config.boolean_keyword bk WHERE translation = locale; - RETURN; -END; -$BODY$ -LANGUAGE plpgsql; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.boolean_keyword_table.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.boolean_keyword_table.sql deleted file mode 100644 index 479cf9361a..0000000000 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.boolean_keyword_table.sql +++ /dev/null @@ -1,18 +0,0 @@ --- DROP TABLE config.boolean_keyword; - -CREATE TABLE config.boolean_keyword -( - id serial NOT NULL, - translation text, - operator text, - keyword text, - CONSTRAINT boolean_keyword_pk PRIMARY KEY (id), - CONSTRAINT boolean_keyword_fk FOREIGN KEY (translation) - REFERENCES config.i18n_locale (code) MATCH SIMPLE - ON UPDATE NO ACTION ON DELETE NO ACTION -) -WITH ( - OIDS=FALSE -); -ALTER TABLE config.boolean_keyword - OWNER TO evergreen; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.config_strings.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.config_strings.sql new file mode 100644 index 0000000000..eccb3400ab --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.config_strings.sql @@ -0,0 +1,13 @@ +create table config.strings ( + purpose text primary key, -- store a use case label here + string text not null -- store the en-US version here +); + +insert into config.strings (purpose,string) values ('bool-op-and',' and '); +insert into config.i18n_core (fq_field,identity_value,translation,string) values ('es.string',' and ','fr-CA',' et '); + +insert into config.strings (purpose,string) values ('bool-op-or',' or '); +insert into config.i18n_core (fq_field,identity_value,translation,string) values ('es.string',' or ','fr-CA',' ou '); + +insert into config.strings (purpose,string) values ('bool-op-disallowed',' not '); +insert into config.i18n_core (fq_field,identity_value,translation,string) values ('es.string',' not ','fr-CA',' pas ');