Projection projection = new Projection(group, projectionElements);
Order order = "value".equals(_sortMode) ?
new Order(projection, new OrderElem(_valueVar, "forward".equals(_sortDirection))) :
new Order(projection, new OrderElem(_countVar, !"forward".equals(_sortDirection)));
TupleQuery query = new MyTupleQuery(new ParsedTupleQuery(order), connection);
TupleQueryResult queryResult = query.evaluate();
try {
return createComponentState(queryResult);
} finally {
queryResult.close();
}