Package com.google.gdata.client.analytics

Examples of com.google.gdata.client.analytics.DataQuery


  /**
   * Tests filters are properly updated.
   */
  public void testUpdateQuery_noFilter() {
    // Test if no filter is set.
    DataQuery dataQuery = TestUtil.getFilledDataQuery();
    dataQuery.setFilters(null);

    queryManager.updateQuery(dataQuery);
    assertNull(dataQuery.getFilters());
  }
View Full Code Here


  /**
   * Tests if a filter has already been set.
   */
  public void testUpdateQuery_filterIsSet() {
    String filter = "ga:visits>5";
    DataQuery dataQuery2 = TestUtil.getFilledDataQuery();
    dataQuery2.setFilters(filter);

    queryManager.updateQuery(dataQuery2);

    String expectedFilter = filter + ";";
    assertTrue(expectedFilter.equals(dataQuery2.getFilters()));
  }
View Full Code Here

   * parameter. Part of the Iterator implementation.
   * @return A DataQuery object.
   */
  @Override
  public DataQuery next() {
    DataQuery result = getFilteredQuery(indexCounter);
    indexCounter++;
    return result;
  }
View Full Code Here

      com.google.gdata.util.ServiceException {

    AnalyticsService analyticsService = new AnalyticsService(CLIENT_NAME);
    analyticsService.setUserCredentials(USERNAME, PASSWORD);

    DataQuery dataQuery = new DataQuery(new URL("https://www.google.com/analytics/feeds/data"));
    dataQuery.setIds(PROFILE_ID);
    dataQuery.setStartDate(GA_START_DATE);
    dataQuery.setEndDate(GA_END_DATE);

    // Dimensions:  Boundaries for the data being requested.
    dataQuery.setDimensions("ga:year,ga:month,ga:adwordsCampaignID," +
        "ga:adwordsAdGroupID,ga:adwordsCriteriaID");

    // Metrics:  The data being requested
    dataQuery.setMetrics("ga:visits,ga:entrances,ga:bounces,ga:transactions," +
        "ga:transactionRevenue,ga:goalCompletionsAll,ga:goalValueAll");

    // A descending sort (highest values first) can be requested by placing a negative symbol in
    // front of the metric to sort by.
    dataQuery.setSort("-ga:transactionRevenue,-ga:entrances");

    // This example is specifically comparing Analytics data to keywords set up in AdWords.
    // AdWords returns clicks achieved via Content Targetting (think adsense on other websites)
    // as having a Criteria ID of 3000000.  While important, these aren't relevant to this example.
    // Thus, filter them out.
    dataQuery.setFilters("ga:adwordsCriteriaID!=3000000");
    dataQuery.setMaxResults(MAX_RESULTS);
    return analyticsService.getFeed(dataQuery.getUrl(), DataFeed.class);
  }
View Full Code Here

  /**
   * Test setQuery stores the original filter.
   */
  public void testSetQuery() {
    String filter = "ga:source==foo";
    DataQuery query = TestUtil.getFilledDataQuery();
    query.setFilters(filter);
    queries.setQuery(query);

    String result = queries.getOriginalFilter();
    assertTrue(filter.equals(result));
  }
View Full Code Here

  /**
   * Test setQuery stores an empty string if no filter is present.
   */
  public void testSetQuery_noFilter() {
    DataQuery query = TestUtil.getFilledDataQuery();
    query.setFilters(null);
    queries.setQuery(query);

    String result = queries.getOriginalFilter();
    assertTrue("".equals(result));
  }
View Full Code Here

  /**
   * Tests getting a filtered query.
   */
  public void testGetFilteredQuery() {
    String filter = "ga:landingPagePath==/foo";
    DataQuery expectedQuery = TestUtil.getNewDataQuery();
    expectedQuery.setFilters(filter);

    queries.setQuery(TestUtil.getNewDataQuery());

    queries.setFilterList(new ArrayList<String>());
    assertNull(queries.getFilteredQuery(0));

    List<String> filterList = new ArrayList<String>();
    queries.setFilterList(filterList);
    filterList.add(filter);

    assertEquals(expectedQuery.getUrl(), queries.getFilteredQuery(0).getUrl());
    assertNull(queries.getFilteredQuery(1));
    assertNull(queries.getFilteredQuery(-1));
  }
View Full Code Here

  /**
   * Tests getting a filtered query from a query that previously has a filter.
   */
  public void testGetFilteredQuery_withPrevFilter() {
    String originalFilter = "ga:source==google;ga:visits>5;";
    DataQuery query = TestUtil.getFilledDataQuery();
    query.setFilters(originalFilter);

    String newFilter = "ga:landingPagePath==/foo";
    List<String> filterList = new ArrayList<String>();
    filterList.add(newFilter);

    queries.setQuery(query);
    queries.setFilterList(filterList);
    DataQuery resultQuery = queries.getFilteredQuery(0);

    String expected = originalFilter + newFilter;
    assertEquals(expected, resultQuery.getFilters());
  }
View Full Code Here

    filterList.add(filter1);
    filterList.add(filter2);
    queries.setFilterList(filterList);
    queries.setQuery(TestUtil.getNewDataQuery());

    DataQuery expectedQuery = TestUtil.getNewDataQuery();
    expectedQuery.setFilters(filter1);
    assertEquals(expectedQuery.getUrl(), queries.next().getUrl());
    assertEquals(1, queries.getCounter());

    expectedQuery.setFilters(filter2);
    assertEquals(expectedQuery.getUrl(), queries.next().getUrl());
    assertEquals(2, queries.getCounter());

    assertNull(queries.next());
    assertEquals(3, queries.getCounter());
  }
View Full Code Here

  /**
   * Executes this program.
   */
  public void execute() {
    DataQuery dataQuery = getDataQuery();
    DataFeed dataFeed = getDataFeed(dataQuery);

    setExpectedStartDate(dataQuery.getStartDate());
    setNumberOfDays(dataQuery);

    printExpectedDates(dataQuery);
    printBackfilledResults(dataFeed);
  }
View Full Code Here

TOP

Related Classes of com.google.gdata.client.analytics.DataQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.