private void populateQueryComponents ( EntityMetadata m , QueryComponent sq ) { boolean hasChildren = false ; if ( sq . children != null && sq . children . size ( ) > 0 ) { hasChildren = true ; for ( QueryComponent subQ : sq . children ) { populateQueryComponents ( m , subQ ) ; } } if ( sq . clauses . size ( ) > 0 || hasChildren ) { if ( sq . clauses . size ( ) > 0 ) { sq . actualQuery = createSubMongoQuery ( m , sq . clauses ) ; } if ( hasChildren ) { List < BasicDBObject > childQs = new ArrayList < BasicDBObject > ( ) ; if ( sq . clauses . size ( ) > 0 ) childQs . add ( sq . actualQuery ) ; for ( QueryComponent subQ : sq . children ) { childQs . add ( subQ . actualQuery ) ; } if ( childQs . size ( ) == 1 ) { sq . actualQuery = childQs . get ( 0 ) ; } else if ( sq . isAnd ) { BasicDBObject dbo = new BasicDBObject ( "$and" , childQs ) ; sq . actualQuery = dbo ; } else { BasicDBObject dbo = new BasicDBObject ( "$or" , childQs ) ; sq . actualQuery = dbo ; } } } }
Populate query components .