Search in sources :

Example 51 with Statement

use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.

the class GetActiveCreativeWrappers 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 {
    CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
    // Create a statement to select creative wrappers.
    StatementBuilder statementBuilder = new StatementBuilder().where("status = :status").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", CreativeWrapperStatus.ACTIVE.toString());
    // Retrieve a small amount of creative wrappers at a time, paging through
    // until all creative wrappers have been retrieved.
    int totalResultSetSize = 0;
    do {
        CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each creative wrapper.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CreativeWrapper creativeWrapper : page.getResults()) {
                System.out.printf("%d) Creative wrapper with ID %d and label ID %d was found.%n", i++, creativeWrapper.getId(), creativeWrapper.getLabelId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CreativeWrapper(com.google.api.ads.admanager.axis.v202205.CreativeWrapper) CreativeWrapperPage(com.google.api.ads.admanager.axis.v202205.CreativeWrapperPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) CreativeWrapperServiceInterface(com.google.api.ads.admanager.axis.v202205.CreativeWrapperServiceInterface)

Example 52 with Statement

use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.

the class UpdateCreativeWrappers method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param creativeWrapperId the ID of the creative wrapper to update.
 * @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, long creativeWrapperId) throws RemoteException {
    // Get the CreativeWrapperService.
    CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
    // Create a statement to only select a single creative wrapper by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeWrapperId);
    // Get the creative wrapper.
    CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
    CreativeWrapper creativeWrapper = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the creative wrapper ordering.
    creativeWrapper.setOrdering(CreativeWrapperOrdering.OUTER);
    // Update the creative wrapper on the server.
    CreativeWrapper[] creativeWrappers = creativeWrapperService.updateCreativeWrappers(new CreativeWrapper[] { creativeWrapper });
    for (CreativeWrapper updatedCreativeWrapper : creativeWrappers) {
        System.out.printf("Creative wrapper with ID %d and wrapping order '%s' was updated.%n", updatedCreativeWrapper.getId(), updatedCreativeWrapper.getOrdering());
    }
}
Also used : CreativeWrapper(com.google.api.ads.admanager.axis.v202205.CreativeWrapper) CreativeWrapperPage(com.google.api.ads.admanager.axis.v202205.CreativeWrapperPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) CreativeWrapperServiceInterface(com.google.api.ads.admanager.axis.v202205.CreativeWrapperServiceInterface)

Example 53 with Statement

use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.

the class GetCustomFieldsForLineItems 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 {
    CustomFieldServiceInterface customFieldService = adManagerServices.get(session, CustomFieldServiceInterface.class);
    // Create a statement to select custom fields.
    StatementBuilder statementBuilder = new StatementBuilder().where("entityType = :entityType").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("entityType", CustomFieldEntityType.LINE_ITEM.toString());
    // Retrieve a small amount of custom fields at a time, paging through
    // until all custom fields have been retrieved.
    int totalResultSetSize = 0;
    do {
        CustomFieldPage page = customFieldService.getCustomFieldsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each custom field.
            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.v202205.CustomFieldPage) CustomFieldServiceInterface(com.google.api.ads.admanager.axis.v202205.CustomFieldServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) CustomField(com.google.api.ads.admanager.axis.v202205.CustomField)

Example 54 with Statement

use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.

the class GetAllCdnConfigurations 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 {
    CdnConfigurationServiceInterface cdnConfigurationService = adManagerServices.get(session, CdnConfigurationServiceInterface.class);
    // Create a statement to select CDN configurations.
    int pageSize = StatementBuilder.SUGGESTED_PAGE_LIMIT;
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(pageSize);
    // Retrieve a small amount of CDN configurations at a time, paging through until all
    // CDN configurations have been retrieved.
    int totalResultSetSize = 0;
    do {
        CdnConfigurationPage page = cdnConfigurationService.getCdnConfigurationsByStatement(statementBuilder.toStatement());
        // Print out some information for each CDN configuration.
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CdnConfiguration cdnConfiguration : page.getResults()) {
                System.out.printf("%d) CDN configuration with ID %d and name '%s' was found.%n", i++, cdnConfiguration.getId(), cdnConfiguration.getName());
            }
        }
        statementBuilder.increaseOffsetBy(pageSize);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CdnConfigurationServiceInterface(com.google.api.ads.admanager.axis.v202205.CdnConfigurationServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) CdnConfiguration(com.google.api.ads.admanager.axis.v202205.CdnConfiguration) CdnConfigurationPage(com.google.api.ads.admanager.axis.v202205.CdnConfigurationPage)

Example 55 with Statement

use of com.google.api.ads.admanager.axis.v202205.Statement in project googleads-java-lib by googleads.

the class GetAllCmsMetadataValues 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 CmsMetadataService.
    CmsMetadataServiceInterface cmsMetadataService = adManagerServices.get(session, CmsMetadataServiceInterface.class);
    // Create a statement to select all CMS metadata values.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get CMS metadata values by statement.
        CmsMetadataValuePage page = cmsMetadataService.getCmsMetadataValuesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (CmsMetadataValue cmsMetadataValue : page.getResults()) {
                System.out.printf("%d) CMS metadata value with ID %d and name '%s' associated with the " + "CmsMetadataKey with ID %d and name '%s' was found.%n", i++, cmsMetadataValue.getCmsMetadataValueId(), cmsMetadataValue.getValueName(), cmsMetadataValue.getKey().getId(), cmsMetadataValue.getKey().getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : CmsMetadataValuePage(com.google.api.ads.admanager.axis.v202205.CmsMetadataValuePage) CmsMetadataServiceInterface(com.google.api.ads.admanager.axis.v202205.CmsMetadataServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) CmsMetadataValue(com.google.api.ads.admanager.axis.v202205.CmsMetadataValue)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)119 Test (org.junit.Test)77 UpdateResult (com.google.api.ads.admanager.axis.v202205.UpdateResult)18 Statement (com.google.api.ads.admanager.axis.v202105.Statement)16 Statement (com.google.api.ads.admanager.axis.v202108.Statement)16 Statement (com.google.api.ads.admanager.axis.v202111.Statement)16 Statement (com.google.api.ads.admanager.axis.v202202.Statement)16 Statement (com.google.api.ads.admanager.axis.v202205.Statement)16 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202205.CustomTargetingServiceInterface)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202205.InventoryServiceInterface)8 AdUnit (com.google.api.ads.admanager.axis.v202205.AdUnit)7 AdUnitPage (com.google.api.ads.admanager.axis.v202205.AdUnitPage)7 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202205.PublisherQueryLanguageServiceInterface)7 ResultSet (com.google.api.ads.admanager.axis.v202205.ResultSet)7 Statement (org.neo4j.driver.v1.Statement)5 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202105.String_ValueMapEntry)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202108.String_ValueMapEntry)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202111.String_ValueMapEntry)4 String_ValueMapEntry (com.google.api.ads.admanager.axis.v202202.String_ValueMapEntry)4 CustomFieldServiceInterface (com.google.api.ads.admanager.axis.v202205.CustomFieldServiceInterface)4