public List < DBObject > readFromMongoDBCollection ( String collection , DataTable table ) { List < DBObject > res = new ArrayList < DBObject > ( ) ; List < String [ ] > colRel = coltoArrayList ( table ) ; DBCollection aux = this . dataBase . getCollection ( collection ) ; for ( int i = 1 ; i < table . raw ( ) . size ( ) ; i ++ ) { // Obtenemos la fila correspondiente BasicDBObject doc = new BasicDBObject ( ) ; List < String > row = table . raw ( ) . get ( i ) ; for ( int x = 0 ; x < row . size ( ) ; x ++ ) { String [ ] colNameType = colRel . get ( x ) ; Object data = castSTringTo ( colNameType [ 1 ] , row . get ( x ) ) ; doc . put ( colNameType [ 0 ] , data ) ; } DBCursor cursor = aux . find ( doc ) ; try { while ( cursor . hasNext ( ) ) { res . add ( cursor . next ( ) ) ; } } finally { cursor . close ( ) ; } } return res ; }
Read data from a MongoDB collection .