value.getClass(), value));
}
else
{
log.error("Query on embedded column/any field of embedded column, is not supported in CouchDB");
throw new QueryHandlerException(
"Query on embedded column/any field of embedded column, is not supported in CouchDB");
}
}
else
{
Attribute col = entity.getAttribute(m.getFieldName(columnName));
interpreter.setKeyValues(columnName,
PropertyAccessorHelper.fromSourceToTargetClass(col.getJavaType(), value.getClass(), value));
interpreter.setKeyName(columnName);
if (columnName.equals(((AbstractAttribute) m.getIdAttribute()).getJPAColumnName()))
{
interpreter.setIdQuery(true);
}
if (condition.equals("="))
{
interpreter.setKeyValue(PropertyAccessorHelper.fromSourceToTargetClass(col.getJavaType(),
value.getClass(), value));
}
else if (condition.equals(">=") || condition.equals(">"))
{
interpreter.setStartKeyValue(PropertyAccessorHelper.fromSourceToTargetClass(col.getJavaType(),
value.getClass(), value));
}
else if (condition.equals("<="))
{
interpreter.setEndKeyValue(PropertyAccessorHelper.fromSourceToTargetClass(col.getJavaType(),
value.getClass(), value));
}
else if (condition.equals("<"))
{
interpreter.setEndKeyValue(PropertyAccessorHelper.fromSourceToTargetClass(col.getJavaType(),
value.getClass(), value));
interpreter.setIncludeLastKey(false);
}
else
{
log.error("Condition:" + condition + " not supported for CouchDB");
throw new QueryHandlerException("Condition:" + condition + " not supported for CouchDB");
}
}
}
else
{
String opr = clause.toString().trim();
if (interpreter.getOperator() == null)
{
if (opr.equalsIgnoreCase("AND"))
{
interpreter.setOperator("AND");
}
else if (opr.equalsIgnoreCase("OR"))
{
log.error("Condition: OR not supported in CouchDB");
throw new QueryHandlerException("Invalid intra clause OR is not supported in CouchDB");
}
else
{
log.error("Invalid intra clause:" + opr + " is not supported in CouchDB");
throw new QueryHandlerException("Invalid intra clause:" + opr + " not supported for CouchDB");
}
}
else if (interpreter.getOperator() != null && !interpreter.getOperator().equalsIgnoreCase(opr))
{
log.error("Multiple combination of AND/OR clause not supported in CouchDB");
throw new QueryHandlerException("Multiple combination of AND/OR clause not supported in CouchDB");
}
// it is a case of "AND", "OR" clause
}
}
return interpreter;