From: Chris Sharp Date: Thu, 8 Sep 2016 10:52:47 +0000 (-0400) Subject: LP#1618993 - Reverse "Contains Matching Substring" logic X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=c087cf85a35b6684a32d3f86f05a0eb52638b365;p=working%2FEvergreen.git LP#1618993 - Reverse "Contains Matching Substring" logic The reporter employs "Contains Matching Substring" operators and there is sometimes a need to "Exclude Matching Substring". --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm b/Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm index d98a04fa25..9032c60f02 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Reporter/SQLBuilder.pm @@ -967,6 +967,14 @@ sub toSQL { $val =~ s/_/\\_/o; $sql .= " LIKE \$_$$\$\%$val\%\$_$$\$"; + } elsif (lc($op) eq 'not like') { + $val = $$val[0] if (ref($val) eq 'ARRAY'); + $val = $val->toSQL; + $val =~ s/\$_$$\$//g; + $val =~ s/%/\\%/o; + $val =~ s/_/\\_/o; + $sql .= "NOT LIKE \$_$$\$\%$val\%\$_$$\$"; + } elsif (lc($op) eq 'ilike') { $val = $$val[0] if (ref($val) eq 'ARRAY'); $val = $val->toSQL; @@ -975,6 +983,14 @@ sub toSQL { $val =~ s/_/\\_/o; $sql .= " ILIKE \$_$$\$\%$val\%\$_$$\$"; + } elsif (lc($op) eq 'not ilike') { + $val = $$val[0] if (ref($val) eq 'ARRAY'); + $val = $val->toSQL; + $val =~ s/\$_$$\$//g; + $val =~ s/%/\\%/o; + $val =~ s/_/\\_/o; + $sql .= "NOT ILIKE \$_$$\$\%$val\%\$_$$\$"; + } else { $val = $$val[0] if (ref($val) eq 'ARRAY'); $sql .= " $op " . $val->toSQL; diff --git a/Open-ILS/web/reports/oils_rpt_filters.js b/Open-ILS/web/reports/oils_rpt_filters.js index b8b5ded004..8f7d3895e3 100644 --- a/Open-ILS/web/reports/oils_rpt_filters.js +++ b/Open-ILS/web/reports/oils_rpt_filters.js @@ -15,6 +15,16 @@ var OILS_RPT_FILTERS = { label : rpt_strings.FILTERS_LABEL_ILIKE }, + + 'not like' : { + label: rpt_strings.FILTERS_LABEL_NOT_LIKE + }, + + 'not ilike' : { + label: rpt_strings.FILTERS_LABEL_NOT_ILIKE + }, + + '>' : { label : rpt_strings.FILTERS_LABEL_GREATER_THAN, labels : { timestamp : rpt_strings.FILTERS_LABEL_GT_TIME } diff --git a/Open-ILS/web/reports/xul/operators.js b/Open-ILS/web/reports/xul/operators.js index 7c512e9c11..d344802e00 100644 --- a/Open-ILS/web/reports/xul/operators.js +++ b/Open-ILS/web/reports/xul/operators.js @@ -9,12 +9,16 @@ var OILS_RPT_FILTERS = { 'like' : { label : rpt_strings.OPERATORS_LIKE - }, - - ilike : { + }, + 'not like' : { + label : rpt_strings.OPERATORS_NOT_LIKE + }, + 'ilike' : { label : rpt_strings.OPERATORS_ILIKE }, - + 'not ilike' : { + label : rpt_strings.OPERATORS_NOT_ILIKE + }, '>' : { label : rpt_strings.OPERATORS_GREATER_THAN, labels : { timestamp : rpt_strings.OPERATORS_GT_TIME } diff --git a/build/i18n/po/reports.js/reports.js.pot b/build/i18n/po/reports.js/reports.js.pot index 52829214c6..c08bdeb544 100644 --- a/build/i18n/po/reports.js/reports.js.pot +++ b/build/i18n/po/reports.js/reports.js.pot @@ -253,6 +253,10 @@ msgstr "" msgid "Contains Matching substring" msgstr "" +#: reports.js:OPERATORS_NOT_LIKE reports.js:FILTERS_LABEL_NOT_LIKE +msgid "Does Not Contain Matching substring" +msgstr "" + #: reports.js:OPERATORS_EQUALS reports.js:TEMPLATE_CONF_EQUALS #: reports.js:FILTERS_LABEL_EQUALS msgid "Equals" @@ -413,6 +417,10 @@ msgstr "" msgid "Contains Matching substring (ignore case)" msgstr "" +#: reports.js:OPERATORS_NOT_ILIKE reports.js:FILTERS_LABEL_NOT_ILIKE +msgid "Does Not Contain Matching substring (ignore case)" +msgstr "" + #: reports.js:TRANSFORMS_MOY reports.js:TFORMS_LABEL_MOY msgid "Month of Year" msgstr ""