Package com.google.gdata.client.spreadsheet

Examples of com.google.gdata.client.spreadsheet.FeedURLFactory


    throws IOException, ServiceException
  {
    if (!isServiceInitialized())
      initializeService();
   
    FeedURLFactory factory = FeedURLFactory.getDefault();
     
    SpreadsheetFeed feed = (SpreadsheetFeed)spreadsheetService.getFeed(factory.getSpreadsheetsFeedUrl(), SpreadsheetFeed.class);
     
      return feed.getEntries();
  }
View Full Code Here


    }
   
    private List<WorksheetEntry> getWorksheetEntriesForDoc(URL docUrl) throws IOException, ServiceException {
        SpreadsheetService spreadsheetService = GDataExtension.getSpreadsheetService(null);
        String visibility = "public";
        FeedURLFactory factory = FeedURLFactory.getDefault();
        String key = GDataExtension.getSpreadsheetID(docUrl);
        docUrl = factory.getWorksheetFeedUrl(key, visibility, "values");
        WorksheetFeed feed = spreadsheetService.getFeed(docUrl, WorksheetFeed.class);
        return feed.getEntries();
    }
View Full Code Here

   * @throws IOException
   * @throws ServiceException
   */
  public List<Map<String, String>> getAllSpreadSheets() throws IOException, ServiceException {

    FeedURLFactory urlFactory = FeedURLFactory.getDefault();
    SpreadsheetQuery spreadsheetQuery =
      new SpreadsheetQuery(urlFactory.getSpreadsheetsFeedUrl());
    SpreadsheetFeed spreadsheetFeed = ss.query(spreadsheetQuery, SpreadsheetFeed.class);
    List<SpreadsheetEntry> entries = spreadsheetFeed.getEntries();

    List<Map<String, String>> list = new ArrayList<Map<String, String>>();
    for (SpreadsheetEntry spreadSheet : entries) {
View Full Code Here

   * @throws ServiceException
   */
  public List<Map<String, String>> getAllWorkSheets(String ssKey) throws IOException,
      ServiceException {

    FeedURLFactory urlFactory = FeedURLFactory.getDefault();
    URL tableFeedUrl = urlFactory.getTableFeedUrl(ssKey);
    TableFeed feed = ss.getFeed(tableFeedUrl, TableFeed.class);
    List<TableEntry> entries = feed.getEntries();

    List<Map<String, String>> list = new ArrayList<Map<String, String>>();
    for (TableEntry entry : entries) {
View Full Code Here

    /*
     * This code doesn't use list-base feed but cell-base feed. because The
     * columnNames are case-insensitive in list-base feed.
     */

    FeedURLFactory urlFactory = FeedURLFactory.getDefault();
    WorksheetQuery worksheetQuery =
      new WorksheetQuery(urlFactory.getWorksheetFeedUrl(ssKey, "private", "values"));
    worksheetQuery.setTitleQuery(kind);
    WorksheetFeed spreadsheetFeed = ss.query(worksheetQuery, WorksheetFeed.class);
    WorksheetEntry workSheet = spreadsheetFeed.getEntries().get(0);
    final int colCount = workSheet.getColCount();
    String[] columnTitle = new String[colCount];
View Full Code Here

    DocumentListEntry newSpreadSheet =
      cs.insert(new URL("https://docs.google.com/feeds/default/private/full/"), entry);

    try {
      // Re-get in "spreadsheet".SpreadsheetEntry
      FeedURLFactory urlFactory = FeedURLFactory.getDefault();
      SpreadsheetQuery spreadsheetQuery =
        new SpreadsheetQuery(urlFactory.getSpreadsheetsFeedUrl());
      spreadsheetQuery.setTitleQuery(fileName);
      SpreadsheetFeed spreadsheetFeed = ss.query(spreadsheetQuery, SpreadsheetFeed.class);
      SpreadsheetEntry spreadsheetEntry = spreadsheetFeed.getEntries().get(0);

      // Modify a default worksheet
View Full Code Here

      throws Exception {

    logger.info("Preparing worksheet :" + kind);

    // Search Spreadsheet
    FeedURLFactory urlFactory = FeedURLFactory.getDefault();
    SpreadsheetQuery spreadsheetQuery =
      new SpreadsheetQuery(urlFactory.getSpreadsheetsFeedUrl());
    SpreadsheetFeed spreadsheetFeed = ss.query(spreadsheetQuery, SpreadsheetFeed.class);
    SpreadsheetEntry spreadsheetEntry = null;
    for (SpreadsheetEntry entry : spreadsheetFeed.getEntries()) {
      if (ssKey.equals(entry.getKey())) {
        spreadsheetEntry = entry;
        logger.info("Spreadsheet:" + ssKey + " is found.");
        break;
      }
    }
    if (spreadsheetEntry == null) {
      throw new RuntimeException("Cannot find spreadsheet:" + ssKey);
    }

    // Modify a worksheet's column size
    URL worksheetFeedUrl = spreadsheetEntry.getWorksheetFeedUrl();
    WorksheetFeed worksheetFeed = ss.getFeed(worksheetFeedUrl, WorksheetFeed.class);
    WorksheetEntry worksheetEntry = null;
    for (WorksheetEntry worksheet : worksheetFeed.getEntries()) {
      if (kind.equals(worksheet.getTitle().getPlainText())) {
        worksheetEntry = worksheet;
        break;
      }
    }
    if (worksheetEntry == null) {
      throw new RuntimeException("Cannot find worksheet:" + kind);
    }
    worksheetEntry.setColCount(properties.size() + 1);
    worksheetEntry.update();
    logger.info("Worksheet:" + kind + "'s column-size is set to " + (properties.size() + 1));

    FeedURLFactory factory = FeedURLFactory.getDefault();
    URL tableFeedUrl = factory.getTableFeedUrl(ssKey);

    // Check if already exists.
    TableEntry tableEntry = null;
    TableFeed feed = ss.getFeed(tableFeedUrl, TableFeed.class);
    for (TableEntry entry : feed.getEntries()) {
      if (entry.getTitle().getPlainText().equals(kind)) {
        tableEntry = entry;
        logger.info("TableFeed:" + kind + " already exists.");
        break;
      }
    }

    // Add TableFeed
    if (tableEntry == null) {
      tableEntry = new TableEntry();
      tableEntry.setTitle(new PlainTextConstruct(kind));
      tableEntry.setWorksheet(new Worksheet(kind));
      tableEntry.setHeader(new Header(1));

      Data tableData = new Data();
      tableData.setNumberOfRows(0);
      tableData.setStartIndex(2);
      tableData.setInsertionMode(InsertionMode.INSERT);

      // Create a title row
      tableData.addColumn(new Column("A", Entity.KEY_RESERVED_PROPERTY));
      for (int i = 0; i < properties.size(); i++) {
        String index = number2columnName(i + 1);
        String columnName = properties.get(i).getName();
        tableData.addColumn(new Column(index, columnName));
      }
      tableEntry.setData(tableData);
      tableEntry = ss.insert(tableFeedUrl, tableEntry);
      logger.info("Craeted tableFeed:" + kind);
    }
    String[] split = tableEntry.getId().split("/");
    final String tableId = split[split.length - 1];

    // Add a "valueType" row (the cells are filled with "*" to be replaced)
    int numberOfRows = tableEntry.getData().getNumberOfRows();
    if (numberOfRows == 0) {
      RecordEntry newEntry = new RecordEntry();
      newEntry.addField(new Field(null, Entity.KEY_RESERVED_PROPERTY, VALUE_TYPE));
      for (int i = 0; i < properties.size(); i++) {
        GbProperty gbProperty = properties.get(i);
        String columnName = gbProperty.getName();
        newEntry.addField(new Field(null, columnName, VALUE_TYPE_NOT_SET));
      }
      URL recordFeedUrl = factory.getRecordFeedUrl(ssKey, tableId);
      ss.insert(recordFeedUrl, newEntry);
      logger.info("Inserted TypeValue row in :" + kind);
    }
    return tableId;
  }
View Full Code Here

   * @throws Exception
   */
  public void dumpData(String ssKey, String kind, String tableId, List<GbEntity> list,
      boolean retry) throws Exception {

    FeedURLFactory factory = FeedURLFactory.getDefault();
    URL recordFeedUrl = factory.getRecordFeedUrl(ssKey, tableId);

    // Get "valueType" row for update.
    logger.info("Checking valueType row in :" + kind);
    RecordQuery query = new RecordQuery(recordFeedUrl);
    query.setSpreadsheetQuery(Entity.KEY_RESERVED_PROPERTY + "=" + VALUE_TYPE);
View Full Code Here

TOP

Related Classes of com.google.gdata.client.spreadsheet.FeedURLFactory

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.