Statement filterStatement =
new StatementBuilder(statementText).putValue("today",
DATE_TIME_FORMAT.format(new Date())).toStatement();
// Set defaults for page and offset.
OrderPage page = new OrderPage();
int offset = 0;
int i = 0;
List<Long> orderIds = new ArrayList<Long>();
do {
// Create a statement to page through draft orders.
filterStatement.setQuery(statementText + " OFFSET " + offset);
// Get orders by statement.
page = orderService.getOrdersByStatement(filterStatement);
if (page.getResults() != null) {
for (Order order : page.getResults()) {
System.out.println(i + ") Order with ID \""
+ order.getId() + "\", name \"" + order.getName()
+ "\", and status \"" + order.getStatus()
+ "\" will be approved.");
orderIds.add(order.getId());
i++;
}
}
offset += 500;
} while (offset < page.getTotalResultSetSize());
System.out.println("Number of orders to be approved: " + orderIds.size());
if (orderIds.size() > 0) {
// Modify statement for action.