Example usage for com.mongodb DBCursor hasNext

List of usage examples for com.mongodb DBCursor hasNext

Introduction

In this page you can find the example usage for com.mongodb DBCursor hasNext.

Prototype

@Override
public boolean hasNext() 

Source Link

Document

Checks if there is another object available.

Usage

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  a  v  a 2  s.com*/
    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 va 2  s.  c om

    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;/* w  w w  .j  av a 2  s.c  o  m*/
    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;/*from  w  w w .  j a  va 2  s  .c o  m*/
    DBCursor obj = coll.find();
    while (obj.hasNext()) {

        item.add((String) obj.next().get("Item"));

    }

    return item;
}

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  a  v  a 2  s .  com*/
    }

    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  w w  .jav  a 2  s  .c  o  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];
    ;/*ww  w.j a va  2 s .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;
}

From source file:com.bigdid.model.Feedback_Order_Months.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   ww w . ja va 2 s  .  c  o m*/
    while (obj.hasNext()) {

        DBObject dbObj = obj.next();
        //            prev_date = current_date;
        //            Date d = (Date) dbObj.get("Order_Date");

        current_date = (String) dbObj.get("month");
        //
        //            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("f_count");

            data.put(current_date, count);
            counter++;
        }
        if (dbObj.get("Feedback").equals("Good")) {
            count[1] = (Integer) dbObj.get("f_count");

            data.put(current_date, count);
            counter++;
        }
        if (dbObj.get("Feedback").equals("Average")) {
            count[2] = (Integer) dbObj.get("f_count");

            data.put(current_date, count);
            counter++;
        }
        if (dbObj.get("Feedback").equals("Bad")) {
            count[3] = (Integer) dbObj.get("f_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;
}

From source file:com.bigdid.model.Feedback_Order_Weeks.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];
    ;// ww  w  .jav a2  s.  com
    while (obj.hasNext()) {

        DBObject dbObj = obj.next();
        //            prev_date = current_date;
        //            Date d = (Date) dbObj.get("Order_Date");

        current_date = (String) dbObj.get("week");
        //
        //            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("f_count");

            data.put(current_date, count);
            counter++;
        }
        if (dbObj.get("Feedback").equals("Good")) {
            count[1] = (Integer) dbObj.get("f_count");

            data.put(current_date, count);
            counter++;
        }
        if (dbObj.get("Feedback").equals("Average")) {
            count[2] = (Integer) dbObj.get("f_count");

            data.put(current_date, count);
            counter++;
        }
        if (dbObj.get("Feedback").equals("Bad")) {
            count[3] = (Integer) dbObj.get("f_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;
}

From source file:com.bigdid.model.Revenue_Item.java

public ArrayList<String> getItem() throws UnknownHostException {
    ArrayList<String> item = new ArrayList<String>();

    int i = 0;//from  www  . j a va  2s . c o m
    DBCursor obj = coll.find();
    while (obj.hasNext()) {

        item.add((String) obj.next().get("Item"));
        i++;

    }

    return item;
}