当前位置: 首页>>代码示例>>Java>>正文


Java Model类代码示例

本文整理汇总了Java中org.javalite.activejdbc.Model的典型用法代码示例。如果您正苦于以下问题:Java Model类的具体用法?Java Model怎么用?Java Model使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Model类属于org.javalite.activejdbc包,在下文中一共展示了Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: create

import org.javalite.activejdbc.Model; //导入依赖的package包/类
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.getTimestamp("created"),
                cv.getTimestamp("modified"));
    }
 
开发者ID:dessalines,项目名称:flowchat,代码行数:27,代码来源:Comment.java

示例2: convertRankToMap

import org.javalite.activejdbc.Model; //导入依赖的package包/类
public static <T extends Model> Map<Long, Integer> convertRankToMap(List<T> drs, String idColumnName) {

        // Convert those votes to a map from id to rank
        Map<Long, Integer> rankMap = new HashMap<>();
        for (T dr : drs) {
            rankMap.put(dr.getLong(idColumnName), dr.getInteger("rank"));
        }

        try {
            log.debug(Tools.JACKSON.writeValueAsString(rankMap));
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }

        return rankMap;
    }
 
开发者ID:dessalines,项目名称:flowchat,代码行数:17,代码来源:Transformations.java

示例3: convertRowsToMap

import org.javalite.activejdbc.Model; //导入依赖的package包/类
public static <T extends Model> Map<Long,List<T>> convertRowsToMap(List<T> tags, String idColumnName) {

        Map<Long,List<T>> map = new HashMap<>();

        for (T dtv : tags) {
            Long id = dtv.getLong(idColumnName);
            List<T> arr = map.get(id);

            if (arr == null) {
                arr = new ArrayList<>();
                map.put(id, arr);
            }

            arr.add(dtv);
        }

        return map;
    }
 
开发者ID:dessalines,项目名称:flowchat,代码行数:19,代码来源:Transformations.java

示例4: create

import org.javalite.activejdbc.Model; //导入依赖的package包/类
public static Communities create(List<? extends Model> communities,
                                 List<Tables.CommunityTagView> communityTags,
                                 List<Tables.CommunityUserView> communityUsers,
                                 List<Tables.CommunityRank> communityRanks,
                                 Long count) {

    // Build maps keyed by community_id of the votes, tags, and users
    Map<Long, Integer> votes = (communityRanks != null) ?
            Transformations.convertRankToMap(communityRanks, "community_id") : null;

    Map<Long, List<Tables.CommunityTagView>> tagMap = (communityTags != null) ?
            Transformations.convertRowsToMap(communityTags, "community_id") : null;

    Map<Long, List<Tables.CommunityUserView>> userMap = (communityUsers != null) ?
            Transformations.convertRowsToMap(communityUsers, "community_id") : null;

    // Convert to a list of community objects
    List<Community> cos = new ArrayList<>();

    for (Model view : communities) {
        Long id = view.getLongId();
        Integer vote = (votes != null && votes.get(id) != null) ? votes.get(id) : null;
        List<Tables.CommunityTagView> tags = (tagMap != null && tagMap.get(id) != null) ? tagMap.get(id) : null;
        List<Tables.CommunityUserView> users = (userMap != null && userMap.get(id) != null) ? userMap.get(id) : null;
        Community c = Community.create(view, tags, users, vote);
        cos.add(c);
    }

    return new Communities(cos, count);
}
 
开发者ID:dessalines,项目名称:flowchat,代码行数:31,代码来源:Communities.java

示例5: create

import org.javalite.activejdbc.Model; //导入依赖的package包/类
public static Comments create(
        LazyList<? extends Model> comments,
        Map<Long, Integer> votes,
        Long topLimit, Long maxDepth) {

    List<Comment> commentObjs = Transformations.convertCommentsToEmbeddedObjects(
            comments, votes, topLimit, maxDepth);

    return new Comments(commentObjs);
}
 
开发者ID:dessalines,项目名称:flowchat,代码行数:11,代码来源:Comments.java

示例6: replies

import org.javalite.activejdbc.Model; //导入依赖的package包/类
public static Comments replies(LazyList<? extends Model> comments) {
    Set<Comment> commentObjs = new LinkedHashSet<>();
    for (Model c : comments) {
        commentObjs.add(Comment.create(c, null));
    }

    // Convert to a list
    List<Comment> list = new ArrayList<>(commentObjs);

    return new Comments(list);

}
 
开发者ID:dessalines,项目名称:flowchat,代码行数:13,代码来源:Comments.java

示例7: convertCommentsToEmbeddedObjects

import org.javalite.activejdbc.Model; //导入依赖的package包/类
public static List<Comment> convertCommentsToEmbeddedObjects(
        List<? extends Model> cvs,
        Map<Long, Integer> votes,
        Long topLimit, Long maxDepth) {

    Map<Long, Comment> commentObjMap = convertCommentThreadedViewToMap(cvs, votes);

    List<Comment> cos = convertCommentsMapToEmbeddedObjects(commentObjMap, topLimit, maxDepth);

    return cos;
}
 
