Package org.json

Examples of org.json.JSONObject.optInt()


            if (article.getBoolean(Article.ARTICLE_IS_PUBLISHED)) {
                statistics.decPublishedBlogArticleCount();
            }

            final JSONObject author = userRepository.getByEmail(article.optString(Article.ARTICLE_AUTHOR_EMAIL));
            author.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, author.optInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT) - 1);
            author.put(UserExt.USER_ARTICLE_COUNT, author.optInt(UserExt.USER_ARTICLE_COUNT) - 1);
            userRepository.update(author.optString(Keys.OBJECT_ID), author);

            transaction.commit();
        } catch (final Exception e) {
View Full Code Here


                statistics.decPublishedBlogArticleCount();
            }

            final JSONObject author = userRepository.getByEmail(article.optString(Article.ARTICLE_AUTHOR_EMAIL));
            author.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, author.optInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT) - 1);
            author.put(UserExt.USER_ARTICLE_COUNT, author.optInt(UserExt.USER_ARTICLE_COUNT) - 1);
            userRepository.update(author.optString(Keys.OBJECT_ID), author);

            transaction.commit();
        } catch (final Exception e) {
            if (transaction.isActive()) {
View Full Code Here

            final boolean postToCommunity = article.optBoolean(Common.POST_TO_COMMUNITY, true);

            article.remove(Common.POST_TO_COMMUNITY); // Do not persist this property
            // Setp 13: Update user article statistic
            final JSONObject author = userRepository.getByEmail(article.optString(Article.ARTICLE_AUTHOR_EMAIL));
            final int userArticleCnt = author.optInt(UserExt.USER_ARTICLE_COUNT);

            author.put(UserExt.USER_ARTICLE_COUNT, userArticleCnt + 1);
            if (article.optBoolean(Article.ARTICLE_IS_PUBLISHED)) {
                author.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, author.optInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT) + 1);
            }
View Full Code Here

            final JSONObject author = userRepository.getByEmail(article.optString(Article.ARTICLE_AUTHOR_EMAIL));
            final int userArticleCnt = author.optInt(UserExt.USER_ARTICLE_COUNT);

            author.put(UserExt.USER_ARTICLE_COUNT, userArticleCnt + 1);
            if (article.optBoolean(Article.ARTICLE_IS_PUBLISHED)) {
                author.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, author.optInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT) + 1);
            }
            userRepository.update(author.optString(Keys.OBJECT_ID), author);
            // Step 14: Set editor type
            if (!article.has(Article.ARTICLE_EDITOR_TYPE)) {
                article.put(Article.ARTICLE_EDITOR_TYPE, preference.optString(Preference.EDITOR_TYPE));
View Full Code Here

                statisticMgmtService.decPublishedBlogArticleCount();
            }

            final JSONObject author = userRepository.getByEmail(article.optString(Article.ARTICLE_AUTHOR_EMAIL));

            author.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, author.optInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT) - 1);
            author.put(UserExt.USER_ARTICLE_COUNT, author.optInt(UserExt.USER_ARTICLE_COUNT) - 1);
            userRepository.update(author.optString(Keys.OBJECT_ID), author);

            transaction.commit();
        } catch (final Exception e) {
View Full Code Here

            }

            final JSONObject author = userRepository.getByEmail(article.optString(Article.ARTICLE_AUTHOR_EMAIL));

            author.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, author.optInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT) - 1);
            author.put(UserExt.USER_ARTICLE_COUNT, author.optInt(UserExt.USER_ARTICLE_COUNT) - 1);
            userRepository.update(author.optString(Keys.OBJECT_ID), author);

            transaction.commit();
        } catch (final Exception e) {
            if (transaction.isActive()) {
View Full Code Here

            return null;
        }

        final Query query = new Query();

        query.setFilter(new PropertyFilter(Link.LINK_ORDER, FilterOperator.LESS_THAN, link.optInt(Link.LINK_ORDER))).addSort(Link.LINK_ORDER,
            SortDirection.DESCENDING);
        query.setCurrentPageNum(1);
        query.setPageSize(1);

        final JSONObject result = get(query);
View Full Code Here

            return null;
        }

        final Query query = new Query();

        query.setFilter(new PropertyFilter(Link.LINK_ORDER, FilterOperator.GREATER_THAN, link.optInt(Link.LINK_ORDER))).addSort(
            Link.LINK_ORDER, SortDirection.ASCENDING);
        query.setCurrentPageNum(1);
        query.setPageSize(1);

        final JSONObject result = get(query);
View Full Code Here

        final Iterator<JSONObject> iterator = archiveDates.iterator();

        while (iterator.hasNext()) {
            final JSONObject archiveDate = iterator.next();

            if (0 == archiveDate.optInt(ArchiveDate.ARCHIVE_DATE_PUBLISHED_ARTICLE_COUNT)) {
                iterator.remove();
            }
        }
    }
}
View Full Code Here

        if (null == link) {
            return null;
        }

        final Query query = new Query();
        query.addFilter(Link.LINK_ORDER, FilterOperator.LESS_THAN, link.optInt(Link.LINK_ORDER)).
                addSort(Link.LINK_ORDER, SortDirection.DESCENDING);
        query.setCurrentPageNum(1);
        query.setPageSize(1);

        final JSONObject result = get(query);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.