Search in sources :

Example 21 with Pager

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

the class GetPermissionsRequest 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("query")) {
        JsonElement jsonQuery = jsonObject.get("query");
        if (jsonQuery != null) {
            query = jsonQuery.getAsString();
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) Pager(com.willshex.blogwt.shared.api.Pager)

Example 22 with Pager

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

the class GetPermissionsResponse method fromJson.

@Override
public void fromJson(JsonObject jsonObject) {
    super.fromJson(jsonObject);
    if (jsonObject.has("permissions")) {
        JsonElement jsonPermissions = jsonObject.get("permissions");
        if (jsonPermissions != null) {
            permissions = new ArrayList<Permission>();
            Permission item = null;
            for (int i = 0; i < jsonPermissions.getAsJsonArray().size(); i++) {
                if (jsonPermissions.getAsJsonArray().get(i) != null) {
                    (item = new Permission()).fromJson(jsonPermissions.getAsJsonArray().get(i).getAsJsonObject());
                    permissions.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) Pager(com.willshex.blogwt.shared.api.Pager) Permission(com.willshex.blogwt.shared.api.datatype.Permission)

Example 23 with Pager

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

the class GetRolesResponse method fromJson.

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

Example 24 with Pager

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

the class GetUsersRequest 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("query")) {
        JsonElement jsonQuery = jsonObject.get("query");
        if (jsonQuery != null) {
            query = jsonQuery.getAsString();
        }
    }
    if (jsonObject.has("user")) {
        JsonElement jsonUser = jsonObject.get("user");
        if (jsonUser != null) {
            user = new User();
            user.fromJson(jsonUser.getAsJsonObject());
        }
    }
    if (jsonObject.has("relationshipType")) {
        JsonElement jsonRelationshipType = jsonObject.get("relationshipType");
        if (jsonRelationshipType != null) {
            relationshipType = RelationshipTypeType.fromString(jsonRelationshipType.getAsString());
        }
    }
    if (jsonObject.has("userIsOther")) {
        JsonElement jsonUserIsOther = jsonObject.get("userIsOther");
        if (jsonUserIsOther != null) {
            userIsOther = Boolean.valueOf(jsonUserIsOther.getAsBoolean());
        }
    }
}
Also used : User(com.willshex.blogwt.shared.api.datatype.User) JsonElement(com.google.gson.JsonElement) Pager(com.willshex.blogwt.shared.api.Pager)

Example 25 with Pager

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

the class SiteMapServlet method printPosts.

private void printPosts(PrintWriter p, String url) {
    List<Post> posts;
    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) {
                p.println(String.format(LOC_FORMAT, url, "#" + PageType.PostDetailPageType.asTargetHistoryToken(post.slug)));
            }
        }
    } 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)

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