Search in sources :

Example 51 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202202.ResultSet in project googleads-java-lib by googleads.

the class PqlTest method testGetColumnLabels.

@Test
public void testGetColumnLabels() {
    ResultSet resultSet = new ResultSet();
    resultSet.getColumnTypes().addAll(Lists.newArrayList(column1, column2, column3));
    assertEquals(Lists.newArrayList("column1", "column2", "column3"), Pql.getColumnLabels(resultSet));
}
Also used : ResultSet(com.google.api.ads.admanager.jaxws.v202202.ResultSet) Test(org.junit.Test)

Example 52 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202202.ResultSet in project googleads-java-lib by googleads.

the class GetAllBrowsers 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 IOException {
    // Get the PublisherQueryLanguageService.
    PublisherQueryLanguageServiceInterface pqlService = adManagerServices.get(session, PublisherQueryLanguageServiceInterface.class);
    // Create statement to select all browsers.
    StatementBuilder statementBuilder = new StatementBuilder().select("Id, BrowserName, MajorVersion, MinorVersion").from("Browser").orderBy("BrowserName ASC").offset(0).limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for result sets.
    ResultSet combinedResultSet = null;
    ResultSet resultSet;
    int i = 0;
    do {
        // Get all browsers.
        resultSet = pqlService.select(statementBuilder.toStatement());
        // Combine result sets with previous ones.
        combinedResultSet = combinedResultSet == null ? resultSet : Pql.combineResultSets(combinedResultSet, resultSet);
        System.out.printf("%d) %d criteria beginning at offset %d were found.%n", i++, resultSet.getRows() == null ? 0 : resultSet.getRows().length, statementBuilder.getOffset());
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (resultSet.getRows() != null && resultSet.getRows().length > 0);
    // Change to your file location.
    String filePath = File.createTempFile("Browsers-", ".csv").toString();
    // Write the result set to a CSV.
    CsvFiles.writeCsv(Pql.resultSetToStringArrayList(combinedResultSet), filePath);
    System.out.printf("Browsers saved to: %s%n", filePath);
}
Also used : PublisherQueryLanguageServiceInterface(com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) ResultSet(com.google.api.ads.admanager.axis.v202202.ResultSet)

Example 53 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202202.ResultSet in project googleads-java-lib by googleads.

the class GetDefaultThirdPartyDataDeclaration 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 Exception {
    // Get the NetworkService.
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    // Get the PublisherQueryLanguageService.
    PublisherQueryLanguageServiceInterface pqlService = adManagerServices.get(session, PublisherQueryLanguageServiceInterface.class);
    // Get the current network's default third party data declaration.
    ThirdPartyDataDeclaration declaration = networkService.getDefaultThirdPartyDataDeclaration();
    if (declaration == null) {
        System.out.println("No default ad technology partners have been set on this network.");
    } else if (DeclarationType.NONE.equals(declaration.getDeclarationType()) || declaration.getThirdPartyCompanyIds().length == 0) {
        System.out.println("This network has specified that there are no ad technology providers " + " associated with its reservation creatives by default.");
    } else {
        System.out.printf("This network has specified %d ad technology provider(s) associated with its reservation" + " creatives by default:%n", declaration.getThirdPartyCompanyIds().length);
        ResultSet companies = pqlService.select(new StatementBuilder().select("name, id").from("rich_media_ad_company").where("id in (:ids)").withBindVariableValue("ids", ImmutableSet.copyOf(Longs.asList(declaration.getThirdPartyCompanyIds()))).toStatement());
        System.out.println(Pql.resultSetToString(companies));
    }
}
Also used : PublisherQueryLanguageServiceInterface(com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface) NetworkServiceInterface(com.google.api.ads.admanager.axis.v202202.NetworkServiceInterface) ThirdPartyDataDeclaration(com.google.api.ads.admanager.axis.v202202.ThirdPartyDataDeclaration) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) ResultSet(com.google.api.ads.admanager.axis.v202202.ResultSet)

Example 54 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202202.ResultSet in project googleads-java-lib by googleads.

