addOr = true;
}
}
catch (Exception e)
{
throw new DatabaseException(e);
}
// add to rules
where_clause.append("(");
where_clause.append(createWhereSql(mapper, true, false,
searchRules.toArray(new QueryRule[searchRules.size()])));
where_clause.append(")");
}
else if (rule.getOperator() == QueryRule.Operator.NESTED
|| (rule.getOperator() == QueryRule.Operator.NOT && rule.getNestedRules() != null && rule
.getNestedRules().length > 0))
{
QueryRule[] nestedrules = rule.getNestedRules();
if (nestedrules.length > 0)
{
if (where_clause.length() > 0)
{
if (previousRule != null && Operator.OR.equals(previousRule.getOperator()))
{
where_clause.append(" OR ");
}
else
{
where_clause.append(" AND ");
}
}
if (rule.getOperator() == QueryRule.Operator.NOT)
{
where_clause.append("NOT");
}
where_clause.append("(");
where_clause.append(createWhereSql(mapper, true, false, nestedrules));
where_clause.append(")");
}
}
// experimental: subqery
else if (rule.getOperator() == QueryRule.Operator.IN_SUBQUERY)
{
if (where_clause.length() > 0)
{
if (previousRule != null && Operator.OR.equals(previousRule.getOperator()))
{
where_clause.append(" OR ");
}
else
{
where_clause.append(" AND ");
}
}
where_clause.append(rule.getField() + " IN(" + rule.getValue() + ")");
}
else if (rule.getOperator() == QueryRule.Operator.IN)
{
// only add if nonempty condition???
if (rule.getValue() == null
|| (rule.getValue() instanceof List<?> && ((List<?>) rule.getValue()).size() == 0)
|| (rule.getValue() instanceof Object[] && ((Object[]) rule.getValue()).length == 0)) throw new DatabaseException(
"empty 'in' clause for rule " + rule);
{
if (where_clause.length() > 0)
{
if (previousRule != null && Operator.OR.equals(previousRule.getOperator()))