}
private String getSqlQuery(QueryCriteria queryCriteria, ProductType type) throws ValidationLayerException, CatalogException {
String sqlQuery = null;
if (queryCriteria instanceof BooleanQueryCriteria) {
BooleanQueryCriteria bqc = (BooleanQueryCriteria) queryCriteria;
if (bqc.getOperator() == BooleanQueryCriteria.NOT) {
sqlQuery = "SELECT DISTINCT product_id FROM " + type.getName() + "_metadata WHERE product_id NOT IN (" + this.getSqlQuery(bqc.getTerms().get(0), type) + ")";
}else {
sqlQuery = "(" + this.getSqlQuery(bqc.getTerms().get(0), type);
String op = bqc.getOperator() == BooleanQueryCriteria.AND ? "INTERSECT" : "UNION";
for (int i = 1; i < bqc.getTerms().size(); i++)
sqlQuery += ") " + op + " (" + this.getSqlQuery(bqc.getTerms().get(i), type);
sqlQuery += ")";
}
}else {
String elementIdStr = this.validationLayer.getElementByName(queryCriteria.getElementName()).getElementId();
if (fieldIdStringFlag)