List of usage examples for com.mongodb DBCursor next
@Override
public DBObject next()
From source file:com.effektif.mongo.MongoJobStore.java
License:Apache License
public Iterator<String> getWorkflowInstanceIdsToLockForJobs() { DBObject query = buildLockNextJobQuery().push(WORKFLOW_INSTANCE_ID).append("$exists", true).pop().get(); // TODO use MongoQuery filterOrganization(query, JobFields.organizationId); DBObject retrieveFields = new BasicDBObject(WORKFLOW_INSTANCE_ID, true); DBCursor jobsDueHavingProcessInstance = jobsCollection.find("jobs-having-process-instance", query, retrieveFields);/* w w w .j a v a 2 s. c om*/ List<String> processInstanceIds = new ArrayList<>(); while (jobsDueHavingProcessInstance.hasNext()) { DBObject partialJob = jobsDueHavingProcessInstance.next(); Object processInstanceId = partialJob.get(WORKFLOW_INSTANCE_ID); processInstanceIds.add(processInstanceId.toString()); } return processInstanceIds.iterator(); }
From source file:com.effektif.mongo.MongoJobStore.java
License:Apache License
protected List<Job> findJobs(MongoCollection collection, JobQuery jobQuery) { List<Job> jobs = new ArrayList<Job>(); BasicDBObject query = createDbQuery(jobQuery); DBCursor jobCursor = collection.find("find-jobs", query); while (jobCursor.hasNext()) { BasicDBObject dbJob = (BasicDBObject) jobCursor.next(); Job job = readJob(dbJob);/* www . ja v a 2s. c o m*/ jobs.add(job); } return jobs; }
From source file:com.effektif.mongo.MongoWorkflowInstanceStore.java
License:Apache License
public List<WorkflowInstanceImpl> findWorkflowInstances(BasicDBObject dbQuery) { DBCursor workflowInstanceCursor = workflowInstancesCollection.find("find-workflow-instance-impls", dbQuery); List<WorkflowInstanceImpl> workflowInstances = new ArrayList<>(); while (workflowInstanceCursor.hasNext()) { BasicDBObject dbWorkflowInstance = (BasicDBObject) workflowInstanceCursor.next(); WorkflowInstanceImpl workflowInstance = readWorkflowInstanceImpl(dbWorkflowInstance); workflowInstances.add(workflowInstance); }//from w w w . j a v a2s . c o m return workflowInstances; }
From source file:com.effektif.mongo.MongoWorkflowInstanceStore.java
License:Apache License
public LinkedHashMap<WorkflowInstanceId, WorkflowInstanceImpl> findWorkflowInstanceMap( Collection<ObjectId> workflowInstanceIds) { LinkedHashMap<WorkflowInstanceId, WorkflowInstanceImpl> workflowInstanceMap = new LinkedHashMap<>(); if (workflowInstanceIds != null && !workflowInstanceIds.isEmpty()) { Query query = new Query()._ids(workflowInstanceIds); DBCursor workflowInstanceCursor = workflowInstancesCollection.find("find-workflow-instance", query.get());//www . j a v a2 s. com while (workflowInstanceCursor.hasNext()) { BasicDBObject dbWorkflowInstance = (BasicDBObject) workflowInstanceCursor.next(); WorkflowInstanceImpl workflowInstance = readWorkflowInstanceImpl(dbWorkflowInstance); workflowInstanceMap.put(workflowInstance.getId(), workflowInstance); } } return workflowInstanceMap; }
From source file:com.effektif.mongo.MongoWorkflowStore.java
License:Apache License
@Override public List<ExecutableWorkflow> findWorkflows(WorkflowQuery query) { if (query == null) { query = new WorkflowQuery(); }/*from w w w .j ava2 s.c o m*/ List<ExecutableWorkflow> workflows = new ArrayList<>(); DBCursor cursor = createWorkflowDbCursor(query); while (cursor.hasNext()) { BasicDBObject dbWorkflow = (BasicDBObject) cursor.next(); ExecutableWorkflow workflow = mongoToWorkflowApi(dbWorkflow, ExecutableWorkflow.class); workflows.add(workflow); } return workflows; }
From source file:com.ejbmongoembeddedtomcat.service.MongoService.java
public List<Customer> readAllCustomer() { List<Customer> customers = new ArrayList<Customer>(); DBCursor cursor = col.find(); while (cursor.hasNext()) { DBObject doc = cursor.next(); Customer cus = CustomerConverter.toCustomer(doc); customers.add(cus);/*w w w . j a v a2 s. c o m*/ } return customers; }
From source file:com.emuneee.camerasyncmanager.util.DatabaseUtil.java
License:Apache License
/** * Returns a camera with id//from w ww . j a v a2s .c o m * @param id * @return */ public Camera getCamera(String id) { Camera camera = null; DB db = getDatabase(); DBCursor cursor = null; try { DBCollection collection = db.getCollection("camera"); BasicDBObject query = new BasicDBObject("_id", id); cursor = collection.find(query); if (cursor.hasNext()) { BasicDBObject dbObj = (BasicDBObject) cursor.next(); camera = dbObjectToCamera(dbObj); } } catch (Exception e) { sLogger.error("Exception retrieving camera with id " + id); sLogger.error(e); } finally { HttpHelper.closeResources(new Object[] { cursor }); } return camera; }
From source file:com.espirit.moddev.examples.uxbridge.newsdrilldown.jpa.NewsHandler.java
License:Apache License
/** * loads a news by the document id//w w w . j a v a 2 s . c o m * * @param id * the id of the document * @param language * language abbreviation like EN or DE * @return the document or null */ private DBObject getNewsById(Long id, String language) { BasicDBObject query = new BasicDBObject(); query.put("fs_id", id); query.put("language", language); DBCursor cur = dbNews.find(query); if (cur.hasNext()) { return cur.next(); } return null; }
From source file:com.espirit.moddev.examples.uxbridge.newsdrilldown.jpa.NewsHandler.java
License:Apache License
/** * loads a category by the document id/* w w w . ja v a 2 s .c om*/ * * @param id * the id of the document * @param language * language abbreviation like EN or DE * @return the document or null */ private DBObject getCategoryById(Long id, String language) { BasicDBObject query = new BasicDBObject(); query.put("fs_id", id); query.put("language", language); DBCursor cur = dbCategories.find(query); if (cur.hasNext()) { return cur.next(); } return null; }
From source file:com.espirit.moddev.examples.uxbridge.newsdrilldown.jpa.NewsHandler.java
License:Apache License
/** * loads a metacategory by the document id * * @param id/*from ww w. j a v a 2 s. c o m*/ * the id of the document * @param language * language abbreviation like EN or DE * @return the document or null */ private DBObject getMetaCategoryById(Long id, String language) { BasicDBObject query = new BasicDBObject(); query.put("fs_id", id); query.put("language", language); DBCursor cur = dbMetaCategories.find(query); if (cur.hasNext()) { return cur.next(); } return null; }