Package org.b3log.latke.repository

Examples of org.b3log.latke.repository.Query


            final List<Filter> filters = new ArrayList<Filter>();

            filters.add(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true));
            filters.add(new PropertyFilter(Article.ARTICLE_VIEW_PWD, FilterOperator.EQUAL, ""));
            final Query query = new Query().setCurrentPageNum(1).setPageSize(outputCnt).setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)).addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).setPageCount(
                1);

            final boolean hasMultipleUsers = userQueryService.hasMultipleUsers();
            String authorName = "";
View Full Code Here


            final List<Filter> filters = new ArrayList<Filter>();

            filters.add(new PropertyFilter(Article.ARTICLE_IS_PUBLISHED, FilterOperator.EQUAL, true));
            filters.add(new PropertyFilter(Article.ARTICLE_VIEW_PWD, FilterOperator.EQUAL, ""));
            final Query query = new Query().setCurrentPageNum(1).setPageSize(outputCnt).setFilter(new CompositeFilter(CompositeFilterOperator.AND, filters)).addSort(Article.ARTICLE_UPDATE_DATE, SortDirection.DESCENDING).setPageCount(
                1);

            final JSONObject articleResult = articleRepository.get(query);
            final JSONArray articles = articleResult.getJSONArray(Keys.RESULTS);
View Full Code Here

        admin = userRepository.getAdmin();

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

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

        final JSONArray users = result.getJSONArray(Keys.RESULTS);
        Assert.assertEquals(users.length(), 1);
        Assert.assertEquals(users.getJSONObject(0).getString(User.USER_EMAIL), "test1@gmail.com");
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

            throws ServletException, IOException {
        if ("0.2.1".equals(SoloServletListener.VERSION)) {
            LOGGER.info("Checking for consistency....");
            final Transaction transaction = pageRepository.beginTransaction();
            try {
                final Query query = new Query();
                final JSONObject result = pageRepository.get(query);
                final JSONArray array = result.getJSONArray(Keys.RESULTS);

                for (int i = 0; i < array.length(); i++) {
                    final JSONObject page = array.getJSONObject(i);
View Full Code Here

            saveAdmin(currentUserName, currentUserEmail);

            Transaction transaction = articleRepository.beginTransaction();
            boolean isConsistent = true;
            try {
                final Query query = new Query();
                final JSONObject result = articleRepository.get(query);
                final JSONArray articles = result.getJSONArray(Keys.RESULTS);
                int cnt = 0;
                for (int i = 0; i < articles.length(); i++) {
                    final JSONObject article = articles.getJSONObject(i);
View Full Code Here

     * @throws ServletException upgrades fails
     */
    private void upgradeLinks() throws ServletException {
        Transaction transaction = null;
        try {
            final Query query = new Query();
            final JSONObject result = linkRepository.get(query);
            final JSONArray links = result.getJSONArray(Keys.RESULTS);
            for (int i = 0; i < links.length(); i++) {
                final JSONObject link = links.getJSONObject(i);
                if (!link.has(Link.LINK_ORDER)) {
View Full Code Here

     * @throws ServletException upgrades fails
     */
    private void upgradeArchiveDates() throws ServletException {
        final Transaction transaction = archiveDateRepository.beginTransaction();
        try {
            final Query query = new Query();
            final JSONObject result = archiveDateRepository.get(query);
            final JSONArray archiveDates = result.getJSONArray(Keys.RESULTS);
            for (int i = 0; i < archiveDates.length(); i++) {
                final JSONObject archiveDate = archiveDates.getJSONObject(i);
                if (!archiveDate.has(
View Full Code Here

     */
    private void saveAdmin(final String adminName, final String adminEmail)
            throws ServletException {
        final Transaction transaction = userRepository.beginTransaction();
        try {
            final Query query = new Query();
            query.addFilter(User.USER_ROLE,
                            FilterOperator.EQUAL, Role.ADMIN_ROLE);
            final JSONObject result = userRepository.get(query);
            final JSONArray users = result.getJSONArray(Keys.RESULTS);
            if (0 == users.length()) {
                final JSONObject admin = new JSONObject();
View Full Code Here

     * @throws ServletException upgrade fails
     */
    private void upgradeTags() throws ServletException {
        final Transaction transaction = tagRepository.beginTransaction();
        try {
            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);
                if (!tag.has(Tag.TAG_PUBLISHED_REFERENCE_COUNT)) {
                    tag.put(Tag.TAG_PUBLISHED_REFERENCE_COUNT,
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.