use of org.b3log.latke.repository.Query in project solo by b3log.
the class SitemapProcessor method addTags.
/**
* Adds tags (tag-articles) and tags wall (/tags.html) into the specified sitemap.
*
* @param sitemap the specified sitemap
* @throws Exception exception
*/
private void addTags(final Sitemap sitemap) throws Exception {
final JSONObject result = tagRepository.get(new Query());
final JSONArray tags = result.getJSONArray(Keys.RESULTS);
for (int i = 0; i < tags.length(); i++) {
final JSONObject tag = tags.getJSONObject(i);
final String link = URLEncoder.encode(tag.getString(Tag.TAG_TITLE), "UTF-8");
final URL url = new URL();
url.setLoc(Latkes.getServePath() + "/tags/" + link);
sitemap.addURL(url);
}
// Tags wall
final URL url = new URL();
url.setLoc(Latkes.getServePath() + "/tags.html");
sitemap.addURL(url);
}
use of org.b3log.latke.repository.Query in project solo by b3log.
the class ArchiveDateRepositoryImpl method getArchiveDates.
@Override
public List<JSONObject> getArchiveDates() throws RepositoryException {
final org.b3log.latke.repository.Query query = new Query().addSort(ArchiveDate.ARCHIVE_TIME, SortDirection.DESCENDING).setPageCount(1);
final JSONObject result = get(query);
final JSONArray archiveDates = result.optJSONArray(Keys.RESULTS);
final List<JSONObject> ret = CollectionUtils.jsonArrayToList(archiveDates);
removeForUnpublishedArticles(ret);
return ret;
}
use of org.b3log.latke.repository.Query in project solo by b3log.
the class ArticleRepositoryImpl method getMostCommentArticles.
@Override
public List<JSONObject> getMostCommentArticles(final int num) throws RepositoryException {
final Query query = new Query().addSort(Article.ARTICLE_COMMENT_COUNT, SortDirection.DESCENDING).addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).setFilter(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true)).setCurrentPageNum(1).setPageSize(num).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 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);
}
Aggregations