List of usage examples for com.mongodb DBCursor next
@Override
public DBObject next()
From source file:com.bbc.remarc.ws.VideoServiceImpl.java
License:Apache License
@GET @Produces("application/json") @Path("/metadata/{id}") public Response getVideoMetadata(@PathParam("id") String id) { log.trace("getAudioMetadata"); DB db = MongoClient.getDB();/*from www. j a v a 2 s . c o m*/ DBCursor results = null; try { db.requestStart(); results = db.getCollection(COLLECTION_NAME).find(BasicDBObjectBuilder.start().add("id", id).get()); if (results.count() == 0) { return Response.status(404).build(); } } finally { db.requestDone(); } return Response.ok(results.next().toString()).build(); }
From source file:com.berkgokden.mongodb.MongoMapStore.java
License:Open Source License
public Map loadAll(Collection keys) { Map map = new HashMap(); BasicDBList dbo = new BasicDBList(); for (Object key : keys) { dbo.add(new BasicDBObject("_id", key)); }//from w w w . ja va 2 s . co m BasicDBObject dbb = new BasicDBObject("$or", dbo); DBCursor cursor = coll.find(dbb); while (cursor.hasNext()) { try { DBObject obj = cursor.next(); Class clazz = Class.forName(obj.get("_class").toString()); map.put(obj.get("_id"), converter.toObject(clazz, obj)); } catch (ClassNotFoundException e) { logger.log(Level.WARNING, e.getMessage(), e); } } return map; }
From source file:com.berkgokden.mongodb.MongoMapStore.java
License:Open Source License
public Set loadAllKeys() { Set keyset = new HashSet(); BasicDBList dbo = new BasicDBList(); dbo.add("_id"); DBCursor cursor = coll.find(null, dbo); while (cursor.hasNext()) { keyset.add(cursor.next().get("_id")); }//from w w w. j av a2 s.c o m return keyset; }
From source file:com.bigdid.model.Competitor_Prices.java
public ArrayList<Integer> getBreakup(String item) throws UnknownHostException { BasicDBObject whereQuery = new BasicDBObject(); whereQuery.put("Item", item); DBCursor obj = coll.find(whereQuery); ArrayList<Integer> price = new ArrayList<Integer>(); while (obj.hasNext()) { price.add((Integer) obj.next().get("Price")); }//from w ww . j a v a 2s.c o m return price; }
From source file:com.bigdid.model.Customer_Feedback.java
public int[] getCount() throws UnknownHostException { // Now connect to your databases String item[] = new String[100]; int i = 0;/*from ww w.j a v a 2 s. c om*/ int count[] = new int[4]; DBCursor obj = coll.find(); while (obj.hasNext()) { DBObject dbObj = obj.next(); count[i] = (Integer) dbObj.get("Count"); i++; } return count; }
From source file:com.bigdid.model.Customer_Return_Percentage.java
public ArrayList<String> getItem() throws UnknownHostException { ArrayList<String> item = new ArrayList<String>(); int i = 0;/*w ww . j a va 2 s.co m*/ DBCursor obj = coll.find(); while (obj.hasNext()) { item.add((String) obj.next().get("Item")); } return item; }
From source file:com.bigdid.model.Customer_Return_Percentage.java
public ArrayList<String> getFeedback() throws UnknownHostException { ArrayList<String> feedback = new ArrayList<String>(); DBCursor obj = coll.find(); // BasicDBObject whereQuery = new BasicDBObject(); // whereQuery.put( "Percentage", -1 ); // obj.sort(whereQuery); int size = obj.size(); int i;/*from w ww.j a va2 s . c om*/ for (i = 0; i < size; i++) { feedback.add(((String) obj.next().get("Percentage"))); System.out.println("Valuesss" + feedback.get(i)); } return feedback; }
From source file:com.bigdid.model.Feedback_Location.java
public int getRevenue(Object city) throws SQLException, UnknownHostException { int revenue = 0; DBCursor obj = coll.find(); while (obj.hasNext()) { if (obj.next().get("Location").equals(city)) { revenue = (Integer) obj.next().get("Order_Value"); }/*w w w . j av a 2 s . co m*/ } return revenue; }
From source file:com.bigdid.model.Feedback_Location.java
public ArrayList<Integer> getGrade(Object Location) throws SQLException, UnknownHostException { // long[] grade = new long[4]; ArrayList<Integer> grade = new ArrayList<Integer>(); String city = (String) Location; BasicDBObject condition0 = new BasicDBObject("Location", city).append("Feedback", "Bad"); DBCursor obj0 = coll.find(condition0); while (obj0.hasNext()) { // grade[0] = (Integer) obj0.next().get("count"); grade.add(0, (Integer) obj0.next().get("count")); }//w ww . j a va 2 s . co m BasicDBObject condition1 = new BasicDBObject("Location", city).append("Feedback", "Good"); DBCursor obj1 = coll.find(condition1); while (obj1.hasNext()) { //grade[1] = (Integer) obj1.next().get("count"); grade.add(1, (Integer) obj1.next().get("count")); } BasicDBObject condition2 = new BasicDBObject("Location", city).append("Feedback", "Average"); DBCursor obj2 = coll.find(condition2); while (obj2.hasNext()) { //grade[2] = (Integer) obj2.next().get("count"); grade.add(2, (Integer) obj2.next().get("count")); } BasicDBObject condition3 = new BasicDBObject("Location", city).append("Feedback", "Excellent"); DBCursor obj3 = coll.find(condition3); while (obj3.hasNext()) { // grade[3] = (Integer) obj3.next().get("count"); grade.add(3, (Integer) obj3.next().get("count")); } sum = (long) (grade.get(0) + grade.get(1) + grade.get(2) + grade.get(3)); return grade; }
From source file:com.bigdid.model.Feedback_Order_Days.java
public LinkedHashMap<String, int[]> getFeedback() { DBCursor obj = coll.find(); String current_date = "0"; String prev_date = "0"; int counter = 0; int[] count = new int[4]; ;//from w w w .ja v a2s . co m while (obj.hasNext()) { DBObject dbObj = obj.next(); prev_date = current_date; Date d = (Date) dbObj.get("Order_Date"); current_date = (String) d.toString().substring(4, 10) + " " + (String) d.toString().substring(24); // // int prev_excellent = 0; // int prev_good = 0; // int prev_average = 0; // int prev_bad=0; if (dbObj.get("Feedback").equals("Excellent")) { count[0] = (Integer) dbObj.get("feedback_count"); data.put(current_date, count); counter++; } if (dbObj.get("Feedback").equals("Good")) { count[1] = (Integer) dbObj.get("feedback_count"); data.put(current_date, count); counter++; } if (dbObj.get("Feedback").equals("Average")) { count[2] = (Integer) dbObj.get("feedback_count"); data.put(current_date, count); counter++; } if (dbObj.get("Feedback").equals("Bad")) { count[3] = (Integer) dbObj.get("feedback_count"); data.put(current_date, count); counter++; } if (counter % 4 == 0) { // System.out.println(current_date); // System.out.println(count[0]); // System.out.println(count[1]); // System.out.println(count[2]); // System.out.println(count[3]); data.put(current_date, count); count = new int[4]; } } return data; }