String op = qlg.getOperator() == QueryLogicalGroup.Operator.AND ? "INTERSECT" : "UNION";
for (int i = 1; i < qlg.getExpressions().size(); i++)
sqlQuery += ") " + op + " (" + this.getSqlQuery(qlg.getExpressions().get(i));
sqlQuery += ")";
}else if (queryExpression instanceof ComparisonQueryExpression){
ComparisonQueryExpression cqe = (ComparisonQueryExpression) queryExpression;
String operator = null;
if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.EQUAL_TO)) {
operator = "=";
} else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.GREATER_THAN)) {
operator = ">";
} else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.GREATER_THAN_EQUAL_TO)) {
operator = ">=";
} else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.LESS_THAN)) {
operator = "<";
} else if (cqe.getOperator().equals(ComparisonQueryExpression.Operator.LESS_THAN_EQUAL_TO)) {
operator = "<=";
} else {
throw new QueryServiceException("Invalid ComparisonQueryExpression Operator '" + cqe.getOperator() + "'");
}
sqlQuery = "SELECT DISTINCT transaction_id FROM transaction_terms WHERE " + bucketNameFilter + " term_name = '" + cqe.getTerm().getName() + "' AND (";
for (int i = 0; i < cqe.getTerm().getValues().size(); i++) {
String value = cqe.getTerm().getValues().get(i);
sqlQuery += "term_value " + operator + " '" + (this.useUTF8 ? URLEncoder.encode(value, "UTF-8") : value) + "'";
if ((i + 1) < cqe.getTerm().getValues().size())
sqlQuery += " OR ";
}
sqlQuery += ")";
}else if (queryExpression instanceof NotQueryExpression) {
NotQueryExpression nqe = (NotQueryExpression) queryExpression;