Executes {@code GetList} with {@code AppEngineDatastoreSession}.

@return The entities match to the specified {@code Filter}s in the
specified range ordered by the specified sort orders as a {@code List}
view.
974335
@Override
	public List<E> execute() {
		logger.fine("Executing [AppEngineGetList] command");
		Class<E> type = metamodel.type();
		Query query = new Query(Translation.toKind(type));
		QueryRestriction restriction = new QueryRestriction();
		Set<Filter<?>> subfilters = new HashSet<Filter<?>>();
		
		for (Filter<?> filter : filters) {
			if (restriction.restricted(filter)) {
				subfilters.add(filter);
			} else {
				Property<?, ?> property = filter.property();
				String name = (property.parent() instanceof EmbeddedProperty) 
						? property.parent().name() + "." + property.name() : property.name();
				boolean key = false;
				
				if (name.equals(Entities.keyField(type).getName())) {
					name = Entity.KEY_RESERVED_PROPERTY;
					key = true;
				}
				
				if (filter instanceof ComparableFilter<?>) {
					ComparableFilter<?> comparableFilter = (ComparableFilter<?>) filter;
					Object value = comparableFilter.value();
					
					if (key) {
						value = Keys.create(Translation.toKind(type), value);
					}
					
					query.setFilter(new Query.FilterPredicate(
							name, Translation.toFilterOperator(comparableFilter.operator()), value));
				} else if (filter instanceof InFilter<?>) {
					InFilter<?> inFilter = (InFilter<?>) filter;
					List<?> values = inFilter.values();
					
					if (key) {
						List<Object> list = new ArrayList<Object>();
						
						for (Object value : values) {
							list.add(Keys.create(Translation.toKind(type), value));
						}
						
						values = list;
					}
					
					query.setFilter(new Query.FilterPredicate(name, FilterOperator.IN, values));
				}
			}
		}
		
		final List<Order<?, ?>> suborders = new ArrayList<Order<?, ?>>();
		
		for (Order<?, ?> order : orders) {
			if (restriction.restricted(order)) {
				suborders.add(order);
			} else {
				Property<?, ?> property = order.property();
				String name = (property.parent() instanceof EmbeddedProperty) 
						? property.parent().name() + "." + property.name() : property.name();
				query.addSort(name, Translation.toSortDirection(order.direction()));
			}
		}
		
		FetchOptions options = FetchOptions.Builder.withOffset(0);
		
		if (subfilters.isEmpty() && suborders.isEmpty()) {
			// Optimization: If all of the specified filters are not restricted, 
			// establishes the offset and the limit at the query execution.
			options = FetchOptions.Builder.withOffset(offset);
			
			if (Integer.MAX_VALUE - limit >= offset) {
				options.limit(limit);
			}
		}
		
		int count = 0;
		List<E> result = new ArrayList<E>();
		
		for (Entity entity : session.datastore().query(query.setKeysOnly(), options)) {
			E e = session.get(type, entity.getKey());
			Iterator<Filter<?>> iterator = subfilters.iterator();
			boolean matches = true;
			
			while (iterator.hasNext()) {
				if (!iterator.next().matches(e)) {
					matches = false;
					break;
				}
			}
			
			if (matches) {
				result.add(e);
				count++;
				
				if (count >= limit) {
					break;
				}
			}
		}
		
		if (!suborders.isEmpty()) {
			Collections.sort(result, new Comparator<E>() {

				@SuppressWarnings("unchecked")
				@Override
				public int compare(E entity1, E entity2) {
					int compare = 0;
					
					for (Order<?, ?> o : suborders) {
						Order<E, ?> order = (Order<E, ?>) o;
						compare = order.compare(entity1, entity2);
						
						if (order.direction() == Order.Direction.DESC) {
							compare = compare * -1;
						}
						
						if (compare != 0) {
							return compare;
						}
					}
					
					return compare;
				};
				
			});
		}
		
		if (subfilters.isEmpty()) {
			return result;
		} else {
			int offset = this.offset;
			
			if (offset > result.size()) {
				offset = result.size() - 1;
			}
			
			int limit = offset + this.limit;
			
			if (limit > result.size()) {
				limit = result.size();
			}
			
			return result.subList(offset, limit);
		}
	}
1308409
public com.google.appengine.v1.Library getLibraries(int index) {
    return libraries_.get(index);
  }
296822
public TypedQuery<T> select(Filter filter, OrderBy orderBy) {
        CriteriaQuery<T> query = cb.createQuery(getEntityClass());
        Root<T> from = query.from(getEntityClass());

        CriteriaMapper criteriaMapper = new CriteriaMapper(from, cb);

        if (orderBy != null) {
            query.orderBy(criteriaMapper.create(orderBy));
        }
        if (filter != null) {
            query.where(criteriaMapper.create(filter));
        }

        return getEntityManager().createQuery(query);
    }
888808
private List<ENTITY> page(List<Match> matches, DaoPage daoPage) {

        if (daoPage.getPageNo() < 1 || daoPage.getPageSize() < 0) {
            return find(matches, daoPage.getOrderList());
        }

        int offset = (daoPage.getPageNo() - 1) * daoPage.getPageSize();
        int limit = daoPage.getPageSize();
        return find(matches, daoPage.getOrderList(), offset, limit);
    }
