// Get DfpUser from "~/dfp.properties".
DfpUser user = new DfpUser();
// Get the LineItemService.
LineItemServiceInterface lineItemService =
user.getService(DfpService.V201302.LINEITEM_SERVICE);
// Set the ID of the order to get line items from.
Long orderId = Long.parseLong("INSERT_ORDER_ID_HERE");
// Create a statement to get line items with even delivery rates.
Statement filterStatement = new StatementBuilder(
"WHERE deliveryRateType = :deliveryRateType AND orderId = :orderId LIMIT 500")
.putValue("orderId", orderId)
.putValue("deliveryRateType", DeliveryRateType.EVENLY.toString()).toStatement();
// Get line items by statement.
LineItemPage page = lineItemService.getLineItemsByStatement(filterStatement);
if (page.getResults() != null) {
LineItem[] lineItems = page.getResults();
// Update each local line item object by changing its delivery rate.
for (int i = 0; i < lineItems.length; i++) {
// Archived line items cannot be updated.
if (lineItems[i].getIsArchived()) {
lineItems[i] = null;
} else {
lineItems[i].setDeliveryRateType(DeliveryRateType.AS_FAST_AS_POSSIBLE);
}
}
// Update the line items on the server.
lineItems = lineItemService.updateLineItems(lineItems);
if (lineItems != null) {
for (LineItem lineItem : lineItems) {
System.out.println("A line item with ID \""
+ lineItem.getId() + "\", belonging to order ID \""