Skip to content

Commit 9862671

Browse files
authored
Merge pull request #65 from redlink-gmbh/umm/421-step-goal-template
MORE-Platform#421: GoalTemplate for Steps
2 parents 35d8951 + f9faef2 commit 9862671

2 files changed

Lines changed: 136 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.redlink.more.studymanager.component.goaltemplate;
2+
3+
import io.redlink.more.studymanager.core.component.GoalTemplate;
4+
import io.redlink.more.studymanager.core.exception.ConfigurationValidationException;
5+
import io.redlink.more.studymanager.core.properties.GoalTemplateProperties;
6+
import io.redlink.more.studymanager.core.sdk.MoreGoalTemplateSDK;
7+
8+
public class StepGoalTemplate<C extends GoalTemplateProperties> extends GoalTemplate<C> {
9+
10+
11+
protected StepGoalTemplate(MoreGoalTemplateSDK sdk, C properties) throws ConfigurationValidationException {
12+
super(sdk, properties);
13+
}
14+
15+
16+
@Override
17+
public void activate() {
18+
}
19+
20+
@Override
21+
public void deactivate() {
22+
}
23+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package io.redlink.more.studymanager.component.goaltemplate;
2+
3+
import io.redlink.more.studymanager.core.exception.ConfigurationValidationException;
4+
import io.redlink.more.studymanager.core.factory.GoalTemplateFactory;
5+
import io.redlink.more.studymanager.core.measurement.Measurement;
6+
import io.redlink.more.studymanager.core.measurement.MeasurementSet;
7+
import io.redlink.more.studymanager.core.properties.GoalTemplateProperties;
8+
import io.redlink.more.studymanager.core.properties.model.BooleanValue;
9+
import io.redlink.more.studymanager.core.properties.model.IntegerRange;
10+
import io.redlink.more.studymanager.core.properties.model.IntegerRangeValue;
11+
import io.redlink.more.studymanager.core.properties.model.StringListValue;
12+
import io.redlink.more.studymanager.core.properties.model.StringValue;
13+
import io.redlink.more.studymanager.core.properties.model.Value;
14+
import io.redlink.more.studymanager.core.sdk.MoreGoalTemplateSDK;
15+
16+
import java.util.List;
17+
import java.util.Set;
18+
19+
20+
public class StepGoalTemplateFactory extends GoalTemplateFactory<StepGoalTemplate<GoalTemplateProperties>, GoalTemplateProperties> {
21+
22+
public StepGoalTemplateFactory() { }
23+
24+
public static final String FIELD_TARGET_STEPS = "targetSteps";
25+
public static final String FIELD_STEPS = "steps";
26+
public static final String FIELD_QUESTION = "question";
27+
public static final String FIELD_ANSWER = "answer";
28+
public static final String FIELD_TARGET_DAYS_IN_WEEK = "targetDays";
29+
30+
protected static final String STEP_PROPERTY_PREFIX = GOAL_TEMPLATE_PROPERTY_PREFIX + "steps.";
31+
32+
33+
private static final MeasurementSet measurements = new MeasurementSet(
34+
"SELF_ASSESSMENT", Set.of(
35+
new Measurement(FIELD_GOAL_KIND, Measurement.Type.STRING),
36+
new Measurement(FIELD_GOAL_CATEGORY, Measurement.Type.STRING),
37+
new Measurement(FIELD_QUESTION, Measurement.Type.STRING),
38+
new Measurement(FIELD_ANSWER, Measurement.Type.STRING),
39+
new Measurement(FIELD_TARGET_STEPS, Measurement.Type.INTEGER),
40+
new Measurement(FIELD_STEPS, Measurement.Type.INTEGER),
41+
new Measurement(FIELD_TARGET_DAYS_IN_WEEK, Measurement.Type.INTEGER)));
42+
43+
44+
@Override
45+
public String getId() {
46+
return "steps";
47+
}
48+
49+
@Override
50+
public MeasurementSet getMeasurementSet() {
51+
return measurements;
52+
}
53+
54+
public List<Value> getProperties() {
55+
return List.of(
56+
CONFIG_SECTION_CONFIGURATION,
57+
//GOAL_TITLE_STATE, -> title can not be modified by user!
58+
//ALLOW_INSTANCES_STATE -> not multiple instances of boolean goals
59+
//CUSTOM_ADHERENCE_CHECKS_STATE, //allow to enable/disable custom adherence checks for multiple checks per day
60+
//ADHERENCE_CHECK_BASED_SCHEDULE_STATE, only once a day in the evening
61+
BASELINE_TRACKING_STATE, //allow to configure baseline tracking for boolean goals (default enabled)
62+
63+
CONFIG_SECTION_GOAL_CONFIGURATION,
64+
new IntegerRangeValue( "steps.stepRange")
65+
.setMin(1)
66+
.setMax(Integer.MAX_VALUE)
67+
.setName(STEP_PROPERTY_PREFIX + "goal.stepRange.name")
68+
.setDescription(STEP_PROPERTY_PREFIX + "goal.stepRange.description")
69+
.setDefaultValue(new IntegerRange(500, 10000))
70+
.setRequired(true),
71+
DAYS_OF_WEEK,
72+
73+
CONFIG_SECTION_STATUS,
74+
STATUS_100_PERCENT_REACHED,
75+
STATUS_75_PERCENT_REACHED.copyOf()
76+
.setDefaultValue("Dein Ziel ist zum greifen nah. Noch ein kleiner Spaziergang und Du hast es geschafft!"),
77+
STATUS_0_PERCENT_REACHED.copyOf()
78+
.setDefaultValue("Du bist auf dem richtigen Weg. Jede Schritt macht Dich stärker."),
79+
80+
81+
CONFIG_SECTION_SELF_REPORT,
82+
new StringValue("question")
83+
.setName(STEP_PROPERTY_PREFIX + ".question.name")
84+
.setDescription(STEP_PROPERTY_PREFIX + "question.description")
85+
.setRequired(false),
86+
new StringListValue("answers")
87+
.setMinSize(2)
88+
.setMaxSize(10)
89+
.setName(STEP_PROPERTY_PREFIX + "goal.answer.name")
90+
.setDescription(STEP_PROPERTY_PREFIX + "goal.answer.description")
91+
.setDefaultValue(List.of(
92+
"No",
93+
"Yes"
94+
))
95+
.setRequired(false),
96+
new BooleanValue("singleChoiceState")
97+
.setName(STEP_PROPERTY_PREFIX + ".singleChoiceState.name")
98+
.setDescription(STEP_PROPERTY_PREFIX + "singleChoiceState.description")
99+
.setRequired(false)
100+
);
101+
}
102+
103+
@Override
104+
public Class<GoalTemplateProperties> getPropertyClass() {
105+
return GoalTemplateProperties.class;
106+
}
107+
108+
@Override
109+
public StepGoalTemplate<GoalTemplateProperties> create(MoreGoalTemplateSDK sdk, GoalTemplateProperties properties) throws ConfigurationValidationException {
110+
return new StepGoalTemplate<>(sdk, properties);
111+
}
112+
113+
}

0 commit comments

Comments
 (0)