private static String getSQLWhereClauseString ( PoiCategoryFilter filter , int version ) { Collection < PoiCategory > superCategories = filter . getAcceptedSuperCategories ( ) ; if ( superCategories . isEmpty ( ) ) { return "" ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( " AND (" ) ; // for each super category for ( Iterator < PoiCategory > superCatIter = superCategories . iterator ( ) ; superCatIter . hasNext ( ) ; ) { PoiCategory superCat = superCatIter . next ( ) ; // All child categories of the super category, including their children Collection < PoiCategory > categories = superCat . deepChildren ( ) ; // Don't forget the super category itself in the search! categories . add ( superCat ) ; if ( version < 2 ) { sb . append ( DbConstants . FIND_IN_BOX_CLAUSE_WHERE_CATEGORY_IN_V1 ) ; } else { sb . append ( DbConstants . FIND_IN_BOX_CLAUSE_WHERE_CATEGORY_IN ) ; } // for each category for ( Iterator < PoiCategory > catIter = categories . iterator ( ) ; catIter . hasNext ( ) ; ) { PoiCategory cat = catIter . next ( ) ; sb . append ( cat . getID ( ) ) ; if ( catIter . hasNext ( ) ) { sb . append ( ", " ) ; } } sb . append ( ")" ) ; // append OR if it is not the last if ( superCatIter . hasNext ( ) ) { sb . append ( " OR " ) ; } } sb . append ( ")" ) ; return sb . toString ( ) ; }
Gets the WHERE clause for the SQL query that looks up POI entries .