Search in sources :

Example 1 with DateTimeUtilities

use of org.finos.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(EntityReference::id).orElse(null));
    record.setListResponseConcat(questionResponse.listResponse().filter(l -> !l.isEmpty()).map(l -> join(l, "; ")).orElse(null));
    return record;
}
Also used : StringUtilities.join(org.finos.waltz.common.StringUtilities.join) DSL(org.jooq.impl.DSL) Tables(org.finos.waltz.schema.Tables) EntityKind(org.finos.waltz.model.EntityKind) Autowired(org.springframework.beans.factory.annotation.Autowired) ListUtilities.newArrayList(org.finos.waltz.common.ListUtilities.newArrayList) EntityReference.mkRef(org.finos.waltz.model.EntityReference.mkRef) SURVEY_INSTANCE(org.finos.waltz.schema.tables.SurveyInstance.SURVEY_INSTANCE) Checks.checkTrue(org.finos.waltz.common.Checks.checkTrue) BigDecimal(java.math.BigDecimal) SetUtilities.map(org.finos.waltz.common.SetUtilities.map) SURVEY_QUESTION_LIST_RESPONSE(org.finos.waltz.schema.Tables.SURVEY_QUESTION_LIST_RESPONSE) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) org.jooq(org.jooq) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) Repository(org.springframework.stereotype.Repository) SURVEY_QUESTION_RESPONSE(org.finos.waltz.schema.tables.SurveyQuestionResponse.SURVEY_QUESTION_RESPONSE) CollectionUtilities.first(org.finos.waltz.common.CollectionUtilities.first) StringUtilities.ifEmpty(org.finos.waltz.common.StringUtilities.ifEmpty) org.finos.waltz.model.survey(org.finos.waltz.model.survey) SurveyQuestionListResponseRecord(org.finos.waltz.schema.tables.records.SurveyQuestionListResponseRecord) Optional.ofNullable(java.util.Optional.ofNullable) ListUtilities.isEmpty(org.finos.waltz.common.ListUtilities.isEmpty) Timestamp(java.sql.Timestamp) Set(java.util.Set) Collectors(java.util.stream.Collectors) Date(java.sql.Date) SURVEY_RUN(org.finos.waltz.schema.Tables.SURVEY_RUN) SurveyQuestionResponseRecord(org.finos.waltz.schema.tables.records.SurveyQuestionResponseRecord) List(java.util.List) Checks.checkNotNull(org.finos.waltz.common.Checks.checkNotNull) Tuple.tuple(org.jooq.lambda.tuple.Tuple.tuple) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) InlineSelectFieldFactory(org.finos.waltz.data.InlineSelectFieldFactory) EntityReference(org.finos.waltz.model.EntityReference) Optional(java.util.Optional) SurveyQuestionResponseRecord(org.finos.waltz.schema.tables.records.SurveyQuestionResponseRecord) DateTimeUtilities(org.finos.waltz.common.DateTimeUtilities) EntityReference(org.finos.waltz.model.EntityReference) BigDecimal(java.math.BigDecimal)

Aggregations

BigDecimal (java.math.BigDecimal)1 Date (java.sql.Date)1 Timestamp (java.sql.Timestamp)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Set (java.util.Set)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 BiConsumer (java.util.function.BiConsumer)1 Collectors (java.util.stream.Collectors)1 Checks.checkNotNull (org.finos.waltz.common.Checks.checkNotNull)1 Checks.checkTrue (org.finos.waltz.common.Checks.checkTrue)1 CollectionUtilities.first (org.finos.waltz.common.CollectionUtilities.first)1 DateTimeUtilities (org.finos.waltz.common.DateTimeUtilities)1 ListUtilities.isEmpty (org.finos.waltz.common.ListUtilities.isEmpty)1 ListUtilities.newArrayList (org.finos.waltz.common.ListUtilities.newArrayList)1 SetUtilities.map (org.finos.waltz.common.SetUtilities.map)1 StringUtilities.ifEmpty (org.finos.waltz.common.StringUtilities.ifEmpty)1 StringUtilities.join (org.finos.waltz.common.StringUtilities.join)1