Package org.b3log.latke.repository

Examples of org.b3log.latke.repository.Query


            final String country = Locales.getCountry(localeString).toLowerCase();
            final String language = Locales.getLanguage(localeString).toLowerCase();
            channel.setLanguage(language + '-' + country);
            channel.setDescription(blogSubtitle);

            final Query query = new Query().setCurrentPageNum(1).
                    setPageSize(ENTRY_OUTPUT_CNT).
                    addFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true).
                    addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).
                    setPageCount(1);
View Full Code Here


            final JSONObject statistic = statisticRepository.get(Statistic.STATISTIC);
            final int publishedArticleCnt = statistic.getInt(Statistic.STATISTIC_PUBLISHED_ARTICLE_COUNT);
            final int pageCount = (int) Math.ceil((double) publishedArticleCnt / (double) pageSize);

            final Query query = new Query().setCurrentPageNum(currentPageNum).setPageSize(pageSize).setPageCount(pageCount).
                    addFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, PUBLISHED).
                    addSort(Article.ARTICLE_PUT_TOP, SortDirection.DESCENDING).
                    index(Article.ARTICLE_PERMALINK);

            if (preference.getBoolean(Preference.ENABLE_ARTICLE_UPDATE_HINT)) {
                query.addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING);
            } else {
                query.addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING);
            }

            final JSONObject result = articleRepository.get(query);
            final List<Integer> pageNums = Paginator.paginate(currentPageNum, pageSize, pageCount, windowSize);
            if (0 != pageNums.size()) {
View Full Code Here

    public void fillLinks(final Map<String, Object> dataModel) throws ServiceException {
        Stopwatchs.start("Fill Links");
        try {
            final Map<String, SortDirection> sorts = new HashMap<String, SortDirection>();
            sorts.put(Link.LINK_ORDER, SortDirection.ASCENDING);
            final Query query = new Query().addSort(Link.LINK_ORDER, SortDirection.ASCENDING).setPageCount(1);
            final JSONObject linkResult = linkRepository.get(query);
            final List<JSONObject> links = org.b3log.latke.util.CollectionUtils.jsonArrayToList(linkResult.getJSONArray(Keys.RESULTS));

            dataModel.put(Link.LINKS, links);
        } catch (final JSONException e) {
View Full Code Here

            dataModel.put(Common.YEAR, String.valueOf(Calendar.getInstance().get(Calendar.YEAR)));

            final String noticeBoard = preference.getString(Preference.NOTICE_BOARD);
            dataModel.put(Preference.NOTICE_BOARD, noticeBoard);

            final Query query = new Query().setPageCount(1);
            final JSONObject result = userRepository.get(query);
            final JSONArray users = result.getJSONArray(Keys.RESULTS);
            final List<JSONObject> userList = CollectionUtils.jsonArrayToList(users);
            dataModel.put(User.USERS, userList);
            for (final JSONObject user : userList) {
View Full Code Here

     */
    @Test(dependsOnMethods = {"add", "getMostViewCountArticles"})
    public void isPublished() throws Exception {
        final ArticleRepository articleRepository = getArticleRepository();

        final JSONArray all = articleRepository.get(new Query()).getJSONArray(Keys.RESULTS);
        Assert.assertNotNull(all);

        final JSONObject article = all.getJSONObject(0);
        Assert.assertTrue(articleRepository.isPublished(article.getString(Keys.OBJECT_ID)));

View Full Code Here

        Assert.assertNotNull(admin);
        Assert.assertEquals("test", admin.optString(User.USER_NAME));

        final JSONObject result =
                userRepository.get(new Query().addFilter(User.USER_NAME,
                                                         FilterOperator.EQUAL,
                                                         "test1"));

        final JSONArray users = result.getJSONArray(Keys.RESULTS);
        Assert.assertEquals(users.length(), 1);
View Full Code Here

     */
    private void addArticles(final Sitemap sitemap, final JSONObject preference) throws Exception {
        final String host = preference.getString(Preference.BLOG_HOST);

        // XXX: query all articles?
        final Query query = new Query().setCurrentPageNum(1).
                addFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true).
                addSort(Article.ARTICLE_CREATE_DATE, SortDirection.DESCENDING);

        // Closes cache avoid Java heap space out of memory while caching
        // query results
View Full Code Here

     * @throws Exception exception
     */
    private void addPages(final Sitemap sitemap, final JSONObject preference) throws Exception {
        final String host = preference.getString(Preference.BLOG_HOST);

        final JSONObject result = pageRepository.get(new Query());
        final JSONArray pages = result.getJSONArray(Keys.RESULTS);
        for (int i = 0; i < pages.length(); i++) {
            final JSONObject page = pages.getJSONObject(i);
            final String permalink = page.getString(Page.PAGE_PERMALINK);

View Full Code Here

     * @throws Exception exception
     */
    private void addTags(final Sitemap sitemap, final JSONObject preference) throws Exception {
        final String host = preference.getString(Preference.BLOG_HOST);

        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");

View Full Code Here

     * @throws Exception exception
     */
    private void addArchives(final Sitemap sitemap, final JSONObject preference) throws Exception {
        final String host = preference.getString(Preference.BLOG_HOST);

        final JSONObject result = archiveDateRepository.get(new Query());
        final JSONArray archiveDates = result.getJSONArray(Keys.RESULTS);
        for (int i = 0; i < archiveDates.length(); i++) {
            final JSONObject archiveDate = archiveDates.getJSONObject(i);
            final long time = archiveDate.getLong(ArchiveDate.ARCHIVE_TIME);
            final String dateString = ArchiveDate.DATE_FORMAT.format(time);
View Full Code Here

TOP

Related Classes of org.b3log.latke.repository.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.