Package org.b3log.latke.repository

Examples of org.b3log.latke.repository.Query


     * }
     * </pre>, returns {@code null} if not found
     * @throws ServiceException service exception
     */
    public JSONObject getOptions(final String category) throws ServiceException {
        final Query query = new Query();

        query.setFilter(new PropertyFilter(Option.OPTION_CATEGORY, FilterOperator.EQUAL, category));

        try {
            final JSONObject result = optionRepository.get(query);
            final JSONArray options = result.getJSONArray(Keys.RESULTS);

View Full Code Here


     *
     * @return {@code true} if exists, {@code false} otherwise
     * @throws ServiceException service exception
     */
    public boolean hasMultipleUsers() throws ServiceException {
        final Query query = new Query().setPageCount(1);

        try {
            final JSONArray users = userRepository.get(query).getJSONArray(Keys.RESULTS);

            return 1 != users.length();
View Full Code Here

        final JSONObject ret = new JSONObject();

        final int currentPageNum = requestJSONObject.optInt(Pagination.PAGINATION_CURRENT_PAGE_NUM);
        final int pageSize = requestJSONObject.optInt(Pagination.PAGINATION_PAGE_SIZE);
        final int windowSize = requestJSONObject.optInt(Pagination.PAGINATION_WINDOW_SIZE);
        final Query query = new Query().setCurrentPageNum(currentPageNum).setPageSize(pageSize);

        JSONObject result = null;

        try {
            result = userRepository.get(query);
View Full Code Here

    public void refresh(final List<AbstractPlugin> plugins) throws Exception {
        if (!initService.isInited()) {
            return;
        }
       
        final JSONObject result = pluginRepository.get(new Query());
        final JSONArray pluginArray = result.getJSONArray(Keys.RESULTS);
        final List<JSONObject> persistedPlugins = CollectionUtils.jsonArrayToList(pluginArray);

        try {
            // Reads plugin status from datastore and clear plugin datastore
View Full Code Here

     *
     * @return {@code true} if exists, {@code false} otherwise
     * @throws ServiceException service exception
     */
    public boolean hasMultipleUsers() throws ServiceException {
        final Query query = new Query().setPageCount(1);

        try {
            final JSONArray users = userRepository.get(query).
                    getJSONArray(Keys.RESULTS);

View Full Code Here

     * @param email the specified email
     * @return {@code true} if it is, {@code false} otherwise
     */
    public boolean isSoloUser(final String email) {
        try {
            final Query query = new Query().setPageCount(1);
            final JSONObject result = userRepository.get(query);
            final JSONArray users = result.getJSONArray(Keys.RESULTS);

            return existEmail(email, users);
        } catch (final Exception e) {
View Full Code Here

     * @param plugins the specified plugins
     * @throws Exception exception
     */
    public static void refresh(final List<AbstractPlugin> plugins)
            throws Exception {
        final JSONObject result = PLUGIN_REPOS.get(new Query());
        final JSONArray pluginArray = result.getJSONArray(Keys.RESULTS);
        final List<JSONObject> persistedPlugins =
                CollectionUtils.jsonArrayToList(pluginArray);

        // Disables plugin repository cache to avoid remove all cache
View Full Code Here

            final int currentPageNum = requestJSONObject.getInt(Pagination.PAGINATION_CURRENT_PAGE_NUM);
            final int pageSize = requestJSONObject.getInt(Pagination.PAGINATION_PAGE_SIZE);
            final int windowSize = requestJSONObject.getInt(Pagination.PAGINATION_WINDOW_SIZE);
            final boolean articleIsPublished = requestJSONObject.optBoolean(ARTICLE_IS_PUBLISHED, true);

            final Query query = new Query().setCurrentPageNum(currentPageNum).
                    setPageSize(pageSize).
                    addSort(ARTICLE_PUT_TOP, SortDirection.DESCENDING).
                    addSort(ARTICLE_CREATE_DATE, SortDirection.DESCENDING).
                    addFilter(ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, articleIsPublished);

            int articleCount = statistics.getBlogArticleCount();
            if (!articleIsPublished) {
                articleCount -= statistics.getPublishedBlogArticleCount();
            }

            final int pageCount = (int) Math.ceil((double) articleCount / (double) pageSize);
            query.setPageCount(pageCount);

            final JSONObject result = articleRepository.get(query);

            final JSONObject pagination = new JSONObject();
            ret.put(Pagination.PAGINATION, pagination);
View Full Code Here

                articleIds.add(articleId);
            }

            final List<JSONObject> ret = new ArrayList<JSONObject>();

            final Query query = new Query().addFilter(Keys.OBJECT_ID, FilterOperator.IN, articleIds).
                    setPageCount(1).index(Article.ARTICLE_PERMALINK);
            result = articleRepository.get(query);
            final JSONArray articles = result.getJSONArray(Keys.RESULTS);
            for (int i = 0; i < articles.length(); i++) {
                final JSONObject article = articles.getJSONObject(i);
View Full Code Here

                articleIds.add(articleId);
            }

            final List<JSONObject> ret = new ArrayList<JSONObject>();

            final Query query = new Query().addFilter(Keys.OBJECT_ID, FilterOperator.IN, articleIds).
                    setPageCount(1).index(Article.ARTICLE_PERMALINK);
            result = articleRepository.get(query);
            final JSONArray articles = result.getJSONArray(Keys.RESULTS);
            for (int i = 0; i < articles.length(); i++) {
                final JSONObject article = articles.getJSONObject(i);
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.