forked from MORE-Platform/more-studymanager-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
#421: GoalTemplate for Steps #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...s/src/main/java/io/redlink/more/studymanager/component/goaltemplate/StepGoalTemplate.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package io.redlink.more.studymanager.component.goaltemplate; | ||
|
|
||
| import io.redlink.more.studymanager.core.component.GoalTemplate; | ||
| import io.redlink.more.studymanager.core.exception.ConfigurationValidationException; | ||
| import io.redlink.more.studymanager.core.properties.GoalTemplateProperties; | ||
| import io.redlink.more.studymanager.core.sdk.MoreGoalTemplateSDK; | ||
|
|
||
| public class StepGoalTemplate<C extends GoalTemplateProperties> extends GoalTemplate<C> { | ||
|
|
||
|
|
||
| protected StepGoalTemplate(MoreGoalTemplateSDK sdk, C properties) throws ConfigurationValidationException { | ||
| super(sdk, properties); | ||
| } | ||
|
|
||
|
|
||
| @Override | ||
| public void activate() { | ||
| } | ||
|
|
||
| @Override | ||
| public void deactivate() { | ||
| } | ||
| } |
113 changes: 113 additions & 0 deletions
113
...ain/java/io/redlink/more/studymanager/component/goaltemplate/StepGoalTemplateFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| package io.redlink.more.studymanager.component.goaltemplate; | ||
|
|
||
| import io.redlink.more.studymanager.core.exception.ConfigurationValidationException; | ||
| import io.redlink.more.studymanager.core.factory.GoalTemplateFactory; | ||
| import io.redlink.more.studymanager.core.measurement.Measurement; | ||
| import io.redlink.more.studymanager.core.measurement.MeasurementSet; | ||
| import io.redlink.more.studymanager.core.properties.GoalTemplateProperties; | ||
| import io.redlink.more.studymanager.core.properties.model.BooleanValue; | ||
| import io.redlink.more.studymanager.core.properties.model.IntegerRange; | ||
| import io.redlink.more.studymanager.core.properties.model.IntegerRangeValue; | ||
| import io.redlink.more.studymanager.core.properties.model.StringListValue; | ||
| import io.redlink.more.studymanager.core.properties.model.StringValue; | ||
| import io.redlink.more.studymanager.core.properties.model.Value; | ||
| import io.redlink.more.studymanager.core.sdk.MoreGoalTemplateSDK; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Set; | ||
|
|
||
|
|
||
| public class StepGoalTemplateFactory extends GoalTemplateFactory<StepGoalTemplate<GoalTemplateProperties>, GoalTemplateProperties> { | ||
|
|
||
| public StepGoalTemplateFactory() { } | ||
|
|
||
| public static final String FIELD_TARGET_STEPS = "targetSteps"; | ||
| public static final String FIELD_STEPS = "steps"; | ||
| public static final String FIELD_QUESTION = "question"; | ||
| public static final String FIELD_ANSWER = "answer"; | ||
| public static final String FIELD_TARGET_DAYS_IN_WEEK = "targetDays"; | ||
|
|
||
| protected static final String STEP_PROPERTY_PREFIX = GOAL_TEMPLATE_PROPERTY_PREFIX + "steps."; | ||
|
|
||
|
|
||
| private static final MeasurementSet measurements = new MeasurementSet( | ||
| "SELF_ASSESSMENT", Set.of( | ||
| new Measurement(FIELD_GOAL_KIND, Measurement.Type.STRING), | ||
| new Measurement(FIELD_GOAL_CATEGORY, Measurement.Type.STRING), | ||
| new Measurement(FIELD_QUESTION, Measurement.Type.STRING), | ||
| new Measurement(FIELD_ANSWER, Measurement.Type.STRING), | ||
| new Measurement(FIELD_TARGET_STEPS, Measurement.Type.INTEGER), | ||
| new Measurement(FIELD_STEPS, Measurement.Type.INTEGER), | ||
| new Measurement(FIELD_TARGET_DAYS_IN_WEEK, Measurement.Type.INTEGER))); | ||
|
|
||
|
|
||
| @Override | ||
| public String getId() { | ||
| return "steps"; | ||
| } | ||
|
|
||
| @Override | ||
| public MeasurementSet getMeasurementSet() { | ||
| return measurements; | ||
| } | ||
|
|
||
| public List<Value> getProperties() { | ||
| return List.of( | ||
| CONFIG_SECTION_CONFIGURATION, | ||
| //GOAL_TITLE_STATE, -> title can not be modified by user! | ||
| //ALLOW_INSTANCES_STATE -> not multiple instances of boolean goals | ||
| //CUSTOM_ADHERENCE_CHECKS_STATE, //allow to enable/disable custom adherence checks for multiple checks per day | ||
| //ADHERENCE_CHECK_BASED_SCHEDULE_STATE, only once a day in the evening | ||
| BASELINE_TRACKING_STATE, //allow to configure baseline tracking for boolean goals (default enabled) | ||
|
|
||
| CONFIG_SECTION_GOAL_CONFIGURATION, | ||
| new IntegerRangeValue( "steps.stepRange") | ||
| .setMin(1) | ||
| .setMax(Integer.MAX_VALUE) | ||
| .setName(STEP_PROPERTY_PREFIX + "goal.stepRange.name") | ||
| .setDescription(STEP_PROPERTY_PREFIX + "goal.stepRange.description") | ||
| .setDefaultValue(new IntegerRange(500, 10000)) | ||
| .setRequired(true), | ||
| DAYS_OF_WEEK, | ||
|
|
||
| CONFIG_SECTION_STATUS, | ||
| STATUS_100_PERCENT_REACHED, | ||
| STATUS_75_PERCENT_REACHED.copyOf() | ||
| .setDefaultValue("Dein Ziel ist zum greifen nah. Noch ein kleiner Spaziergang und Du hast es geschafft!"), | ||
| STATUS_0_PERCENT_REACHED.copyOf() | ||
| .setDefaultValue("Du bist auf dem richtigen Weg. Jede Schritt macht Dich stärker."), | ||
|
|
||
|
|
||
| CONFIG_SECTION_SELF_REPORT, | ||
| new StringValue("question") | ||
| .setName(STEP_PROPERTY_PREFIX + ".question.name") | ||
| .setDescription(STEP_PROPERTY_PREFIX + "question.description") | ||
| .setRequired(false), | ||
| new StringListValue("answers") | ||
| .setMinSize(2) | ||
| .setMaxSize(10) | ||
| .setName(STEP_PROPERTY_PREFIX + "goal.answer.name") | ||
| .setDescription(STEP_PROPERTY_PREFIX + "goal.answer.description") | ||
| .setDefaultValue(List.of( | ||
| "No", | ||
| "Yes" | ||
| )) | ||
| .setRequired(false), | ||
| new BooleanValue("singleChoiceState") | ||
| .setName(STEP_PROPERTY_PREFIX + ".singleChoiceState.name") | ||
| .setDescription(STEP_PROPERTY_PREFIX + "singleChoiceState.description") | ||
| .setRequired(false) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public Class<GoalTemplateProperties> getPropertyClass() { | ||
| return GoalTemplateProperties.class; | ||
| } | ||
|
|
||
| @Override | ||
| public StepGoalTemplate<GoalTemplateProperties> create(MoreGoalTemplateSDK sdk, GoalTemplateProperties properties) throws ConfigurationValidationException { | ||
| return new StepGoalTemplate<>(sdk, properties); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was mir da noch eingefallen ist. evtl brauchen wir ein toggle ob das ziel vom garmin genommen wird oder das ziel direkt eingegeben werden kann. glaub das haben wir noch nicht drinnen oder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janoliver20 hast Du das in der App implementiert?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ist ausgeredet. Die DAILY_STEPS daten von GarminConnect sind derzeit nicht verfügbar. Schauen erstmal warum und dann updaten wir das GoalTemplate