Example usage for com.mongodb MongoClientURI MongoClientURI

List of usage examples for com.mongodb MongoClientURI MongoClientURI

Introduction

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

Prototype

public MongoClientURI(final String uri) 

Source Link

Document

Creates a MongoURI from the given string.

Usage

From source file:tour.Decimal128QuickTour.java

License:Apache License

/**
 * Run this main method to see the output of this quick example.
 *
 * @param args takes an optional single argument for the connection string
 *//* w  ww  .j  a va2  s. c o m*/
public static void main(final String[] args) {
    MongoClient mongoClient;

    if (args.length == 0) {
        // connect to the local database server
        mongoClient = new MongoClient();
    } else {
        mongoClient = new MongoClient(new MongoClientURI(args[0]));
    }

    // get handle to "mydb" database
    MongoDatabase database = mongoClient.getDatabase("mydb");

    // get a handle to the "test" collection
    MongoCollection<Document> collection = database.getCollection("test");

    // drop all the data in it
    collection.drop();

    // make a document and insert it
    Document doc = new Document("name", "MongoDB").append("amount1", Decimal128.parse(".10"))
            .append("amount2", new Decimal128(42L)).append("amount3", new Decimal128(new BigDecimal(".200")));

    collection.insertOne(doc);

    Document first = collection.find().filter(Filters.eq("amount1", new Decimal128(new BigDecimal(".10"))))
            .first();

    Decimal128 amount3 = (Decimal128) first.get("amount3");
    BigDecimal amount2AsBigDecimal = amount3.bigDecimalValue();

    System.out.println(amount3.toString());
    System.out.println(amount2AsBigDecimal.toString());

}

From source file:tour.NewQuickTour.java

License:Apache License

/**
 * Run this main method to see the output of this quick example.
 *
 * @param args takes an optional single argument for the connection string
 *//* w w  w .  ja  v a  2  s  . c o m*/
