Search in sources :

Example 96 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder in project googleads-java-lib by googleads.

the class GetAdUnitHierarchy method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the InventoryService.
    InventoryServiceInterface inventoryService = adManagerServices.get(session, InventoryServiceInterface.class);
    // Get the NetworkService.
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    // Get the effective root ad unit.
    String rootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();
    // Create a statement to select only the root ad unit by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", rootAdUnitId);
    AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement());
    AdUnit effectiveRootAdUnit = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Get all ad units.
    List<AdUnit> adUnits = getAllAdUnits(adManagerServices, session);
    buildAndDisplayAdUnitTree(effectiveRootAdUnit, adUnits);
}
Also used : NetworkServiceInterface(com.google.api.ads.admanager.axis.v202111.NetworkServiceInterface) AdUnitPage(com.google.api.ads.admanager.axis.v202111.AdUnitPage) AdUnit(com.google.api.ads.admanager.axis.v202111.AdUnit) InventoryServiceInterface(com.google.api.ads.admanager.axis.v202111.InventoryServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)

Example 97 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder in project googleads-java-lib by googleads.

the class GetAllAdUnits method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the InventoryService.
    InventoryServiceInterface inventoryService = adManagerServices.get(session, InventoryServiceInterface.class);
    // Create a statement to select all ad units.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get ad units by statement.
        AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (AdUnit adUnit : page.getResults()) {
                System.out.printf("%d) Ad unit with ID '%s' and name '%s' was found.%n", i++, adUnit.getId(), adUnit.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : AdUnitPage(com.google.api.ads.admanager.axis.v202111.AdUnitPage) AdUnit(com.google.api.ads.admanager.axis.v202111.AdUnit) InventoryServiceInterface(com.google.api.ads.admanager.axis.v202111.InventoryServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)

Example 98 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder in project googleads-java-lib by googleads.

the class GetAllCustomFields method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the CustomFieldService.
    CustomFieldServiceInterface customFieldService = adManagerServices.get(session, CustomFieldServiceInterface.class);
    // Create a statement to get all custom fields.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get custom fields by statement.
        CustomFieldPage page = customFieldService.getCustomFieldsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CustomField customField : page.getResults()) {
                System.out.printf("%d) Custom field with ID %d and name '%s' was found.%n", i++, customField.getId(), customField.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CustomFieldPage(com.google.api.ads.admanager.axis.v202111.CustomFieldPage) CustomFieldServiceInterface(com.google.api.ads.admanager.axis.v202111.CustomFieldServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) CustomField(com.google.api.ads.admanager.axis.v202111.CustomField)

Example 99 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder in project googleads-java-lib by googleads.

the class GetAllCreativeTemplates method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    // Get the CreativeTemplateService.
    CreativeTemplateServiceInterface creativeTemplateService = adManagerServices.get(session, CreativeTemplateServiceInterface.class);
    // Create a statement to get all creative templates.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // 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()) {
                System.out.printf("%d) Creative template with ID %d and name '%s' was found.%n", i++, creativeTemplate.getId(), creativeTemplate.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CreativeTemplateServiceInterface(com.google.api.ads.admanager.axis.v202111.CreativeTemplateServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) CreativeTemplate(com.google.api.ads.admanager.axis.v202111.CreativeTemplate) CreativeTemplatePage(com.google.api.ads.admanager.axis.v202111.CreativeTemplatePage)

Example 100 with StatementBuilder

use of com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder in project googleads-java-lib by googleads.

the class GetAllNativeStyles method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws RemoteException {
    NativeStyleServiceInterface nativeStyleService = adManagerServices.get(session, NativeStyleServiceInterface.class);
    // Create a statement to select native styles.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Retrieve a small amount of native styles at a time, paging through
    // until all native styles have been retrieved.
    int totalResultSetSize = 0;
    do {
        NativeStylePage page = nativeStyleService.getNativeStylesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each native style.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (NativeStyle nativeStyle : page.getResults()) {
                System.out.printf("%d) Native style with ID %d and name '%s' was found.%n", i++, nativeStyle.getId(), nativeStyle.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : NativeStyleServiceInterface(com.google.api.ads.admanager.axis.v202111.NativeStyleServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) NativeStylePage(com.google.api.ads.admanager.axis.v202111.NativeStylePage) NativeStyle(com.google.api.ads.admanager.axis.v202111.NativeStyle)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)120 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)120 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)120 UpdateResult (com.google.api.ads.admanager.axis.v202108.UpdateResult)18 UpdateResult (com.google.api.ads.admanager.axis.v202111.UpdateResult)18 UpdateResult (com.google.api.ads.admanager.axis.v202202.UpdateResult)18 ArrayList (java.util.ArrayList)18 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202108.CustomTargetingServiceInterface)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202108.InventoryServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202108.PublisherQueryLanguageServiceInterface)8 ResultSet (com.google.api.ads.admanager.axis.v202108.ResultSet)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202202.InventoryServiceInterface)8 AdUnit (com.google.api.ads.admanager.axis.v202108.AdUnit)7 AdUnitPage (com.google.api.ads.admanager.axis.v202108.AdUnitPage)7 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202202.CustomTargetingServiceInterface)6 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202111.CustomTargetingServiceInterface)5 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202111.InventoryServiceInterface)5 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface)5 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202111.PublisherQueryLanguageServiceInterface)5 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)5