Search in sources :

Example 1 with DateTimeUtilities

use of com.khartec.waltz.common.DateTimeUtilities 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(er -> er.id()).orElse(null));
    return record;
}
Also used : SurveyQuestionResponseRecord(com.khartec.waltz.schema.tables.records.SurveyQuestionResponseRecord) DateTimeUtilities(com.khartec.waltz.common.DateTimeUtilities) EntityReference(com.khartec.waltz.model.EntityReference) ImmutableSurveyQuestionResponse(com.khartec.waltz.model.survey.ImmutableSurveyQuestionResponse) SurveyQuestionResponse(com.khartec.waltz.model.survey.SurveyQuestionResponse) BigDecimal(java.math.BigDecimal)

Aggregations

DateTimeUtilities (com.khartec.waltz.common.DateTimeUtilities)1 EntityReference (com.khartec.waltz.model.EntityReference)1 ImmutableSurveyQuestionResponse (com.khartec.waltz.model.survey.ImmutableSurveyQuestionResponse)1 SurveyQuestionResponse (com.khartec.waltz.model.survey.SurveyQuestionResponse)1 SurveyQuestionResponseRecord (com.khartec.waltz.schema.tables.records.SurveyQuestionResponseRecord)1 BigDecimal (java.math.BigDecimal)1