public class GetActivePlacements {
public static void runExample(DfpServices dfpServices, DfpSession session)
throws Exception {
// Get the PlacementService.
PlacementServiceInterface placementService =
dfpServices.get(session, PlacementServiceInterface.class);
// Create a statement to only select active placements.
StatementBuilder statementBuilder = new StatementBuilder()
.where("status = :status")
.orderBy("id ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.withBindVariableValue("status", InventoryStatus.ACTIVE.toString());
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get placements by statement.
PlacementPage page =
placementService.getPlacementsByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (Placement placement : page.getResults()) {