// Get the UserTeamAssociationService.
UserTeamAssociationServiceInterface userTeamAssociationService =
dfpServices.get(session, UserTeamAssociationServiceInterface.class);
// Create a statement to select all user team associations for a user.
StatementBuilder statementBuilder = new StatementBuilder()
.where("WHERE userId = :userId ")
.orderBy("userId ASC, teamId ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.withBindVariableValue("userId", userId);
// 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 association with user ID \"%d\" and team ID \"%d\" was found.\n", i++,
userTeamAssociation.getUserId(), userTeamAssociation.getTeamId());
}
}
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (statementBuilder.getOffset() < totalResultSetSize);
System.out.printf("Number of results found: %d\n", totalResultSetSize);
}