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;
switch (this.field) {
case NAME:
return this.op(card.getName(), this.operand);
return op(card.getName(), this.operand);
case SUBTYPE:
shouldContain = (this.getOperator() == StringOp.CONTAINS) || (this.getOperator() == StringOp.EQUALS);
return shouldContain == card.getType().subTypeContains(this.operand);
case ORACLE_TEXT:
shouldContain = (this.getOperator() == StringOp.CONTAINS) || (this.getOperator() == StringOp.EQUALS);
return shouldContain == card.getOracleText().contains(this.operand);
return op(card.getOracleText(), operand);
case JOINED_TYPE:
return this.op(card.getType().toString(), this.operand);
return op(card.getType().toString(), operand);
default:
return false;
}

View File

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