1026973
public Iterator iterateObjects(org.kie.api.runtime.ObjectFilter filter) {
        return getObjectStore().iterateObjects(filter);
    }
736973
private List<Entity> runQuery(Query query) throws DatastoreException {
    RunQueryRequest.Builder request = RunQueryRequest.newBuilder();
    request.setQuery(query);
    RunQueryResponse response = datastore.runQuery(request.build());

    if (response.getBatch().getMoreResults() == QueryResultBatch.MoreResultsType.NOT_FINISHED) {
      System.err.println("WARNING: partial results\n");
    }
    List<EntityResult> results = response.getBatch().getEntityResultsList();
    List<Entity> entities = new ArrayList<Entity>(results.size());
    for (EntityResult result : results) {
      entities.add(result.getEntity());
    }
    return entities;
  }
686548
@Override
    public List<FILTERTYPE> getAllFilter() {

        final List<FILTERTYPE> list = new ArrayList<FILTERTYPE>();
        final List<Node> nodeList = model.get("filter");
        for (final Node node : nodeList) {
            final FILTERTYPE filter = this.createNewFilterViewForModel(node);
            list.add(filter);
        }

        return list;
    }
988742
public List<ENTITY> find(List<Match> matches, List<Order> order) {
        return find(matches, order, 0, 0);
    }
455837
public static List<ModelServiceInstance> filter(ServiceInstanceQuery query, List<ModelServiceInstance> list) {

        List<ModelServiceInstance> instances = new ArrayList<ModelServiceInstance>();
        for (ModelServiceInstance instance : list) {
            boolean passed = true;
            for (QueryCriterion criterion : query.getCriteria()) {
                if (criterion.isMatch(instance.getMetadata()) == false) {
                    passed = false;
                    break;
                }
            }
            if (passed) {
                instances.add(instance);
            }
        }
        return instances;

    }
389986
@Override
    public List<?> getResultList() {
        if (log.isDebugEnabled())
            log.debug("JPA Query: " + getJPAQuery());

        // get luence query
        String q = luceneQuery;
        if (null == q) {
            q = KunderaCoreUtils.getLuceneQueryFromJPAQuery(kunderaQuery, kunderaMetadata);
        }

        if (log.isDebugEnabled())
            log.debug("Lucene Query: " + q);

        EntityMetadata m = kunderaQuery.getEntityMetadata();
        Client client = persistenceDelegeator.getClient(m);

        handlePostEvent();
        Map<String, Object> searchFilter = client.getIndexManager().search(m.getEntityClazz(), q, -1, maxResult);

        if (kunderaQuery.isAliasOnly()) {
            String[] primaryKeys = searchFilter.values().toArray(new String[] {});
            return persistenceDelegeator.find(m.getEntityClazz(), primaryKeys);
        } else {
            return persistenceDelegeator.find(m.getEntityClazz(), searchFilter);

        }

    }
1070827
protected final List<T> findSortedByQuery(String query, String sort, Object... params) {
        return this.dataAccess.findSortedByQuery(query, sort, params);
    }
852452
public Query orderedBy( List<Ordering> orderings ) {
        return new Query(source, constraint, orderings, columns, getLimits(), distinct);
    }
555092
public List<?> getList(PMContext ctx, EntityFilter filter, ListSort sort, Integer from, Integer count) throws PMException {
        return getDataAccess().list(ctx, filter, null, sort, from, count);
    }
1270370
public Iterator<InternalFactHandle> iterateFactHandles(org.kie.api.runtime.ObjectFilter filter) {
        return getObjectStore().iterateFactHandles(filter);
    }
194943
public static List<ModelServiceInstance> filter(ServiceInstanceQuery query, List<ModelServiceInstance> list) {

        if (list == null || list.size() == 0) {
            return Collections.emptyList();
        }

        List<QueryCriterion> criteria = query.getCriteria();

        if (criteria == null || criteria.size() == 0) {
            return list;
        }

        List<ModelServiceInstance> instances = new ArrayList<ModelServiceInstance>();
        for (ModelServiceInstance instance : list) {
            boolean passed = true;
            for (QueryCriterion criterion : criteria) {
                if (criterion.isMatch(instance.getMetadata()) == false) {
                    passed = false;
                    break;
                }
            }
            if (passed) {
                instances.add(instance);
            }
        }

        return instances;

    }
1079437
public static Result list(int page, String sortBy, String order, String filter) {
        return ok(
            list.render(
                Computer.page(page, 10, sortBy, order, filter),
                sortBy, order, filter
            )
        );
    }
795247
public List<ENTITY> find(List<Match> matches, List<Order> order, int offset, int limit) {
        // FIXME
        Query operate =
                queryGenerator.getSelectQuery(matches, (order == null) ? null : order.toArray(new Order[order.size()]));
        String sql = operate.getSql();
        List<Object> params = operate.getParams();

        if (offset != 0 || limit != 0) {
            sql = sql + " limit ?, ?";
            params.add(offset);
            params.add(limit);
        }

        // 执行操作
        return findBySQL(sql, operate.getParams());
    }