Package com.google.appengine.api.datastore

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


      ids.add(creator.create(contact));
    }
   
    deletor.delete("Contact", ids.get(0));
   
    final PreparedQuery pq = db.prepare(new Query("Contact"));
   
    // only 9 contacts should have survived this
    assertEquals(9, pq.countEntities());
   
    // the deleted entity should not be retrieved because it should have been deleted.
    for (final Entity entity: pq.asIterable()) {
      assertFalse(ids.get(0) == entity.getKey().getId());
    }
   
    assertNull(reader.get("Contact", ids.get(0)));
  }
View Full Code Here


  private long lastCacheUpdate = 0;

  // TODO only transmit required fields for listview - do not copy all fields into dto to save bandwidth
  @Override
  public ListQueryResult getAll(String kind, final int from, final int to) {
    final PreparedQuery pq = db.prepare(new Query(kind));
    return copy.entitiesToDtoArray(kind, pq.countEntities(withDefaults()), pq.asIterable(withLimit(to - from + 1).offset(from)), false);
  }
View Full Code Here

    return db.prepare(nameQuery);
  }

  @Override
  public Dto getByName(String kind, String name) {
    final PreparedQuery pq = getFiltered(kind, "name", FilterOperator.EQUAL, name);
    // TODO should still indicate that nothing has to be resolved
    return copy.entityToDto(kind, pq.asSingleEntity(), false/*, false*/);
  }
 
View Full Code Here

    return copy.entityToDto(kind, pq.asSingleEntity(), false/*, false*/);
  }

  @Override
  public ListQueryResult getAllAssignedTo(String kind, long assignedTo, int from, int to) {
    final PreparedQuery pq = getFiltered(kind, "assignedTo", FilterOperator.EQUAL, KeyFactory.createKey(Employee.class.getSimpleName(), assignedTo));
    return copy.entitiesToDtoArray(kind, pq.countEntities(withDefaults()), pq.asIterable(), false);
  }
View Full Code Here

    return copy.entitiesToDtoArray(kind, pq.countEntities(withDefaults()), pq.asIterable(), false);
  }

  @Override
  public ListQueryResult getAllMarked(String kind, int from, int to) {
    final PreparedQuery pq = getFiltered(kind, "marked", FilterOperator.EQUAL, true);
    return copy.entitiesToDtoArray(kind, pq.countEntities(withDefaults()), pq.asIterable(), false);
  }
View Full Code Here

    if (r.get(originating).containsKey(related)) {
      final Key keyOrigin = KeyFactory.createKey(related, id);

      for (final String fieldName : r.get(originating).get(related)) {
        // TODO use parallel fetch instead if possible
        final PreparedQuery pq = getFiltered(originating, fieldName, FilterOperator.EQUAL, keyOrigin);

        for (final Entity entity : pq.asIterable()) {
          // TODO should still indicate that nothing has to be resolved
          result.add(copy.entityToDto(originating, entity, false/*, false*/));
        }
      }
    }
 
View Full Code Here

  }

  @Override
  public ListQueryResult getAllByNamePrefix(String kind, String prefix, int from, int to) {
    final ArrayList<Dto> hits = new ArrayList<Dto>();
    final PreparedQuery pq = getFiltered(kind, "name", FilterOperator.GREATER_THAN_OR_EQUAL, prefix);

    for (final Entity entity : pq.asIterable()) {
      if (null != entity.getProperty("name") && entity.getProperty("name") instanceof String && entity.getProperty("name").toString().startsWith(prefix)) {
        // TODO should still indicate that nothing has to be resolved
        hits.add(copy.entityToDto(kind, entity, false/*, false*/));
      }
    }
 
View Full Code Here

    return diff > CACHE_EXPIRATION;
  }

  private List<Entity> getCachedList(final String kind) {
    if (isCacheOutOfDate() || !cache.containsKey(kind)) {
      final PreparedQuery pq = db.prepare(new Query(kind));
      cache.put(kind, pq.asList(withDefaults()));
      lastCacheUpdate = System.currentTimeMillis();
      log.info("fulltext search cache updated");
    }

    return cache.get(kind);
View Full Code Here

  @Override
  public ListQueryResult getAll(String kind, String sortColumn, honeycrm.client.s.SortDirection sortDirection, int from, int to) {
    final Query q = new Query(kind);
    final SortDirection dir = sortDirection.equals(honeycrm.client.s.SortDirection.Ascending) ? SortDirection.ASCENDING : SortDirection.DESCENDING;
    q.addSort(sortColumn, dir);
    PreparedQuery pq = db.prepare(q);
    return copy.entitiesToDtoArray(kind, pq.countEntities(withDefaults()), pq.asIterable(withLimit(to - from + 1).offset(from)), false);
  }
View Full Code Here

  }

  @Override
  public ArrayList<String> getPluginNames() {
    final ArrayList<String> list = new ArrayList<String>();
    final PreparedQuery q = db.prepare(new Query("Plugin"));
    for (final Entity e: q.asIterable()) {
      list.add(String.valueOf(e.getProperty("name")));
    }
    return list;
  }
View Full Code Here

TOP

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

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.