Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.Cursor


          .setLength(metadata.getLength())
          .setLastModified(metadata.getLastModified())
          .build();
      items.add(listItem);
    }
    Cursor cursor = dsResults.getCursor();
    String nextMarker = null;
    if (items.size() == maxResults && cursor != null) {
      nextMarker = cursor.toWebSafeString();
    }
    if (marker != null && marker.equals(nextMarker)) {
    }
    return new ListItemBatch(items, nextMarker);
  }
View Full Code Here


  private ChapterManager chapterManager;

  @RequestMapping("/offline/getEventStats")
  public ModelAndView handleRequest(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
    Cursor cursor = null;
    Date nowDate = null;
    Date thenDate = null;
    if (request.getParameter(CURSOR_KEY) != null) {
      cursor = Cursor.fromWebSafeString(request.getParameter(CURSOR_KEY));
    }
View Full Code Here

  private JdoStatsDao statsDao;

  @RequestMapping("/offline/getChapterStats")
  public ModelAndView handleRequest(HttpServletRequest request,
      HttpServletResponse response) throws ServletException, IOException {
    Cursor cursor = null;
    if (request.getParameter(CURSOR_KEY) != null) {
      cursor = Cursor.fromWebSafeString(request.getParameter(CURSOR_KEY));
    }

    PersistenceManager pm = PMF.get().getPersistenceManager();
View Full Code Here

    Query q = pm.newQuery(Flight.class);
    q.setRange(0, 1);
    List<Flight> flights = (List<Flight>) q.execute();
    assertEquals(1, flights.size());
    assertEquals(e1.getKey(), KeyFactory.stringToKey(flights.get(0).getId()));
    Cursor c = JDOCursorHelper.getCursor(flights);
    assertNotNull(c);

    extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, c);
    q.setExtensions(extensionMap);
    flights = (List<Flight>) q.execute();
    assertEquals(1, flights.size());
    assertEquals(e2.getKey(), KeyFactory.stringToKey(flights.get(0).getId()));
    assertNotNull(JDOCursorHelper.getCursor(flights));

    extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, c.toWebSafeString());
    q.setExtensions(extensionMap);
    flights = (List<Flight>) q.execute();
    assertEquals(1, flights.size());
    assertEquals(e2.getKey(), KeyFactory.stringToKey(flights.get(0).getId()));
    c = JDOCursorHelper.getCursor(flights);
    assertNotNull(c);

    extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, c);
    q.setExtensions(extensionMap);
    flights = (List<Flight>) q.execute();
    assertEquals(1, flights.size());
    assertEquals(e3.getKey(), KeyFactory.stringToKey(flights.get(0).getId()));
    assertNotNull(JDOCursorHelper.getCursor(flights));

    extensionMap.put(JDOCursorHelper.CURSOR_EXTENSION, c.toWebSafeString());
    q.setExtensions(extensionMap);
    flights = (List<Flight>) q.execute();
    assertEquals(1, flights.size());
    assertEquals(e3.getKey(), KeyFactory.stringToKey(flights.get(0).getId()));
    assertNotNull(JDOCursorHelper.getCursor(flights));
View Full Code Here

    commitTxn();
   
    assertEquals(lowLevelCursors, ormCursors);

    for (int i = 0; i < lowLevelCursors.size(); i++) {
      Cursor lowLevelCursor = lowLevelCursors.get(i);
      @SuppressWarnings("deprecation")
      List<Entity> list = ds.prepare(query).asList(FetchOptions.Builder.withCursor(lowLevelCursor));
      assertEquals(3 - i, list.size());
    }
  }
View Full Code Here

    Query q = em.createQuery("select from " + Book.class.getName() + " b");
    q.setMaxResults(1);
    List<Book> books = (List<Book>) q.getResultList();
    assertEquals(1, books.size());
    assertEquals(e1.getKey(), KeyFactory.stringToKey(books.get(0).getId()));
    Cursor c = JPACursorHelper.getCursor(books);
    assertNotNull(c);

    q.setHint(JPACursorHelper.CURSOR_HINT, c);
    books = (List<Book>) q.getResultList();
    assertEquals(1, books.size());
    assertEquals(e2.getKey(), KeyFactory.stringToKey(books.get(0).getId()));
    assertNotNull(JPACursorHelper.getCursor(books));

    q.setHint(JPACursorHelper.CURSOR_HINT, c.toWebSafeString());
    books = (List<Book>) q.getResultList();
    assertEquals(1, books.size());
    assertEquals(e2.getKey(), KeyFactory.stringToKey(books.get(0).getId()));
    c = JPACursorHelper.getCursor(books);
    assertNotNull(c);

    q.setHint(JPACursorHelper.CURSOR_HINT, c);
    books = (List<Book>) q.getResultList();
    assertEquals(1, books.size());
    assertEquals(e3.getKey(), KeyFactory.stringToKey(books.get(0).getId()));
    assertNotNull(JPACursorHelper.getCursor(books));

    q.setHint(JPACursorHelper.CURSOR_HINT, c.toWebSafeString());
    books = (List<Book>) q.getResultList();
    assertEquals(1, books.size());
    assertEquals(e3.getKey(), KeyFactory.stringToKey(books.get(0).getId()));
    assertNotNull(JPACursorHelper.getCursor(books));
View Full Code Here

    ormCursors.add(JPACursorHelper.getCursor(bookIter));

    assertEquals(lowLevelCursors, ormCursors);

    for (int i = 0; i < lowLevelCursors.size(); i++) {
      Cursor lowLevelCursor = lowLevelCursors.get(i);
      @SuppressWarnings("deprecation")
      List<Entity> list = ds.prepare(query).asList(FetchOptions.Builder.withCursor(lowLevelCursor));
      assertEquals(3 - i, list.size());
    }
  }
View Full Code Here

      if (getExecutionContext().getStatistics() != null) {
        getExecutionContext().getStatistics().incrementNumReads();
      }

      Iterable<Entity> entityIterable;
      Cursor endCursor = null;
      if (opts != null) {
        if (opts.getLimit() != null) {
          QueryResultList<Entity> entities = preparedQuery.asQueryResultList(opts);
          endCursor = entities.getCursor();
          entityIterable = entities;
View Full Code Here

      }
    }

    // users can provide the cursor as a Cursor or its String representation.
    // If we have a cursor, add it to the fetch options
    Cursor cursor = null;
    Object obj = query.getExtension(CursorHelper.QUERY_CURSOR_PROPERTY_NAME);
    if (obj != null) {
      if (obj instanceof Cursor) {
        cursor = (Cursor) obj;
      }
View Full Code Here

  }

  private FetchOptions cloneFetchOptions(FetchOptions fetchOptions) {
    checkNotNull(fetchOptions);
    FetchOptions clonedOptions = cloneFetchOptionsPrefetchAndChunkSize(fetchOptions);
    Cursor startCursor = fetchOptions.getStartCursor();
    if (startCursor != null) {
      clonedOptions.startCursor(startCursor);
    }
    Cursor endCursor = fetchOptions.getEndCursor();
    if (endCursor != null) {
      clonedOptions.endCursor(endCursor);
    }
    Integer limit = fetchOptions.getLimit();
    if (limit != null) {
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.Cursor

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.