Java Code Examples for com.google.gdata.data.spreadsheet.WorksheetFeed#getEntries()

The following examples show how to use com.google.gdata.data.spreadsheet.WorksheetFeed#getEntries() . 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: GSpreadCreateQuery.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private boolean isWorkSheetExists(TGSpreadConnection conn) {
    WorksheetFeed worksheetFeed = conn.getWorksheetFeed();
    for (WorksheetEntry worksheet : worksheetFeed.getEntries()) {
        if (this.getTableName().equals(worksheet.getTitle().getPlainText())) {
            return true;
        }
    }
    return false;
}
 
Example 2
Source File: GSpreadCreateQuery.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private WorksheetEntry getCurrentWorksheetEntry(TGSpreadConnection conn) throws SQLException {
    WorksheetEntry currentWorksheetEntry = null;
    SpreadsheetEntry currentSpreadsheetEntry =
            conn.getSpreadSheetFeed().getEntries().get(0);
    WorksheetFeed worksheetFeed =
            conn.getFeedProcessor().getFeed(
                    currentSpreadsheetEntry.getWorksheetFeedUrl(), WorksheetFeed.class);
    for (WorksheetEntry worksheetEntry : worksheetFeed.getEntries()) {
        if (this.getTableName().equals(worksheetEntry.getTitle().getPlainText())) {
            currentWorksheetEntry = worksheetEntry;
            break;
        }
    }
    return currentWorksheetEntry;
}
 
Example 3
Source File: TDriverUtil.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public static WorksheetEntry getCurrentWorkSheetEntry(TGSpreadConnection connection,
                                                      String sheetName) throws SQLException {
    SpreadsheetEntry spreadsheetEntry = connection.getSpreadSheetFeed().getEntries().get(0);
    WorksheetQuery worksheetQuery =
            TDriverUtil.createWorkSheetQuery(spreadsheetEntry.getWorksheetFeedUrl());
    WorksheetFeed worksheetFeed = connection.getFeedProcessor().getFeed(worksheetQuery,
                                                                        WorksheetFeed.class);
    for (WorksheetEntry entry : worksheetFeed.getEntries()) {
        if (sheetName.equals(entry.getTitle().getPlainText())) {
            return entry;
        }
    }
    return null;
}
 
Example 4
Source File: SendSpreadsheetsAsyncTask.java    From mytracks with Apache License 2.0 5 votes vote down vote up
/**
 * Gets the worksheet url.
 * 
 * @param spreadsheetService the spreadsheet service
 * @param spreadsheetId the spreadsheet id
 */
private URL getWorksheetUrl(SpreadsheetService spreadsheetService, String spreadsheetId)
    throws IOException, ServiceException {
  if (isCancelled()) {
    return null;
  }
  URL url = new URL(String.format(Locale.US, GET_WORKSHEETS_URI, spreadsheetId));
  WorksheetFeed feed = spreadsheetService.getFeed(url, WorksheetFeed.class);
  List<WorksheetEntry> worksheets = feed.getEntries();

  if (worksheets.size() > 0) {
    return worksheets.get(0).getListFeedUrl();
  }
  return null;
}
 
Example 5
Source File: GSpreadDataReader.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public void populateData() throws SQLException {
    int tmp = -1;

    TGSpreadConnection gsConnection = (TGSpreadConnection) getConnection();
    WorksheetFeed workSheetFeed = gsConnection.getWorksheetFeed();
    if (workSheetFeed == null) {
        throw new SQLException("Work sheet feed it not initialized properly and is null");
    }
    List<WorksheetEntry> workSheets = workSheetFeed.getEntries();
    for (WorksheetEntry workSheet : workSheets) {
        DataRow dataRow = null;
        CellFeed cellFeed = TDriverUtil.getGSpreadCellFeed((TGSpreadConnection) getConnection(), workSheet);

        ColumnInfo[] headers = this.extractHeaders(workSheet);
        DataTable result = new FixedDataTable(workSheet.getTitle().getPlainText(), headers);
        for (CellEntry cell : cellFeed.getEntries()) {
            int rowId = TDriverUtil.getRowIndex(cell.getId());
            if (tmp != rowId && rowId != 1) {
                if (dataRow != null) {
                    result.addRow(this.fillUpEmptyCells(dataRow, headers));
                }
                dataRow = new DataRow(rowId - 1);
                tmp = rowId;
            }
            int columnId = TDriverUtil.getColumnIndex(cell.getId());
            if (columnId > headers.length) {
                continue;
            }
            if (rowId != 1 && dataRow != null) {
                DataCell dataCell =
                        new DataCell(TDriverUtil.getColumnIndex(cell.getId()),
                                cell.getContent().getType(),
                                cell.getTextContent().getContent().getPlainText());

                dataRow.addCell(dataCell.getColumnId(), dataCell);
            }
        }
        /* adding the last row of the sheet */
        if (dataRow != null) {
            result.addRow(this.fillUpEmptyCells(dataRow, headers));
        }
        this.getData().put(result.getTableName(), result);
    }
}
 
Example 6
Source File: validation.java    From oncokb with GNU Affero General Public License v3.0 4 votes vote down vote up
private static void getWorksheets() throws IOException, ServiceException {
    String propFileName = "properties/config.properties";
    Properties prop = new Properties();
    ValidationConfig config = new ValidationConfig();
    InputStream inputStream = config.getStram(propFileName);

    if (inputStream != null) {
        try {
            prop.load(inputStream);
        } catch (IOException ex) {
            Logger.getLogger(validation.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        throw new FileNotFoundException("property file '" + propFileName + "' not found in the classpath");
    }

    String REPORT_PARENT_FOLDER = prop.getProperty("google.report_parent_folder");
    String REPORT_DATA_TEMPLATE = prop.getProperty("google.report_data_template");

    System.out.println("Got drive service");

    DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
    Date date = new Date();

    String fileName = "Data run " + dateFormat.format(date);
    File file = new File();
    file.setTitle(fileName);
    file.setParents(Arrays.asList(new ParentReference().setId(REPORT_PARENT_FOLDER)));
    file.setDescription("New File created from server");

    System.out.println("Copying file");

    file = driveService.files().copy(REPORT_DATA_TEMPLATE, file).execute();

    System.out.println("Successfully copied file. Start to change file content");

    String fileId = file.getId();
    URL SPREADSHEET_FEED_URL = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full/" + fileId);

    SpreadsheetEntry spreadSheetEntry = spreadsheetService.getEntry(SPREADSHEET_FEED_URL, SpreadsheetEntry.class);

    WorksheetFeed worksheetFeed = spreadsheetService.getFeed(
        spreadSheetEntry.getWorksheetFeedUrl(), WorksheetFeed.class);
    worksheets = worksheetFeed.getEntries();
}