List of usage examples for com.mongodb DBCursor toArray
public List<DBObject> toArray()
From source file:models.MessageThread.java
License:Open Source License
public static List<MessageThread> getUserThreads(ObjectId uid) { // TODO limitneme to na 30, treba potom pridat moznost zobrazit vsetko List<MessageThread> r = null; try {//from w w w . j a v a 2 s . com BasicDBObject query = new BasicDBObject().append(USERS, uid); BasicDBObject sort = new BasicDBObject().append(LAST, 1); DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CMessageThread).find(query).sort(sort).limit(30); if (iobj == null) { r = new ArrayList<MessageThread>(); } else { Logger.info("user threads found"); r = Lists.transform(iobj.toArray(), MongoDB.getSelf().toMessageThread()); } } catch (Exception ex) { Logger.info("getUserThreads"); ex.printStackTrace(); Logger.info(ex.toString()); } return r; }
From source file:models.NodeContent.java
License:Open Source License
static List<NodeContent> load(List<ObjectId> nodeIds) { List<NodeContent> nodes = null; try {//w w w . jav a 2s . c o m DBObject query = new BasicDBObject("_id", new BasicDBObject().append("$in", nodeIds.toArray(new ObjectId[nodeIds.size()]))); DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CNode).find(query); if (iobj != null) nodes = Lists.transform(iobj.toArray(), MongoDB.getSelf().toNodeContent()); } catch (Exception ex) { Logger.info("load nodes::"); ex.printStackTrace(); Logger.info(ex.toString()); } return nodes; }
From source file:models.NodeContent.java
License:Open Source License
protected List<NodeContent> loadVector() { List<NodeContent> nodes = null; // TODO estepredtym by to chcelo vybrat zacachovane a vratit ich tak try {/*from w w w .ja va 2 s . c o m*/ DBObject query = new BasicDBObject("_id", new BasicDBObject().append("$in", vector.toArray(new ObjectId[vector.size()]))); DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CNode).find(query); if (iobj != null) nodes = Lists.transform(iobj.toArray(), MongoDB.getSelf().toNodeContent()); } catch (Exception ex) { Logger.info("load nodes::"); ex.printStackTrace(); Logger.info(ex.toString()); } return nodes; }
From source file:models.Nodelist.java
License:Open Source License
public static List<NodeContent> getKlist(Integer count) { List<NodeContent> r = null; try {/* w w w. j a v a 2s . c o m*/ // Long t24hAgo = 0l; // kQuery.append(CREATED, new BasicDBObject("$gt", t24hAgo)). DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CNode).find(kQuery).sort(kSort) .limit(count == null ? 100 : count); // query.append(fooks, new BasicDBObject("$notin", 1)); ? if (iobj != null) r = Lists.transform(iobj.toArray(), MongoDB.getSelf().toNodeContent()); } catch (Exception ex) { Logger.info("getKlist"); ex.printStackTrace(); Logger.info(ex.toString()); } return r; }
From source file:models.Nodelist.java
License:Open Source License
public static List<NodeContent> getLastNodes(Integer count) { List<NodeContent> r = null; try {//from w w w . j a v a2 s . com BasicDBObject query = new BasicDBObject().append(CREATED, new BasicDBObject("$gt", System.currentTimeMillis() - t24h)); DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CNode).find(query).sort(lastSort) .limit(count == null ? 30 : count); if (iobj != null) r = Lists.transform(iobj.toArray(), MongoDB.getSelf().toNodeContent()); } catch (Exception ex) { Logger.info("getLastNodes"); ex.printStackTrace(); Logger.info(ex.toString()); } return r; }
From source file:models.Nodelist.java
License:Open Source License
public static List<NodeContent> getUserNodes(String uid, Integer count) { List<NodeContent> r = null; try {//from w w w.j a v a 2 s . c o m BasicDBObject query = new BasicDBObject().append(OWNER, uid); // new ObjectId( DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CNode).find(query).sort(lastSort) .limit(count == null ? 30 : count); if (iobj != null) r = Lists.transform(iobj.toArray(), MongoDB.getSelf().toNodeContent()); } catch (Exception ex) { Logger.info("getUserNodes"); ex.printStackTrace(); Logger.info(ex.toString()); } return r; }
From source file:models.Page.java
License:Open Source License
public static List<Page> loadPages() { List<Page> pages = null; try {//from w w w . j a va 2s .c o m DBCursor iobj = (DBCursor) MongoDB.getDB().getCollection(MongoDB.CPage).find(); if (iobj != null) pages = Lists.transform(iobj.toArray(), MongoDB.getSelf().toPage()); } catch (Exception ex) { Logger.info("Page list load fail"); ex.printStackTrace(); Logger.info(ex.toString()); return null; } return pages; }
From source file:models.Tag.java
License:Open Source License
public static List<Tag> load() { List<Tag> tags = null;/*from w ww . java2s. co m*/ try { DBCursor iobj = (DBCursor) MongoDB.getDB().getCollection(MongoDB.CTag).find(); if (iobj != null) tags = Lists.transform(iobj.toArray(), MongoDB.getSelf().toTag()); } catch (Exception ex) { Logger.info("Page list load fail"); ex.printStackTrace(); Logger.info(ex.toString()); return null; } return tags; }
From source file:models.Tag.java
License:Open Source License
public static List<NodeContent> getTaggedNodes(String tag) { List<NodeContent> nodes = null; try {//from w ww .j ava 2s . c o m DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CNode).find(new BasicDBObject("tags", tag)); if (iobj != null) nodes = Lists.transform(iobj.toArray(), MongoDB.getSelf().toNodeContent()); } catch (Exception ex) { Logger.info("getTaggedNodes::"); ex.printStackTrace(); Logger.info(ex.toString()); } return nodes; }
From source file:models.Tag.java
License:Open Source License
public static List<Tag> getTagCloud(String tag) { List<Tag> r = null;/*from ww w . ja v a 2 s. com*/ try { BasicDBObject query = new BasicDBObject().append("tag", tag); BasicDBObject sort = new BasicDBObject().append("tag", 1); DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CTag).find(query).sort(sort).limit(30); if (iobj == null) { r = new ArrayList<Tag>(); } else { Logger.info("tags found"); r = Lists.transform(iobj.toArray(), MongoDB.getSelf().toTag()); } } catch (Exception ex) { Logger.info("getTagCloud"); ex.printStackTrace(); Logger.info(ex.toString()); } return r; }