Search in sources :

Example 16 with UpdateResult

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

the class DeactivateUsers method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param userId the ID of the user to deactivate.
 * @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 userId) throws RemoteException {
    // Get the UserService.
    UserServiceInterface userService = adManagerServices.get(session, UserServiceInterface.class);
    // Create a statement to select a user.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", userId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get users by statement.
        UserPage page = userService.getUsersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (User user : page.getResults()) {
                System.out.printf("%d) User with ID %d will be deactivated.%n", i++, user.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of users to be deactivated: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202205.DeactivateUsers action = new com.google.api.ads.admanager.axis.v202205.DeactivateUsers();
        // Perform action.
        UpdateResult result = userService.performUserAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of users deactivated: %d%n", result.getNumChanges());
        } else {
            System.out.println("No users were deactivated.");
        }
    }
}
Also used : UserServiceInterface(com.google.api.ads.admanager.axis.v202205.UserServiceInterface) User(com.google.api.ads.admanager.axis.v202205.User) UserPage(com.google.api.ads.admanager.axis.v202205.UserPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) UpdateResult(com.google.api.ads.admanager.axis.v202205.UpdateResult)

Example 17 with UpdateResult

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

the class SubmitSiteForApproval method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param siteId the ID of the site to submit for approval.
 * @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 siteId) throws RemoteException {
    // Get the SiteService.
    SiteServiceInterface siteService = adManagerServices.get(session, SiteServiceInterface.class);
    // Create a statement to select a site.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", siteId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get sites by statement.
        SitePage page = siteService.getSitesByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Site site : page.getResults()) {
                System.out.printf("%d) Site with ID %d will be submitted for approval.%n", i++, site.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of sites to be submitted: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202205.SubmitSiteForApproval action = new com.google.api.ads.admanager.axis.v202205.SubmitSiteForApproval();
        // Perform action.
        UpdateResult result = siteService.performSiteAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of sites submitted: %d%n", result.getNumChanges());
        } else {
            System.out.println("No sites were submitted.");
        }
    }
}
Also used : Site(com.google.api.ads.admanager.axis.v202205.Site) SitePage(com.google.api.ads.admanager.axis.v202205.SitePage) SiteServiceInterface(com.google.api.ads.admanager.axis.v202205.SiteServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) UpdateResult(com.google.api.ads.admanager.axis.v202205.UpdateResult)

Example 18 with UpdateResult

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

the class DeactivatePlacements method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param placementId the ID of the placement to deactivate.
 * @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 placementId) throws RemoteException {
    // Get the PlacementService.
    PlacementServiceInterface placementService = adManagerServices.get(session, PlacementServiceInterface.class);
    // Create a statement to select a placement.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", placementId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get placements by statement.
        PlacementPage page = placementService.getPlacementsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Placement placement : page.getResults()) {
                System.out.printf("%d) Placement with ID %d will be deactivated.%n", i++, placement.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of placements to be deactivated: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202202.DeactivatePlacements action = new com.google.api.ads.admanager.axis.v202202.DeactivatePlacements();
        // Perform action.
        UpdateResult result = placementService.performPlacementAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of placements deactivated: %d%n", result.getNumChanges());
        } else {
            System.out.println("No placements were deactivated.");
        }
    }
}
Also used : PlacementPage(com.google.api.ads.admanager.axis.v202202.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202202.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202202.PlacementServiceInterface) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult)

Example 19 with UpdateResult

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

the class ArchiveProposalLineItems method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalLineItemId the ID of the proposal line item to archive.
 * @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 proposalLineItemId) throws RemoteException {
    // Get the ProposalLineItemService.
    ProposalLineItemServiceInterface proposalLineItemService = adManagerServices.get(session, ProposalLineItemServiceInterface.class);
    // Create a statement to select a proposal line item.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", proposalLineItemId);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get proposal line items by statement.
        ProposalLineItemPage page = proposalLineItemService.getProposalLineItemsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (ProposalLineItem proposalLineItem : page.getResults()) {
                System.out.printf("%d) Proposal line item with ID %d will be archived.%n", i++, proposalLineItem.getId());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of proposal line items to be archived: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202202.ArchiveProposalLineItems action = new com.google.api.ads.admanager.axis.v202202.ArchiveProposalLineItems();
        // Perform action.
        UpdateResult result = proposalLineItemService.performProposalLineItemAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of proposal line items archived: %d%n", result.getNumChanges());
        } else {
            System.out.println("No proposal line items were archived.");
        }
    }
}
Also used : ProposalLineItemPage(com.google.api.ads.admanager.axis.v202202.ProposalLineItemPage) ProposalLineItem(com.google.api.ads.admanager.axis.v202202.ProposalLineItem) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult) ProposalLineItemServiceInterface(com.google.api.ads.admanager.axis.v202202.ProposalLineItemServiceInterface)

Example 20 with UpdateResult

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

the class RequestBuyerAcceptance method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the proposal ID to send.
 * @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 proposalId) throws RemoteException {
    // Get the ProposalService.
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    // Create a statement to only select a single proposal by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", proposalId);
    // Retrieve a small amount of proposals at a time, paging through until all
    // proposals have been retrieved.
    int totalResultSetSize = 0;
    do {
        ProposalPage page = proposalService.getProposalsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each proposal.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Proposal proposal : page.getResults()) {
                System.out.printf("%d) Proposal with ID %d and name '%s' will be sent to Marketplace for buyer " + "acceptance.%n", i++, proposal.getId(), proposal.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of proposals to be sent to Marketplace for buyer acceptance: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202202.RequestBuyerAcceptance action = new com.google.api.ads.admanager.axis.v202202.RequestBuyerAcceptance();
        // Perform action.
        UpdateResult result = proposalService.performProposalAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of proposals that were sent to Marketplace for buyer acceptance: %d%n", result.getNumChanges());
        } else {
            System.out.println("No proposals were sent to Marketplace for buyer acceptance.");
        }
    }
}
Also used : ProposalServiceInterface(com.google.api.ads.admanager.axis.v202202.ProposalServiceInterface) ProposalPage(com.google.api.ads.admanager.axis.v202202.ProposalPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202202.Proposal) UpdateResult(com.google.api.ads.admanager.axis.v202202.UpdateResult)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)18 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)18 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)18 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)18 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 UpdateResult (com.google.api.ads.admanager.axis.v202205.UpdateResult)18 UpdateResult (org.apache.ignite.internal.processors.query.h2.UpdateResult)11 SQLException (java.sql.SQLException)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)6 DmlStatementsProcessor (org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor)6 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)3 QueryCursorImpl (org.apache.ignite.internal.processors.cache.QueryCursorImpl)3 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202108.LineItemCreativeAssociationServiceInterface)2 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202202.CustomTargetingServiceInterface)2 CustomTargetingServiceInterface (com.google.api.ads.admanager.axis.v202205.CustomTargetingServiceInterface)2 LineItemCreativeAssociationServiceInterface (com.google.api.ads.admanager.axis.v202205.LineItemCreativeAssociationServiceInterface)2 BatchUpdateException (java.sql.BatchUpdateException)2