Search in sources :

Example 1 with SurveyQuestion

use of org.finos.waltz.model.survey.SurveyQuestion in project waltz by khartec.

the class SurveyInstanceExtractor method mkCSVReport.

private byte[] mkCSVReport(List<SurveyQuestion> questions, List<List<Object>> reportRows) throws IOException {
    List<String> headers = mkHeaderStrings(questions);
    StringWriter writer = new StringWriter();
    CsvListWriter csvWriter = new CsvListWriter(writer, CsvPreference.EXCEL_PREFERENCE);
    csvWriter.write(headers);
    reportRows.forEach(unchecked(row -> csvWriter.write(simplify(row))));
    csvWriter.flush();
    return writer.toString().getBytes();
}
Also used : DSL(org.jooq.impl.DSL) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) DIConfiguration(org.finos.waltz.service.DIConfiguration) SetUtilities.asSet(org.finos.waltz.common.SetUtilities.asSet) SURVEY_INSTANCE(org.finos.waltz.schema.tables.SurveyInstance.SURVEY_INSTANCE) SurveyInstanceStatus(org.finos.waltz.model.survey.SurveyInstanceStatus) Tuple2(org.jooq.lambda.tuple.Tuple2) Tuple3(org.jooq.lambda.tuple.Tuple3) ExtractorUtilities.sanitizeSheetName(org.finos.waltz.web.endpoints.extracts.ExtractorUtilities.sanitizeSheetName) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CsvListWriter(org.supercsv.io.CsvListWriter) org.jooq(org.jooq) Cell(org.apache.poi.ss.usermodel.Cell) SXSSFSheet(org.apache.poi.xssf.streaming.SXSSFSheet) CellRangeAddress(org.apache.poi.ss.util.CellRangeAddress) EnumUtilities.names(org.finos.waltz.common.EnumUtilities.names) SurveyQuestion(org.finos.waltz.model.survey.SurveyQuestion) StringUtilities.mkSafe(org.finos.waltz.common.StringUtilities.mkSafe) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MapUtilities.indexBy(org.finos.waltz.common.MapUtilities.indexBy) Stream(java.util.stream.Stream) InlineSelectFieldFactory(org.finos.waltz.data.InlineSelectFieldFactory) WebUtilities(org.finos.waltz.web.WebUtilities) SetUtilities(org.finos.waltz.common.SetUtilities) CellType(org.apache.poi.ss.usermodel.CellType) Spark.get(spark.Spark.get) java.util(java.util) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EntityKind(org.finos.waltz.model.EntityKind) CsvPreference(org.supercsv.prefs.CsvPreference) SurveyQuestionDao(org.finos.waltz.data.survey.SurveyQuestionDao) SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) Service(org.springframework.stereotype.Service) Request(spark.Request) SURVEY_RUN(org.finos.waltz.schema.tables.SurveyRun.SURVEY_RUN) SURVEY_QUESTION(org.finos.waltz.schema.tables.SurveyQuestion.SURVEY_QUESTION) SURVEY_QUESTION_RESPONSE(org.finos.waltz.schema.tables.SurveyQuestionResponse.SURVEY_QUESTION_RESPONSE) CollectionUtilities.first(org.finos.waltz.common.CollectionUtilities.first) Logger(org.slf4j.Logger) Optional.ofNullable(java.util.Optional.ofNullable) StringWriter(java.io.StringWriter) SURVEY_TEMPLATE(org.finos.waltz.schema.tables.SurveyTemplate.SURVEY_TEMPLATE) IOException(java.io.IOException) Collectors.toList(java.util.stream.Collectors.toList) CheckedConsumer.unchecked(org.jooq.lambda.fi.util.function.CheckedConsumer.unchecked) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) ListUtilities(org.finos.waltz.common.ListUtilities) FunctionUtilities(org.finos.waltz.common.FunctionUtilities) Row(org.apache.poi.ss.usermodel.Row) SetUtilities.fromArray(org.finos.waltz.common.SetUtilities.fromArray) StringWriter(java.io.StringWriter) CsvListWriter(org.supercsv.io.CsvListWriter)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 java.util (java.util)1 Optional.ofNullable (java.util.Optional.ofNullable)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors.toList (java.util.stream.Collectors.toList)1 Stream (java.util.stream.Stream)1 Cell (org.apache.poi.ss.usermodel.Cell)1 CellType (org.apache.poi.ss.usermodel.CellType)1 Row (org.apache.poi.ss.usermodel.Row)1 CellRangeAddress (org.apache.poi.ss.util.CellRangeAddress)1 SXSSFSheet (org.apache.poi.xssf.streaming.SXSSFSheet)1 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)1 CollectionUtilities.first (org.finos.waltz.common.CollectionUtilities.first)1 EnumUtilities.names (org.finos.waltz.common.EnumUtilities.names)1 FunctionUtilities (org.finos.waltz.common.FunctionUtilities)1 ListUtilities (org.finos.waltz.common.ListUtilities)1 MapUtilities.indexBy (org.finos.waltz.common.MapUtilities.indexBy)1 SetUtilities (org.finos.waltz.common.SetUtilities)1