From 38896e1649c563d16ab6e2f8abed68d0e5f0b256 Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 11 Nov 2009 18:52:01 +0000 Subject: [PATCH] add initial cut of support for in-db array datatype operators git-svn-id: svn://svn.open-ils.org/ILS/trunk@14869 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm | 10 ++++++++++ Open-ILS/web/js/dojo/openils/reports/nls/reports.js | 4 ++++ Open-ILS/web/reports/oils_rpt_filters.js | 8 ++++++++ Open-ILS/web/reports/xul/operators.js | 8 ++++++++ Open-ILS/web/reports/xul/template-config.js | 19 +++++++++++-------- Open-ILS/web/reports/xul/transforms.js | 1 + 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm b/Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm index 228b6d38d..44ed54889 100644 --- a/Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm +++ b/Open-ILS/src/perlmods/OpenILS/Reporter/SQLBuilder.pm @@ -943,6 +943,16 @@ sub toSQL { } elsif (lc($op) eq 'not in') { $sql .= " NOT IN (". join(",", map { $_->toSQL } @$val).")"; + } elsif (lc($op) eq '= any') { + $val = $$val[0] if (ref($val) eq 'ARRAY'); + $val = $val->toSQL; + $sql = "$val = ANY (".$self->SUPER::toSQL.")"; + + } elsif (lc($op) eq '<> any') { + $val = $$val[0] if (ref($val) eq 'ARRAY'); + $val = $val->toSQL; + $sql = "$val <> ANY (".$self->SUPER::toSQL.")"; + } elsif (lc($op) eq 'is blank') { $sql = '('. $self->SUPER::toSQL ." IS NULL OR ". $self->SUPER::toSQL ." = '')"; diff --git a/Open-ILS/web/js/dojo/openils/reports/nls/reports.js b/Open-ILS/web/js/dojo/openils/reports/nls/reports.js index f9b72e551..34bd06ff4 100644 --- a/Open-ILS/web/js/dojo/openils/reports/nls/reports.js +++ b/Open-ILS/web/js/dojo/openils/reports/nls/reports.js @@ -25,6 +25,8 @@ "FILTERS_LABEL_NOT_NULL": "Is not NULL", "FILTERS_LABEL_NULL_BLANK": "Is NULL or Blank", "FILTERS_LABEL_NOT_NULL_BLANK": "Is not NULL or Blank", + "FILTERS_LABEL_EQ_ANY": "Equals Any", + "FILTERS_LABEL_NE_ANY": "Does Not Equal Any", "FOLDERS_TEMPLATES": "Templates", "FOLDERS_TEMPLATE": "Template", @@ -104,6 +106,8 @@ "OPERATORS_IS_NOT_NULL": "Is not NULL", "OPERATORS_NULL_BLANK": "Is NULL or Blank", "OPERATORS_NOT_NULL_BLANK": "Is not NULL or Blank", + "OPERATORS_EQ_ANY": "Equals Any", + "OPERATORS_NE_ANY": "Does Not Equal Any", "SOURCE_BROWSE_AGGREGATE": "Aggregate", "SOURCE_BROWSE_NON_AGGREGATE": "Non-Aggregate", diff --git a/Open-ILS/web/reports/oils_rpt_filters.js b/Open-ILS/web/reports/oils_rpt_filters.js index 714cb7b54..b8b5ded00 100644 --- a/Open-ILS/web/reports/oils_rpt_filters.js +++ b/Open-ILS/web/reports/oils_rpt_filters.js @@ -66,6 +66,14 @@ var OILS_RPT_FILTERS = { 'is not blank' : { label : rpt_strings.FILTERS_LABEL_NOT_NULL_BLANK + }, + + '= any' : { + label : rpt_strings.FILTERS_LABEL_EQ_ANY + }, + + '<> any' : { + label : rpt_strings.FILTERS_LABEL_NE_ANY } } diff --git a/Open-ILS/web/reports/xul/operators.js b/Open-ILS/web/reports/xul/operators.js index d717c300f..7c512e9c1 100644 --- a/Open-ILS/web/reports/xul/operators.js +++ b/Open-ILS/web/reports/xul/operators.js @@ -66,6 +66,14 @@ var OILS_RPT_FILTERS = { 'is not blank' : { label : rpt_strings.OPERATORS_NOT_NULL_BLANK + }, + + '= any' : { + labels : { 'array' : rpt_strings.OPERATORS_EQ_ANY } + }, + + '<> any' : { + labels : { 'array' : rpt_strings.OPERATORS_NE_ANY } } } diff --git a/Open-ILS/web/reports/xul/template-config.js b/Open-ILS/web/reports/xul/template-config.js index 387c7c864..c72758f71 100644 --- a/Open-ILS/web/reports/xul/template-config.js +++ b/Open-ILS/web/reports/xul/template-config.js @@ -105,7 +105,7 @@ function addReportAtoms () { alias : field_label, join : jointype, datatype : datatype, - op : '=', + op : (datatype == 'array') ? '= any' : '=', op_label : rpt_strings.TEMPLATE_CONF_EQUALS, op_value : {} }; @@ -513,13 +513,16 @@ function populateOperatorContext () { for (var i in OILS_RPT_FILTERS) { var o = OILS_RPT_FILTERS[i]; - menu.appendChild( - createMenuItem( - { label : o.label, - onmouseup : "changeOperator({op:'"+i+"',label:'"+o.label+"'})" - } - ) - ); + if (o.label) { + menu.appendChild( + createMenuItem( + { label : o.label, + onmouseup : "changeOperator({op:'"+i+"',label:'"+o.label+"'})" + } + ) + ); + } + if (o.labels) { var keys = getKeys(o.labels); for ( var k in keys ) { diff --git a/Open-ILS/web/reports/xul/transforms.js b/Open-ILS/web/reports/xul/transforms.js index 86abb5376..96b909d8e 100644 --- a/Open-ILS/web/reports/xul/transforms.js +++ b/Open-ILS/web/reports/xul/transforms.js @@ -1,6 +1,7 @@ dojo.requireLocalization("openils.reports", "reports"); var rpt_strings = dojo.i18n.getLocalization("openils.reports", "reports"); +var OILS_RPT_DTYPE_ARRAY = 'array'; var OILS_RPT_DTYPE_STRING = 'text'; var OILS_RPT_DTYPE_MONEY = 'money'; var OILS_RPT_DTYPE_BOOL = 'bool'; -- 2.11.0