Package com.google.appengine.api.datastore

Examples of com.google.appengine.api.datastore.DatastoreService.prepare()


    public int count(String kind) throws NullPointerException {
        if (kind == null) {
            throw new NullPointerException("The kind parameter is null.");
        }
        DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
        return ds.prepare(new Query(kind)).countEntities(
            FetchOptions.Builder.withLimit(Integer.MAX_VALUE));
    }
}
View Full Code Here


      Query getRevisionValues = new Query(AppEngineRecord.class.getSimpleName());
      getRevisionValues.setAncestor(lookupKey);
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

      List<Entity> results =
          datastore.prepare(getRevisionValues).asList(FetchOptions.Builder.withDefaults());
      for (Entity result : results) {
        ByteArrayInputStream bais =
            new ByteArrayInputStream(((Blob) result.getProperty("revision")).getBytes());
        ObjectInputStream ndis = new ObjectInputStream(bais);
        answer.add(new RevValue(((Revision) ndis.readObject()).getBytes(),
View Full Code Here

    try {
      Query getIndices = new Query(Lookup.class.getSimpleName());
      getIndices.setAncestor(castUser(user).getKey());
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
      List<Entity> results =
          datastore.prepare(getIndices).asList(FetchOptions.Builder.withDefaults());
      List<byte[]> answer = new ArrayList<byte[]>();
      for (Entity result : results) {
        Object index = result.getProperty("index");
        if (index instanceof ShortBlob) {
          answer.add(((ShortBlob) index).getBytes());
View Full Code Here

      Query getRevisionValues = new Query(AppEngineRecord.class.getSimpleName());
      getRevisionValues.setAncestor(lookupKey);
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

      List<Entity> results =
          datastore.prepare(getRevisionValues).asList(FetchOptions.Builder.withDefaults());
      for (Entity result : results) {
        ByteArrayInputStream bais =
            new ByteArrayInputStream(((Blob) result.getProperty("revision")).getBytes());
        ObjectInputStream ndis = new ObjectInputStream(bais);
        answer.add(((Revision) ndis.readObject()).getBytes());
View Full Code Here

        Query getRevisionValues = new Query(AppEngineRecord.class.getSimpleName());
        getRevisionValues.setAncestor(lookupKey);
        DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

        List<Entity> results =
            datastore.prepare(getRevisionValues).asList(FetchOptions.Builder.withDefaults());
        for (Entity entity : results) {
          pm.deletePersistent(pm.getObjectById(AppEngineRecord.class, entity.getKey()));
        }

      } finally {// even if there is no value the index still needs to be deleted - but we haven't
View Full Code Here

    try {
      Query getAllNonces = new Query(AENonce.class.getSimpleName());
      DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

      List<Entity> results =
          datastore.prepare(getAllNonces).asList(FetchOptions.Builder.withDefaults());
      for (Entity entity : results) {
        int sinceEpoch = (int) (long) ((Long) entity.getProperty("sinceEpoch"));
        if (!Nonce.isRecent(sinceEpoch)) {
          pm.deletePersistent(pm.getObjectById(AENonce.class, entity.getKey()));
        }
View Full Code Here

  {
   
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
      Key transactionKey = KeyFactory.createKey("UserTransactions", user.getUserId());
      Query query = new Query("Transaction", transactionKey).addSort("date", Query.SortDirection.DESCENDING);
      List<Entity> transactions = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(5));
      for (Entity t : transactions) {
           response.getWriter().println("type:"+t.getProperty("type"));
           response.getWriter().println("<br/>");
           response.getWriter().println("date:"+t.getProperty("date"));
           response.getWriter().println("<br/>");
View Full Code Here

                    1939);
        q.addSort("copyrightYear");
        q.addSort("title");

        // Perform the query.
        PreparedQuery pq = ds.prepare(q);
        for (Entity result : pq.asIterable()) {
            String title = (String) result.getProperty("title");
            out.println("<p>Query result: title = " + title + "</p>");
        }
View Full Code Here

        List<Map<String, Object>> uploads = new ArrayList<Map<String, Object>>();

        Key userGroupKey = KeyFactory.createKey("UserUploadGroup", user.getEmail());
        Query q = new Query("UserUpload").setAncestor(userGroupKey);
        q.addFilter("user", Query.FilterOperator.EQUAL, user);
        PreparedQuery pq = ds.prepare(q);
        Iterable<Entity> results = pq.asIterable();
        for (Entity result : results) {
            Map<String, Object> upload = new HashMap<String, Object>();
            upload.put("description", (String) result.getProperty("description"));
            BlobKey blobKey = (BlobKey) result.getProperty("upload");
View Full Code Here

        query.setKeysOnly();

        final DatastoreService ds = Store.P.Get();
        final MemcacheService mc = Store.C.Get();

        PreparedQuery stmt = ds.prepare(query);

        Iterable<Entity> list = stmt.asIterable();

        for (Entity ent : list){
            final Key key = ent.getKey();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.