public static void main(final String[] args) {
    MongoClient mongoClient;

    if (args.length == 0) {
        // connect to the local database server
        mongoClient = new MongoClient();
    } else {
        mongoClient = new MongoClient(new MongoClientURI(args[0]));
    }

    // get handle to "mydb" database
    MongoDatabase database = mongoClient.getDatabase("mydb");

    database.drop();

    // get a list of the collections in this database and print them out
    List<String> collectionNames = database.listCollectionNames().into(new ArrayList<String>());
    for (final String s : collectionNames) {
        System.out.println(s);
    }

    // get a handle to the "test" collection
    MongoCollection<Document> collection = database.getCollection("test");

    // drop all the data in it
    collection.drop();

    // make a document and insert it
    Document doc = new Document("name", "MongoDB").append("type", "database").append("count", 1).append("info",
            new Document("x", 203).append("y", 102));

    collection.insertOne(doc);

    // get it (since it's the only one in there since we dropped the rest earlier on)
    Document myDoc = collection.find().first();
    System.out.println(myDoc);

    // now, lets add lots of little documents to the collection so we can explore queries and cursors
    List<Document> documents = new ArrayList<Document>();
    for (int i = 0; i < 100; i++) {
        documents.add(new Document("i", i));
    }
    collection.insertMany(documents);
    System.out.println(
            "total # of documents after inserting 100 small ones (should be 101) " + collection.count());

    // lets get all the documents in the collection and print them out
    MongoCursor<Document> cursor = collection.find().iterator();
    try {
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    } finally {
        cursor.close();
    }

    for (Document cur : collection.find()) {
        System.out.println(cur);
    }

    // now use a query to get 1 document out
    myDoc = collection.find(eq("i", 71)).first();
    System.out.println(myDoc);

    // now use a range query to get a larger subset
    cursor = collection.find(gt("i", 50)).iterator();

    try {
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    } finally {
        cursor.close();
    }

    // range query with multiple constraints
    cursor = collection.find(and(gt("i", 50), lte("i", 100))).iterator();

    try {
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    } finally {
        cursor.close();
    }

    // max time
    collection.find().maxTime(1, TimeUnit.SECONDS).first();

    collection.drop();

    // ordered bulk writes
    List<WriteModel<Document>> writes = new ArrayList<WriteModel<Document>>();
    writes.add(new InsertOneModel<Document>(new Document("_id", 4)));
    writes.add(new InsertOneModel<Document>(new Document("_id", 5)));
    writes.add(new InsertOneModel<Document>(new Document("_id", 6)));
    writes.add(
            new UpdateOneModel<Document>(new Document("_id", 1), new Document("$set", new Document("x", 2))));
    writes.add(new DeleteOneModel<Document>(new Document("_id", 2)));
    writes.add(new ReplaceOneModel<Document>(new Document("_id", 3), new Document("_id", 3).append("x", 4)));

    collection.bulkWrite(writes);

    collection.drop();

    collection.bulkWrite(writes, new BulkWriteOptions().ordered(false));

    // getting a list of databases
    for (String name : mongoClient.listDatabaseNames()) {
        System.out.println(name);
    }

    // drop a database
    mongoClient.dropDatabase("databaseToBeDropped");

    // create a collection
    database.createCollection("cappedCollection",
            new CreateCollectionOptions().capped(true).sizeInBytes(0x100000));

    for (String name : database.listCollectionNames()) {
        System.out.println(name);
    }

    // create an ascending index on the "i" field
    collection.createIndex(new Document("i", 1));

    // list the indexes on the collection
    for (final Document index : collection.listIndexes()) {
        System.out.println(index);
    }

    // create a text index on the "content" field
    collection.createIndex(new Document("content", "text"));

    collection.insertOne(new Document("_id", 0).append("content", "textual content"));
    collection.insertOne(new Document("_id", 1).append("content", "additional content"));
    collection.insertOne(new Document("_id", 2).append("content", "irrelevant content"));

    // Find using the text index
    Document search = new Document("$search", "textual content -irrelevant");
    Document textSearch = new Document("$text", search);
    long matchCount = collection.count(textSearch);
    System.out.println("Text search matches: " + matchCount);

    // Find using the $language operator
    textSearch = new Document("$text", search.append("$language", "english"));
    matchCount = collection.count(textSearch);
    System.out.println("Text search matches (english): " + matchCount);

    // Find the highest scoring match
    Document projection = new Document("score", new Document("$meta", "textScore"));
    myDoc = collection.find(textSearch).projection(projection).first();
    System.out.println("Highest scoring document: " + myDoc);

    // release resources
    mongoClient.close();
}

From source file:tour.QuickTour.java

License:Apache License

/**
 * Run this main method to see the output of this quick example.
 *
 * @param args takes an optional single argument for the connection string
 *//*www.j a v  a  2  s  .co m*/
@SuppressWarnings("deprecation")
public static void main(final String[] args) {
    MongoClient mongoClient;

    if (args.length == 0) {
        // connect to the local database server
        mongoClient = new MongoClient();
    } else {
        mongoClient = new MongoClient(new MongoClientURI(args[0]));
    }

    // get handle to the "mydb" database
    DB db = mongoClient.getDB("mydb");

    // get a list of the collections in this database and print them out
    Set<String> collectionNames = db.getCollectionNames();
    for (final String s : collectionNames) {
        System.out.println(s);
    }

    // get a handle to the "test" collection
    DBCollection collection = db.getCollection("test");

    // drop all the data in it
    collection.drop();

    // make a document and insert it
    BasicDBObject doc = new BasicDBObject("name", "MongoDB").append("type", "database").append("count", 1)
            .append("info", new BasicDBObject("x", 203).append("y", 102));

    collection.insert(doc);

    // get it (since it's the only one in there since we dropped the rest earlier on)
    DBObject myDoc = collection.findOne();
    System.out.println(myDoc);

    // now, lets add lots of little documents to the collection so we can explore queries and cursors
    List<DBObject> documents = new ArrayList<DBObject>();
    for (int i = 0; i < 100; i++) {
        documents.add(new BasicDBObject().append("i", i));
    }
    collection.insert(documents);
    System.out.println(
            "total # of documents after inserting 100 small ones (should be 101) " + collection.getCount());

    // lets get all the documents in the collection and print them out
    DBCursor cursor = collection.find();
    try {
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    } finally {
        cursor.close();
    }

    // now use a query to get 1 document out
    cursor = collection.find(new BasicDBObject("i", 71));

    try {
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    } finally {
        cursor.close();
    }

    // now use a range query to get a larger subset
    cursor = collection.find(new BasicDBObject("i", new BasicDBObject("$gt", 50)));

    try {
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    } finally {
        cursor.close();
    }

    // range query with multiple constraints
    cursor = collection.find(new BasicDBObject("i", new BasicDBObject("$gt", 20).append("$lte", 30)));

    try {
        while (cursor.hasNext()) {
            System.out.println(cursor.next());
        }
    } finally {
        cursor.close();
    }

    // create an ascending index on the "i" field
    collection.createIndex(new BasicDBObject("i", 1));

    // list the indexes on the collection
    List<DBObject> list = collection.getIndexInfo();
    for (final DBObject o : list) {
        System.out.println(o);
    }

    // release resources
    mongoClient.close();
}