the class GetLineItemsNamedLike 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.
 * @throws IOException if unable to write the response to a file.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws IOException {
    // Get the PublisherQueryLanguageService.
    PublisherQueryLanguageServiceInterface pqlService = adManagerServices.get(session, PublisherQueryLanguageServiceInterface.class);
    // Create statement to select all line items.
    StatementBuilder statementBuilder = new StatementBuilder().select("Id, Name, Status").from("Line_Item").where("Name LIKE 'line item%'").orderBy("Id ASC").offset(0).limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for result sets.
    ResultSet combinedResultSet = null;
    ResultSet resultSet;
    int i = 0;
    do {
        // Get line items like 'line item%'.
        resultSet = pqlService.select(statementBuilder.toStatement());
        // Combine result sets with previous ones.
        combinedResultSet = combinedResultSet == null ? resultSet : Pql.combineResultSets(combinedResultSet, resultSet);
        System.out.printf("%d) %d line items beginning at offset %d were found.%n", i++, resultSet.getRows() == null ? 0 : resultSet.getRows().length, statementBuilder.getOffset());
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (resultSet.getRows() != null && resultSet.getRows().length > 0);
    // Change to your file location.
    String filePath = File.createTempFile("Line-Items-Named-Like-", ".csv").toString();
    // Write the result set to a CSV.
    CsvFiles.writeCsv(Pql.resultSetToStringArrayList(combinedResultSet), filePath);
    System.out.printf("Line items saved to: %s%n", filePath);
}
Also used : PublisherQueryLanguageServiceInterface(com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder) ResultSet(com.google.api.ads.admanager.axis.v202202.ResultSet)

Example 55 with ResultSet

use of com.google.api.ads.admanager.jaxws.v202202.ResultSet in project googleads-java-lib by googleads.

the class GetDefaultThirdPartyDataDeclaration 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 Exception {
    // Get the NetworkService.
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    // Get the PublisherQueryLanguageService.
    PublisherQueryLanguageServiceInterface pqlService = adManagerServices.get(session, PublisherQueryLanguageServiceInterface.class);
    // Get the current network's default third party data declaration.
    ThirdPartyDataDeclaration declaration = networkService.getDefaultThirdPartyDataDeclaration();
    if (declaration == null) {
        System.out.println("No default ad technology partners have been set on this network.");
    } else if (DeclarationType.NONE.equals(declaration.getDeclarationType()) || declaration.getThirdPartyCompanyIds().length == 0) {
        System.out.println("This network has specified that there are no ad technology providers " + " associated with its reservation creatives by default.");
    } else {
        System.out.printf("This network has specified %d ad technology provider(s) associated with its reservation" + " creatives by default:%n", declaration.getThirdPartyCompanyIds().length);
        ResultSet companies = pqlService.select(new StatementBuilder().select("name, id").from("rich_media_ad_company").where("id in (:ids)").withBindVariableValue("ids", ImmutableSet.copyOf(Longs.asList(declaration.getThirdPartyCompanyIds()))).toStatement());
        System.out.println(Pql.resultSetToString(companies));
    }
}
Also used : PublisherQueryLanguageServiceInterface(com.google.api.ads.admanager.axis.v202108.PublisherQueryLanguageServiceInterface) NetworkServiceInterface(com.google.api.ads.admanager.axis.v202108.NetworkServiceInterface) ThirdPartyDataDeclaration(com.google.api.ads.admanager.axis.v202108.ThirdPartyDataDeclaration) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) ResultSet(com.google.api.ads.admanager.axis.v202108.ResultSet)

Aggregations

Test (org.junit.Test)25 ResultSet (com.google.api.ads.admanager.axis.v202108.ResultSet)12 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)12 ResultSet (com.google.api.ads.admanager.axis.v202202.ResultSet)12 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)8 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)8 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202108.PublisherQueryLanguageServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202111.PublisherQueryLanguageServiceInterface)8 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202202.PublisherQueryLanguageServiceInterface)8 Function (com.google.common.base.Function)8 DateTime (org.joda.time.DateTime)6 ResultSet (com.google.spanner.v1.ResultSet)5 ResultSet (com.google.api.ads.admanager.axis.v202105.ResultSet)4 Row (com.google.api.ads.admanager.axis.v202108.Row)4 Row (com.google.api.ads.admanager.axis.v202111.Row)4 Row (com.google.api.ads.admanager.axis.v202202.Row)4 ResultSet (com.google.api.ads.admanager.jaxws.v202105.ResultSet)4 ResultSet (com.google.api.ads.admanager.jaxws.v202108.ResultSet)4 ResultSet (com.google.api.ads.admanager.jaxws.v202111.ResultSet)4