Package com.google.gdata.data.analytics

Examples of com.google.gdata.data.analytics.DataFeed


    query.setEndDate("2008-10-31");
    URL url = query.getUrl();
    System.out.println("URL: " + url.toString());

    // Send our request to the Analytics API and wait for the results to come back
    DataFeed feed;
    try {
      feed = as.getFeed(url, DataFeed.class);
    } catch (IOException e) {
      System.err.println("Network error trying to retrieve feed: " + e.getMessage());
      return;
View Full Code Here


       //request account feed to get profile name
       String[] profileList = getAccountList(tableId).get(0);
      setProfileName(profileList[1]);
      setQueryURL(getDataFeedQuery().toString());
      // Make a request to the Data Feed.
      DataFeed dataFeed = analyticsService.getFeed(getDataFeedQuery(), DataFeed.class);
      dataList.add(new String[] {"Year", "Month", "Visits", "Transactions", "Quantity", "Unique Pg.V", "Bounce Rate", "eCommerce Conv.", "CI"});
     
     
      NumberFormat f = NumberFormat.getInstance(Locale.US);
      if (f instanceof DecimalFormat) {
        ((DecimalFormat) f).applyPattern("###.#");
      }
     
     
      // Put the results in a list of String arrays.
      for (DataEntry entry : dataFeed.getEntries()) {
        // Calculate bounce rate.
        bounceRate = entry.doubleValueOf("ga:bounces") / entry.doubleValueOf("ga:entrances") * 100;
        eComRate = entry.doubleValueOf("ga:transactions") / entry.doubleValueOf("ga:visits") * 100;
        Metric myVisits = entry.getMetric("ga:visits");
       
View Full Code Here

    AccountEntry profile = accountFeed.getEntries().get(0);
    String tableId = profile.getTableId().getValue();

    // Print the results of a basic request
    DataQuery basicQuery = getBasicQuery(tableId);
    DataFeed basicData = myService.getFeed(basicQuery, DataFeed.class);
    printData("BASIC RESULTS", basicData);

    // Ask Analytics to return the data sorted in descending order of visits
    DataQuery sortedQuery = getBasicQuery(tableId);
    sortedQuery.setSort("-ga:visits");
    DataFeed sortedData = myService.getFeed(sortedQuery, DataFeed.class);
    printData("SORTED RESULTS", sortedData);

    // Ask Analytics to filter out browsers that contain the word "Explorer"
    DataQuery filteredQuery = getBasicQuery(tableId);
    filteredQuery.setFilters("ga:browser!@Explorer");
    DataFeed filteredData = myService.getFeed(filteredQuery, DataFeed.class);
    printData("FILTERED RESULTS", filteredData);
  }
View Full Code Here

    query.setIds(tableId);
    query.setDimensions(columnTypeMap.getColumnString(ColumnType.DIMENSION));
    query.setMetrics(columnTypeMap.getColumnString(ColumnType.METRIC));
    query.setStartDate(startDate);
    query.setEndDate(endDate);
    DataFeed feed = analyticsService.getFeed(query, DataFeed.class);
    return feed.getEntries();
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Override
  public <F extends IFeed> F getFeed(Query query, Class<F> feedClass)
  throws IOException, ServiceException {

    DataFeed feed = new DataFeed();
    List<DataEntry> entryList = new ArrayList<DataEntry>();

    int numEntries = metrics[0].length;
    for (int entryIndex = 0; entryIndex < numEntries; entryIndex++) {
      DataEntry entry = new DataEntry();

      // Add all dimensions.
      for (int dimensionIndex = 0; dimensionIndex < dimensions.length; dimensionIndex++) {
        Dimension dimension = new Dimension();
        dimension.setValue(dimensions[dimensionIndex][entryIndex]);
        if (dimensionNames != null) {
          dimension.setName(dimensionNames[dimensionIndex]);
        }
        entry.addDimension(dimension);
      }
      // Add all metrics.
      for (int metricIndex = 0; metricIndex < metrics.length; metricIndex++) {
        Metric metric = new Metric();
        metric.setValue(metrics[metricIndex][entryIndex]);
        metric.setConfidenceInterval(confidenceInterval);
        entry.addMetric(metric);
      }
      entryList.add(entry);
    }

    feed.setEntries(entryList);
    return (F) feed;
  }
View Full Code Here

  /**
   * Ensure we can get a feed.
   */
  public void testGetFeed() {
    DataFeed feed = dataManager.getFeed(TestUtil.getNewDataQuery());
    assertNotNull(feed);
    assertEquals(testMetrics[0].length, feed.getEntries().size());

    int i = 0;
    for (DataEntry entry : feed.getEntries()) {
      assertEquals(testDimensions[0][i], entry.getDimensions().get(0).getValue());
      assertEquals(testMetrics[0][i], entry.getMetrics().get(0).getValue());
      i++;
    }
  }
View Full Code Here

    String[][] expectedDimensionValues = new String[][] {{"a", "b", "c", "d"},
        {"20100101", "20100101", "20100101", "20100101"}};
    String[][] expectedMetricValues = new String[][] {{"1", "2", "3", "4"}};

    DataFeed feed = asMock.getDataFeed(dimensionNames, expectedDimensionValues,
        expectedMetricValues);
    resultManager.addRows(feed);

    List<String> dimResults = results.getRowNames();
    assertEquals(expectedDimensionValues[0].length, dimResults.size());
View Full Code Here

    String[][] expectedDimensionValues = new String[][] {{"a", "b", "c", "d"},
        {"20100101", "20100101", "20100101", "20100101"}};
    String[][] expectedMetricValues = new String[][] {{"1", "2", "3", "4"}};

    DataFeed feed = asMock.getDataFeed(dimensionNames, expectedDimensionValues,
        expectedMetricValues);
    resultManager.addRows(feed);

    table = results.getTable();
    assertEquals(4, table.size());
View Full Code Here

    String[][] expectedDimensionValues = new String[][] {{"a", "a", "a", "b", "b", "b"},
        {"20100101", "20100102", "20100103", "20100101", "20100102", "20100103"}};
    String[][] expectedMetricValues = new String[][] {{"1", "2", "3", "4", "5", "6"}};

    DataFeed feed = asMock.getDataFeed(dimensionNames, expectedDimensionValues,
        expectedMetricValues);
    resultManager.addRows(feed);

    table = results.getTable();
    assertEquals(2, table.size());
View Full Code Here

    String[][] expectedDimensionValues = new String[][] {{"a", "b", "b", "b"},
        {"20100103", "20100101", "20100102", "20100103"}};
    String[][] expectedMetricValues = new String[][] {{"3", "4", "5", "6"}};

    DataFeed feed = asMock.getDataFeed(dimensionNames, expectedDimensionValues,
        expectedMetricValues);
    resultManager.addRows(feed);

    table = results.getTable();
    assertEquals(2, table.size());
View Full Code Here

TOP

Related Classes of com.google.gdata.data.analytics.DataFeed

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.