Esempio n. 1
0
 private void appendQueryParams(URI query) {
   for (Map.Entry<String, String> param : queryParams.entrySet()) {
     query.param(param.getKey(), param.getValue());
   }
 }
Esempio n. 2
0
  public String buildQuery() {
    if (cachedQuery != null) {
      return cachedQuery;
    }

    URI query = buildViewPath();

    if (isNotEmpty(key)) {
      query.param("key", key);
    }

    if (isNotEmpty(startKey)) {
      query.param("startkey", startKey);
    }

    if (isNotEmpty(endKey)) {
      query.param("endkey", endKey);
    }

    if (isNotEmpty(startDocId)) {
      query.param("startkey_docid", startDocId);
    }

    if (isNotEmpty(endDocId)) {
      query.param("endkey_docid", endDocId);
    }

    if (hasValue(limit)) {
      query.param("limit", limit);
    }

    if (staleOk != null) {
      query.param("stale", staleOk);
    }

    if (descending) {
      query.param("descending", "true");
    }

    if (!inclusiveEnd) {
      query.param("inclusive_end", "false");
    }

    if (!reduce) {
      query.param("reduce", "false");
    }

    if (hasValue(skip)) {
      query.param("skip", skip);
    }

    if (includeDocs) {
      query.param("include_docs", "true");
    }

    if (group) {
      query.param("group", "true");
    }

    if (hasValue(groupLevel)) {
      query.param("group_level", groupLevel);
    }

    if (queryParams != null && !queryParams.isEmpty()) {
      appendQueryParams(query);
    }

    cachedQuery = query.toString();
    return cachedQuery;
  }