Search in sources :

Example 26 with Page

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

the class PageService method populatePostContents.

private void populatePostContents(List<Page> pages) {
    List<Post> posts = new ArrayList<Post>();
    for (Page page : pages) {
        posts.addAll(PersistenceHelper.batchLookup(PostServiceProvider.provide(), page.postKeys));
    }
    // FIXME: just load in one go (batcg)
    for (Post post : posts) {
        post.content = PostServiceProvider.provide().getPostContent(post);
    }
    Map<Long, Post> postLookup = new HashMap<Long, Post>();
    for (Post post : posts) {
        postLookup.put(post.id, post);
    }
    List<Post> pagePosts;
    for (Page page : pages) {
        pagePosts = new ArrayList<Post>();
        for (Key<Post> key : page.postKeys) {
            pagePosts.add(postLookup.get(keyToId(key)));
        }
        page.posts = pagePosts;
    }
}
Also used : HashMap(java.util.HashMap) Post(com.willshex.blogwt.shared.api.datatype.Post) ArrayList(java.util.ArrayList) Page(com.willshex.blogwt.shared.api.datatype.Page)

Example 27 with Page

use of com.willshex.blogwt.shared.api.datatype.Page 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 28 with Page

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

the class PageService method index.

/* (non-Javadoc)
	 * 
	 * @see
	 * com.willshex.blogwt.server.service.search.IIndex#index(java.lang.Long) */
@Override
public void index(Long id) {
    Page page = getPage(id);
    page.owner = UserServiceProvider.provide().getUser(keyToId(page.ownerKey));
    populatePostContents(Arrays.asList(page));
    SearchHelper.indexDocument(toDocument(page));
}
Also used : Page(com.willshex.blogwt.shared.api.datatype.Page)

Aggregations

Page (com.willshex.blogwt.shared.api.datatype.Page)28 JsonElement (com.google.gson.JsonElement)10 Post (com.willshex.blogwt.shared.api.datatype.Post)9 ArrayList (java.util.ArrayList)6 User (com.willshex.blogwt.shared.api.datatype.User)4 HashMap (java.util.HashMap)4 Pager (com.willshex.blogwt.shared.api.Pager)3 GetPageRequest (com.willshex.blogwt.shared.api.page.call.GetPageRequest)3 GWT (com.google.gwt.core.client.GWT)2 Element (com.google.gwt.dom.client.Element)2 Key (com.googlecode.objectify.Key)2 DefaultEventBus (com.willshex.blogwt.client.DefaultEventBus)2 GetPageEventHandler (com.willshex.blogwt.client.api.page.event.GetPageEventHandler)2 NavigationController (com.willshex.blogwt.client.controller.NavigationController)2 PageController (com.willshex.blogwt.client.controller.PageController)2 NavigationChangedEventHandler (com.willshex.blogwt.client.event.NavigationChangedEventHandler)2 PageTypeHelper (com.willshex.blogwt.client.helper.PageTypeHelper)2 WizardDialogPage (com.willshex.blogwt.client.page.wizard.WizardDialogPage)2 WizardPage (com.willshex.blogwt.client.wizard.WizardPage)2 InputValidationException (com.willshex.gson.web.service.server.InputValidationException)2