Package com.google.gdata.data.spreadsheet

Examples of com.google.gdata.data.spreadsheet.SpreadsheetEntry


  @SuppressWarnings("unchecked")
  @Test
  public void runAuthWithDataTest() throws Exception {

    String[] kinds = new String[] { "TestKind1" };
    final SpreadsheetEntry spreadsheet = SpreadsheetUtil.createSpreadsheet(authSubToken, kinds);
    try {
      ControllerTester tester = new ControllerTester();
      HttpSession session = tester.request.getSession(true);
      session.setAttribute("token", authSubToken);
     
      tester.request.setParameter("ssKey", spreadsheet.getKey());
      String run = tester.start("/restore/sheet");
      assertNotNull(run);
      List<Map<String, Object>> list = (List) tester.request.getAttribute("list");
      assertThat(list.size(), not(0));
    } finally {
View Full Code Here


  @Test
  public void runWithoutDataTest() throws Exception {

    String[] kinds = { "TestKind1" };
    SpreadsheetEntry ssEntry = SpreadsheetUtil.createSpreadsheet(authSubToken, kinds);
    try {
      Key controlKey =
        TaskQueueUtil.prepareRestoreControlKey("TestKind1", ssEntry.getKey(), authSubToken);

      ControllerTester tester = new ControllerTester();
      tester.request.setParameter("controlKey", KeyFactory.keyToString(controlKey));
      String run = tester.start("/tasks/restore");
      assertNull(run);
View Full Code Here

  @Test
  public void runWithDataTest() throws Exception {

    String[] kinds = { "TestKind1" };
    SpreadsheetEntry ssEntry = SpreadsheetUtil.createAndDumpSpreadsheet(authSubToken, kinds);
    try {
      Key controlKey =
        TaskQueueUtil.prepareRestoreControlKey("TestKind1", ssEntry.getKey(), authSubToken);

      ControllerTester tester = new ControllerTester();
      tester.request.setParameter("controlKey", KeyFactory.keyToString(controlKey));
      String run = tester.start("/tasks/restore");
      assertNull(run);
View Full Code Here

        ServiceException, URISyntaxException {
        SpreadsheetService service = new SpreadsheetService("MySpreadsheetIntegration-foo");
        URL url = new URL("https://spreadsheets.google.com/feeds/spreadsheets/private/full?title=GSS-Dev-Schedule");
        SpreadsheetFeed feed = service.getFeed(url, SpreadsheetFeed.class);
        List<SpreadsheetEntry> spreadsheets = feed.getEntries();
        SpreadsheetEntry spreadsheet = spreadsheets.get(0);
        WorksheetFeed worksheetFeed = service.getFeed(spreadsheet.getWorksheetFeedUrl(), WorksheetFeed.class);
        List<WorksheetEntry> worksheets = worksheetFeed.getEntries();
        WorksheetEntry worksheet = worksheets.get(0);
        // fetch A1 only
        URL cellFeedUrl = new URI(worksheet.getCellFeedUrl().toString() + "?min-row=1&max-row=1&min-col=1&max-col=1")
            .toURL();
View Full Code Here

  public String getExportLink(DocumentListEntry entry, String format){
    return ((MediaContent) entry.getContent()).getUri() + "&exportFormat=" + format;
  }
  public void createReprtWorksheets(String title) {
    try {
      SpreadsheetEntry spEntry = findSpreadsheetEntry(title);
      for (WorksheetEntry wsEntry : spEntry.getWorksheets()) {
        if (wsEntry.getTitle().getPlainText().equals("Sheet 1") || wsEntry.getTitle().getPlainText().equals("Sheet1")) {
          wsEntry.setTitle(new PlainTextConstruct(ChartTypes.TOTAL));
          wsEntry.setRowCount(20);
          wsEntry.setColCount(2);
          wsEntry.update();
          break;
        }
      }
      URL wsFeedUrl = spEntry.getWorksheetFeedUrl();
      WorksheetEntry wsEntry = null;
      if (spEntry != null) {
        if (findWorksheetEntry(ChartTypes.DAY, spEntry) == null) {
          wsEntry = new WorksheetEntry();
          wsEntry.setRowCount(365);
View Full Code Here

    return null;
  }

  public void initStatSpreadSheet(String title) {
    try {
      SpreadsheetEntry spEntry = findSpreadsheetEntry(title);
      if (spEntry != null) {
        WorksheetEntry wsEntry = findWorksheetEntry(ChartTypes.DAY, spEntry);
        if (wsEntry != null) {
          initStatWorksheet(wsEntry, ChartTypes.DAY);
        }
View Full Code Here

   
    private List<WorksheetEntry> getWorksheetEntriesForDoc(URL docUrl, String token) throws IOException, ServiceException {
        if (token != null) {
            try {
                SpreadsheetService spreadsheetService = GDataExtension.getSpreadsheetService(token);
                SpreadsheetEntry spreadsheetEntry = spreadsheetService.getEntry(docUrl, SpreadsheetEntry.class);
                return spreadsheetEntry.getWorksheets();
            } catch (ServiceException e) {
                // Ignore and fall through, pretending that we're not logged in.
            }
        }
        return getWorksheetEntriesForDoc(docUrl);
View Full Code Here

       
        try {
            WorksheetEntry worksheetEntry = service.getEntry(worksheetURL, WorksheetEntry.class);
            String spreadsheetName = docURL.toExternalForm();
            try {
                SpreadsheetEntry spreadsheetEntry = service.getEntry(docURL, SpreadsheetEntry.class);
                spreadsheetName = spreadsheetEntry.getTitle().getPlainText();
            } catch (ServiceException e) { // RedirectRequiredException among others
                // fall back to just using the URL (better for traceability anyway?)
            }
           
            String fileSource = spreadsheetName + " # " +
View Full Code Here

    final UserService user = UserServiceFactory.getUserService();
    final User currentUser = user.getCurrentUser();

    // Craete new spreadsheet
    GbSpreadsheetService gss = new GbSpreadsheetService(token);
    SpreadsheetEntry spreadsheet;
    while (true) {
      try {
        spreadsheet = gss.createSpreadsheet(Arrays.asList(kinds));
        break;
      } catch (IOException ioe) {
        // retry when timeout.
      }
    }
    logger.fine("ssKey=" + spreadsheet.getKey());

    List<Key> putKeys = null;
    try {
      // Prepare control table.
      Key controlId = datastore.allocateIds("dump", 1).getStart();
      List<Entity> list = new ArrayList<Entity>();
      Queue queue = QueueFactory.getDefaultQueue();
      List<TaskOptions> taskList = Lists.newArrayList();
      int countDown = 10000;
      for (int i = 0; i < kinds.length; i++) {
        Key childKey = KeyFactory.createKey(controlId, GbControl.NAME, kinds[i]);
        Entity control = new Entity(childKey);
        control.setProperty(GbControl.KIND_NAME, kinds[i]);
        control.setProperty(GbControl.COUNT, 0);
        if (currentUser != null) {
          control.setProperty(GbControl.REPORT_TO, new Email(currentUser.getEmail()));
        }
        control.setProperty(GbControl.AUTH_SUB_TOKEN, token);
        control.setProperty(GbControl.SPREADSHEET_KEY, spreadsheet.getKey());
        control.setProperty(GbControl.UPDATE_DATE, new Date());
        list.add(control);

        // Start task queue chain for each kind.
        taskList
          .add(TaskOptions.Builder.url("/tasks/dump.gobo").param(
            "controlKey",
            KeyFactory.keyToString(childKey)).countdownMillis(countDown).method(
            Method.GET));

        // to avoid the collision on the spreadsheet.
        countDown += 500;
      }
      putKeys = datastore.put(list);
      queue.add(taskList);

    } catch (Exception e) {
      if (putKeys != null) {
        try {
          datastore.delete(putKeys);
        } catch (Exception e2) {
          e2.printStackTrace();
        }
      }
      throw e;
    }

    return redirect("started.gobo?docURL="
      + response.encodeRedirectURL(spreadsheet.getHtmlLink().getHref()));
  }
View Full Code Here

      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
      URL worksheetFeedUrl = spreadsheetEntry.getWorksheetFeedUrl();
      WorksheetFeed worksheetFeed = ss.getFeed(worksheetFeedUrl, WorksheetFeed.class);
      WorksheetEntry defaultWorksheet = worksheetFeed.getEntries().get(0);
      defaultWorksheet.setTitle(new PlainTextConstruct(targetKinds.get(0)));
      defaultWorksheet.setRowCount(2);
      defaultWorksheet.setColCount(1);
View Full Code Here

TOP

Related Classes of com.google.gdata.data.spreadsheet.SpreadsheetEntry

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.