use of org.b3log.latke.repository.Query in project solo by b3log.
the class PageRepositoryImpl method getUnder.
@Override
public JSONObject getUnder(final String id) throws RepositoryException {
final JSONObject page = get(id);
if (null == page) {
return null;
}
final Query query = new Query().setFilter(new PropertyFilter(Page.PAGE_ORDER, FilterOperator.GREATER_THAN, page.optInt(Page.PAGE_ORDER))).addSort(Page.PAGE_ORDER, SortDirection.ASCENDING).setCurrentPageNum(1).setPageSize(1).setPageCount(1);
final JSONObject result = get(query);
final JSONArray array = result.optJSONArray(Keys.RESULTS);
if (1 != array.length()) {
return null;
}
return array.optJSONObject(0);
}
use of org.b3log.latke.repository.Query in project solo by b3log.
the class PageRepositoryImpl method getByOrder.
@Override
public JSONObject getByOrder(final int order) throws RepositoryException {
final Query query = new Query().setFilter(new PropertyFilter(Page.PAGE_ORDER, FilterOperator.EQUAL, order)).setPageCount(1);
final JSONObject result = get(query);
final JSONArray array = result.optJSONArray(Keys.RESULTS);
if (0 == array.length()) {
return null;
}
return array.optJSONObject(0);
}
use of org.b3log.latke.repository.Query in project solo by b3log.
the class TagArticleRepositoryImpl method getByArticleId.
@Override
public List<JSONObject> getByArticleId(final String articleId) throws RepositoryException {
final Query query = new Query().setFilter(new PropertyFilter(Article.ARTICLE + "_" + Keys.OBJECT_ID, FilterOperator.EQUAL, articleId)).setPageCount(1);
final JSONObject result = get(query);
final JSONArray array = result.optJSONArray(Keys.RESULTS);
return CollectionUtils.jsonArrayToList(array);
}
use of org.b3log.latke.repository.Query in project solo by b3log.
the class TagRepositoryImpl method getByTitle.
@Override
public JSONObject getByTitle(final String tagTitle) throws RepositoryException {
final Query query = new Query().setFilter(new PropertyFilter(Tag.TAG_TITLE, FilterOperator.EQUAL, tagTitle)).setPageCount(1);
final JSONObject result = get(query);
final JSONArray array = result.optJSONArray(Keys.RESULTS);
if (0 == array.length()) {
return null;
}
return array.optJSONObject(0);
}
use of org.b3log.latke.repository.Query in project solo by b3log.
the class UserRepositoryImpl method getAdmin.
@Override
public JSONObject getAdmin() throws RepositoryException {
final Query query = new Query().setFilter(new PropertyFilter(User.USER_ROLE, FilterOperator.EQUAL, Role.ADMIN_ROLE)).setPageCount(1);
final JSONObject result = get(query);
final JSONArray array = result.optJSONArray(Keys.RESULTS);
if (0 == array.length()) {
return null;
}
return array.optJSONObject(0);
}
Aggregations