*/
public class GetAllActivities {
public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
// Get the ActivityService.
ActivityServiceInterface activityService =
dfpServices.get(session, ActivityServiceInterface.class);
// Get all activity groups
List<Integer> activityGroupIds = getAllActivityGroupIds(dfpServices, session);
// Create a statement to get all activities for an activity group.
StatementBuilder statementBuilder = new StatementBuilder()
.where("activityGroupId = :activityGroupId")
.orderBy("id ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
int totalResultsCounter = 0;
for (Integer activityGroupId : activityGroupIds) {
// Set the activity group ID to select from.
statementBuilder.withBindVariableValue("activityGroupId", activityGroupId);
// Default for total result set size and offset.
int totalResultSetSize = 0;
statementBuilder.offset(0);
do {
// Get activities by statement.
ActivityPage page =
activityService.getActivitiesByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
for (Activity activity : page.getResults()) {
System.out.printf(