/**
* Append the expression and recursively to the query row.
*/
protected void appendExpressionToQueryRow(Expression expression, AbstractRecord row, DatabaseQuery query) {
if (expression.isRelationExpression()) {
RelationExpression relation = (RelationExpression)expression;
Object left = extractValueFromExpression(relation.getFirstChild(), query);
Object right = extractValueFromExpression(relation.getSecondChild(), query);
if (relation.getOperator().getSelector() == ExpressionOperator.Equal) {
row.put(left, right);
} else {
DatabaseRecord nested = new DatabaseRecord();
if (relation.getOperator().getSelector() == ExpressionOperator.GreaterThan) {
nested.put("$gt", right);
} else if (relation.getOperator().getSelector() == ExpressionOperator.LessThan) {
nested.put("$lt", right);
} else if (relation.getOperator().getSelector() == ExpressionOperator.LessThanEqual) {
nested.put("$lte", right);
} else if (relation.getOperator().getSelector() == ExpressionOperator.GreaterThanEqual) {
nested.put("$gte", right);
} else if (relation.getOperator().getSelector() == ExpressionOperator.NotEqual) {
nested.put("$ne", right);
} else if (relation.getOperator().getSelector() == ExpressionOperator.In) {
nested.put("$in", right);
row.put(left, nested);
} else if (relation.getOperator().getSelector() == ExpressionOperator.NotIn) {
nested.put("$nin", right);
row.put(left, nested);
} else {
throw new EISException("Query too complex for Mongo translation, relation [" + expression + "] not supported in query: " + query);
}