From source file:wasdev.sample.store.MongoDbVisitorStore.java

License:Apache License

private static MongoClient createClient() {

    //Update the following lines if using Self Signed Certs and uncomment lines 223, 224, 241
    String keyStoreName = null, keyStorePass = null;
    //System.out.println("Using TrustStore name \"" + keyStoreName +
    //                   "\" and password \"" + keyStorePass + "\"");
    KeyStore keyStore = initializeKeyStore(keyStoreName, keyStorePass);
    String url = null, certString = null;
    //End updates for self signed certs

    if (System.getenv("VCAP_SERVICES") != null) {
        // When running in Bluemix, the VCAP_SERVICES env var will have the
        // credentials for all bound/connected services
        // Parse the VCAP JSON structure looking for mongodb.
        JsonObject mongoCredentials = VCAPHelper.getCloudCredentials("mongodb");

        if (mongoCredentials == null) {
            System.out.println("No MongoDB database service bound to this application");
            return null;
        }//from  w ww.  j  a v  a2 s . c om
        url = mongoCredentials.get("uri").getAsString();
        //certString = mongoCredentials.get("ca_certificate_base64").getAsString();
    } else {
        System.out.println("Running locally. Looking for credentials in mongo.properties");
        url = VCAPHelper.getLocalProperties("mongo.properties").getProperty("mongo_url");
        if (url == null || url.length() == 0) {
            System.out.println("To use a database, set the MongoDB url in src/main/resources/mongo.properties");
            return null;
        }

        certString = VCAPHelper.getLocalProperties("mongo.properties").getProperty("mongo_ssl");
    }

    if (keyStore != null) {
        System.setProperty("javax.net.ssl.trustStore", keyStoreName);
        System.setProperty("javax.net.ssl.trustStorePassword", keyStorePass);

        addCertToKeyStore(keyStore, certString);
    } else {
        System.out.println("A TrustStore could not be found or created.");
    }

    try {
        System.out.println("Connecting to MongoDb");
        MongoClient client = new MongoClient(new MongoClientURI(url));
        return client;
    } catch (Exception e) {
        System.out.println("Unable to connect to database");
        //e.printStackTrace();
        return null;
    }
}

From source file:week2.BlogController.java

License:Apache License

public BlogController(String mongoURIString) throws IOException {
    final MongoClient mongoClient = new MongoClient(new MongoClientURI(mongoURIString));
    final MongoDatabase blogDatabase = mongoClient.getDatabase("blog");

    userDAO = new UserDAO(blogDatabase);
    sessionDAO = new SessionDAO(blogDatabase);

    setPort(8082);// www  .ja va2s.co  m
    initializeRoutes();
}

From source file:wetree.MongoConnector.java

public MongoConnector() {
    MongoClientURI connectionURI = new MongoClientURI("mongodb://localhost:27017");
    this.client = new MongoClient(connectionURI);
    this.database = this.client.getDatabase("hyphe");
    this.collection = this.database.getCollection("AXA.pages");
}

