Search in sources :

Example 51 with Statement

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

the class GetAllOrders 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 OrderService.
    OrderServiceInterface orderService = adManagerServices.get(session, OrderServiceInterface.class);
    // Create a statement to select all orders.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get orders by statement.
        OrderPage page = orderService.getOrdersByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Order order : page.getResults()) {
                System.out.printf("%d) Order with ID %d and name '%s' was found.%n", i++, order.getId(), order.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : Order(com.google.api.ads.admanager.axis.v202111.Order) OrderPage(com.google.api.ads.admanager.axis.v202111.OrderPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) OrderServiceInterface(com.google.api.ads.admanager.axis.v202111.OrderServiceInterface)

Example 52 with Statement

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

the class GetActivePlacements 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 {
    PlacementServiceInterface placementService = adManagerServices.get(session, PlacementServiceInterface.class);
    // Create a statement to select placements.
    StatementBuilder statementBuilder = new StatementBuilder().where("status = :status").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("status", InventoryStatus.ACTIVE.toString());
    // Retrieve a small amount of placements at a time, paging through
    // until all placements have been retrieved.
    int totalResultSetSize = 0;
    do {
        PlacementPage page = placementService.getPlacementsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each placement.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Placement placement : page.getResults()) {
                System.out.printf("%d) Placement with ID %d and name '%s' was found.%n", i++, placement.getId(), placement.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : PlacementPage(com.google.api.ads.admanager.axis.v202111.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202111.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202111.PlacementServiceInterface)

Example 53 with Statement

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

the class GetAllPlacements 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 PlacementService.
    PlacementServiceInterface placementService = adManagerServices.get(session, PlacementServiceInterface.class);
    // Create a statement to get all placements.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // 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 and name '%s' was found.%n", i++, placement.getId(), placement.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : PlacementPage(com.google.api.ads.admanager.axis.v202111.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202111.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202111.PlacementServiceInterface)

Example 54 with Statement

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

the class UpdatePlacements method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param placementId the ID of the placement 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 placementId) throws RemoteException {
    // Get the PlacementService.
    PlacementServiceInterface placementService = adManagerServices.get(session, PlacementServiceInterface.class);
    // Create a statement to only select a single placement by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", placementId);
    // Get the placement.
    PlacementPage page = placementService.getPlacementsByStatement(statementBuilder.toStatement());
    Placement placement = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    placement.setDescription("This placement contains all leaderboards.");
    // Update the placement on the server.
    Placement[] placements = placementService.updatePlacements(new Placement[] { placement });
    for (Placement updatedPlacement : placements) {
        System.out.printf("Placement with ID %d and name '%s' was updated.%n", updatedPlacement.getId(), updatedPlacement.getName());
    }
}
Also used : PlacementPage(com.google.api.ads.admanager.axis.v202111.PlacementPage) Placement(com.google.api.ads.admanager.axis.v202111.Placement) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder) PlacementServiceInterface(com.google.api.ads.admanager.axis.v202111.PlacementServiceInterface)

Example 55 with Statement

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

the class StatementBuilder method toStatement.

/**
 * Gets the {@link Statement} representing the state of this statement builder.
 *
 * @return the {@link Statement}
 */
public Statement toStatement() {
    Statement statement = new Statement();
    statement.setQuery(queryBuilder.buildQuery());
    statement.getValues().addAll(Maps.toList(queryBuilder.getBindVariableMap(), StringValueMapEntry.class));
    return statement;
}
Also used : Statement(com.google.api.ads.admanager.jaxws.v202111.Statement) StringValueMapEntry(com.google.api.ads.admanager.jaxws.v202111.StringValueMapEntry)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)119 Test (org.junit.Test)77 UpdateResult (com.google.api.ads.admanager.axis.v202111.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.v202111.CustomTargetingServiceInterface)8 InventoryServiceInterface (com.google.api.ads.admanager.axis.v202111.InventoryServiceInterface)8 AdUnit (com.google.api.ads.admanager.axis.v202111.AdUnit)7 AdUnitPage (com.google.api.ads.admanager.axis.v202111.AdUnitPage)7 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202111.PublisherQueryLanguageServiceInterface)7 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)7 ArrayList (java.util.ArrayList)6 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface)5 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 LineItem (com.google.api.ads.admanager.axis.v202111.LineItem)4