Package com.mongodb

Examples of com.mongodb.DBCursor


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

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

      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


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

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

      List<String> ids = new ArrayList<String>();
      while (cursor.hasNext())
      {
        DBObject next = cursor.next();
        String messageGuid = (String) next.get("guid");
        ids.add(messageGuid);
      }
      logger.info("Found "+ids.size()+" messages for responder: "+responderId+", topic: "+topicId+" that have no processing state annotation");
      return ids;
View Full Code Here

      query.put("timestamp", new BasicDBObject("$gt", withinMs));

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

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

      query.put("timestamp", new BasicDBObject("$gt", withinMs));

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

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

  {
    try
    {
//      BasicDBObject query = new BasicDBObject();

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

          + ", range: "+offset+" -> "+limit);
      //BasicDBObject query = new BasicDBObject();
      BasicDBObject byTimestamp = new BasicDBObject();
      byTimestamp.put("timestamp", 1);

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

      query.put("responderGuid", responderGuid);

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

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

    // no arguments, will ask DB what the last updated Id was (checking persistent storage)
    private DBCursor initializeCursor() {
        Object lastVal = tailTracking.lastVal;
        // lastVal can be null if we are initializing and there is no persistence enabled
        DBCursor answer;
        if (lastVal == null) {
            answer = dbCol.find().addOption(Bytes.QUERYOPTION_TAILABLE).addOption(Bytes.QUERYOPTION_AWAITDATA);
        } else {
            DBObject queryObj = new BasicDBObject(tailTracking.getIncreasingFieldName(), new BasicDBObject("$gt", lastVal));
            answer = dbCol.find(queryObj).addOption(Bytes.QUERYOPTION_TAILABLE).addOption(Bytes.QUERYOPTION_AWAITDATA);
View Full Code Here

        // get the batch size and number to skip
        Integer batchSize = exchange.getIn().getHeader(MongoDbConstants.BATCH_SIZE, Integer.class);
        Integer numToSkip = exchange.getIn().getHeader(MongoDbConstants.NUM_TO_SKIP, Integer.class);
        Integer limit = exchange.getIn().getHeader(MongoDbConstants.LIMIT, Integer.class);
        DBObject sortBy = exchange.getIn().getHeader(MongoDbConstants.SORT_BY, DBObject.class);
        DBCursor ret = null;
        try
            if (query == null && fieldFilter == null) {
                ret = dbCol.find(new BasicDBObject());
            } else if (fieldFilter == null) {
                ret = dbCol.find(query);
            } else {
                ret = dbCol.find(query, fieldFilter);
            }
           
            if (sortBy != null) {
                ret.sort(sortBy);
            }
           
            if (batchSize != null) {
                ret.batchSize(batchSize.intValue());
            }
           
            if (numToSkip != null) {
                ret.skip(numToSkip.intValue());
            }
   
            if (limit != null) {
                ret.limit(limit.intValue());
            }
           
            Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.findAll);
            resultMessage.setBody(ret.toArray());
            resultMessage.setHeader(MongoDbConstants.RESULT_TOTAL_SIZE, ret.count());
            resultMessage.setHeader(MongoDbConstants.RESULT_PAGE_SIZE, ret.size());
           
        } catch (Exception e) {
            // rethrow the exception
            throw e;
        } finally {
            // make sure the cursor is closed
            if (ret != null) {
                ret.close();
            }
        }
       
    }
View Full Code Here

            long startTime, long endTime) throws ManifoldCFException, ServiceInterruption {
        getSession();
        DBCollection fsFiles = session.getCollection(
                bucket + GridFSConstants.COLLECTION_SEPERATOR + GridFSConstants.FILES_COLLECTION_NAME
        );
        DBCursor dnc = fsFiles.find();
        while (dnc.hasNext()) {
            DBObject dbo = dnc.next();
            String _id = dbo.get("_id").toString();
            activities.addSeedDocument(_id);
            if (Logging.connectors.isDebugEnabled()) {
                Logging.connectors.debug("GridFS: Document _id = " + _id + " added to queue");
            }
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.