From source file:xyz.kvantum.server.implementation.MongoApplicationStructure.java

License:Apache License

MongoApplicationStructure(final String applicationName) {
    super(applicationName);

    // Turn off the really annoying MongoDB spam :/
    {/*from w w w.jav a  2s  .co  m*/
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        Logger rootLogger = loggerContext.getLogger("org.mongodb.driver");
        rootLogger.setLevel(Level.OFF);
    }

    this.mongoClient = new MongoClient(new MongoClientURI(CoreConfig.MongoDB.uri));
    xyz.kvantum.server.api.logging.Logger.info("Initialized MongoApplicationStructure: {}",
            this.applicationName);

    this.morphia = new Morphia();
    this.morphia.mapPackage("com.github.intellectualsites.kvantum.implementation");
    this.morphiaDatastore = morphia.createDatastore(this.mongoClient, CoreConfig.MongoDB.dbMorphia);

    new MongoAccountManager(this); // Initialize
}

From source file:xyz.lexteam.minecraft.staple.db.Database.java

License:MIT License

public Database(Configuration configuration) {
    MongoClientURI clientURI = new MongoClientURI(configuration.getDatabase().getUri());
    this.mongoClient = new MongoClient(clientURI);
    this.mongoDatabase = this.mongoClient.getDatabase(clientURI.getDatabase());
}

From source file:yelpapp.HW3.java

