private void buildMatchQueryParams(AVSaveOption option, LinkedList<Map<String, Object>> pendingRequests) { Map<String, Object> whereOperationMap = null; if (option != null && option.matchQuery != null) { whereOperationMap = option.matchQuery.conditions.compileWhereOperationMap(); } if (pendingRequests.size() >= 1) { Map<String, Object> thisObjectPendingRequest = pendingRequests.get(0); Map<String, Object> whereMap = new HashMap<>(); if ((whereOperationMap != null && !whereOperationMap.isEmpty())) { whereMap.put("where", AVUtils.restfulServerData(whereOperationMap)); } if (fetchWhenSave || (option != null && option.fetchWhenSave)) { whereMap.put("fetchWhenSave", true); } if ("PUT".equals(thisObjectPendingRequest.get("method"))) { thisObjectPendingRequest.put("params", whereMap); } } }
private void buildMatchQueryParams(AVSaveOption option, LinkedList<Map<String, Object>> pendingRequests) { Map<String, Object> whereOperationMap = null; if (option != null && option.matchQuery != null) { whereOperationMap = option.matchQuery.conditions.compileWhereOperationMap(); } if (pendingRequests.size() >= 1) { Map<String, Object> thisObjectPendingRequest = pendingRequests.get(0); Map<String, Object> whereMap = new HashMap<String, Object>(); if ((whereOperationMap != null && !whereOperationMap.isEmpty())) { whereMap.put("where", AVUtils.restfulServerData(whereOperationMap)); } if (fetchWhenSave || (option != null && option.fetchWhenSave)) { whereMap.put("fetchWhenSave", true); } if ("PUT".equals(thisObjectPendingRequest.get("method"))) { thisObjectPendingRequest.put("params", whereMap); } } }
public void addAndItems(QueryConditions conditions) { Map<String, Object> queryOperationMap = conditions.compileWhereOperationMap(); QueryOperation op = new QueryOperation("$and", "$and", queryOperationMap); List<QueryOperation> ops = where.get(QueryOperation.AND_OP); if (ops == null) { ops = new LinkedList<QueryOperation>(); where.put(QueryOperation.AND_OP, ops); } Iterator<QueryOperation> it = ops.iterator(); while (it.hasNext()) { QueryOperation o = it.next(); if (o.equals(op)) { it.remove(); } } ops.add(op); }
public void addAndItems(QueryConditions conditions) { Map<String, Object> queryOperationMap = conditions .compileWhereOperationMap(); QueryOperation op = new QueryOperation("$and", "$and", queryOperationMap); List<QueryOperation> ops = where.get(QueryOperation.AND_OP); if (ops == null) { ops = new LinkedList<QueryOperation>(); where.put(QueryOperation.AND_OP, ops); } Iterator<QueryOperation> it = ops.iterator(); while (it.hasNext()) { QueryOperation o = it.next(); if (o.equals(op)) { it.remove(); } } ops.add(op); }
/** * Add a constraint to the query that requires a particular key's value does not match another * AVQuery. This only works on keys whose values are AVObjects or lists of AVObjects. * * @param key The key to check. * @param query The query that the value should not match * @return Returns the query so you can chain this call. */ public AVQuery<T> whereDoesNotMatchQuery(String key, AVQuery<?> query) { Map<String, Object> map = AVUtils.createMap("className", query.className); map.put("where", query.conditions.compileWhereOperationMap()); addWhereItem(key, "$notInQuery", map); return this; }
/** * Add a constraint to the query that requires a particular key's value does not match another * AVQuery. This only works on keys whose values are AVObjects or lists of AVObjects. * * @param key The key to check. * @param query The query that the value should not match * @return Returns the query so you can chain this call. */ public AVQuery<T> whereDoesNotMatchQuery(String key, AVQuery<?> query) { Map<String, Object> map = AVUtils.createMap("className", query.className); map.put("where", query.conditions.compileWhereOperationMap()); addWhereItem(key, "$notInQuery", map); return this; }
public Map<String, String> assembleParameters() { if (where.keySet().size() > 0) { parameters.put("where", AVUtils.restfulServerData(compileWhereOperationMap())); } if (limit > 0) { parameters.put("limit", Integer.toString(limit)); } if (skip >= 0) { parameters.put("skip", Integer.toString(skip)); } if (!AVUtils.isBlankString(order)) { parameters.put("order", order); } if (!AVUtils.isEmptyList(include)) { String value = AVUtils.joinCollection(include, ","); parameters.put("include", value); } if (selectedKeys != null && selectedKeys.size() > 0) { String keys = AVUtils.joinCollection(selectedKeys, ","); parameters.put("keys", keys); } return parameters; }
public Map<String, String> assembleParameters() { if (where.keySet().size() > 0) { parameters.put("where", AVUtils.restfulServerData(compileWhereOperationMap())); } if (limit > 0) { parameters.put("limit", Integer.toString(limit)); } if (skip >= 0) { parameters.put("skip", Integer.toString(skip)); } if (!AVUtils.isBlankString(order)) { parameters.put("order", order); } if (!AVUtils.isEmptyList(include)) { String value = AVUtils.joinCollection(include, ","); parameters.put("include", value); } if (selectedKeys != null && selectedKeys.size() > 0) { String keys = AVUtils.joinCollection(selectedKeys, ","); parameters.put("keys", keys); } return parameters; }
/** * Add a constraint to the query that requires a particular key's value does not match any value * for a key in the results of another AVQuery. * * @param key The key whose value is being checked and excluded * @param keyInQuery The key in the objects from the sub query to look in * @param query The sub query to run * @return Returns the query so you can chain this call. */ public AVQuery<T> whereDoesNotMatchKeyInQuery(String key, String keyInQuery, AVQuery<?> query) { Map<String, Object> map = AVUtils.createMap("className", query.className); map.put("where", query.conditions.compileWhereOperationMap()); Map<String, Object> queryMap = AVUtils.createMap("query", map); queryMap.put("key", keyInQuery); addWhereItem(key, "$dontSelect", queryMap); return this; }
/** * Add a constraint to the query that requires a particular key's value does not match any value * for a key in the results of another AVQuery. * * @param key The key whose value is being checked and excluded * @param keyInQuery The key in the objects from the sub query to look in * @param query The sub query to run * @return Returns the query so you can chain this call. */ public AVQuery<T> whereDoesNotMatchKeyInQuery(String key, String keyInQuery, AVQuery<?> query) { Map<String, Object> map = AVUtils.createMap("className", query.className); map.put("where", query.conditions.compileWhereOperationMap()); Map<String, Object> queryMap = AVUtils.createMap("query", map); queryMap.put("key", keyInQuery); addWhereItem(key, "$dontSelect", queryMap); return this; }
/** * Add a constraint to the query that requires a particular key's value matches a value for a key * in the results of another AVQuery * * @param key The key whose value is being checked * @param keyInQuery The key in the objects from the sub query to look in * @param query The sub query to run * @return Returns the query so you can chain this call. */ public AVQuery<T> whereMatchesKeyInQuery(String key, String keyInQuery, AVQuery<?> query) { Map<String, Object> inner = new HashMap<String, Object>(); inner.put("className", query.getClassName()); inner.put("where", query.conditions.compileWhereOperationMap()); if (query.conditions.getSkip() > 0) inner.put("skip", query.conditions.getSkip()); if (query.conditions.getLimit() > 0) inner.put("limit", query.conditions.getLimit()); if (!AVUtils.isBlankContent(query.getOrder())) inner.put("order", query.getOrder()); Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("query", inner); queryMap.put("key", keyInQuery); return addWhereItem(key, "$select", queryMap); }
/** * Add a constraint to the query that requires a particular key's value matches a value for a key * in the results of another AVQuery * * @param key The key whose value is being checked * @param keyInQuery The key in the objects from the sub query to look in * @param query The sub query to run * @return Returns the query so you can chain this call. */ public AVQuery<T> whereMatchesKeyInQuery(String key, String keyInQuery, AVQuery<?> query) { Map<String, Object> inner = new HashMap<String, Object>(); inner.put("className", query.getClassName()); inner.put("where", query.conditions.compileWhereOperationMap()); if (query.conditions.getSkip() > 0) inner.put("skip", query.conditions.getSkip()); if (query.conditions.getLimit() > 0) inner.put("limit", query.conditions.getLimit()); if (!AVUtils.isBlankContent(query.getOrder())) inner.put("order", query.getOrder()); Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("query", inner); queryMap.put("key", keyInQuery); return addWhereItem(key, "$select", queryMap); }
/** * Constructs a query that is the or of the given queries. * * @param queries The list of AVQueries to 'or' together * @return A AVQuery that is the 'or' of the passed in queries */ public static <T extends AVObject> AVQuery<T> or(List<AVQuery<T>> queries) { String className = null; if (queries.size() > 0) { className = queries.get(0).getClassName(); } AVQuery<T> result = new AVQuery<T>(className); if (queries.size() > 1) { for (AVQuery<T> query : queries) { if (!className.equals(query.getClassName())) { throw new IllegalArgumentException("All queries must be for the same class"); } result.addOrItems(new QueryOperation("$or", "$or", query.conditions .compileWhereOperationMap())); } } else { result.setWhere(queries.get(0).conditions.getWhere()); } return result; }
/** * Constructs a query that is the or of the given queries. * * @param queries The list of AVQueries to 'or' together * @return A AVQuery that is the 'or' of the passed in queries */ public static <T extends AVObject> AVQuery<T> or(List<AVQuery<T>> queries) { String className = null; if (queries.size() > 0) { className = queries.get(0).getClassName(); } AVQuery<T> result = new AVQuery<T>(className); if (queries.size() > 1) { for (AVQuery<T> query : queries) { if (!className.equals(query.getClassName())) { throw new IllegalArgumentException("All queries must be for the same class"); } result.addOrItems(new QueryOperation("$or", "$or", query.conditions .compileWhereOperationMap())); } } else { result.setWhere(queries.get(0).conditions.getWhere()); } return result; }
/** * Add a constraint to the query that requires a particular key's value match another AVQuery. * This only works on keys whose values are AVObjects or lists of AVObjects. * * @param key The key to check. * @param query The query that the value should match * @return Returns the query so you can chain this call. */ public AVQuery<T> whereMatchesQuery(String key, AVQuery<?> query) { Map<String, Object> map = AVUtils.createMap("where", query.conditions.compileWhereOperationMap()); map.put("className", query.className); if (query.conditions.getSkip() > 0) map.put("skip", query.conditions.getSkip()); if (query.conditions.getLimit() > 0) map.put("limit", query.conditions.getLimit()); if (!AVUtils.isBlankContent(query.getOrder())) map.put("order", query.getOrder()); addWhereItem(key, "$inQuery", map); return this; }
/** * Add a constraint to the query that requires a particular key's value match another AVQuery. * This only works on keys whose values are AVObjects or lists of AVObjects. * * @param key The key to check. * @param query The query that the value should match * @return Returns the query so you can chain this call. */ public AVQuery<T> whereMatchesQuery(String key, AVQuery<?> query) { Map<String, Object> map = AVUtils.createMap("where", query.conditions.compileWhereOperationMap()); map.put("className", query.className); if (query.conditions.getSkip() > 0) map.put("skip", query.conditions.getSkip()); if (query.conditions.getLimit() > 0) map.put("limit", query.conditions.getLimit()); if (!AVUtils.isBlankContent(query.getOrder())) map.put("order", query.getOrder()); addWhereItem(key, "$inQuery", map); return this; }
whereOperationMap = option.matchQuery.conditions.compileWhereOperationMap(); Map<String, Object> whereMap = new HashMap<>(); if ((whereOperationMap != null && !whereOperationMap.isEmpty())) {
whereOperationMap = option.matchQuery.conditions.compileWhereOperationMap(); Map<String, Object> whereMap = new HashMap<String, Object>(); if ((whereOperationMap != null && !whereOperationMap.isEmpty())) {