}
public static ComplexQuery parseSqlQueryMethod(String sqlStringQueryMethod)
throws QueryFormulationException {
if (!Pattern.matches("((?:SQL)|(?:sql))\\s*(.*)\\s*\\{\\s*SELECT.*FROM.*(?:WHERE.*){0,1}\\}", sqlStringQueryMethod))
throw new QueryFormulationException("Malformed SQL method");
try {
ComplexQuery complexQuery = parseSqlQuery(stripOutSqlDefinition(sqlStringQueryMethod));
for (Expression expr : getSqlStatementArgs(sqlStringQueryMethod)) {
if (expr.getKey().toUpperCase().equals("FORMAT"))
complexQuery.setToStringResultFormat(expr.getValue());
else if (expr.getKey().toUpperCase().equals("SORT_BY"))
complexQuery.setSortByMetKey(expr.getValue());
else if (expr.getKey().toUpperCase().equals("FILTER"))
complexQuery.setQueryFilter(createFilter(expr));
}
return complexQuery;
}catch (Exception e) {
e.printStackTrace();
throw new QueryFormulationException("Failed to parse SQL method : " + e.getMessage());
}
}