Package com.google.appengine.api.datastore.Query

Examples of com.google.appengine.api.datastore.Query.FilterPredicate


  private void filterToEqualityListAndRange(Filter filter, List<Filter> equality, Range range) {
    if (filter == null) {
      return;
    }
    if (filter instanceof FilterPredicate) {
      FilterPredicate predicate = (FilterPredicate) filter;
      switch (predicate.getOperator()) {
        case EQUAL:
          equality.add(predicate);
          break;
        case GREATER_THAN:
        case GREATER_THAN_OR_EQUAL:
View Full Code Here


  private static <T> List<Range> boundriesToRanges(Range orig, SortedSet<T> boundrySet) {
    List<Range> result = new ArrayList<>();
    List<T> boundries = new ArrayList<>(boundrySet);
    String property = orig.getPropertyName();
    FilterPredicate lower =
        new FilterPredicate(property, orig.getLowerBound().getOperator(), boundries.get(0));
    for (int i = 1; i < boundries.size() - 1; i++) {
      result.add(new Range(lower, new FilterPredicate(property, LESS_THAN, boundries.get(i))));
      lower = new FilterPredicate(property, GREATER_THAN_OR_EQUAL, boundries.get(i));
    }
    result.add(new Range(lower, new FilterPredicate(property, orig.getUpperBound().getOperator(),
        boundries.get(boundries.size() - 1))));
    return result;
  }
View Full Code Here

    }
    List<Entity> item = runQuery(q, 1);
    if (item.isEmpty()) {
      return null;
    }
    return new FilterPredicate(propertyName,
        direction == DESCENDING ? LESS_THAN_OR_EQUAL : GREATER_THAN_OR_EQUAL, item.get(0));
  }
View Full Code Here

   
    Key dbKey = KeyFactory.createKey(db, userId);
    HashMap<String, HashMap<String, Object>> attributes = new HashMap<String, HashMap<String, Object>>();
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
   
    Filter idFilter = new FilterPredicate("id", FilterOperator.EQUAL, id);
    Query query = new Query(table, dbKey)
        .addSort("name", SortDirection.ASCENDING)
        .setFilter(idFilter);
   
    PreparedQuery pq = datastore.prepare(query);
View Full Code Here

  private static final Logger LOGGER = Logger.getLogger(ImageServlet.class
      .getName());

  public final static BlobKey getBlobKeyByFileName(final String fileName) {

    Filter nameFilter = new FilterPredicate("filename",
        FilterOperator.EQUAL, fileName);

    final Query query = new Query("__BlobInfo__").setFilter(nameFilter);

    query.addSort("creation", SortDirection.DESCENDING);
View Full Code Here

  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException
  {
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    Query q = new Query("setting");
    Filter filter = new FilterPredicate("mention",Query.FilterOperator.EQUAL,true);
    q.setFilter(filter);
    PreparedQuery pq = datastore.prepare(q);
    for (Entity result : pq.asIterable())
    {
      Key key = result.getKey();
View Full Code Here

    DatastoreService datastore = DatastoreServiceFactory
        .getDatastoreService();
    ArrayList<Page> pages = new ArrayList<Page>();
    // The Query interface assembles a query
    Query q = new Query(Page.PAGEHISTORY);
    q.setFilter(new FilterPredicate(Page.NAME, Query.FilterOperator.EQUAL,
        name));

    q.addSort(Page.DATE, SortDirection.DESCENDING);

    // PreparedQuery contains the methods for fetching query results
View Full Code Here

  }

  private String getActiveTables() {
    Step step = MiniProfiler.step("API.getActiveTables");
    try {
      Filter segmentFilter = new FilterPredicate("segment",
          FilterOperator.IN, ACTIVE_SEGMENTS);

      Query q = new Query("Table").setFilter(segmentFilter);
      DatastoreService datastore = DatastoreServiceFactory
          .getDatastoreService();
View Full Code Here

    // TODO 0.1 need to try to go to memcache for this first somehow
    Step step = MiniProfiler.step("API.getMementos(" + tableId + ","
        + mementoId + ")");
    try {

      Filter tableIdFilter = new FilterPredicate("tableId",
          FilterOperator.EQUAL, tableId);

      Filter mementoIdFilter = new FilterPredicate("mementoId",
          FilterOperator.GREATER_THAN, mementoId);

      Filter tableIdAndMementoIdFilter = new CompositeFilter(
          CompositeFilterOperator.AND, Arrays.asList(tableIdFilter,
              mementoIdFilter));
View Full Code Here

  }

  private String getOpenAndActiveTables(String playerName) {
    Step step = MiniProfiler.step("API.getOpenAndActiveTables");
    try {
      Filter playerFilter = new FilterPredicate("players",
          FilterOperator.EQUAL, playerName);

      Filter activeSegmentFilter = new FilterPredicate("segment",
          FilterOperator.IN, ACTIVE_SEGMENTS);

      Filter openSegmentFilter = new FilterPredicate("segment",
          FilterOperator.IN, OPEN_SEGMENTS);

      Filter segmentFilter = new CompositeFilter(
          CompositeFilterOperator.OR, Arrays.asList(
              activeSegmentFilter, openSegmentFilter));
View Full Code Here

TOP

Related Classes of com.google.appengine.api.datastore.Query.FilterPredicate

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.