Search in sources :

Example 1 with HasStringValue

use of org.activityinfo.model.type.primitive.HasStringValue in project activityinfo by bedatadriven.

the class IndicatorValueTableUpdater method executeTextUpdate.

private void executeTextUpdate(QueryExecutor executor, IndicatorUpdate update) {
    HasStringValue textValue = (HasStringValue) update.value;
    executor.update("REPLACE INTO indicatorvalue (reportingPeriodId, indicatorId, TextValue) VALUES (?, ?, ?)", Arrays.asList(reportingPeriodId, update.indicatorId, textValue.asString()));
}
Also used : HasStringValue(org.activityinfo.model.type.primitive.HasStringValue)

Example 2 with HasStringValue

use of org.activityinfo.model.type.primitive.HasStringValue 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;
}
Also used : FilterConfigBean(com.sencha.gxt.data.shared.loader.FilterConfigBean) HasStringValue(org.activityinfo.model.type.primitive.HasStringValue) FilterConfig(com.sencha.gxt.data.shared.loader.FilterConfig) FieldValue(org.activityinfo.model.type.FieldValue)

Aggregations

HasStringValue (org.activityinfo.model.type.primitive.HasStringValue)2 FilterConfig (com.sencha.gxt.data.shared.loader.FilterConfig)1 FilterConfigBean (com.sencha.gxt.data.shared.loader.FilterConfigBean)1 FieldValue (org.activityinfo.model.type.FieldValue)1