From 372ea35c772369a034c2a2d1bebdf6909f104dc3 Mon Sep 17 00:00:00 2001 From: Andi Huber Date: Mon, 5 Aug 2024 13:27:27 +0200 Subject: [PATCH] reporting: adding missing respondent columns --- .../recall24/reporter/dom/ConsumptionRow.java | 40 ++++++++++++++----- .../reporter/tabular/TabularReporters.java | 10 +++++ .../src/main/resources/companion-schema.yaml | 15 ++++++- .../resources/records/ConsumptionRow.yaml | 15 ++++++- 4 files changed, 67 insertions(+), 13 deletions(-) diff --git a/recall24/reporter/src/main/java/dita/recall24/reporter/dom/ConsumptionRow.java b/recall24/reporter/src/main/java/dita/recall24/reporter/dom/ConsumptionRow.java index 95c457dc..d485bb92 100644 --- a/recall24/reporter/src/main/java/dita/recall24/reporter/dom/ConsumptionRow.java +++ b/recall24/reporter/src/main/java/dita/recall24/reporter/dom/ConsumptionRow.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -19,12 +19,10 @@ // Auto-generated by Causeway-Stuff code generator. package dita.recall24.reporter.dom; +import jakarta.inject.Named; +import java.lang.String; import java.math.BigDecimal; - import javax.annotation.processing.Generated; - -import jakarta.inject.Named; - import org.apache.causeway.applib.annotation.DomainObject; import org.apache.causeway.applib.annotation.DomainObjectLayout; import org.apache.causeway.applib.annotation.ObjectSupport; @@ -40,6 +38,11 @@ * respondent identifier, * unique to the * corresponding survey + * @param respondentSex 1=male + * 2=female + * @param respondentAge age at first + * interview day + * =ageInDays/365.2422 * @param interviewOrdinal respondent's * n-th interview * (chronological) @@ -82,6 +85,23 @@ public record ConsumptionRow( @PropertyLayout( fieldSetId = "details", sequence = "3", + describedAs = "1=male\n" + + "2=female", + hidden = Where.NOWHERE + ) + int respondentSex, + @PropertyLayout( + fieldSetId = "details", + sequence = "4", + describedAs = "age at first\n" + + "interview day\n" + + "=ageInDays/365.2422", + hidden = Where.NOWHERE + ) + BigDecimal respondentAge, + @PropertyLayout( + fieldSetId = "details", + sequence = "5", describedAs = "respondent's\n" + "n-th interview\n" + "(chronological)", @@ -90,7 +110,7 @@ public record ConsumptionRow( int interviewOrdinal, @PropertyLayout( fieldSetId = "details", - sequence = "4", + sequence = "6", describedAs = "food\n" + "consumption\n" + "occasion\n" @@ -100,7 +120,7 @@ public record ConsumptionRow( String fco, @PropertyLayout( fieldSetId = "details", - sequence = "5", + sequence = "7", describedAs = "meal happened\n" + "when and where", hidden = Where.NOWHERE @@ -108,7 +128,7 @@ public record ConsumptionRow( String meal, @PropertyLayout( fieldSetId = "details", - sequence = "6", + sequence = "8", describedAs = "quantity\n" + "consumed [g]", hidden = Where.NOWHERE @@ -116,7 +136,7 @@ public record ConsumptionRow( BigDecimal quantity, @PropertyLayout( fieldSetId = "details", - sequence = "7", + sequence = "9", describedAs = "Nut.: Energie inkl. Ballaststoffen[kcal]", hidden = Where.NOWHERE ) diff --git a/recall24/reporter/src/main/java/dita/recall24/reporter/tabular/TabularReporters.java b/recall24/reporter/src/main/java/dita/recall24/reporter/tabular/TabularReporters.java index a427d74b..82c8a084 100644 --- a/recall24/reporter/src/main/java/dita/recall24/reporter/tabular/TabularReporters.java +++ b/recall24/reporter/src/main/java/dita/recall24/reporter/tabular/TabularReporters.java @@ -19,7 +19,9 @@ package dita.recall24.reporter.tabular; import java.io.File; +import java.math.BigDecimal; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.HashSet; import java.util.Locale; @@ -41,6 +43,7 @@ import dita.commons.qmap.QualifiedMapEntry; import dita.commons.sid.SemanticIdentifier; import dita.commons.sid.SemanticIdentifierSet; +import dita.commons.types.Sex; import dita.recall24.dto.Interview24; import dita.recall24.dto.InterviewSet24; import dita.recall24.dto.Meal24; @@ -95,6 +98,8 @@ private static class RowFactory { final Set respondentAliasSeenBefore = new HashSet<>(); int respondentOrdinal; String respondentAlias; + Sex respondentSex; + long respondentAgeInDays; int interviewOrdinal; String fco; String meal; @@ -107,6 +112,8 @@ ConsumptionRow row( return new ConsumptionRow( respondentOrdinal, respondentAlias, + respondentSex.ordinal(), + BigDecimal.valueOf(Math.round(respondentAgeInDays/36.52422)).scaleByPowerOfTen(-1), interviewOrdinal, fco, meal, @@ -136,6 +143,9 @@ public void report(final File file) { case Interview24.Dto iv -> { rowFactory.setRespondentAlias(iv.parentRespondent().alias()); rowFactory.setInterviewOrdinal(iv.interviewOrdinal()); + rowFactory.setRespondentSex(iv.parentRespondent().sex()); + rowFactory.setRespondentAgeInDays( + ChronoUnit.DAYS.between(iv.parentRespondent().dateOfBirth(), iv.interviewDate())); } case Meal24.Dto meal -> { rowFactory.setFco(meal.foodConsumptionOccasionId()); diff --git a/recall24/reporter/src/main/resources/companion-schema.yaml b/recall24/reporter/src/main/resources/companion-schema.yaml index 80113971..cc85075f 100644 --- a/recall24/reporter/src/main/resources/companion-schema.yaml +++ b/recall24/reporter/src/main/resources/companion-schema.yaml @@ -40,6 +40,19 @@ viewmodels: respondent identifier, unique to the corresponding survey + respondentSex: + type: int + required: true + description: | + 1=male + 2=female + respondentAge: + type: BigDecimal + required: true + description: | + age at first + interview day + =ageInDays/365.2422 interviewOrdinal: type: int required: true @@ -68,7 +81,7 @@ viewmodels: quantity consumed [g] GCALZB: - type: java.lang.Number + type: BigDecimal required: true description: | Nut.: Energie inkl. Ballaststoffen[kcal] diff --git a/recall24/reporter/src/main/resources/records/ConsumptionRow.yaml b/recall24/reporter/src/main/resources/records/ConsumptionRow.yaml index 9a1fd34f..b8ef3a16 100644 --- a/recall24/reporter/src/main/resources/records/ConsumptionRow.yaml +++ b/recall24/reporter/src/main/resources/records/ConsumptionRow.yaml @@ -18,7 +18,7 @@ # ----------------------------------------------------------- viewmodel: - generator: record + generator: record namespace: reporter.dom fields: respondentOrdinal: @@ -34,6 +34,17 @@ viewmodel: respondent identifier, unique to the corresponding survey + respondentSex: + type: int + description: | + 1=male + 2=female + respondentAge: + type: BigDecimal + description: | + age at first + interview day + =ageInDays/365.2422 interviewOrdinal: type: int description: | @@ -58,6 +69,6 @@ viewmodel: quantity consumed [g] GCALZB: - type: java.lang.Number + type: BigDecimal description: | Nut.: Energie inkl. Ballaststoffen[kcal] \ No newline at end of file