public List < TaxonomyTerm > selectPostTerms ( final long postId , final String taxonomy ) throws SQLException { Connection conn = null ; PreparedStatement stmt = null ; ResultSet rs = null ; List < Long > termIds = Lists . newArrayListWithExpectedSize ( 8 ) ; Timer . Context ctx = metrics . postTermsSelectTimer . time ( ) ; try { conn = connectionSupplier . getConnection ( ) ; stmt = conn . prepareStatement ( selectPostTermsSQL ) ; stmt . setLong ( 1 , postId ) ; rs = stmt . executeQuery ( ) ; while ( rs . next ( ) ) { termIds . add ( rs . getLong ( 1 ) ) ; } } finally { ctx . stop ( ) ; SQLUtil . closeQuietly ( conn , stmt , rs ) ; } if ( termIds . size ( ) == 0 ) { return ImmutableList . of ( ) ; } List < TaxonomyTerm > terms = Lists . newArrayListWithExpectedSize ( termIds . size ( ) ) ; for ( long termId : termIds ) { TaxonomyTerm term = resolveTaxonomyTerm ( termId ) ; if ( term != null && ( taxonomy == null || term . taxonomy . equals ( taxonomy ) ) ) { terms . add ( term ) ; } } return terms ; }
Selects all terms associated with a post .