make string searches in oracle text case insensitive

This commit is contained in:
myk
2013-03-05 17:05:07 +00:00
parent afe3fa4c8a
commit cb6ded65a8
2 changed files with 6 additions and 12 deletions

View File

@@ -290,15 +290,14 @@ public final class CardRulesPredicates {
boolean shouldContain; boolean shouldContain;
switch (this.field) { switch (this.field) {
case NAME: case NAME:
return this.op(card.getName(), this.operand); return op(card.getName(), this.operand);
case SUBTYPE: case SUBTYPE:
shouldContain = (this.getOperator() == StringOp.CONTAINS) || (this.getOperator() == StringOp.EQUALS); shouldContain = (this.getOperator() == StringOp.CONTAINS) || (this.getOperator() == StringOp.EQUALS);
return shouldContain == card.getType().subTypeContains(this.operand); return shouldContain == card.getType().subTypeContains(this.operand);
case ORACLE_TEXT: case ORACLE_TEXT:
shouldContain = (this.getOperator() == StringOp.CONTAINS) || (this.getOperator() == StringOp.EQUALS); return op(card.getOracleText(), operand);
return shouldContain == card.getOracleText().contains(this.operand);
case JOINED_TYPE: case JOINED_TYPE:
return this.op(card.getType().toString(), this.operand); return op(card.getType().toString(), operand);
default: default:
return false; return false;
} }

View File

@@ -88,10 +88,7 @@ public class SFilterUtil {
return Predicates.alwaysTrue(); return Predicates.alwaysTrue();
} }
String[] splitText = text String[] splitText = text.replaceAll(",", "").replaceAll(" ", " ").split(" ");
.replaceAll(",", "")
.replaceAll(" ", " ")
.toLowerCase().split(" ");
List<Predicate<CardRules>> terms = new ArrayList<Predicate<CardRules>>(); List<Predicate<CardRules>> terms = new ArrayList<Predicate<CardRules>>();
for (String s : splitText) { for (String s : splitText) {
@@ -99,9 +96,7 @@ public class SFilterUtil {
if (inName) { subands.add(CardRulesPredicates.name(StringOp.CONTAINS_IC, s)); } if (inName) { subands.add(CardRulesPredicates.name(StringOp.CONTAINS_IC, s)); }
if (inType) { subands.add(CardRulesPredicates.joinedType(StringOp.CONTAINS_IC, s)); } if (inType) { subands.add(CardRulesPredicates.joinedType(StringOp.CONTAINS_IC, s)); }
if (inText) { subands.add(CardRulesPredicates.rules(StringOp.CONTAINS_IC, s)); }
// rules cannot compare in ignore-case way
if (inText) { subands.add(CardRulesPredicates.rules(StringOp.CONTAINS, s)); }
terms.add(Predicates.or(subands)); terms.add(Predicates.or(subands));
} }