String statementText = "WHERE customTargetingKeyId = :customTargetingKeyId";
StatementBuilder statementBuilder = new StatementBuilder("")
.putValue("customTargetingKeyId", customTargetingKeyId);
// Set defaults for page and offset.
CustomTargetingValuePage page = new CustomTargetingValuePage();
int offset = 0;
List<Long> customTargetingValueIds = new ArrayList<Long>();
do {
// Create a statement to page through custom targeting values.
statementBuilder.setQuery(statementText + " LIMIT 500 OFFSET " + offset);
// Get custom targeting values by statement.
page = customTargetingService.getCustomTargetingValuesByStatement(
statementBuilder.toStatement());
if (page.getResults() != null) {
for (CustomTargetingValue customTargetingValue : page.getResults()) {
customTargetingValueIds.add(customTargetingValue.getId());
}
}
offset += 500;
} while (offset < page.getTotalResultSetSize());
System.out.println(
"Number of custom targeting values to be deleted: " + customTargetingValueIds.size());
if (customTargetingValueIds.size() > 0) {