private static final String LINE_ITEM_ID = "INSERT_LINE_ITEM_ID_HERE";
public static void runExample(DfpServices dfpServices, DfpSession session, long lineItemId)
throws Exception {
// Get the LineItemCreativeAssociationService.
LineItemCreativeAssociationServiceInterface licaService =
dfpServices.get(session, LineItemCreativeAssociationServiceInterface.class);
// Create a statement to all LICAs for a line item.
StatementBuilder statementBuilder = new StatementBuilder()
.where("WHERE lineItemId = :lineItemId ")
.orderBy("lineItemId ASC, creativeId ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.withBindVariableValue("lineItemId", lineItemId);
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get LICAs by statement.
LineItemCreativeAssociationPage page =
licaService.getLineItemCreativeAssociationsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (LineItemCreativeAssociation lica : page.getResults()) {