public static <T extends AVObject> AVQuery<T> and(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.addAndItems(query); } } else { result.setWhere(queries.get(0).conditions.getWhere()); } return result; }
public static <T extends AVObject> AVQuery<T> and(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.addAndItems(query); } } else { result.setWhere(queries.get(0).conditions.getWhere()); } return result; }
private String queryPath() { if (!AVUtils.isBlankString(externalQueryPath)) { return externalQueryPath; } return AVPowerfulUtils.getEndpoint(getClassName()); }
private String queryPath() { if (!AVUtils.isBlankString(externalQueryPath)) { return externalQueryPath; } return AVPowerfulUtils.getEndpoint(getClassName()); }
/** * 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; }
@SuppressWarnings("unchecked") protected List<T> processResults(String content) throws Exception { if (AVUtils.isBlankContent(content)) { return Collections.emptyList(); } AVResponse resp = new AVResponse(); resp = JSON.parseObject(content, resp.getClass()); List<T> result = new LinkedList<T>(); for (Map item : resp.results) { if (item != null && !item.isEmpty()) { AVObject object; if (clazz != null) { object = clazz.newInstance(); } else { object = AVUtils.newAVObjectByClassName(resp.className, this.getClassName()); } AVUtils.copyPropertiesFromMapToAVObject(item, object); object.rebuildInstanceData(); result.add((T) object); } } return result; }
@SuppressWarnings("unchecked") protected List<T> processResults(String content) throws Exception { if (AVUtils.isBlankContent(content)) { return Collections.emptyList(); } AVResponse resp = new AVResponse(); resp = JSON.parseObject(content, resp.getClass()); List<T> result = new LinkedList<T>(); for (Map item : resp.results) { if (item != null && !item.isEmpty()) { AVObject object; if (clazz != null) { object = clazz.newInstance(); } else { object = AVUtils.newAVObjectByClassName(resp.className, this.getClassName()); } AVUtils.copyPropertiesFromMapToAVObject(item, object); object.rebuildInstanceData(); result.add((T) object); } } return result; }
/** * 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); }
private void sendInBackground(boolean sync, final SaveCallback callback) { if (!checkCurrentUser(callback)) { return; } if (query == null) { AVStatus.sendStatusToFollowersInBackgroud(sync, this, callback); return; } Map<String, Object> queryBody = new HashMap<String, Object>(); Map<String, Object> parameters = myQueryParameters(query); queryBody.putAll(parameters); queryBody.put("className", query.getClassName()); // 之前好像直接设成Timeline,而inboxType会永远被忽略掉。 Map<String, Object> body = statusBody(this, AVUtils.isBlankString(this.inboxType) ? INBOX_TYPE.TIMELINE.toString() : this.inboxType, queryBody); postStatusImpl(this, body, callback, sync); }
public void sendInBackground(final SaveCallback callback) { if (!checkCurrentUser(callback)) { return; } if (query == null) { AVStatus.sendStatusToFollowersInBackgroud(this, callback); return; } Map<String, Object> queryBody = new HashMap<String, Object>(); Map<String, Object> parameters = myQueryParameters(query); queryBody.putAll(parameters); queryBody.put("className", query.getClassName()); // 之前好像直接设成Timeline,而inboxType会永远被忽略掉。 Map<String, Object> body = statusBody(this, AVUtils.isBlankString(this.inboxType) ? INBOX_TYPE.TIMELINE.toString() : this.inboxType, queryBody); postStatusImpl(this, body, callback); }
/** * A helper method to concisely send a push to a query. This method is equivalent to * * <pre> * AVPush push = new AVPush(); * push.setData(data); * push.setQuery(query); * push.sendInBackground(); * </pre> * * @param data The entire data of the push message. See the push guide for more details on the * data format. * @param query A AVInstallation query which specifies the recipients of a push. * @throws AVException if query is not valid */ static void sendDataInBackground(JSONObject data, AVQuery<? extends AVObject> query) throws AVException { if (!query.getClassName().equals(INSTALLATIONTAG)) { throw new AVException(AVException.OTHER_CAUSE, "only installation query is valid"); } AVPush push = new AVPush(); push.setData(data); push.setQuery(query); push.sendInBackground(); }
params.put("className", query.getClassName());
/** * A helper method to concisely send a push message to a query. This method is equivalent to * * <pre> * AVPush push = new AVPush(); * push.setMessage(message); * push.setQuery(query); * push.sendInBackground(); * </pre> * * @param message The message that will be shown in the notification. * @param query A AVInstallation query which specifies the recipients of a push. */ public static void sendMessageInBackground(String message, AVQuery<? extends AVObject> query) { if (!query.getClassName().equals(INSTALLATIONTAG)) { InternalConfigurationController.globalInstance().getInternalLogger() .e(AVPush.class.getSimpleName(), "only installation query is valid"); return; } AVPush push = new AVPush(); push.setMessage(message); push.setQuery(query); push.sendInBackground(false, null); }
/** * A helper method to concisely send a push message to a query. This method is equivalent to * * <pre> * AVPush push = new AVPush(); * push.setMessage(message); * push.setQuery(query); * push.sendInBackground(callback); * </pre> * * @param message The message that will be shown in the notification. * @param query A AVInstallation query which specifies the recipients of a push. * @param callback callback.done(e) is called when the send completes. */ public static void sendMessageInBackground(String message, AVQuery<? extends AVObject> query, SendCallback callback) { if (!query.getClassName().equals(INSTALLATIONTAG)) { if (callback != null) { callback.done(new AVException(AVException.OTHER_CAUSE, "only installation query is valid")); } } AVPush push = new AVPush(); push.setMessage(message); push.setQuery(query); push.sendInBackground(false, callback); }
/** * A helper method to concisely send a push to a query. This method is equivalent to * * <pre> * AVPush push = new AVPush(); * push.setData(data); * push.setQuery(query); * push.sendInBackground(callback); * </pre> * * @param data The entire data of the push message. See the push guide for more details on the * data format. * @param query A AVInstallation query which specifies the recipients of a push. * @param callback callback.done(e) is called when the send completes. */ public static void sendDataInBackground(JSONObject data, AVQuery<? extends AVObject> query, SendCallback callback) { if (!query.getClassName().equals(INSTALLATIONTAG)) { if (callback != null) { callback.done(new AVException(AVException.OTHER_CAUSE, "only installation query is valid")); } } AVPush push = new AVPush(); push.setData(data); push.setQuery(query); push.sendInBackground(false, callback); }
Map<String, String> params = null; if (option != null && option.matchQuery != null) { if (this.getClassName() != null && !this.getClassName().equals(option.matchQuery.getClassName())) { callback.internalDone(new AVException(0, "AVObject class inconsistant with AVQuery in AVDeleteOption")); return;
object = (T) AVUtils.newAVObjectByClassName(AVQuery.this.getClassName());
(T) AVUtils.newAVObjectByClassName(AVQuery.this.getClassName());