Issue #1807 Change DbQueryHandler to include order by informaton in the query.
Change-Id: Icbdeddc4f730ff757cf4e107457a368178ddef48 Former-commit-id: 8e2030c19a79f8ae8fe2127bfb3c7364aa5f0516
This commit is contained in:
parent
8363eba409
commit
4f889b6999
2 changed files with 30 additions and 3 deletions
|
@ -37,6 +37,7 @@ import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 21, 2010 mschenke Initial creation
|
||||
* Mar 19, 2013 1807 rferrel Added orderBy to the toString.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -288,9 +289,20 @@ public class DbQueryRequest implements IServerRequest {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DbQueryRequest [database=" + database + ", entityClass="
|
||||
+ entityClass + ", fields=" + fields + ", distinct=" + distinct
|
||||
+ ", constraints=" + constraints + "]";
|
||||
return "DbQueryRequest [database="
|
||||
+ database
|
||||
+ ", entityClass="
|
||||
+ entityClass
|
||||
+ ", fields="
|
||||
+ fields
|
||||
+ ", distinct="
|
||||
+ distinct
|
||||
+ ", constraints="
|
||||
+ constraints
|
||||
+ ", orderBy="
|
||||
+ (orderBy == null ? "null" : String.format(
|
||||
"[field=%s, mode=%s]", orderBy.field,
|
||||
orderBy.mode.toString())) + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ import com.raytheon.uf.common.dataquery.db.QueryParam;
|
|||
import com.raytheon.uf.common.dataquery.db.QueryParam.QueryOperand;
|
||||
import com.raytheon.uf.common.dataquery.db.ReturnedField;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest.OrderBy;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest.OrderMode;
|
||||
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest.RequestField;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
|
||||
|
@ -48,6 +50,7 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 21, 2010 mschenke Initial creation
|
||||
* Mar 19, 2013 1807 rferrel OrderBy now performed.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -56,6 +59,13 @@ import com.raytheon.uf.edex.database.query.DatabaseQuery;
|
|||
*/
|
||||
public class DbQueryHandler implements IRequestHandler<DbQueryRequest> {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
|
||||
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
|
||||
*/
|
||||
@Override
|
||||
public DbQueryResponse handleRequest(DbQueryRequest request)
|
||||
throws Exception {
|
||||
|
@ -152,6 +162,11 @@ public class DbQueryHandler implements IRequestHandler<DbQueryRequest> {
|
|||
dbQuery.addQueryParam(param);
|
||||
}
|
||||
|
||||
OrderBy orderBy = request.getOrderBy();
|
||||
if (orderBy != null) {
|
||||
dbQuery.addOrder(orderBy.getField(), orderBy.mode == OrderMode.ASC);
|
||||
}
|
||||
|
||||
List<?> vals = new CoreDao(DaoConfig.forDatabase(dbName))
|
||||
.queryByCriteria(dbQuery);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue