use of org.adempiere.ad.dao.IQueryFilterModifier in project metasfresh-webui-api by metasfresh.
the class SqlDefaultDocumentFilterConverter method buildSqlWhereClause_StandardWidget.
private final String buildSqlWhereClause_StandardWidget(final SqlParamsCollector sqlParams, final DocumentFilterParam filterParam, final SqlOptions sqlOpts) {
final SqlEntityFieldBinding paramBinding = getParameterBinding(filterParam.getFieldName());
final DocumentFieldWidgetType widgetType = paramBinding.getWidgetType();
//
// Regular filter
final IQueryFilterModifier fieldModifier = extractFieldModifier(widgetType);
final IQueryFilterModifier valueModifier = extractValueModifier(widgetType);
final String columnSql = extractColumnSql(paramBinding, fieldModifier, sqlOpts);
final Operator operator = filterParam.getOperator();
switch(operator) {
case EQUAL:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
final boolean negate = false;
return buildSqlWhereClause_Equals(columnSql, sqlValue, negate, sqlParams);
}
case NOT_EQUAL:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
final boolean negate = true;
return buildSqlWhereClause_Equals(columnSql, sqlValue, negate, sqlParams);
}
case IN_ARRAY:
{
final List<Object> sqlValuesList = filterParam.getValueAsList(itemObj -> convertToSqlValue(itemObj, paramBinding, valueModifier));
return buildSqlWhereClause_InArray(columnSql, sqlValuesList, sqlParams);
}
case GREATER:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
return buildSqlWhereClause_Compare(columnSql, ">", sqlValue, sqlParams);
}
case GREATER_OR_EQUAL:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
return buildSqlWhereClause_Compare(columnSql, ">=", sqlValue, sqlParams);
}
case LESS:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
return buildSqlWhereClause_Compare(columnSql, "<", sqlValue, sqlParams);
}
case LESS_OR_EQUAL:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
return buildSqlWhereClause_Compare(columnSql, "<=", sqlValue, sqlParams);
}
case LIKE:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
final boolean negate = false;
final boolean ignoreCase = false;
return buildSqlWhereClause_Like(columnSql, negate, ignoreCase, sqlValue, sqlParams);
}
case NOT_LIKE:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
final boolean negate = true;
final boolean ignoreCase = false;
return buildSqlWhereClause_Like(columnSql, negate, ignoreCase, sqlValue, sqlParams);
}
case LIKE_I:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
final boolean negate = false;
final boolean ignoreCase = true;
return buildSqlWhereClause_Like(columnSql, negate, ignoreCase, sqlValue, sqlParams);
}
case NOT_LIKE_I:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
final boolean negate = true;
final boolean ignoreCase = true;
return buildSqlWhereClause_Like(columnSql, negate, ignoreCase, sqlValue, sqlParams);
}
case BETWEEN:
{
final Object sqlValue = convertToSqlValue(filterParam.getValue(), paramBinding, valueModifier);
final Object sqlValueTo = convertToSqlValue(filterParam.getValueTo(), paramBinding, valueModifier);
return buildSqlWhereClause_Between(columnSql, sqlValue, sqlValueTo, sqlParams);
}
default:
{
throw new IllegalArgumentException("Operator not supported: " + operator);
}
}
}
Aggregations