private static List < String [ ] > exportQueryPageCommentsAsCsv ( ReplierExportStrategy replierExportStrategy , QueryPage queryPage , ReportPageCommentProcessor processor ) { QueryQuestionCommentDAO queryQuestionCommentDAO = new QueryQuestionCommentDAO ( ) ; List < String [ ] > rows = new ArrayList <> ( ) ; processor . processComments ( ) ; List < QueryQuestionComment > rootComments = processor . getRootComments ( ) ; if ( rootComments != null && ! rootComments . isEmpty ( ) ) { Map < Long , List < QueryQuestionComment > > childCommentMap = queryQuestionCommentDAO . listTreesByQueryPage ( queryPage ) ; for ( QueryQuestionComment rootComment : rootComments ) { String rootUser = getReplierExportStrategyValue ( replierExportStrategy , rootComment . getQueryReply ( ) ) ; String rootLabel = processor . getCommentLabel ( rootComment . getId ( ) ) ; rows . add ( new String [ ] { rootUser , rootLabel , rootComment . getComment ( ) , "" } ) ; List < QueryQuestionComment > childComments = childCommentMap . get ( rootComment . getId ( ) ) ; if ( childComments != null ) { childComments . forEach ( childComment -> { String childUser = getReplierExportStrategyValue ( replierExportStrategy , childComment . getQueryReply ( ) ) ; rows . add ( new String [ ] { childUser , "" , "" , childComment . getComment ( ) } ) ; } ) ; } } } return rows ; }
Exports single query page into CSV rows using comment processor