use of com.willshex.blogwt.shared.api.datatype.PostContent in project blogwt by billy1380.
the class PostController method createPost.
public void createPost(String title, Boolean listed, Boolean commentsEnabled, String summary, String content, Boolean publish, String tags) {
BlogService blogService = ApiHelper.createBlogClient();
final CreatePostRequest input = SessionController.get().setSession(ApiHelper.setAccessCode(new CreatePostRequest())).post(new Post().title(title).summary(summary).content(new PostContent().body(content)).tags(TagHelper.convertToTagList(tags)).listed(listed).commentsEnabled(commentsEnabled)).publish(publish);
blogService.createPost(input, new AsyncCallback<CreatePostResponse>() {
@Override
public void onSuccess(CreatePostResponse output) {
if (output.status == StatusType.StatusTypeSuccess) {
}
DefaultEventBus.get().fireEventFromSource(new CreatePostSuccess(input, output), PostController.this);
}
@Override
public void onFailure(Throwable caught) {
DefaultEventBus.get().fireEventFromSource(new CreatePostFailure(input, caught), PostController.this);
}
});
}
use of com.willshex.blogwt.shared.api.datatype.PostContent in project blogwt by billy1380.
the class PostService method getUserViewablePosts.
/* (non-Javadoc)
*
* @see
* com.willshex.blogwt.server.service.post.IPostService#getUserViewablePosts
* (com.willshex.blogwt.shared.api.datatype.User, java.lang.Boolean,
* java.lang.Boolean, java.lang.Integer, java.lang.Integer,
* com.willshex.blogwt.shared.api.datatype.PostSortType,
* com.willshex.blogwt.shared.api.SortDirectionType) */
@Override
public List<Post> getUserViewablePosts(User user, Boolean showAll, Boolean includeContents, Integer start, Integer count, PostSortType sortBy, SortDirectionType sortDirection) {
Query<Post> query = load();
if (user != null && user.id != null) {
query = query.filter(PostSortType.PostSortTypeAuthor.toString() + "Key", user);
}
if (showAll == null || !showAll.booleanValue()) {
query = query.filter(PostSortType.PostSortTypeListed.toString(), Boolean.TRUE);
}
if (start != null) {
query = query.offset(start.intValue());
}
if (count != null) {
query = query.limit(count.intValue());
}
if (sortBy != null) {
String condition = sortBy.toString();
if (sortDirection != null) {
switch(sortDirection) {
case SortDirectionTypeDescending:
condition = "-" + condition;
break;
default:
break;
}
}
query = query.order(condition);
}
List<Post> posts = query.list();
if (Boolean.TRUE.equals(includeContents)) {
List<Long> postContentIds = new ArrayList<Long>();
for (Post post : posts) {
postContentIds.add(keyToId(post.contentKey));
}
Map<Long, PostContent> contents = loadContent().ids(postContentIds);
for (Post post : posts) {
post.content = contents.get(keyToId(post.contentKey));
}
}
return posts;
}
use of com.willshex.blogwt.shared.api.datatype.PostContent in project blogwt by billy1380.
the class PostService method getUserViewablePartialSlugPosts.
/* (non-Javadoc)
*
* @see com.willshex.blogwt.server.service.post.IPostService#
* getUserViewablePartialSlugPosts(java.lang.String,
* com.willshex.blogwt.shared.api.datatype.User, java.lang.Boolean,
* java.lang.Boolean, java.lang.Integer, java.lang.Integer,
* com.willshex.blogwt.shared.api.datatype.PostSortType,
* com.willshex.blogwt.shared.api.SortDirectionType) */
@Override
public List<Post> getUserViewablePartialSlugPosts(String partialSlug, User user, Boolean showAll, Boolean includeContents, Integer start, Integer count, PostSortType sortBy, SortDirectionType sortDirection) {
Query<Post> query = load();
if (user != null && user.id != null) {
query = query.filter(PostSortType.PostSortTypeAuthor.toString() + "Key", user);
}
if (showAll == null || !showAll.booleanValue()) {
query = query.filter(PostSortType.PostSortTypeListed.toString(), Boolean.TRUE);
}
if (start != null) {
query = query.offset(start.intValue());
}
if (count != null) {
query = query.limit(count.intValue());
}
if (sortBy != null) {
String condition = sortBy.toString();
if (sortDirection != null) {
switch(sortDirection) {
case SortDirectionTypeDescending:
condition = "-" + condition;
break;
default:
break;
}
}
query = query.order(condition);
}
if (partialSlug != null) {
query = SearchHelper.addStartsWith("slug", partialSlug.toLowerCase(), query);
}
List<Post> posts = query.list();
if (Boolean.TRUE.equals(includeContents)) {
List<Long> postContentIds = new ArrayList<Long>();
for (Post post : posts) {
postContentIds.add(keyToId(post.contentKey));
}
Map<Long, PostContent> contents = loadContent().ids(postContentIds);
for (Post post : posts) {
post.content = contents.get(keyToId(post.contentKey));
}
}
return posts;
}
Aggregations