com.google.gdata.client.Query Java Examples

The following examples show how to use com.google.gdata.client.Query. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntryProviderImpl.java    From google-sites-liberation with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public List<BaseContentEntry<?>> getEntries(Query query, 
    SitesService sitesService) throws IOException, ServiceException {
  checkNotNull(query, "query");
  checkNotNull(sitesService, "sitesService");
  List<BaseContentEntry> baseEntries = 
      sitesService.getFeed(query, ContentFeed.class).getEntries();
  List<BaseContentEntry<?>> adaptedEntries = Lists.newLinkedList();
  for (BaseContentEntry entry : baseEntries) {
    BaseContentEntry<?> adaptedEntry = 
        (BaseContentEntry<?>) entry.getAdaptedEntry();
    if (adaptedEntry == null) {
      adaptedEntries.add(entry);
    } else {
      adaptedEntries.add(adaptedEntry);
    }
  }
  return adaptedEntries;
}
 
Example #2
Source File: ContinuousContentFeedTest.java    From google-sites-liberation with Apache License 2.0 6 votes vote down vote up
public List<BaseContentEntry<?>> getEntries(Query query, SitesService sitesService) 
    throws ServiceException, IOException {
  int fromIndex = query.getStartIndex() - 1;
  int max = Math.min(maxResultsPerRequest, query.getMaxResults());
  int toIndex = Math.min(fromIndex + max, entries.size());
  if (fromIndex > toIndex) {
    return new ArrayList<BaseContentEntry<?>>();
  }
  List<BaseContentEntry<?>> response = entries.subList(fromIndex, toIndex);
  if (response.contains(serviceExceptionEntry)) {
    throw new ServiceException("Error");
  }
  if (response.contains(ioExceptionEntry)) {
    throw new IOException("Error");
  }
  return response;
}
 
Example #3
Source File: GoogleSpreadsheetInputDialog.java    From pdi-google-spreadsheet-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void getSpreadsheetFields() {
    try {
        GoogleSpreadsheetInputMeta meta = new GoogleSpreadsheetInputMeta();
        setData(meta);

        wFields.table.removeAll();

        String accessToken = GoogleSpreadsheet.getAccessToken(meta.getServiceEmail(), meta.getPrivateKeyStore());
        if (accessToken == null || accessToken.equals("")) {
            throw new Exception("Unable to get access token.");
        }

        SpreadsheetService service = new SpreadsheetService("PentahoKettleTransformStep-v1");
        service.setHeader("Authorization", String.format("Bearer %s", accessToken));

        Query feedQuery = new Query(FeedURLFactory.getDefault().getListFeedUrl(meta.getSpreadsheetKey(), meta.getWorksheetId(), "private", "full"));
        feedQuery.setMaxResults(1);
        ListFeed feed = service.getFeed(feedQuery, ListFeed.class);
        List<ListEntry> rows = feed.getEntries();
        ListEntry row = rows.get(0);

        for (String tag : row.getCustomElements().getTags()) {
            TableItem item = new TableItem(wFields.table, SWT.NONE);
            item.setText(1, Const.trim(tag));
            item.setText(2, ValueMeta.getTypeDesc(ValueMetaInterface.TYPE_STRING));
        }
        wFields.removeEmptyRows();
        wFields.setRowNums();
        wFields.optWidth(true);
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "System.Dialog.Error.Title"), "Error getting Fields", e);
    }
}
 
Example #4
Source File: EntryProvider.java    From google-sites-liberation with Apache License 2.0 2 votes vote down vote up
/**
 * Returns list of entries for the given query.
 */
List<BaseContentEntry<?>> getEntries(Query query, SitesService sitesService) 
    throws IOException, ServiceException;