Search in sources :

Example 1 with GridComponentMultiSearchFilterRule

use of com.qcadoo.view.internal.components.grid.GridComponentMultiSearchFilterRule in project qcadoo by qcadoo.

the class GridComponentMultiSearchFilter method addRule.

public void addRule(final String field, final String operator, final String data) {
    GridComponentFilterOperator filterOperator = resolveOperator(operator);
    rules.add(new GridComponentMultiSearchFilterRule(field, filterOperator, data));
}
Also used : GridComponentFilterOperator(com.qcadoo.view.internal.components.grid.GridComponentFilterOperator) GridComponentMultiSearchFilterRule(com.qcadoo.view.internal.components.grid.GridComponentMultiSearchFilterRule)

Example 2 with GridComponentMultiSearchFilterRule

use of com.qcadoo.view.internal.components.grid.GridComponentMultiSearchFilterRule in project qcadoo by qcadoo.

the class GridComponentMultiSearchFilter method toJson.

public JSONObject toJson() throws JSONException {
    if (groupOperator != null && !rules.isEmpty()) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(JSON_GROUP_OPERATOR_FIELD, groupOperator.getValue());
        JSONArray jsonRules = new JSONArray();
        for (GridComponentMultiSearchFilterRule rule : rules) {
            JSONObject jsonRule = new JSONObject();
            jsonRule.put(GridComponentMultiSearchFilterRule.JSON_FIELD_FIELD, rule.getField());
            jsonRule.put(GridComponentMultiSearchFilterRule.JSON_OPERATOR_FIELD, rule.getFilterOperator().getValue());
            jsonRule.put(GridComponentMultiSearchFilterRule.JSON_DATA_FIELD, rule.getData());
            jsonRules.put(jsonRule);
        }
        jsonObject.put(JSON_RULES_FIELD, jsonRules);
        return jsonObject;
    }
    return null;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) GridComponentMultiSearchFilterRule(com.qcadoo.view.internal.components.grid.GridComponentMultiSearchFilterRule)

Aggregations

GridComponentMultiSearchFilterRule (com.qcadoo.view.internal.components.grid.GridComponentMultiSearchFilterRule)2 GridComponentFilterOperator (com.qcadoo.view.internal.components.grid.GridComponentFilterOperator)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1