开发者ID:dessalines,项目名称:flowchat,代码行数:12,代码来源:Transformations.java

示例8: messageNextPage

import org.javalite.activejdbc.Model; //导入依赖的package包/类
public void messageNextPage(Session session, String nextPageDataStr) {
    SessionScope ss = SessionScope.findBySession(sessionScopes, session);

    // Get the object
    NextPageData nextPageData = NextPageData.fromJson(nextPageDataStr);

    // Refetch the comments based on the new limit
    LazyList<Model> comments = fetchComments(ss);

    // send the comments from up to the new limit to them
    sendMessage(session, Comments.create(comments,
            fetchVotesMap(ss.getUserObj().getId()),
            nextPageData.getTopLimit(), nextPageData.getMaxDepth()).json());

}
 
开发者ID:dessalines,项目名称:flowchat,代码行数:16,代码来源:ThreadedChatWebSocket.java

示例9: fetchComments

import org.javalite.activejdbc.Model; //导入依赖的package包/类
private static LazyList<Model> fetchComments(SessionScope scope) {
    if (scope.getTopParentId() != null) {
        return CommentBreadcrumbsView.where("discussion_id = ? and parent_id = ?",
                scope.getDiscussionId(), scope.getTopParentId());
    } else {
        return CommentThreadedView.where("discussion_id = ?", scope.getDiscussionId());
    }
}
 
开发者ID:dessalines,项目名称:flowchat,代码行数:9,代码来源:ThreadedChatWebSocket.java

示例10: fetchUserComments

import org.javalite.activejdbc.Model; //导入依赖的package包/类
public static String fetchUserComments(Integer userId, Integer commentUserId, String orderBy, 
		Integer pageNum, Integer pageSize) {
	LazyList<Model> cvs = COMMENT_VIEW.findBySQL(
			COMMENT_VIEW_SQL(userId, null, null, null, null, orderBy, commentUserId, null, 
					pageNum, pageSize, null));

	String json = Tools.wrapPaginatorArray(
			Tools.replaceNewlines(cvs.toJson(false)),
			Long.valueOf(cvs.size()));
	
	return json;
}
 
开发者ID:dessalines,项目名称:referendum,代码行数:13,代码来源:Actions.java

示例11: validate

import org.javalite.activejdbc.Model; //导入依赖的package包/类
@Override
public void validate(Model m) {
    if(m.get(attribute) == null){
        m.addValidator(this, attribute);
        return;
    }
    Object value = m.get(attribute);
    if (!(value instanceof String)) {
        throw new IllegalArgumentException("attribute " + attribute + " is not String");
    }
    Matcher matcher = pattern.matcher((String) value);
    if(!matcher.matches()){
       m.addValidator(this, attribute);
    }
}
 
开发者ID:javalite,项目名称:activejdbc,代码行数:16,代码来源:RegexpValidator.java

示例12: convert

import org.javalite.activejdbc.Model; //导入依赖的package包/类
@Override
public void convert(Model m) {
    Object val = m.get(attributeName);
    if (!(val instanceof java.util.Date) && !blank(val)) {
        try {
            long time = df.parse(val.toString()).getTime();
            java.sql.Date d = new java.sql.Date(time);
            m.set(attributeName, d);
        } catch (ParseException e) {
            m.addValidator(this, attributeName);
        }
    }
}
 
开发者ID:javalite,项目名称:activejdbc,代码行数:14,代码来源:DateConverter.java

示例13: validate

import org.javalite.activejdbc.Model; //导入依赖的package包/类
@Override
public void validate(Model m) {
    Object value = m.get(attribute);
    if (!(value instanceof String)) {
        throw new IllegalArgumentException("Attribute must be a String");
    }

    if (!lengthOption.validate((String) (m.get(attribute)))) {
        m.addValidator(this, attribute);
    }
}
 
开发者ID:javalite,项目名称:activejdbc,代码行数:12,代码来源:AttributeLengthValidator.java

示例14: convert

import org.javalite.activejdbc.Model; //导入依赖的package包/类
@Override
public void convert(Model m) {
    Object val = m.get(attributeName);
    if (!(val instanceof Timestamp) && !blank(val)) {
        try {
            long time = df.parse(val.toString()).getTime();
            Timestamp t = new Timestamp(time);
            m.set(attributeName, t);
        } catch(ParseException e) {
            m.addValidator(this, attributeName);
        }
    }
}
 
开发者ID:javalite,项目名称:activejdbc,代码行数:14,代码来源:TimestampConverter.java

示例15: validate

import org.javalite.activejdbc.Model; //导入依赖的package包/类
@Override
public void validate(Model m) {
    if (blank(m.get(attribute))) {
        //TODO: use resource bundles for messages
        m.addValidator(this, attribute);
    }
}
 
开发者ID:javalite,项目名称:activejdbc,代码行数:8,代码来源:AttributePresenceValidator.java


注:本文中的org.javalite.activejdbc.Model类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。