use of org.finos.waltz.schema.tables.SurveyQuestionResponse.SURVEY_QUESTION_RESPONSE in project waltz by khartec.
the class SurveyQuestionResponseDao method mkRecord.
private SurveyQuestionResponseRecord mkRecord(SurveyInstanceQuestionResponse response) {
SurveyQuestionResponse questionResponse = response.questionResponse();
Optional<EntityReference> entityResponse = questionResponse.entityResponse();
SurveyQuestionResponseRecord record = dsl.newRecord(SURVEY_QUESTION_RESPONSE);
record.setSurveyInstanceId(response.surveyInstanceId());
record.setQuestionId(questionResponse.questionId());
record.setPersonId(response.personId());
record.setLastUpdatedAt(Timestamp.valueOf(response.lastUpdatedAt()));
record.setComment(questionResponse.comment().map(c -> ifEmpty(c, null)).orElse(null));
record.setStringResponse(questionResponse.stringResponse().map(s -> ifEmpty(s, null)).orElse(null));
record.setNumberResponse(questionResponse.numberResponse().map(BigDecimal::valueOf).orElse(null));
record.setBooleanResponse(questionResponse.booleanResponse().orElse(null));
record.setDateResponse(questionResponse.dateResponse().map(DateTimeUtilities::toSqlDate).orElse(null));
record.setEntityResponseKind(entityResponse.map(er -> er.kind().name()).orElse(null));
record.setEntityResponseId(entityResponse.map(EntityReference::id).orElse(null));
record.setListResponseConcat(questionResponse.listResponse().filter(l -> !l.isEmpty()).map(l -> join(l, "; ")).orElse(null));
return record;
}
Aggregations