Java Code Examples for org.javalite.activejdbc.Model#getTimestamp()

The following examples show how to use org.javalite.activejdbc.Model#getTimestamp() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Comment.java    From flowchat with GNU General Public License v3.0 5 votes vote down vote up
public static Comment create(Model cv, Integer vote) {

        User user = User.create(cv.getLong("user_id"), cv.getString("user_name"));
        User modifiedByUser = User.create(cv.getLong("modified_by_user_id"), cv.getString("modified_by_user_name"));

        return new Comment(cv.getLong("id"), user, modifiedByUser, cv.getLong("discussion_id"),
                cv.getLong("discussion_owner_id"), cv.getString("text_"), cv.getLong("path_length"),
                cv.getLong("parent_id"), cv.getLong("parent_user_id"), cv.getString("breadcrumbs"),
                cv.getLong("num_of_parents"), cv.getLong("num_of_children"), cv.getInteger("avg_rank"), vote,
                cv.getInteger("number_of_votes"), cv.getBoolean("deleted"), cv.getBoolean("read"),
                cv.getBoolean("stickied"), cv.getTimestamp("created"), cv.getTimestamp("modified"));
    }
 
Example 2
Source File: Community.java    From flowchat with GNU General Public License v3.0 4 votes vote down vote up
public static Community create(Model c,
                               List<Tables.CommunityTagView> communityTags,
                               List<Tables.CommunityUserView> communityUsers,
                               Integer vote) {
    // convert the tags
    List<Tag> tags = null;
    if (communityTags != null) {
        tags = new ArrayList<>();
        for (Tables.CommunityTagView dtv : communityTags) {
            tags.add(Tag.create(dtv.getLong("tag_id"), dtv.getString("name")));
        }
    }

    // convert the user community roles
    User creator = null;
    List<User> moderators = new ArrayList<>();
    List<User> privateUsers = new ArrayList<>();
    List<User> blockedUsers = new ArrayList<>();

    if (communityUsers != null) {
        for (Tables.CommunityUserView udv : communityUsers) {

            CommunityRole role = CommunityRole.values()[udv.getLong("community_role_id").intValue() - 1];

            User userObj = User.create(udv.getLong("user_id"), udv.getString("name"));

            switch (role) {
                case CREATOR:
                    creator = userObj;
                    break;
                case MODERATOR:
                    moderators.add(userObj);
                    break;
                case BLOCKED:
                    blockedUsers.add(userObj);
                    break;
                case USER:
                    privateUsers.add(userObj);
                    break;
            }
        }
    }

    // Create the modified by user
    User modifiedByUser = User.create(c.getLong("modified_by_user_id"), c.getString("modified_by_user_name"));

    return new Community(c.getLongId(),
            c.getString("name"),
            c.getString("text_"),
            c.getBoolean("private"),
            c.getBoolean("nsfw"),
            c.getInteger("avg_rank"),
            vote,
            c.getInteger("number_of_votes"),
            tags,
            creator,
            modifiedByUser,
            moderators,
            privateUsers,
            blockedUsers,
            c.getBoolean("deleted"),
            c.getTimestamp("created"),
            c.getTimestamp("modified"));
}
 
Example 3
Source File: Discussion.java    From flowchat with GNU General Public License v3.0 4 votes vote down vote up
public static Discussion create(Model d,
                                Tables.CommunityNoTextView cntv,
                                List<Tables.DiscussionTagView> discussionTags,
                                List<Tables.DiscussionUserView> discussionUsers,
                                List<Tables.CommunityUserView> communityUsers,
                                Integer vote) {
    // convert the tags
    List<Tag> tags = null;
    if (discussionTags != null) {
        tags = new ArrayList<>();
        for (Tables.DiscussionTagView dtv : discussionTags) {
            tags.add(Tag.create(dtv.getLong("tag_id"), dtv.getString("name")));
        }
    }

    // convert the user discussion roles
    User creator = null;
    List<User> privateUsers = new ArrayList<>();
    List<User> blockedUsers = new ArrayList<>();

    if (discussionUsers != null) {
        for (Tables.DiscussionUserView udv : discussionUsers) {

            DiscussionRole role = DiscussionRole.values()[udv.getLong("discussion_role_id").intValue() - 1];

            User userObj = User.create(udv.getLong("user_id"), udv.getString("name"));

            switch (role) {
                case BLOCKED:
                    blockedUsers.add(userObj);
                    break;
                case USER:
                    privateUsers.add(userObj);
                    break;
                case CREATOR:
                    creator = userObj;
                    break;
            }
        }
    }

    // Create the community
    Community community = (cntv != null) ? Community.create(cntv, null, communityUsers, null) : null;

    // If the community is NSFW, the discussion must be
    Boolean nsfw = (community != null && community.getNsfw()) ? true :  d.getBoolean("nsfw");

    // Create the modified by user
    User modifiedByUser = User.create(d.getLong("modified_by_user_id"), d.getString("modified_by_user_name"));

    return new Discussion(d.getLongId(),
            d.getString("title"),
            d.getString("link"),
            d.getString("text_"),
            d.getBoolean("private"),
            nsfw,
            d.getBoolean("stickied"),
            d.getInteger("avg_rank"),
            vote,
            d.getInteger("number_of_votes"),
            d.getInteger("number_of_comments"),
            tags,
            creator,
            modifiedByUser,
            privateUsers,
            blockedUsers,
            d.getBoolean("deleted"),
            community,
            d.getTimestamp("created"),
            d.getTimestamp("modified"));
}