forked from MORE-Platform/more-studymanager-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Goal template api impl / Goal SDK / AmoutOf-GoalTemplate #50
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
Show all changes
16 commits
Select commit
Hold shift + click to select a range
428fce2
#326: API refinement and fixes
67e042f
#326: Implementation of the Goal APIs for the StudyManager
3b5f59f
Merge branch 'develop' into umm/326-goal-template-api-impl
0a33bd6
326: Return a default StudyGoalConfig if not yet present
e6c808d
#326: Fixed unit test after refactoring the applicationContext.getBea…
04c22d8
#326: Several fixes and adaptations to tests. Also changed the depend…
3de64bd
#326 fix for null check_id
25071e6
#326: Refinements to the GoalTemplates + Fixes in keys
8a99ab4
This changes the StringTemplateValue so that the stored value is allo…
8653c9b
Fixed a casting issue
janoliver20 43659cb
Merge remote-tracking branch 'origin/umm/326-goal-template-api-impl' …
janoliver20 679eab9
Fixed a StackOverflow Exception
janoliver20 3986939
Documentation
janoliver20 6573c57
Setting min/max values for IntegerRangeValues
d6de703
Merge branch 'umm/326-goal-template-api-impl' of github.com:redlink-g…
c0115ca
#326: This fixes the validation error for IntegerRangeValue. Also add…
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
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
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
25 changes: 25 additions & 0 deletions
25
...-core/src/main/java/io/redlink/more/studymanager/core/properties/model/ConfigSection.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,25 @@ | ||
| /* | ||
| * Copyright LBI-DHP and/or licensed to LBI-DHP under one or more | ||
| * contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute | ||
| * for Digital Health and Prevention -- A research institute of the | ||
| * Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur | ||
| * Förderung der wissenschaftlichen Forschung). | ||
| * Licensed under the Elastic License 2.0. | ||
| */ | ||
| package io.redlink.more.studymanager.core.properties.model; | ||
|
|
||
| public class ConfigSection extends Value<Void> { | ||
| public ConfigSection(String id) { | ||
| super(id); | ||
| } | ||
|
|
||
| @Override | ||
| public Class<Void> getValueType() { | ||
| return Void.class; | ||
| } | ||
|
|
||
| @Override | ||
| public String getType() { | ||
| return "GROUPING"; | ||
| } | ||
| } |
51 changes: 51 additions & 0 deletions
51
...r-core/src/main/java/io/redlink/more/studymanager/core/properties/model/IntegerRange.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,51 @@ | ||
| package io.redlink.more.studymanager.core.properties.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonAlias; | ||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| public class IntegerRange { | ||
|
|
||
| // Defines the lower set value of the range | ||
| private final int lower; | ||
| // Defines the upper set value of the range | ||
| private final int upper; | ||
|
|
||
| @JsonCreator | ||
| public IntegerRange( | ||
| @JsonProperty("lower") @JsonAlias({"min"}) int lower, | ||
| @JsonProperty("upper") @JsonAlias({"max"}) int upper) { | ||
| this.lower = lower; | ||
| this.upper = upper; | ||
| } | ||
|
|
||
| public int getLower() { | ||
| return lower; | ||
| } | ||
|
|
||
| public int getUpper() { | ||
| return upper; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| IntegerRange that = (IntegerRange) o; | ||
| return lower == that.lower && upper == that.upper; | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(lower, upper); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "IntegerRange{" + | ||
| "lower=" + lower + | ||
| ", upper=" + upper + | ||
| '}'; | ||
| } | ||
| } | ||
63 changes: 63 additions & 0 deletions
63
...e/src/main/java/io/redlink/more/studymanager/core/properties/model/IntegerRangeValue.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,63 @@ | ||
| /* | ||
| * Copyright LBI-DHP and/or licensed to LBI-DHP under one or more | ||
| * contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute | ||
| * for Digital Health and Prevention -- A research institute of the | ||
| * Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur | ||
| * Förderung der wissenschaftlichen Forschung). | ||
| * Licensed under the Elastic License 2.0. | ||
| */ | ||
| package io.redlink.more.studymanager.core.properties.model; | ||
|
|
||
| import io.redlink.more.studymanager.core.validation.ValidationIssue; | ||
|
|
||
| public class IntegerRangeValue extends Value<IntegerRange> { | ||
|
|
||
| // Defines the minimum value of the range, not equal to IntegerRange.lower which defines the user set lower bound | ||
| private int min = 0; | ||
| // Defines the maximum value of the range, not equal to IntegerRange.upper which defines the user set upper bound | ||
| private int max = Integer.MAX_VALUE; | ||
|
|
||
| public IntegerRangeValue(String id) { | ||
| super(id); | ||
| } | ||
|
|
||
| @Override | ||
| public String getType() { | ||
| return "INTEGER_RANGE"; | ||
| } | ||
|
|
||
| @Override | ||
| public Class<IntegerRange> getValueType() { | ||
| return IntegerRange.class; | ||
| } | ||
|
|
||
| @Override | ||
| public ValidationIssue doValidate(IntegerRange range) { | ||
| if (range != null && range.getLower() > range.getUpper()) { | ||
| return ValidationIssue.error(this, "Lower bound of RangeValue MUST NOT be higer as the upper bound (lower:" + range.getLower() + ", upper: " + range.getUpper() + ")"); | ||
| } | ||
| if (range != null && (range.getLower() < getMin() || range.getUpper() > getMax())) { | ||
| return ValidationIssue.error(this, "Value must between " + getMin() + " and " + getMax()); | ||
| } | ||
| return ValidationIssue.NONE; | ||
| } | ||
|
|
||
| public int getMin() { | ||
| return min; | ||
| } | ||
|
|
||
| public IntegerRangeValue setMin(int min) { | ||
| this.min = min; | ||
| return this; | ||
| } | ||
|
|
||
| public int getMax() { | ||
| return max; | ||
| } | ||
|
|
||
| public IntegerRangeValue setMax(int max) { | ||
| this.max = max; | ||
| return this; | ||
| } | ||
|
|
||
| } |
42 changes: 42 additions & 0 deletions
42
...e/src/main/java/io/redlink/more/studymanager/core/properties/model/NamedIntegerRange.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,42 @@ | ||
| package io.redlink.more.studymanager.core.properties.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| public class NamedIntegerRange extends IntegerRange { | ||
|
|
||
| private String name; | ||
|
|
||
| @JsonCreator | ||
| public NamedIntegerRange(String name, int lower, int upper) { | ||
| super(lower, upper); | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
| if (!super.equals(o)) return false; | ||
| NamedIntegerRange that = (NamedIntegerRange) o; | ||
| return Objects.equals(name, that.name); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hash(super.hashCode(), name); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "NamedIntegerRange{" + | ||
| "name='" + name + '\'' + | ||
| "lower=" + getLower() + | ||
| ", upper=" + getUpper() + | ||
| '}'; | ||
| } | ||
| } |
64 changes: 64 additions & 0 deletions
64
.../main/java/io/redlink/more/studymanager/core/properties/model/NamedIntegerRangeValue.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,64 @@ | ||
| /* | ||
| * Copyright LBI-DHP and/or licensed to LBI-DHP under one or more | ||
| * contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute | ||
| * for Digital Health and Prevention -- A research institute of the | ||
| * Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur | ||
| * Förderung der wissenschaftlichen Forschung). | ||
| * Licensed under the Elastic License 2.0. | ||
| */ | ||
| package io.redlink.more.studymanager.core.properties.model; | ||
|
|
||
| import io.redlink.more.studymanager.core.validation.ValidationIssue; | ||
|
|
||
| public class NamedIntegerRangeValue extends Value<NamedIntegerRange> { | ||
|
|
||
| private int min = 0; | ||
| private int max = Integer.MAX_VALUE; | ||
|
|
||
| public NamedIntegerRangeValue(String id) { | ||
| super(id); | ||
| } | ||
|
|
||
| @Override | ||
| public String getType() { | ||
| return "INTEGER_RANGE"; | ||
| } | ||
|
|
||
| @Override | ||
| public Class<NamedIntegerRange> getValueType() { | ||
| return NamedIntegerRange.class; | ||
| } | ||
|
|
||
| @Override | ||
| public ValidationIssue doValidate(NamedIntegerRange namedRange) { | ||
| if(namedRange != null && namedRange.getName() == null || namedRange.getName().isBlank()) { | ||
| return ValidationIssue.error(this, "The name of the RangeValue MUST NOT be blank"); | ||
| } | ||
| if(namedRange != null && namedRange.getLower() > namedRange.getUpper()) { | ||
| return ValidationIssue.error(this, "Lower bound of RangeValue MUST NOT be higer as the upper bound (lower:" + namedRange.getLower() + ", upper: " + namedRange.getUpper() + ")"); | ||
| } | ||
| if (namedRange != null && (namedRange.getLower() < getMin() || namedRange.getUpper() > getMax()) ) { | ||
| return ValidationIssue.error(this, "Value must between " + getMin() + " and " + getMax()); | ||
| } | ||
| return ValidationIssue.NONE; | ||
| } | ||
|
|
||
| public int getMin() { | ||
| return min; | ||
| } | ||
|
|
||
| public NamedIntegerRangeValue setMin(int min) { | ||
| this.min = min; | ||
| return this; | ||
| } | ||
|
|
||
| public int getMax() { | ||
| return max; | ||
| } | ||
|
|
||
| public NamedIntegerRangeValue setMax(int max) { | ||
| this.max = max; | ||
| return this; | ||
| } | ||
|
|
||
| } |
57 changes: 57 additions & 0 deletions
57
...src/main/java/io/redlink/more/studymanager/core/properties/model/StringTemplateValue.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,57 @@ | ||
| package io.redlink.more.studymanager.core.properties.model; | ||
|
|
||
| import io.redlink.more.studymanager.core.validation.ValidationIssue; | ||
|
|
||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; | ||
|
|
||
| /** | ||
| * Type that allows to refer other values via <id>. Before saving those MUST BE replaced with the actual values. | ||
| * The validation will fail if the stored value contains any templates (<id>) | ||
| */ | ||
| public class StringTemplateValue extends StringValue { | ||
|
|
||
|
|
||
| private static final Pattern TEMPLATE_PATTERN = Pattern.compile("<[(^>)]+>"); | ||
| private Set<String> allowList; | ||
|
|
||
| public StringTemplateValue(String id) { | ||
| this(id, null); | ||
| } | ||
|
|
||
| public StringTemplateValue(String id, Set<String> allowList) { | ||
| super(id); | ||
| this.allowList = allowList; | ||
| } | ||
|
|
||
| @Override | ||
| public String getType() { | ||
| return "STRINGTEMPLATE"; | ||
| } | ||
|
|
||
| protected ValidationIssue doValidate(String value) { | ||
| if (value == null) { | ||
| return super.doValidate(value); | ||
| } | ||
| if (allowList != null) { //check that only allowed templates are used | ||
| int start = 0; | ||
| Matcher m = TEMPLATE_PATTERN.matcher(value); | ||
| Set<String> notAllowed = new HashSet<>(); | ||
| while (m.find(start)) { | ||
| String template = m.group(1); | ||
| start = m.end(); | ||
| if (!allowList.contains(template)) { | ||
| notAllowed.add(template); | ||
| } | ||
| } | ||
| if (!notAllowed.isEmpty()) { | ||
| return ValidationIssue.error(this, String.format( | ||
| "The value contains the unknown templates %s (allowed are: %s)!", notAllowed, allowList)); | ||
| } | ||
| } | ||
| return super.doValidate(value); | ||
| } | ||
|
|
||
| } |
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
25 changes: 25 additions & 0 deletions
25
...ger-core/src/main/java/io/redlink/more/studymanager/core/properties/model/ValueGroup.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,25 @@ | ||
| /* | ||
| * Copyright LBI-DHP and/or licensed to LBI-DHP under one or more | ||
| * contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute | ||
| * for Digital Health and Prevention -- A research institute of the | ||
| * Ludwig Boltzmann Gesellschaft, Österreichische Vereinigung zur | ||
| * Förderung der wissenschaftlichen Forschung). | ||
| * Licensed under the Elastic License 2.0. | ||
| */ | ||
| package io.redlink.more.studymanager.core.properties.model; | ||
|
|
||
| public class ValueGroup extends Value<Void> { | ||
| public ValueGroup(String id) { | ||
| super(id); | ||
| } | ||
|
|
||
| @Override | ||
| public Class<Void> getValueType() { | ||
| return Void.class; | ||
| } | ||
|
|
||
| @Override | ||
| public String getType() { | ||
| return "GROUPING"; | ||
| } | ||
| } |
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,2 @@ | ||
| # More Studymanager Goal Templates | ||
|
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.