Search in sources :

Example 46 with Post

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

the class TagService method addTag.

@Override
public Tag addTag(Tag tag) {
    if (tag.created == null) {
        tag.created = new Date();
    }
    tag.name = tag.name.toLowerCase();
    tag.slug = PostHelper.slugify(tag.name);
    if (tag.posts != null) {
        for (Post post : tag.posts) {
            if (tag.postKeys == null) {
                tag.postKeys = new ArrayList<Key<Post>>();
            }
            tag.postKeys.add(Key.create(post));
        }
    }
    Key<Tag> key = provide().save().entity(tag).now();
    tag.id = keyToId(key);
    return tag;
}
Also used : Post(com.willshex.blogwt.shared.api.datatype.Post) Tag(com.willshex.blogwt.shared.api.datatype.Tag) Date(java.util.Date) Key(com.googlecode.objectify.Key)

Example 47 with Post

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

the class CreatePostResponse method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("post")) {
        JsonElement jsonPost = jsonObject.get("post");
        if (jsonPost != null) {
            post = new Post();
            post.fromJson(jsonPost.getAsJsonObject());
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Post(com.willshex.blogwt.shared.api.datatype.Post)

Example 48 with Post

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

the class DeletePostRequest method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("post")) {
        JsonElement jsonPost = jsonObject.get("post");
        if (jsonPost != null) {
            post = new Post();
            post.fromJson(jsonPost.getAsJsonObject());
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Post(com.willshex.blogwt.shared.api.datatype.Post)

Example 49 with Post

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

the class GetPostRequest method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("post")) {
        JsonElement jsonPost = jsonObject.get("post");
        if (jsonPost != null) {
            post = new Post();
            post.fromJson(jsonPost.getAsJsonObject());
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Post(com.willshex.blogwt.shared.api.datatype.Post)

Example 50 with Post

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

the class GetPostsResponse method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("posts")) {
        JsonElement jsonPosts = jsonObject.get("posts");
        if (jsonPosts != null) {
            posts = new ArrayList<Post>();
            Post item = null;
            for (int i = 0; i < jsonPosts.getAsJsonArray().size(); i++) {
                if (jsonPosts.getAsJsonArray().get(i) != null) {
                    (item = new Post()).fromJson(jsonPosts.getAsJsonArray().get(i).getAsJsonObject());
                    posts.add(item);
                }
            }
        }
    }
    if (jsonObject.has("pager")) {
        JsonElement jsonPager = jsonObject.get("pager");
        if (jsonPager != null) {
            pager = new Pager();
            pager.fromJson(jsonPager.getAsJsonObject());
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Post(com.willshex.blogwt.shared.api.datatype.Post) Pager(com.willshex.blogwt.shared.api.Pager)

Aggregations

Post (com.willshex.blogwt.shared.api.datatype.Post)52 JsonElement (com.google.gson.JsonElement)11 ArrayList (java.util.ArrayList)11 Pager (com.willshex.blogwt.shared.api.Pager)10 Key (com.googlecode.objectify.Key)8 Page (com.willshex.blogwt.shared.api.datatype.Page)7 Date (java.util.Date)6 InputValidationException (com.willshex.gson.web.service.server.InputValidationException)5 HashMap (java.util.HashMap)5 Tag (com.willshex.blogwt.shared.api.datatype.Tag)4 User (com.willshex.blogwt.shared.api.datatype.User)4 ArchiveEntry (com.willshex.blogwt.shared.api.datatype.ArchiveEntry)3 PostContent (com.willshex.blogwt.shared.api.datatype.PostContent)3 ScoredDocument (com.google.appengine.api.search.ScoredDocument)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)2 EditPageWizardPage (com.willshex.blogwt.client.wizard.page.EditPageWizardPage)2 SelectPostWizardPage (com.willshex.blogwt.client.wizard.page.SelectPostWizardPage)2 GetPostRequest (com.willshex.blogwt.shared.api.blog.call.GetPostRequest)2 MarkdownProcessor (org.markdown4j.server.MarkdownProcessor)2 Document (com.google.appengine.api.search.Document)1