本文整理汇总了Java中org.javalite.activejdbc.LazyList类的典型用法代码示例。如果您正苦于以下问题:Java LazyList类的具体用法?Java LazyList怎么用?Java LazyList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LazyList类属于org.javalite.activejdbc包,在下文中一共展示了LazyList类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static TorrentDetail create(
Tables.Torrent torrent,
LazyList<Tables.FileView> files) {
List<FileDetail> fileDetails = new ArrayList<>();
for (Tables.FileView f : files) {
fileDetails.add(
FileDetail.create(
f.getString("path"),
f.getLong("size_bytes"),
f.getInteger("index_")));
}
Long peers = files.get(0).getLong("peers");
return new TorrentDetail(torrent.getString("name"),
torrent.getString("info_hash"),
torrent.getTimestamp("created"),
fileDetails,
files.get(0).getLong("peers"),
torrent.getLong("size_bytes"));
}
开发者ID:dessalines,项目名称:torfiles,代码行数:23,代码来源:TorrentDetail.java
示例2: listAction
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
@GET
@Template(name = "/post/list")
public ViewData listAction(@DefaultValue("1") @QueryParam("page") int page) {
int postsPerPage = Configuration.POSTS_PER_PAGE;
Paginator p = new Paginator(Post.class, postsPerPage, "*").orderBy("created_at desc");
int pageCount = Math.max((int) p.pageCount(), 1);
int pageNumber = (page > pageCount) ? pageCount : Math.max(1, page);
LazyList posts = p.getPage(pageNumber);
ViewData.set("model", posts);
HashMap<String, Object> pagination = new HashMap<>();
pagination.put("currentPage", pageNumber);
pagination.put("totalPages", pageCount);
pagination.put("linkUrl", RESOURCE_PATH);
ViewData.set("pagination", pagination);
return ViewData;
}
开发者ID:autoschool,项目名称:splinter,代码行数:21,代码来源:PostResource.java
示例3: getPlayerStatisticWithType
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public PlayerStatistic getPlayerStatisticWithType(String type)
{
LazyList<PlayerStatistic> fetched = this.get(PlayerStatistic.class, "type = ?", type);
PlayerStatistic playerStatistic = null;
if (fetched.size() > 0)
{
playerStatistic = fetched.get(0);
}
if (playerStatistic == null)
{
playerStatistic = new PlayerStatistic();
playerStatistic.set("type", type);
playerStatistic.set("value", 0);
playerStatistic.setParent(this);
playerStatistic.saveIt();
}
return playerStatistic;
}
开发者ID:BitLimit,项目名称:Bits,代码行数:22,代码来源:PlayerServerRecord.java
示例4: create
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static Tags create(LazyList<com.chat.db.Tables.Tag> tags) {
// Convert to a list of discussion objects
List<Tag> tos = new ArrayList<>();
for (com.chat.db.Tables.Tag tag : tags) {
Tag to = Tag.create(tag);
tos.add(to);
}
return new Tags(tos);
}
开发者ID:dessalines,项目名称:flowchat,代码行数:12,代码来源:Tags.java
示例5: create
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static Users create(LazyList<com.chat.db.Tables.User> users) {
// Convert to a list of discussion objects
Set<User> uos = new LinkedHashSet<>();
for (com.chat.db.Tables.User user : users) {
User uo = User.create(user);
uos.add(uo);
}
return new Users(uos);
}
开发者ID:dessalines,项目名称:flowchat,代码行数:12,代码来源:Users.java
示例6: create
import org.javalite.activejdbc.LazyList; //导入依赖的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
示例7: replies
import org.javalite.activejdbc.LazyList; //导入依赖的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
示例8: messageNextPage
import org.javalite.activejdbc.LazyList; //导入依赖的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.LazyList; //导入依赖的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: search
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static void search() {
get("/search", (req, res) -> {
String nameParam = req.queryParams("q");
String nameTokens = Tools.tokenizeNameQuery(nameParam);
String limitParam = req.queryParams("limit");
Integer limit = (limitParam != null) ? Integer.valueOf(limitParam) : 25;
String pageParam = req.queryParams("page");
Integer page = (pageParam != null) ? Integer.valueOf(pageParam) : 1;
Integer offset = (page - 1) * limit;
LazyList<Tables.FileView> files = (nameTokens != null) ?
Tables.FileView.findBySQL(
"with cte as ( select * from file_view " +
"where text_search @@ to_tsquery('" + nameTokens + "')) " +
"select * from cte " +
"order by peers desc, size_bytes desc limit " + limit + " offset " + offset) :
Tables.FileView.findAll().orderBy("peers desc, size_bytes desc").limit(limit).offset(offset);
return Tools.wrapPagedResults(files.toJson(false),
999L,
page);
});
}
开发者ID:dessalines,项目名称:torfiles,代码行数:31,代码来源:Endpoints.java
示例11: fetchUserComments
import org.javalite.activejdbc.LazyList; //导入依赖的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
示例12: fetchUserMessages
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static String fetchUserMessages(Integer userId, Integer parentUserId, String orderBy,
Integer pageNum, Integer pageSize, Boolean read) {
LazyList<CommentView> cvs = fetchUserMessageList(userId, parentUserId, orderBy, pageNum, pageSize, read);
String json = Tools.wrapPaginatorArray(
Tools.replaceNewlines(cvs.toJson(false)),
Long.valueOf(cvs.size()));
return json;
}
开发者ID:dessalines,项目名称:referendum,代码行数:12,代码来源:Actions.java
示例13: fetchUserMessageList
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static LazyList<CommentView> fetchUserMessageList(Integer userId, Integer parentUserId, String orderBy,
Integer pageNum, Integer pageSize, Boolean read) {
LazyList<CommentView> cvs = COMMENT_VIEW.findBySQL(
COMMENT_VIEW_SQL(userId, null, null, 1, 1, orderBy, null, parentUserId, null, null, read));
return cvs;
}
开发者ID:dessalines,项目名称:referendum,代码行数:8,代码来源:Actions.java
示例14: saveDiscussion
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static Discussion saveDiscussion(Long userId, Discussion do_) {
Timestamp cTime = new Timestamp(new Date().getTime());
Tables.Discussion d = Tables.Discussion.findFirst("id = ?", do_.getId());
LazyList<DiscussionUserView> udv = DiscussionUserView.where("discussion_id = ?", do_.getId());
log.debug(udv.toJson(true));
log.debug(do_.json());
if (do_.getTitle() != null) d.set("title", do_.getTitle());
if (do_.getLink() != null) d.set("link", do_.getLink());
if (do_.getText() != null) d.set("text_", do_.getText());
if (do_.getPrivate_() != null) d.set("private", do_.getPrivate_());
if (do_.getDeleted() != null) d.set("deleted", do_.getDeleted());
if (do_.getCommunity() != null) d.set("community_id", do_.getCommunity().getId());
d.set("modified_by_user_id", userId);
d.set("modified", cTime);
d.saveIt();
// Add the discussion tags
if (do_.getTags() != null) {
diffCreateOrDeleteDiscussionTags(do_);
}
if (do_.getPrivateUsers() != null) {
diffCreateOrDeleteDiscussionUsers(do_.getId(), do_.getPrivateUsers(), DiscussionRole.USER);
}
if (do_.getBlockedUsers() != null) {
diffCreateOrDeleteDiscussionUsers(do_.getId(), do_.getBlockedUsers(), DiscussionRole.BLOCKED);
}
// Fetch the full view
DiscussionFullView dfv = DiscussionFullView.findFirst("id = ?", do_.getId());
List<DiscussionTagView> dtv = DiscussionTagView.where("discussion_id = ?", do_.getId());
List<DiscussionUserView> ud = DiscussionUserView.where("discussion_id = ?", do_.getId());
CommunityNoTextView cntv = CommunityNoTextView.findFirst("id = ?", dfv.getLong("community_id"));
List<Tables.CommunityUserView> communityUsers = Tables.CommunityUserView.where("community_id = ?", cntv.getLong("id"));
Discussion doOut = Discussion.create(dfv, cntv, dtv, ud, communityUsers, null);
return doOut;
}
开发者ID:dessalines,项目名称:flowchat,代码行数:47,代码来源:Actions.java
示例15: markAllRepliesAsRead
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static void markAllRepliesAsRead(Long userId) {
// Fetch your unread replies
LazyList<CommentBreadcrumbsView> cbv = CommentBreadcrumbsView.where(
"parent_user_id = ? and user_id != ? and read = false",
userId, userId);
Set<Long> ids = cbv.collectDistinct("id");
if (ids.size() > 0) {
String inQuery = Tools.convertListToInQuery(ids);
Comment.update("read = ?", "id in " + inQuery, true);
}
}
开发者ID:dessalines,项目名称:flowchat,代码行数:19,代码来源:Actions.java
示例16: saveCommunity
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static Community saveCommunity(Long userId, Community co_) {
Timestamp cTime = new Timestamp(new Date().getTime());
Tables.Community c = Tables.Community.findFirst("id = ?", co_.getId());
LazyList<CommunityUserView> cuv = CommunityUserView.where("community_id = ?", co_.getId());
log.debug(cuv.toJson(true));
log.debug(co_.json());
if (co_.getName() != null) c.set("name", co_.getName());
if (co_.getText() != null) c.set("text_", co_.getText());
if (co_.getPrivate_() != null) c.set("private", co_.getPrivate_());
if (co_.getDeleted() != null) c.set("deleted", co_.getDeleted());
c.set("modified_by_user_id", userId);
c.set("modified", cTime);
try {
c.saveIt();
} catch (Exception e) {
e.printStackTrace();
if (e.getLocalizedMessage().contains("already exists")) {
throw new NoSuchElementException("Community already exists");
}
}
// Add the community tags
if (co_.getTags() != null) {
diffCreateOrDeleteCommunityTags(co_);
}
if (co_.getPrivateUsers() != null) {
diffCreateOrDeleteCommunityUsers(co_.getId(), co_.getPrivateUsers(), CommunityRole.USER);
}
if (co_.getBlockedUsers() != null) {
diffCreateOrDeleteCommunityUsers(co_.getId(), co_.getBlockedUsers(), CommunityRole.BLOCKED);
}
if (co_.getModerators() != null) {
diffCreateOrDeleteCommunityUsers(co_.getId(), co_.getModerators(), CommunityRole.MODERATOR);
}
// Fetch the full view
CommunityView cv = CommunityView.findFirst("id = ?", co_.getId());
List<CommunityTagView> ctv = CommunityTagView.where("community_id = ?", co_.getId());
List<CommunityUserView> cuvO = CommunityUserView.where("community_id = ?", co_.getId());
Community coOut = Community.create(cv, ctv, cuvO, null);
return coOut;
}
开发者ID:dessalines,项目名称:flowchat,代码行数:55,代码来源:Actions.java
示例17: onConnect
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
@OnWebSocketConnect
public void onConnect(Session session) throws Exception {
Tools.dbInit();
// Get or create the session scope
SessionScope ss = setupSessionScope(session);
// Send them their user info
session.getRemote().sendString(ss.getUserObj().json("user"));
LazyList<Model> comments = fetchComments(ss);
// send the comments
session.getRemote().sendString(Comments.create(comments,
fetchVotesMap(ss.getUserObj().getId()), topLimit, maxDepth).json());
// send the updated users to everyone in the right scope(just discussion)
Set<SessionScope> filteredScopes = SessionScope.constructFilteredUserScopesFromSessionRequest(sessionScopes, session);
broadcastMessage(filteredScopes, Users.create(SessionScope.getUserObjects(filteredScopes)).json());
log.debug("session scope " + ss + " joined");
Tools.dbClose();
}
开发者ID:dessalines,项目名称:flowchat,代码行数:27,代码来源:ThreadedChatWebSocket.java
示例18: messageReply
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public void messageReply(Session session, String replyDataStr) {
SessionScope ss = SessionScope.findBySession(sessionScopes, session);
// Get the object
ReplyData replyData = ReplyData.fromJson(replyDataStr);
// Collect only works on refetch
LazyList<Model> comments = fetchComments(ss);
log.debug(ss.toString());
// Necessary for comment tree
Array arr = (Array) comments.collect("breadcrumbs", "id", replyData.getParentId()).get(0);
List<Long> parentBreadCrumbs = Tools.convertArrayToList(arr);
com.chat.db.Tables.Comment newComment = Actions.createComment(ss.getUserObj().getId(),
ss.getDiscussionId(),
parentBreadCrumbs,
replyData.getReply());
// Fetch the comment threaded view
CommentThreadedView ctv = CommentThreadedView.findFirst("id = ?", newComment.getLongId());
// Convert to a proper commentObj
Comment co = Comment.create(ctv, null);
Set<SessionScope> filteredScopes = SessionScope.constructFilteredMessageScopesFromSessionRequest(
sessionScopes, session, co.getBreadcrumbs());
broadcastMessage(filteredScopes, co.json("reply"));
// TODO find a way to do this without having to query every time?
com.chat.types.discussion.Discussion do_ = Actions.saveFavoriteDiscussion(ss.getUserObj().getId(), ss.getDiscussionId());
if (do_ != null) sendMessage(session, do_.json("discussion"));
}
开发者ID:dessalines,项目名称:flowchat,代码行数:41,代码来源:ThreadedChatWebSocket.java
示例19: detail
import org.javalite.activejdbc.LazyList; //导入依赖的package包/类
public static void detail() {
get("/torrent_detail/:info_hash", (req, res) -> {
String infoHash = req.params(":info_hash");
Tables.Torrent torrent = Tables.Torrent.findFirst("info_hash = ?", infoHash);
LazyList<Tables.FileView> files = Tables.FileView.where("info_hash = ?", infoHash).orderBy("path");
TorrentDetail td = TorrentDetail.create(torrent, files);
return td.json();
});
}
开发者ID:dessalines,项目名称:torfiles,代码行数:15,代码来源:Endpoints.java
注:本文中的org.javalite.activejdbc.LazyList类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论