*/
private static QueryRule convertOperator(JQGridRule jqGridRule)
{
// ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']
QueryRule rule = new QueryRule(jqGridRule.getField(), QueryRule.Operator.EQUALS, jqGridRule.getData());
switch (jqGridRule.getOp())
{
case eq:
rule.setOperator(QueryRule.Operator.EQUALS);
return rule;
case ne:
rule.setOperator(QueryRule.Operator.EQUALS);
return toNotRule(rule);
case lt:
rule.setOperator(QueryRule.Operator.LESS);
return rule;
case le:
rule.setOperator(QueryRule.Operator.LESS_EQUAL);
return rule;
case gt:
rule.setOperator(QueryRule.Operator.GREATER);
return rule;
case ge:
rule.setOperator(QueryRule.Operator.GREATER_EQUAL);
return rule;
case bw:
rule.setValue(jqGridRule.getData() + "%");
rule.setOperator(QueryRule.Operator.LIKE);
return rule;
case bn:
// NOT
rule.setValue(jqGridRule.getData() + "%");
rule.setOperator(QueryRule.Operator.LIKE);
rule = toNotRule(rule);
return rule;
case in:
rule.setOperator(QueryRule.Operator.IN);
return rule;
case ni:
// NOT
rule.setOperator(QueryRule.Operator.IN);
rule = toNotRule(rule);
return rule;
case ew:
rule.setValue("%" + jqGridRule.getData());
rule.setOperator(QueryRule.Operator.LIKE);
return rule;
case en:
// NOT
rule.setValue("%" + jqGridRule.getData());
rule.setOperator(QueryRule.Operator.LIKE);
return toNotRule(rule);
case cn:
rule.setValue("%" + jqGridRule.getData() + "%");
rule.setOperator(QueryRule.Operator.LIKE);
return rule;
case nc:
// NOT
rule.setValue("%" + jqGridRule.getData() + "%");
rule.setOperator(QueryRule.Operator.LIKE);
return toNotRule(rule);
default:
throw new IllegalArgumentException(String.format("Unkown Operator: %s", jqGridRule.getOp()));
}
}