com.google.gdata.data.spreadsheet.ListFeed Java Examples
The following examples show how to use
com.google.gdata.data.spreadsheet.ListFeed.
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: GoogleSheetsService.java From q with Apache License 2.0 | 5 votes |
private List<String> extractWorksheetData(SpreadsheetEntry spreadsheet, String worksheetId, String[] header) throws Throwable, IOException, ServiceException { List<String> returnValue = Lists.newArrayList(); WorksheetEntry worksheet = getWorksheet(spreadsheet, worksheetId); if (worksheet != null) { ListFeed listFeed = getListFeedForWorksheet(worksheet); returnValue = getAllEntries(listFeed, header); } return returnValue; }
Example #2
Source File: GoogleSheetsService.java From q with Apache License 2.0 | 5 votes |
private List<String> getAllEntries(ListFeed listFeed, String[] headerDefault) { List<String> returnValue = Lists.newArrayList(); Joiner joiner = Joiner.on(Properties.inputDelimiter.get()); Set<String> header = null; List<ListEntry> entries = listFeed.getEntries(); if (entries != null && entries.size() > 0) { ListEntry listEntry = entries.get(0); if (listEntry != null) header = listEntry.getCustomElements().getTags(); } if (header == null && headerDefault != null) { header = new LinkedHashSet<String>(); for (String headerItem : headerDefault) { header.add(headerItem); } } returnValue.add(joiner.join(header)); for (ListEntry row : entries) { List<String> rowValues = Lists.newArrayList(); for (String tag : header) { String value = row.getCustomElements().getValue(tag); if (value == null) value = ""; rowValues.add(value); } String rowValuesString = joiner.join(rowValues); returnValue.add(rowValuesString); } return returnValue; }
Example #3
Source File: TDriverUtil.java From micro-integrator with Apache License 2.0 | 4 votes |
public static ListFeed getListFeed(TGSpreadConnection connection, WorksheetEntry currentWorkSheet) throws SQLException { ListQuery listQuery = new ListQuery(currentWorkSheet.getListFeedUrl()); return connection.getFeedProcessor().getFeed(listQuery, ListFeed.class); }
Example #4
Source File: GoogleSheetsService.java From q with Apache License 2.0 | 4 votes |
private ListFeed getListFeedForWorksheet(WorksheetEntry worksheet) throws IOException, ServiceException { URL listFeedUrl = worksheet.getListFeedUrl(); ListFeed cellFeed = spreadsheetService.getFeed(listFeedUrl, ListFeed.class); return cellFeed; }
Example #5
Source File: GoogleUtils.java From mytracks with Apache License 2.0 | 4 votes |
/** * Deletes Google Spreadsheets row. * * @param context the context * @param accountName the account name * @param trackName the track name * @return true if deletion is success. */ public static boolean deleteSpreadsheetsRow( Context context, String accountName, String trackName) { try { // Get spreadsheet Id List<File> files = searchSpreadsheets(context, accountName); if (files == null || files.size() == 0) { return false; } String spreadsheetId = files.get(0).getId(); // Get spreadsheet service SpreadsheetService spreadsheetService = new SpreadsheetService( "MyTracks-" + SystemUtils.getMyTracksVersion(context)); Credential credential = new Credential(BearerToken.authorizationHeaderAccessMethod()); credential.setAccessToken( SendToGoogleUtils.getToken(context, accountName, SendToGoogleUtils.SPREADSHEETS_SCOPE)); spreadsheetService.setOAuth2Credentials(credential); // Get work sheet WorksheetFeed worksheetFeed = spreadsheetService.getFeed(new URL( String.format(Locale.US, SendSpreadsheetsAsyncTask.GET_WORKSHEETS_URI, spreadsheetId)), WorksheetFeed.class); Iterator<WorksheetEntry> worksheetEntryIterator = worksheetFeed.getEntries().iterator(); while (worksheetEntryIterator.hasNext()) { WorksheetEntry worksheetEntry = (WorksheetEntry) worksheetEntryIterator.next(); String worksheetTitle = worksheetEntry.getTitle().getPlainText(); if (worksheetTitle.equals(SPREADSHEETS_WORKSHEET_NAME)) { URL url = worksheetEntry.getListFeedUrl(); Iterator<ListEntry> listEntryIterator = spreadsheetService.getFeed(url, ListFeed.class) .getEntries().iterator(); while (listEntryIterator.hasNext()) { ListEntry listEntry = (ListEntry) listEntryIterator.next(); String name = listEntry.getCustomElements().getValue(SPREADSHEETS_TRANCK_NAME_COLUMN); if (name.equals(trackName)) { listEntry.delete(); return true; } } } } } catch (Exception e) { Log.e(TAG, "Unable to delete spreadsheets row.", e); } return false; }