[open-ils-commits] SPAM: r10170 - in trunk/Open-ILS: examples
src/javascript/backend/catalog src/perlmods/OpenILS/Application
src/perlmods/OpenILS/Application/Storage/CDBI
src/perlmods/OpenILS/Application/Storage/Driver/Pg
src/perlmods/OpenILS/Application/Storage/Publisher src/sql/Pg
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jul 29 00:45:49 EDT 2008
Author: miker
Date: 2008-07-29 00:45:42 -0400 (Tue, 29 Jul 2008)
New Revision: 10170
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js
trunk/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/metabib.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm
trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm
trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
Log:
Adding date filtering support and automatic/configurable default preferred language code
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2008-07-29 04:42:35 UTC (rev 10169)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2008-07-29 04:45:42 UTC (rev 10170)
@@ -1513,6 +1513,8 @@
<field reporter:label="Bib Record Entry" name="record" oils_obj:array_position="15" oils_persist:virtual="false" reporter:datatype="link"/>
<field reporter:label="TMat" name="type_mat" oils_obj:array_position="16" oils_persist:virtual="false" oils_persist:primitive="string" reporter:datatype="text"/>
<field reporter:label="Video Recording Format" name="vr_format" oils_obj:array_position="17" oils_persist:virtual="false" oils_persist:primitive="string" reporter:datatype="text"/>
+ <field reporter:label="Date1" name="date1" oils_obj:array_position="18" oils_persist:virtual="false" oils_persist:primitive="string" reporter:datatype="text"/>
+ <field reporter:label="Date2" name="date2" oils_obj:array_position="19" oils_persist:virtual="false" oils_persist:primitive="string" reporter:datatype="text"/>
</fields>
<links>
<link field="record" reltype="has_a" key="id" map="" class="bre"/>
Modified: trunk/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js
===================================================================
--- trunk/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js 2008-07-29 04:42:35 UTC (rev 10169)
+++ trunk/Open-ILS/src/javascript/backend/catalog/biblio_descriptor.js 2008-07-29 04:45:42 UTC (rev 10170)
@@ -22,6 +22,8 @@
environment.result.cat_form( extractFixedField( marcdoc, 'Desc' ) );
environment.result.pub_status( extractFixedField( marcdoc, 'DtSt' ) );
environment.result.item_lang( extractFixedField( marcdoc, 'Lang' ) );
+environment.result.date1( extractFixedField( marcdoc, 'Date1' ) );
+environment.result.date2( extractFixedField( marcdoc, 'Date2' ) );
environment.result.vr_format( videorecordingFormatCode( marcdoc ) );
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm 2008-07-29 04:42:35 UTC (rev 10169)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Ingest.pm 2008-07-29 04:45:42 UTC (rev 10170)
@@ -1088,6 +1088,14 @@
my $res = $rd_script->run || ($log->error( "Descriptor script died! $@" ) && return undef);
$log->debug("Script for biblio descriptor extraction completed successfully");
+ if ($res->{date1} ne ' ') {
+ $res->{date1} =~ tr/ux/00/;
+ }
+
+ if ($res->{date2} ne ' ') {
+ $res->{date2} =~ tr/ux/99/;
+ }
+
return $res;
}
__PACKAGE__->register_method(
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm 2008-07-29 04:42:35 UTC (rev 10169)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/config.pm 2008-07-29 04:45:42 UTC (rev 10170)
@@ -118,6 +118,20 @@
__PACKAGE__->columns(Essential => qw/value/);
#-------------------------------------------------------------------------------
+package config::i18n_locale;
+use base qw/config/;
+__PACKAGE__->table('config_i18n_locale');
+__PACKAGE__->columns(Primary => 'code');
+__PACKAGE__->columns(Essential => qw/marc_code name description/);
+#-------------------------------------------------------------------------------
+package config::i18n_core;
+use base qw/config/;
+__PACKAGE__->table('config_i18n_core');
+__PACKAGE__->columns(Primary => 'id');
+__PACKAGE__->columns(Essential => qw/fq_field identity_value translation string/);
+#-------------------------------------------------------------------------------
+
+
1;
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/metabib.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/metabib.pm 2008-07-29 04:42:35 UTC (rev 10169)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/metabib.pm 2008-07-29 04:45:42 UTC (rev 10170)
@@ -80,7 +80,7 @@
metabib::record_descriptor->columns( Primary => qw/id/ );
metabib::record_descriptor->columns( Essential => qw/record item_type item_form bib_level
control_type char_encoding enc_level lit_form vr_format
- cat_form pub_status item_lang audience type_mat/ );
+ cat_form pub_status item_lang audience type_mat date1 date2/ );
#-------------------------------------------------------------------------------
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm 2008-07-29 04:42:35 UTC (rev 10169)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm 2008-07-29 04:45:42 UTC (rev 10170)
@@ -672,6 +672,17 @@
#-------------------------------------------------------------------------------
+ package config::i18n_locale;
+ config::i18n_locale->table('config.i18n_locale');
+
+ #-------------------------------------------------------------------------------
+
+ package config::i18n_core;
+ config::i18n_core->sequence( 'config.i18n_core_id_seq' );
+ config::i18n_core->table('config.i18n_core');
+
+ #-------------------------------------------------------------------------------
+
package config::item_form_map;
config::item_form_map->table('config.item_form_map');
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm 2008-07-29 04:42:35 UTC (rev 10169)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm 2008-07-29 04:45:42 UTC (rev 10170)
@@ -2328,12 +2328,47 @@
cachable => 1,
);
+
+my %locale_map;
+my $default_preferred_language;
+my $default_preferred_language_weight;
+
# XXX factored most of the PG dependant stuff out of here... need to find a way to do "dependants".
sub staged_fts {
my $self = shift;
my $client = shift;
my %args = @_;
-
+
+ if (!$locale_map{COMPLETE}) {
+
+ my @locales = config::i18n_locale->search_where({ code => { '<>' => '' } });
+ for my $locale ( @locales ) {
+ $locale_map{$locale->code} = $locale->marc_code;
+ }
+ $locale_map{COMPLETE} = 1;
+
+ }
+
+ if (!$default_preferred_language) {
+
+ $default_preferred_language = OpenSRF::Utils::SettingsClient
+ ->new
+ ->config_value(
+ apps => 'open-ils.storage' => app_settings => 'default_preferred_language'
+ );
+
+ }
+
+ if (!$default_preferred_language_weight) {
+
+ $default_preferred_language_weight = OpenSRF::Utils::SettingsClient
+ ->new
+ ->config_value(
+ apps => 'open-ils.storage' => app_settings => 'default_preferred_language_weight'
+ );
+
+ }
+
my $ou = $args{org_unit};
my $limit = $args{limit} || 10;
my $offset = $args{offset} || 0;
@@ -2346,8 +2381,17 @@
die "No search arguments were passed to ".$self->api_name;
}
- my (@statuses, at locations, at types, at forms, at lang, at aud, at lit_form, at vformats, at bib_level);
+ my (@between, at statuses, at locations, at types, at forms, at lang, at aud, at lit_form, at vformats, at bib_level);
+ if (!defined($args{preferred_language})) {
+ $args{preferred_language} =
+ $locale_map{ $self->session->session_locale || $default_preferred_language } || 'eng';
+ }
+
+ if (!defined($args{preferred_language_weight})) {
+ $args{preferred_language_weight} = $default_preferred_language_weight || 2;
+ }
+
if ($args{available}) {
@statuses = (0,7,12);
}
@@ -2357,6 +2401,12 @@
@locations = @$s;
}
+ if (my $b = $args{between}) {
+ if (ref($b) && @$b == 2) {
+ @between = @$b;
+ }
+ }
+
if (my $s = $args{statuses}) {
$s = [$s] if (!ref($s));
@statuses = @$s;
@@ -2457,6 +2507,10 @@
my $param_forms = '$${' . join(',', map { s/\$//go; "\"$_\""} @forms) . '}$$';
my $param_vformats = '$${' . join(',', map { s/\$//go; "\"$_\"" } @vformats) . '}$$';
my $param_bib_level = '$${' . join(',', map { s/\$//go; "\"$_\"" } @bib_level) . '}$$';
+ my $param_before = $args{before}; $param_before = 'NULL' unless (defined($param_before) and length($param_before) > 0 );
+ my $param_after = $args{after}; $param_after = 'NULL' unless (defined($param_after) and length($param_after) > 0 );
+ my $param_during = $args{during}; $param_during = 'NULL' unless (defined($param_during) and length($param_during) > 0 );
+ my $param_between = '$${"' . join('","', map { int($_) } @between) . '"}$$';
my $param_pref_lang = $args{preferred_language}; $param_pref_lang =~ s/\$//go; $param_pref_lang = '$$'.$param_pref_lang.'$$';
my $param_pref_lang_multiplier = $args{preferred_language_weight}; $param_pref_lang_multiplier ||= 'NULL';
my $param_sort = $args{'sort'}; $param_sort =~ s/\$//go; $param_sort = '$$'.$param_sort.'$$';
@@ -2482,6 +2536,10 @@
$param_forms\:\:TEXT[],
$param_vformats\:\:TEXT[],
$param_bib_level\:\:TEXT[],
+ $param_before\:\:TEXT,
+ $param_after\:\:TEXT,
+ $param_during\:\:TEXT,
+ $param_between\:\:TEXT[],
$param_pref_lang\:\:TEXT,
$param_pref_lang_multiplier\:\:REAL,
$param_sort\:\:TEXT,
Modified: trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql 2008-07-29 04:42:35 UTC (rev 10169)
+++ trunk/Open-ILS/src/sql/Pg/300.schema.staged_search.sql 2008-07-29 04:45:42 UTC (rev 10170)
@@ -57,6 +57,10 @@
param_forms TEXT[],
param_vformats TEXT[],
param_bib_level TEXT[],
+ param_before TEXT,
+ param_after TEXT,
+ param_during TEXT,
+ param_between TEXT[],
param_pref_lang TEXT,
param_pref_lang_multiplier REAL,
param_sort TEXT,
@@ -241,7 +245,7 @@
current_rank := ' CASE WHEN mrd.item_lang = ' || quote_literal( param_pref_lang ) ||
' THEN ' || param_pref_lang_multiplier || '::REAL ELSE 1.0 END ';
- --ranks := array_append( ranks, current_rank );
+ -- ranks := array_append( ranks, current_rank );
END IF;
current_rank := ' AVG( ( (' || array_to_string( ranks, ') + (' ) || ') ) * ' || current_rank || ' ) ';
@@ -254,16 +258,7 @@
tmp_text := '999999';
IF param_sort_desc THEN tmp_text := '0'; END IF;
- current_rank := $$
- ( COALESCE( FIRST ((
- SELECT SUBSTRING(frp.value FROM E'\\d{4}')
- FROM metabib.full_rec frp
- WHERE frp.record = m.source
- AND frp.tag = '260'
- AND frp.subfield = 'c'
- LIMIT 1
- )), $$ || quote_literal(tmp_text) || $$ )::INT )
- $$;
+ current_rank := $$ COALESCE( mrd.date1, $$ || quote_literal(tmp_text) || $$ )::INT ) $$;
ELSIF param_sort = 'title' THEN
@@ -337,6 +332,22 @@
where_clause = where_clause || $$ AND mrd.bib_level IN ('$$ || array_to_string(param_bib_level, $$','$$) || $$') $$;
END IF;
+ IF param_before IS NOT NULL AND param_before <> '' THEN
+ where_clause = where_clause || $$ AND mrd.date1 <= $$ || quote_literal(param_before) || ' ';
+ END IF;
+
+ IF param_after IS NOT NULL AND param_after <> '' THEN
+ where_clause = where_clause || $$ AND mrd.date1 >= $$ || quote_literal(param_after) || ' ';
+ END IF;
+
+ IF param_during IS NOT NULL AND param_during <> '' THEN
+ where_clause = where_clause || $$ AND $$ || quote_literal(param_during) || $$ BETWEEN mrd.date1 AND mrd.date2 $$;
+ END IF;
+
+ IF param_between IS NOT NULL AND array_upper(param_between, 1) > 0 THEN
+ where_clause = where_clause || $$ AND mrd.date1 BETWEEN $$ || array_to_string(param_bib_level, $$' AND '$$) || ' ';
+ END IF;
+
core_rel_query := select_clause || from_clause || where_clause ||
' GROUP BY 1 ORDER BY 4' || CASE WHEN sort_desc THEN ' DESC' ELSE ' ASC' END || ';';
--RAISE NOTICE 'Base Query: %', core_rel_query;
@@ -546,15 +557,6 @@
END;
$func$ LANGUAGE PLPGSQL;
-/*
- param_statuses INT[],
- param_audience TEXT[], x
- param_language TEXT[], x
- param_lit_form TEXT[], x
- param_types TEXT[], x
- param_forms TEXT[], x
- param_vformats TEXT[], x
-*/
CREATE OR REPLACE FUNCTION search.explode_array(anyarray) RETURNS SETOF anyelement AS $BODY$
SELECT ($1)[s] FROM generate_series(1, array_upper($1, 1)) AS s;
More information about the open-ils-commits
mailing list