Ejemplo n.º 1
0
 @Override
 public <T extends Searchable> Future<Long> count(final Specification<T> specification) {
   final Class<?> specClass = specification.getClass();
   final String parentName = client.getDslName(specClass.getDeclaringClass());
   return client.sendRequest(
       Long.class,
       DOMAIN_URI + "count/" + parentName + "?specification=" + specClass.getSimpleName(),
       "PUT",
       specification,
       new int[] {200});
 }
Ejemplo n.º 2
0
  @Override
  public <T extends Searchable> Future<List<T>> search(
      final Specification<T> specification,
      final Integer limit,
      final Integer offset,
      final Iterable<Map.Entry<String, Boolean>> order) {

    if (specification == null) throw new IllegalArgumentException("Specification can't be null");
    final Class<?> specClass = specification.getClass();
    @SuppressWarnings("unchecked")
    final Class<T> manifest = (Class<T>) specClass.getDeclaringClass();
    final String parentName = client.getDslName(manifest);

    final String url =
        Utils.appendLimitOffsetOrder(
            parentName + "?specification=" + specClass.getSimpleName(),
            limit,
            offset,
            order,
            false);

    return client.sendCollectionRequest(
        manifest, DOMAIN_URI + "search/" + url, "PUT", specification, new int[] {200});
  }