public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception { // Get the PlacementService. PlacementServiceInterface placementService = dfpServices.get(session, PlacementServiceInterface.class); // Create a statement to get all placements. StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT); // 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()) { System.out.printf( "%d) Placement with ID \"%d\" and name \"%s\" was found.\n", i++, placement.getId(), placement.getName()); } } statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT); } while (statementBuilder.getOffset() < totalResultSetSize); System.out.printf("Number of results found: %d\n", totalResultSetSize); }
public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception { // Get the UserTeamAssociationService. UserTeamAssociationServiceInterface userTeamAssociationService = dfpServices.get(session, UserTeamAssociationServiceInterface.class); // Create a statement to select all user team associations. StatementBuilder statementBuilder = new StatementBuilder() .orderBy("teamId ASC, userId ASC") .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT); // Default for total result set size. int totalResultSetSize = 0; do { // Get user team associations by statement. UserTeamAssociationPage page = userTeamAssociationService.getUserTeamAssociationsByStatement( statementBuilder.toStatement()); if (page.getResults() != null) { totalResultSetSize = page.getTotalResultSetSize(); int i = page.getStartIndex(); for (UserTeamAssociation userTeamAssociation : page.getResults()) { System.out.printf( "%d) User team associations with team ID \"%d\" and user ID \"%d\" was found.\n", i++, userTeamAssociation.getTeamId(), userTeamAssociation.getUserId()); } } statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT); } while (statementBuilder.getOffset() < totalResultSetSize); System.out.printf("Number of results found: %d\n", totalResultSetSize); }