@Override
protected Object internalRun() {
Database database = _context.getDatabase();
try {
SailRepositoryConnection connection = (SailRepositoryConnection)
database.getRepository().getConnection();
try {
Group2 group = new Group2(_builder.makeFilterTupleExpr());
group.addGroupElement(new GroupElem(_countVar.getName(), new Count(_itemVar)));
group.addGroupBindingName(_valueVar.getName());
ProjectionElemList projectionElements = new ProjectionElemList();
projectionElements.addElement(new ProjectionElem(_valueVar.getName()));
projectionElements.addElement(new ProjectionElem(_countVar.getName()));
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();
}
} finally {
connection.close();
}
} catch (Exception e) {
_logger.error("Error querying to compute list facet", e);
}
return null;