*/
public class GetSystemDefinedCreativeTemplates {
public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
// Get the CreativeTemplateService.
CreativeTemplateServiceInterface creativeTemplateService =
dfpServices.get(session, CreativeTemplateServiceInterface.class);
// Create a statement to select only system defined creative templates.
StatementBuilder statementBuilder = new StatementBuilder()
.where("type = :type")
.orderBy("id ASC")
.limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
.withBindVariableValue("type", CreativeTemplateType.SYSTEM_DEFINED.toString());
// Default for total result set size.
int totalResultSetSize = 0;
do {
// Get creative templates by statement.
CreativeTemplatePage page =
creativeTemplateService.getCreativeTemplatesByStatement(statementBuilder.toStatement());
if (page.getResults() != null) {
totalResultSetSize = page.getTotalResultSetSize();
int i = page.getStartIndex();
for (CreativeTemplate creativeTemplate : page.getResults()) {