use of com.sencha.gxt.data.shared.loader.FilterConfigBean in project activityinfo by bedatadriven.
the class ColumnFilterParserTest method string.
@Test
public void string() {
FilterConfig cfg = new FilterConfigBean();
cfg.setType("string");
cfg.setComparison("contains");
cfg.setValue("Bar");
assertThat(toFormula(A, cfg).asExpression(), equalTo("ISNUMBER(SEARCH(\"Bar\", A))"));
}
use of com.sencha.gxt.data.shared.loader.FilterConfigBean in project activityinfo by bedatadriven.
the class ColumnFilterParserTest method test.
@Test
public void test() {
FilterConfig c = new FilterConfigBean();
c.setComparison("on");
c.setType("date");
c.setValue("1505779200000");
assertThat(toFormula(A, c).asExpression(), equalTo("A == DATE(2017, 9, 19)"));
}
use of com.sencha.gxt.data.shared.loader.FilterConfigBean in project activityinfo by bedatadriven.
the class ColumnFilterParser method parseStringContains.
/**
* Tries to parse an expression in the form ISNUMBER(SEARCH(substring, string))
*/
private boolean parseStringContains(FormulaNode node, Multimap<Integer, FilterConfig> result) {
if (!(node instanceof FunctionCallNode)) {
return false;
}
FunctionCallNode isNumberCall = ((FunctionCallNode) node);
if (isNumberCall.getFunction() != IsNumberFunction.INSTANCE) {
return false;
}
FormulaNode isNumberArgument = Formulas.simplify(isNumberCall.getArgument(0));
if (!(isNumberArgument instanceof FunctionCallNode)) {
return false;
}
FunctionCallNode searchCall = (FunctionCallNode) isNumberArgument;
if (searchCall.getFunction() != SearchFunction.INSTANCE) {
return false;
}
if (searchCall.getArgumentCount() != 2) {
return false;
}
FieldValue substring = parseLiteral(searchCall.getArgument(0));
if (!(substring instanceof HasStringValue)) {
return false;
}
FormulaNode columnExpr = searchCall.getArgument(1);
Integer columnIndex = columnMap.get(columnExpr);
if (columnIndex == -1) {
return false;
}
FilterConfig filterConfig = new FilterConfigBean();
filterConfig.setType("string");
filterConfig.setComparison("contains");
filterConfig.setValue(((HasStringValue) substring).asString());
result.put(columnIndex, filterConfig);
return true;
}
use of com.sencha.gxt.data.shared.loader.FilterConfigBean in project activityinfo by bedatadriven.
the class ColumnFilterParser method dateFilter.
private FilterConfig dateFilter(FunctionCallNode callNode, LocalDate value) {
FilterConfig config = new FilterConfigBean();
config.setType("date");
config.setComparison(parseDateComparison(callNode));
config.setValue("" + value.atMidnightInMyTimezone().getTime());
return config;
}
Aggregations