Package com.mongodb

Examples of com.mongodb.DBCursor


    }

    @Override
    public List<Center> getCentersByName(String name) {
        List<Center> centers = null;
        DBCursor cursor = coll.find(new BasicDBObject(CenterKeys.name, name.toUpperCase()));
        if(cursor.hasNext()) centers = new FastList<Center>();
        while (cursor.hasNext()) {
            DBObject obj = cursor.next();
            if (obj.get(CenterKeys.name).equals(name)) {
                centers.add(factory.createCenter(obj.toMap()));
            }
        }
        return centers != null? centers : Collections.EMPTY_LIST;
View Full Code Here


    }

    @Override
    public List<String> getCentersNames() {
        List<String> names = null;
        DBCursor cursor = coll.find();
        if(cursor.hasNext()) names = new FastList<String>();
        while (cursor.hasNext()) {
            names.add(cursor.next().get(CenterKeys.name).toString());
        }
        return names != null ? names : Collections.EMPTY_LIST;
    }
View Full Code Here

            filter = FrameworkUtil.createFilter(filterValue);
        }

        DBCollection coll = getCollection();

        DBCursor cursor = coll.find();
        try {
            while (cursor.hasNext()) {
                // Hmm, there might be a more clever way of doing this...
                Role role = m_helper.deserialize(cursor.next());
                if ((filter == null) || filter.match(role.getProperties())) {
                    roles.add(role);
                }
            }
        } finally {
            cursor.close();
        }

        return roles.toArray(new Role[roles.size()]);
    }
View Full Code Here

    @Override
    public Role getRole(String name) {
        DBCollection coll = getCollection();

        DBCursor cursor = coll.find(getTemplateObject(name));
        try {
            if (cursor.hasNext()) {
                return m_helper.deserialize(cursor.next());
            }
        } finally {
            cursor.close();
        }

        return null;
    }
View Full Code Here

    if (matcher == null) {
      return;
    }
    JsonObject sort = message.body.getObject("sort");
    DBCollection coll = db.getCollection(collection);
    DBCursor cursor = coll.find(jsonToDBObject(matcher));
    if (limit != -1) {
      cursor.limit(limit);
    }
    if (sort != null) {
      cursor.sort(jsonToDBObject(sort));
    }
    sendBatch(message, cursor, batchSize);
  }
View Full Code Here

            queryBuilder.greaterThanEquals(startValue);
        }
        DBObject query = queryBuilder.get();
        long start = start();
        try {
            DBCursor cursor = dbCollection.find(query).sort(BY_ID_ASC);
            List<T> list = new ArrayList<T>();
            for (int i = 0; i < limit && cursor.hasNext(); i++) {
                DBObject o = cursor.next();
                T doc = convertFromDBObject(collection, o);
                if (collection == Collection.NODES && doc != null) {
                    doc.seal();
                    String id = doc.getId();
                    Lock lock = getAndLock(id);
View Full Code Here

      query.put("topicGuid", topicGuid);

      BasicDBObject byTimestamp = new BasicDBObject();
      byTimestamp.put("publishedTimestamp", 1);

      DBCursor cursor = collection.find(query).sort(byTimestamp).skip(offset).limit(limit);
      List<Message> docs = new ArrayList<Message>();
      while (cursor.hasNext())
      {
        DBObject next = cursor.next();
        docs.add(deserialise(next, Message.class, true));
      }
      return docs;
    }
    catch(Exception e)
View Full Code Here

      BasicDBObject query = new BasicDBObject();

      BasicDBObject byTimestamp = new BasicDBObject();
      byTimestamp.put("publishedTimestamp", 1);

      DBCursor cursor = collection.find(query).sort(byTimestamp).skip(offset).limit(limit);

      List<Message> docs = new ArrayList<Message>();
      while (cursor.hasNext())
      {
        DBObject next = cursor.next();
        docs.add(deserialise(next, Message.class, true));
      }
      return docs;
    }
    catch(Exception e)
View Full Code Here

      query.put("publishedTimestamp", new BasicDBObject("$gt", afterTimestamp));

      BasicDBObject byTimestamp = new BasicDBObject();
      byTimestamp.put("publishedTimestamp", 1);

      DBCursor cursor = collection.find(query).sort(byTimestamp);

      List<Message> docs = new ArrayList<Message>();
      long lastTimestamp = Long.MIN_VALUE;
      while (cursor.hasNext())
      {
        DBObject next = cursor.next();
        Message message = deserialise(next, Message.class, true);

        if (docs.size() >= preferredLimit &&
            lastTimestamp != message.getPublishedTimestamp())
        {
View Full Code Here

      keys.put("guid", 1);

      BasicDBObject byTimestamp = new BasicDBObject();
      byTimestamp.put("publishedTimestamp", 1);

      DBCursor cursor = collection.find(query).sort(byTimestamp);

      List<String> ids = new ArrayList<String>();
      while (cursor.hasNext())
      {
        DBObject next = cursor.next();
        String messageGuid = (String) next.get("guid");
        ids.add(messageGuid);;
      }
      return ids;
    }
View Full Code Here

TOP

Related Classes of com.mongodb.DBCursor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.