Skip to content

Commit

Permalink
reporting: adding missing respondent columns
Browse files Browse the repository at this point in the history
  • Loading branch information
andi-huber committed Aug 5, 2024
1 parent a908b41 commit 372ea35
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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)",
Expand All @@ -90,7 +110,7 @@ public record ConsumptionRow(
int interviewOrdinal,
@PropertyLayout(
fieldSetId = "details",
sequence = "4",
sequence = "6",
describedAs = "food\n"
+ "consumption\n"
+ "occasion\n"
Expand All @@ -100,23 +120,23 @@ public record ConsumptionRow(
String fco,
@PropertyLayout(
fieldSetId = "details",
sequence = "5",
sequence = "7",
describedAs = "meal happened\n"
+ "when and where",
hidden = Where.NOWHERE
)
String meal,
@PropertyLayout(
fieldSetId = "details",
sequence = "6",
sequence = "8",
describedAs = "quantity\n"
+ "consumed [g]",
hidden = Where.NOWHERE
)
BigDecimal quantity,
@PropertyLayout(
fieldSetId = "details",
sequence = "7",
sequence = "9",
describedAs = "Nut.: Energie inkl. Ballaststoffen[kcal]",
hidden = Where.NOWHERE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -95,6 +98,8 @@ private static class RowFactory {
final Set<String> respondentAliasSeenBefore = new HashSet<>();
int respondentOrdinal;
String respondentAlias;
Sex respondentSex;
long respondentAgeInDays;
int interviewOrdinal;
String fco;
String meal;
Expand All @@ -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,
Expand Down Expand Up @@ -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());
Expand Down
15 changes: 14 additions & 1 deletion recall24/reporter/src/main/resources/companion-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,7 +81,7 @@ viewmodels:
quantity
consumed [g]
GCALZB:
type: java.lang.Number
type: BigDecimal
required: true
description: |
Nut.: Energie inkl. Ballaststoffen[kcal]
Expand Down
15 changes: 13 additions & 2 deletions recall24/reporter/src/main/resources/records/ConsumptionRow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# -----------------------------------------------------------

viewmodel:
generator: record
generator: record
namespace: reporter.dom
fields:
respondentOrdinal:
Expand All @@ -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: |
Expand All @@ -58,6 +69,6 @@ viewmodel:
quantity
consumed [g]
GCALZB:
type: java.lang.Number
type: BigDecimal
description: |
Nut.: Energie inkl. Ballaststoffen[kcal]

0 comments on commit 372ea35

Please sign in to comment.