Search in sources :

Example 26 with Pager

use of com.willshex.blogwt.shared.api.Pager in project blogwt by billy1380.

the class PageService method indexAll.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.service.search.IIndex#indexAll() */
@Override
public void indexAll() {
    Pager pager = PagerHelper.createDefaultPager();
    List<Page> pages = null;
    do {
        pages = getPages(Boolean.FALSE, pager.start, pager.count, null, null);
        for (Page page : pages) {
            SearchHelper.queueToIndex(getName(), page.id);
        }
        PagerHelper.moveForward(pager);
    } while (pages != null && pages.size() >= pager.count.intValue());
}
Also used : Pager(com.willshex.blogwt.shared.api.Pager) Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 27 with Pager

use of com.willshex.blogwt.shared.api.Pager in project blogwt by billy1380.

the class PostService method indexAll.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.service.search.IIndex#indexAll() */
@Override
public void indexAll() {
    Pager pager = PagerHelper.createDefaultPager();
    List<Post> posts = null;
    do {
        posts = getPosts(Boolean.FALSE, Boolean.FALSE, pager.start, pager.count, null, null);
        for (Post post : posts) {
            SearchHelper.queueToIndex(getName(), post.id);
        }
        PagerHelper.moveForward(pager);
    } while (posts != null && posts.size() >= pager.count.intValue());
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) Pager(com.willshex.blogwt.shared.api.Pager)

Example 28 with Pager

use of com.willshex.blogwt.shared.api.Pager in project blogwt by billy1380.

the class PostService method clearLinks.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.service.post.IPostService#clearLinks() */
@Override
public void clearLinks() {
    Pager pager = PagerHelper.createDefaultPager();
    List<Post> posts = null;
    do {
        posts = getPosts(Boolean.FALSE, Boolean.FALSE, pager.start, pager.count, PostSortType.PostSortTypePublished, SortDirectionType.SortDirectionTypeDescending);
        if (posts != null) {
            for (Post post : posts) {
                post.nextSlug = null;
                post.previousSlug = null;
            }
            provide().save().entities(posts).now();
        }
        PagerHelper.moveForward(pager);
    } while (posts != null && posts.size() >= pager.count.intValue());
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) Pager(com.willshex.blogwt.shared.api.Pager)

Example 29 with Pager

use of com.willshex.blogwt.shared.api.Pager in project blogwt by billy1380.

the class TagService method generateTags.

/* (non-Javadoc)
	 * 
	 * @see com.willshex.blogwt.server.service.tag.ITagService#generateTags() */
@Override
public void generateTags() {
    Map<String, Tag> tagLookup = new HashMap<String, Tag>();
    List<Post> posts;
    Tag tag;
    Pager pager = PagerHelper.createDefaultPager();
    do {
        posts = PostServiceProvider.provide().getPosts(Boolean.FALSE, Boolean.FALSE, pager.start, pager.count, PostSortType.PostSortTypePublished, SortDirectionType.SortDirectionTypeDescending);
        if (posts != null) {
            PagerHelper.moveForward(pager);
            for (Post post : posts) {
                if (post.tags != null) {
                    for (String postTag : post.tags) {
                        tag = tagLookup.get(postTag.toLowerCase());
                        if (tag == null) {
                            tag = new Tag().name(postTag.toLowerCase()).posts(new ArrayList<Post>());
                            tagLookup.put(tag.name, tag);
                        }
                        tag.posts.add(post);
                    }
                }
            }
        }
    } while (posts != null && posts.size() >= pager.count.intValue());
    if (tagLookup.size() > 0) {
        addTagBatch(tagLookup.values());
    }
}
Also used : HashMap(java.util.HashMap) Post(com.willshex.blogwt.shared.api.datatype.Post) Pager(com.willshex.blogwt.shared.api.Pager) ArrayList(java.util.ArrayList) Tag(com.willshex.blogwt.shared.api.datatype.Tag)

Example 30 with Pager

use of com.willshex.blogwt.shared.api.Pager in project blogwt by billy1380.

the class GetPostsRequest method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("pager")) {
        JsonElement jsonPager = jsonObject.get("pager");
        if (jsonPager != null) {
            pager = new Pager();
            pager.fromJson(jsonPager.getAsJsonObject());
        }
    }
    if (jsonObject.has("includePostContents")) {
        JsonElement jsonIncludePostContents = jsonObject.get("includePostContents");
        if (jsonIncludePostContents != null) {
            includePostContents = Boolean.valueOf(jsonIncludePostContents.getAsBoolean());
        }
    }
    if (jsonObject.has("tag")) {
        JsonElement jsonTag = jsonObject.get("tag");
        if (jsonTag != null) {
            tag = jsonTag.getAsString();
        }
    }
    if (jsonObject.has("archiveEntry")) {
        JsonElement jsonArchiveEntry = jsonObject.get("archiveEntry");
        if (jsonArchiveEntry != null) {
            archiveEntry = new ArchiveEntry();
            archiveEntry.fromJson(jsonArchiveEntry.getAsJsonObject());
        }
    }
    if (jsonObject.has("query")) {
        JsonElement jsonQuery = jsonObject.get("query");
        if (jsonQuery != null) {
            query = jsonQuery.getAsString();
        }
    }
    if (jsonObject.has("showAll")) {
        JsonElement jsonShowAll = jsonObject.get("showAll");
        if (jsonShowAll != null) {
            showAll = Boolean.valueOf(jsonShowAll.getAsBoolean());
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Pager(com.willshex.blogwt.shared.api.Pager) ArchiveEntry(com.willshex.blogwt.shared.api.datatype.ArchiveEntry)

Aggregations

Pager (com.willshex.blogwt.shared.api.Pager)35 JsonElement (com.google.gson.JsonElement)26 Post (com.willshex.blogwt.shared.api.datatype.Post)10 User (com.willshex.blogwt.shared.api.datatype.User)6 Page (com.willshex.blogwt.shared.api.datatype.Page)3 ArrayList (java.util.ArrayList)3 ArchiveEntry (com.willshex.blogwt.shared.api.datatype.ArchiveEntry)2 HashMap (java.util.HashMap)2 SyndContent (com.rometools.rome.feed.synd.SyndContent)1 SyndContentImpl (com.rometools.rome.feed.synd.SyndContentImpl)1 SyndEntry (com.rometools.rome.feed.synd.SyndEntry)1 SyndEntryImpl (com.rometools.rome.feed.synd.SyndEntryImpl)1 SyndFeed (com.rometools.rome.feed.synd.SyndFeed)1 SyndFeedImpl (com.rometools.rome.feed.synd.SyndFeedImpl)1 GeneratedDownload (com.willshex.blogwt.shared.api.datatype.GeneratedDownload)1 MetaNotification (com.willshex.blogwt.shared.api.datatype.MetaNotification)1 Notification (com.willshex.blogwt.shared.api.datatype.Notification)1 NotificationSetting (com.willshex.blogwt.shared.api.datatype.NotificationSetting)1 Permission (com.willshex.blogwt.shared.api.datatype.Permission)1 Property (com.willshex.blogwt.shared.api.datatype.Property)1