Search in sources :

Example 1 with SearchAnalyticsQueryResponse

use of com.google.api.services.webmasters.model.SearchAnalyticsQueryResponse in project incubator-gobblin by apache.

the class GoogleWebmasterClientImpl method getPages.

@Override
public List<String> getPages(String siteProperty, String startDate, String endDate, String country, int rowLimit, List<GoogleWebmasterFilter.Dimension> requestedDimensions, List<ApiDimensionFilter> filters, int startRow) throws IOException {
    checkRowLimit(rowLimit);
    Preconditions.checkArgument(requestedDimensions.contains(GoogleWebmasterFilter.Dimension.PAGE));
    SearchAnalyticsQueryResponse rspByCountry = createSearchAnalyticsQuery(siteProperty, startDate, endDate, requestedDimensions, GoogleWebmasterFilter.andGroupFilters(filters), rowLimit, startRow).execute();
    List<ApiDataRow> pageRows = rspByCountry.getRows();
    List<String> pages = new ArrayList<>(rowLimit);
    if (pageRows != null) {
        int pageIndex = requestedDimensions.indexOf(GoogleWebmasterFilter.Dimension.PAGE);
        for (ApiDataRow row : pageRows) {
            pages.add(row.getKeys().get(pageIndex));
        }
    }
    return pages;
}
Also used : SearchAnalyticsQueryResponse(com.google.api.services.webmasters.model.SearchAnalyticsQueryResponse) ArrayList(java.util.ArrayList) ApiDataRow(com.google.api.services.webmasters.model.ApiDataRow)

Example 2 with SearchAnalyticsQueryResponse

use of com.google.api.services.webmasters.model.SearchAnalyticsQueryResponse in project incubator-gobblin by apache.

the class GoogleWebmasterDataFetcherImpl method performSearchAnalyticsQueryInBatch.

@Override
public void performSearchAnalyticsQueryInBatch(List<ProducerJob> jobs, List<ArrayList<ApiDimensionFilter>> filterList, List<JsonBatchCallback<SearchAnalyticsQueryResponse>> callbackList, List<Dimension> requestedDimensions, int rowLimit) throws IOException {
    BatchRequest batchRequest = _client.createBatch();
    for (int i = 0; i < jobs.size(); ++i) {
        ProducerJob job = jobs.get(i);
        ArrayList<ApiDimensionFilter> filters = filterList.get(i);
        JsonBatchCallback<SearchAnalyticsQueryResponse> callback = callbackList.get(i);
        _client.createSearchAnalyticsQuery(_siteProperty, job.getStartDate(), job.getEndDate(), requestedDimensions, GoogleWebmasterFilter.andGroupFilters(filters), rowLimit, 0).queue(batchRequest, callback);
    }
    batchRequest.execute();
}
Also used : BatchRequest(com.google.api.client.googleapis.batch.BatchRequest) SearchAnalyticsQueryResponse(com.google.api.services.webmasters.model.SearchAnalyticsQueryResponse) ApiDimensionFilter(com.google.api.services.webmasters.model.ApiDimensionFilter)

Aggregations

SearchAnalyticsQueryResponse (com.google.api.services.webmasters.model.SearchAnalyticsQueryResponse)2 BatchRequest (com.google.api.client.googleapis.batch.BatchRequest)1 ApiDataRow (com.google.api.services.webmasters.model.ApiDataRow)1 ApiDimensionFilter (com.google.api.services.webmasters.model.ApiDimensionFilter)1 ArrayList (java.util.ArrayList)1