public static byte [ ] exportQueryCommentsAsCsv ( Locale locale , ReplierExportStrategy replierExportStrategy , List < QueryReply > replies , Query query , PanelStamp stamp ) throws IOException { QueryPageDAO queryPageDAO = new QueryPageDAO ( ) ; List < QueryPage > queryPages = queryPageDAO . listByQuery ( query ) ; Collections . sort ( queryPages , new QueryPageNumberComparator ( ) ) ; String [ ] columnHeaders = new String [ ] { getReplierExportStrategyLabel ( locale , replierExportStrategy ) , Messages . getInstance ( ) . getText ( locale , "panelAdmin.query.export.csvCommentAnswerColumn" ) , Messages . getInstance ( ) . getText ( locale , "panelAdmin.query.export.csvCommentCommentColumn" ) , Messages . getInstance ( ) . getText ( locale , "panelAdmin.query.export.csvCommentReplyColumn" ) , } ; List < String [ ] > rows = new ArrayList <> ( ) ; for ( QueryPage queryPage : queryPages ) { List < String [ ] > pageRows = exportQueryPageCommentsAsCsv ( replierExportStrategy , replies , stamp , queryPage ) ; if ( ! pageRows . isEmpty ( ) ) { rows . add ( new String [ ] { "" , "" , "" , "" } ) ; rows . add ( new String [ ] { queryPage . getTitle ( ) , "" , "" , "" } ) ; rows . add ( new String [ ] { "" , "" , "" , "" } ) ; rows . addAll ( pageRows ) ; } } return writeCsv ( columnHeaders , rows ) ; }
Export query comments into CSV byte array