public QueryDataScroller managedQuery(String fields, String from, String where, String orderBy, String groupBy, String having) {
return this.managedQuery(null, fields, from, where, orderBy, groupBy, having);
}
public QueryDataScroller managedQuery(Map<String, Object> parameters, String fields, String from, String where, String orderBy, String groupBy, String having) {
QueryBuilderSelectJPA jpa = new QueryBuilderSelectJPA();
for (String table : from.split(",")) {
jpa.getFrom().add(table.trim());
}
for (String field : fields.split(",")) {
jpa.getSelected().addSelected(field.trim());
}
if (where != null && !"".equals(where.trim())) {
jpa.getWhere().addParameterized(where, parameters == null ? new String[0] : parameters.keySet().toArray(new String[parameters.size()]));
if (parameters != null) jpa.getParameters().putAll(parameters);
}
if (groupBy != null && !"".equals(groupBy.trim())) {
jpa.groupBy(groupBy.split(","));
if (having != null && !"".equals(having.trim())) {
jpa.getHaving().addParameterized(having, parameters == null ? new String[0] : parameters.keySet().toArray(new String[parameters.size()]));
if (parameters != null) jpa.getParameters().putAll(parameters);
}
}
if (orderBy != null) {
for (String order : orderBy.split(",")) {
if (order.trim().equals("")) continue;
String[] parts = order.split(" ");
if (parts.length == 2 && "DESC".equalsIgnoreCase( parts[1] )) {
jpa.getOrderBy().addOrderBy(parts[0].trim(), Direction.DESC);
} else {
jpa.getOrderBy().addOrderBy(order.trim());
}
}
}
return new QueryDataScroller(new QueryExecutorJPA(this), jpa);