private < E > List < E > loadQueryData ( EntityMetadata entityMetadata , BasicDBObject mongoQuery , BasicDBObject orderBy , int maxResult , int firstResult , boolean isCountQuery , BasicDBObject keys , String ... results ) throws InstantiationException , IllegalAccessException { String documentName = entityMetadata . getTableName ( ) ; List entities = new ArrayList < E > ( ) ; Object object = getDBCursorInstance ( mongoQuery , orderBy , maxResult , firstResult , keys , documentName , isCountQuery ) ; DBCursor cursor = null ; if ( object instanceof Long ) { List < Long > lst = new ArrayList < Long > ( ) ; lst . add ( ( Long ) object ) ; return ( List < E > ) lst ; } else { cursor = ( DBCursor ) object ; } if ( results != null && results . length > 0 ) { DBCollection dbCollection = mongoDb . getCollection ( documentName ) ; KunderaCoreUtils . printQuery ( "Find document: " + mongoQuery , showQuery ) ; for ( int i = 1 ; i < results . length ; i ++ ) { String result = results [ i ] ; // If User wants search on a column within a particular super // column, // fetch that embedded object collection only // otherwise retrieve whole entity // TODO: improve code if ( result != null && result . indexOf ( "." ) >= 0 ) { // TODO i need to discuss with Amresh before modifying it. entities . addAll ( handler . getEmbeddedObjectList ( dbCollection , entityMetadata , documentName , mongoQuery , result , orderBy , maxResult , firstResult , keys , kunderaMetadata ) ) ; return entities ; } } } log . debug ( "Fetching data from " + documentName + " for Filter " + mongoQuery . toString ( ) ) ; while ( cursor . hasNext ( ) ) { DBObject fetchedDocument = cursor . next ( ) ; populateEntity ( entityMetadata , entities , fetchedDocument ) ; } return entities ; }
Load query data .