public List<String> getBusinessDetails(ArrayList<String> Cat, String checkinfrom, String checkinto,
        String noofcheckin_cond, String noofcheckinvalue, Date reviewfrom, Date Reviewto, String Stars_cond,
        String Stars_value, String votes_cond, String votes_value, String searchForComboBox,
        Boolean isaddressselected, Double longitude, Double latitude, Boolean isproximityset,
        String proximity) {/*from w w w  .j  a  v a  2  s .  c om*/
    SearchResults SearchResults = new SearchResults();
    Connection dbconnection;
    dbconnection = YelpDBConnectionFactory.connectDatabase();

    MongoClient client;

    client = new MongoClient(new MongoClientURI("mongodb://localhost:27017"));

    // TODO Auto-generated method stub
    MongoCollection<Document> b_collection = client.getDatabase("YelpApplication")
            .getCollection("YelpBusiness");
    ArrayList<String> str = Cat;

    String option;
    if (searchForComboBox == "AND") {
        option = "$all";
    } else {
        option = "$in";
    }
    String query = "";

    FindIterable<Document> resultBussinessid = b_collection
            .find(new Document("categories", new Document(option, str)))
            .projection(fields(include("business_id"), excludeId()));
    MongoCursor<Document> iterator = resultBussinessid.iterator();
    final List<String> categoryBuissnessList = new ArrayList<String>();
    resultBussinessid.forEach(new Block<Document>() {
        @Override
        public void apply(final Document document) {
            // TODO Auto-generated method stub
            System.out.println("document" + document);

            //if (document != null)System.out.println(document.toJson().toString().trim());

            JSONParser parser = new JSONParser();
            JSONObject jsonObject;

            try {
                jsonObject = (JSONObject) parser.parse(document.toJson().toString().trim());
                String business_id = (String) jsonObject.get("business_id");
                categoryBuissnessList.add(business_id);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            //Votes Parsing

        }
    });

    query = query + queryCategoryQuery(str);
    List<String> reviewBuissnessList = null;
    reviewBuissnessList = getReviewBusiness(reviewfrom, Reviewto, Stars_cond, Stars_value, votes_cond,
            votes_value);

    System.out.println("reviewBuissnessList" + reviewBuissnessList);

    List<String> proximityBuissnessList = null;
    if (isaddressselected && isproximityset) {
        System.out.println("proximity" + proximity);
        proximityBuissnessList = proximityQuery(longitude, latitude, Integer.parseInt(proximity));

        System.out.println("proximityBuissnessList" + proximityBuissnessList);
        query = query + proxqueryonly(longitude, latitude, Integer.parseInt(proximity));
    }
    List<String> CheckinBuissnessList = null;
    if (!noofcheckinvalue.equalsIgnoreCase("0")) {

        CheckinBuissnessList = getcheckinbusiness(categoryBuissnessList, Integer.parseInt(checkinfrom),
                Integer.parseInt(checkinto), Integer.parseInt(noofcheckinvalue));

    }
    System.out.println("categoryBuissnessList before merging" + categoryBuissnessList.size() + "    jfcjvkbkk  "
            + searchForComboBox);
    if (reviewBuissnessList != null)
        System.out.println("categoryBuissnessList before merging" + reviewBuissnessList.size());
    if (proximityBuissnessList != null)
        System.out.println("categoryBuissnessList before merging" + proximityBuissnessList.size());
    if (categoryBuissnessList != null)
        System.out.println("categoryBuissnessList before merging" + categoryBuissnessList);
    Set ptempimityBuissnessList = new HashSet<String>();
    if (searchForComboBox.equalsIgnoreCase("or")) {
        //do union
        System.out.println("in if ");
        //col.addAll(otherCol)// for union
        if (reviewBuissnessList != null && !votes_value.equalsIgnoreCase("0"))
            categoryBuissnessList.addAll(reviewBuissnessList);
        if (proximityBuissnessList != null)
            categoryBuissnessList.addAll(proximityBuissnessList);

    } else {
        //intersection
        System.out.println("in else ");

        //col.retainAll(otherCol) // for intersection
        if (reviewBuissnessList != null)
            categoryBuissnessList.retainAll(reviewBuissnessList);
        if (proximityBuissnessList != null)
            categoryBuissnessList.retainAll(proximityBuissnessList);

    }
    if (reviewBuissnessList != null)
        System.out.println("categoryBuissnessList before merging" + reviewBuissnessList.size());
    if (proximityBuissnessList != null)
        System.out.println("categoryBuissnessList before merging" + proximityBuissnessList.size());
    if (categoryBuissnessList != null)
        System.out.println("categoryBuissnessList before merging" + categoryBuissnessList.size());
    if (categoryBuissnessList != null)
        System.out.println("categoryBuissnessList" + categoryBuissnessList.size());
    System.out.println("categoryBuissnessList" + categoryBuissnessList);

    FindIterable<Document> result = b_collection
            .find(new Document("business_id", new Document(option, categoryBuissnessList)))
            .projection(fields(include("name", "city", "stars", "state"), excludeId())).limit(100);
    /*iterator = result.iterator();
    while(iterator.hasNext()){
      if(isdebug)System.out.println(iterator.next());
    }*/
    final List<String> businesses = new ArrayList<String>();
    result.forEach(new Block<Document>() {
        @Override
        public void apply(final Document document) {
            // TODO Auto-generated method stub
            businesses.add(document.toJson().toString().trim());
            System.out.println(document.toJson().toString().trim());
        }
    });

    /*
            
    if( subCat== null || (subCat != null &&subCat.size() == 0) )  {
               
       subCat = getSubcatogeries(Cat);
    }
       System.out.println("got subcat"+subCat);
               
               
     List userResults = new ArrayList();
     int count=0; 
     String query = "";
       try { 
               
       boolean firstwhereclause = true;//+ "      where ";
               
       String  checkinquery ="";
      if(!noofcheckinvalue.equalsIgnoreCase("0")) {
         checkinquery = " SELECT bid   FROM ( SELECT bus.B_BID    AS bid,   SUM(chek.C_COUNT ) AS checkcount   FROM Y_BUSINESS_TB bus JOIN Y_CHECKIN_TB chek  ON chek.C_B_ID =bus.B_BID     JOIN Y_BUS_SUB_CATEGORY subcat      ON bus.B_BID = subcat.B_ID"
            +" WHERE ";
                 
          String cin = formincondition(subCat);
          checkinquery =  checkinquery +" subcat.S_SUB_CAT_NAME  " +cin +"  and chek.C_INFO  between '" +checkinfrom+"' and '"+checkinto+"'  "
       + " group by bus.B_BID)  where checkcount " +noofcheckin_cond+" "+noofcheckinvalue;
                  
                  
      }
              
      String  reviewquery ="";
     if(reviewfrom != null && Reviewto != null && ( !Stars_value.equalsIgnoreCase("0") && !votes_value.equalsIgnoreCase("0")) ) {
         String rin = formincondition(subCat);
        reviewquery = " select bus.B_BID as  bid from Y_BUSINESS_TB bus  join  Y_REVIEWS_TB review on bus.B_BID = review.R_BUSS_ID "
            + "join Y_BUS_SUB_CATEGORY subcat on bus.B_BID = subcat.B_ID where subcat.S_SUB_CAT_NAME " +rin+ " ";
             
          DateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
            String date_string_reviewfrom = df.format(reviewfrom);  
            String date_string_reviewto = df.format(Reviewto);  
                    
        reviewquery = reviewquery+" and review.R_PUBLISH_DATE BETWEEN '"+date_string_reviewfrom+"' and '"+date_string_reviewto+"' ";
        if ( !votes_value.equalsIgnoreCase("0") ) {
            
           reviewquery = reviewquery+ " and review.R_VOTES " +votes_cond+ "  '" + votes_value+"' " ;
                   
        }
        if (  !Stars_value.equalsIgnoreCase("0")) {
                   
           reviewquery = reviewquery+ " and  review.r_stars "+ Stars_cond+" '"+Stars_value+"'      ";
        }
                 
                 
     }
     query = " "
           + ""
           + "select B_BID,B_NAME,B_CITY,B_STATE,B_STARS from Y_BUSINESS_TB ab where ab.B_BID in (";
     System.out.println("reviewquery "+reviewquery.equalsIgnoreCase("")+" reviewquery");
     System.out.println("checkinquery "+checkinquery.equalsIgnoreCase("")+" checkinquery.equalsIgnoreCase(");
             
             
      if (reviewquery.equalsIgnoreCase("") && checkinquery.equalsIgnoreCase("")) 
     {
                
         System.out.println("reviewquerasdasdy"+reviewquery+"reviewquery");
        String subcatonly = " select B_ID from Y_BUS_SUB_CATEGORY  where S_SUB_CAT_NAME ";
        String subcatin = formincondition(subCat);
        subcatonly =subcatonly+subcatin;
        query=query+subcatonly + " ) ";
     }
             
      else {      if (reviewquery.equalsIgnoreCase("")){
                
            query = query+checkinquery+ " ) ";
      }
      else if (checkinquery.equalsIgnoreCase("")){
                
            query = query+reviewquery+ " ) ";
      }
             
      else {
         query = query+checkinquery+ " INTERSECT "+reviewquery+ " ) ";
      }
               
      }
               
                
          System.out.println("query"+query);
                  
          }catch (Exception e){
                
            e.printStackTrace();
        }
      //   System.out.println(query);
      //   SearchResults.setIsusersearchResults(true);
      //   SearchResults.numberofrecords=count;
      //   SearchResults.setUserSearchresults(userResults);
      //   SearchResults.Query = query;
    */ return businesses;
}

From source file:yelpapp.HW3.java

private List<String> getcheckinbusiness(List businessids, Integer fromdate, Integer todate,
        Integer keyedin_count) {/*w w  w.  j a v  a2s.  c  om*/
    System.out.println("checkinSEARCH ");

    MongoClient client;
    String searchForComboBox = "and";
    System.out.println(businessids);
    DB db1 = new MongoClient("localhost", 27017).getDB("YelpApplication");
    DBCollection dbcollection = db1.getCollection("YelpCheckin");
    List<String> cbeckinBusinessList = null;
    client = new MongoClient(new MongoClientURI("mongodb://localhost:27017"));
    /*   System.out.println(asList(match(eq("name", "Tyler")), 
     lookup("YelpReview", "business_id", "business_id", "YelpBusinessReviews"), 
     unwind("$YelpBusinessReviews"),
             
     project(fields(computed("date", "$YelpBusinessReviews.date"), computed("stars", "$YelpBusinessReviews.stars"), computed("text", "$YelpBusinessReviews.text"), computed("userName", "name"), computed("usefulVotes", "votes.useful"),  excludeId())),
     unwind("$userName")));*/
    MongoCollection<Document> b_collection = client.getDatabase("YelpApplication").getCollection("YelpCheckin");
    /*   db.YelpUser.aggregate([
                          { 
                            $match: {
                                 $and: [ 
                                     { business_id: { $in: [ 5, 15 ] } }
                                     {date: {$gt: 3,$lt :5}}, 
                              {stars: {$gt: 3}}, 
                                     {$votes.useful: {$gt:2}},
                                       
                                       
                                 ]
                            }
                          }
                         ])*/

    FindIterable<Document> result = b_collection
            .find(new Document("business_id", new Document("$in", businessids)))
            .projection(fields(include("business_id", "checkin_info"), excludeId()));
    System.out.println("   asdas =" + result);
    MongoCursor<Document> iterator = result.iterator();

    final List<String> checkinJson = new ArrayList<String>();
    result.forEach(new Block<Document>() {
        @Override
        public void apply(final Document document) {
            // TODO Auto-generated method stub
            checkinJson.add(document.toJson().toString().trim());
            if (isdebug)
                System.out.println(document.toJson().toString().trim());
        }
    });
    System.out.println("" + checkinJson);

    //got jasonobjects
    try {
        Iterator<String> iterator2 = checkinJson.iterator();
        HashMap<String, Integer> cbeckincountmap = new HashMap<String, Integer>();
        while (iterator2.hasNext()) {
            JSONParser parser = new JSONParser();
            JSONObject jsonObject;

            jsonObject = (JSONObject) parser.parse(iterator2.next());

            //Votes Parsing
            String business_id = (String) jsonObject.get("business_id");

            JSONObject checkininfo = (JSONObject) jsonObject.get("checkin_info");
            String[][] checkin = new String[24][7];
            String[][] checkinT = new String[7][24];
            int checkincount = 0;
            String c_info = null;
            for (int i = 0; i < 24; i++) {
                for (int j = 0; j < 7; j++) {
                    checkin[i][j] = getcheckininfo(checkininfo, i + "-" + j);
                    c_info = getcheckininfo(checkininfo, i + "-" + j);

                    if (c_info != null) {

                        String dayhour = (i >= 10) ? "" + j + i : j + "0" + i;
                        Integer dayhourInt = Integer.parseInt(dayhour);
                        Integer c_infoInt = Integer.parseInt(c_info);
                        /* p_statement.setNString(2, dayhour);
                         p_statement.setNString(3, c_info);//count
                        */

                        if (dayhourInt > fromdate && dayhourInt < todate) {
                            Integer ccount = cbeckincountmap.get(business_id);
                            if (ccount != null) {
                                Integer existing_value = cbeckincountmap.get(business_id);
                                cbeckincountmap.put(business_id, existing_value + c_infoInt);

                            } else {

                                cbeckincountmap.put(business_id, c_infoInt);

                            }
                        }

                        checkincount++;

                        //make changes  to checkin to hold day and then hours
                        // also store the count.

                        //System.out.println(" i = "+i +"J = "+j + "Value "+c_info);
                    }

                    //System.out.println("checkin [][]= "+i+" "+j+" "+checkin[i][j]);
                }
            }
            //System.out.println("checkin [][]= "+checkin);

            // checkinT = ParseJson.transpose(checkin);

            //            
            //              count++;
            //              System.out.println(count+"\n");
        }

        System.out.println("cbeckincountmap" + cbeckincountmap);
        cbeckincountmap.keySet();
        cbeckinBusinessList = new ArrayList<String>();
        Integer count;
        for (String string : cbeckincountmap.keySet()) {
            count = cbeckincountmap.get(string);
            if (count > keyedin_count) {
                cbeckinBusinessList.add(string);
            }
        }

    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.out.println("Done executing checkin");
    return cbeckinBusinessList;
}