-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create configuration for locking the Submission for a flow after it is submitted #437
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8990b1c
Avoid configuration property namespacing issues
spokenbird 1a88e3a
Consolidate DisabedFlowPropertyConfiguration to FormFlowConfiguration…
spokenbird 8d15387
Create test for locked submission in a given flow
spokenbird ca1ce8f
WIP - Beginning implementation
spokenbird 19d38f4
WIP - Implement for POST and add default message on redirect
spokenbird a032a5d
WIP Adding more tests and implementations to make them pass
spokenbird 76b31a9
WIP More tests and Build Time error handling!
spokenbird eae5e3d
Add edge case tests
spokenbird 47e41d2
Refactory FlowsConfigurationFactory
spokenbird ac51af3
Validate first screen when session continuity interceptor is enabled
spokenbird 63abc56
Add tests for flows configuration vactory flow validations
spokenbird d3e9e42
Fix method access modifiers
spokenbird f1cc8c0
Add documentation of submission locking to the README
spokenbird 29549df
Fix failing tests
spokenbird 11b5e6d
Merge branch 'main' into configure-submission-locking
spokenbird fdfd1a2
Merge branch 'main' into configure-submission-locking
spokenbird 2fd4375
Merge branch 'main' into configure-submission-locking
spokenbird c73b38c
Cleanup from code walk through
spokenbird 436bae0
Revert shouldRedirectDueToLockedSubmission signature change to fix fa…
spokenbird be63eb7
Merge branch 'main' into configure-submission-locking
spokenbird 70cc1d8
Merge branch 'main' into configure-submission-locking
spokenbird 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 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 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 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package formflow.library; | ||
|
||
import formflow.library.config.FlowConfiguration; | ||
import formflow.library.config.FormFlowConfigurationProperties; | ||
import formflow.library.data.Submission; | ||
import formflow.library.data.SubmissionRepositoryService; | ||
import formflow.library.data.UserFileRepositoryService; | ||
|
@@ -11,6 +12,7 @@ | |
import java.util.Map; | ||
import java.util.HashMap; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.context.MessageSource; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.server.ResponseStatusException; | ||
|
||
|
@@ -22,14 +24,21 @@ public abstract class FormFlowController { | |
protected final UserFileRepositoryService userFileRepositoryService; | ||
|
||
protected final List<FlowConfiguration> flowConfigurations; | ||
|
||
protected final FormFlowConfigurationProperties formFlowConfigurationProperties; | ||
|
||
protected final MessageSource messageSource; | ||
|
||
public static final String SUBMISSION_MAP_NAME = "submissionMap"; | ||
|
||
FormFlowController(SubmissionRepositoryService submissionRepositoryService, UserFileRepositoryService userFileRepositoryService, | ||
List<FlowConfiguration> flowConfigurations) { | ||
List<FlowConfiguration> flowConfigurations, FormFlowConfigurationProperties formFlowConfigurationProperties, | ||
MessageSource messageSource) { | ||
this.submissionRepositoryService = submissionRepositoryService; | ||
this.userFileRepositoryService = userFileRepositoryService; | ||
this.flowConfigurations = flowConfigurations; | ||
this.formFlowConfigurationProperties = formFlowConfigurationProperties; | ||
this.messageSource = messageSource; | ||
} | ||
|
||
protected Submission saveToRepository(Submission submission) { | ||
|
@@ -167,4 +176,24 @@ protected void setSubmissionInSession(HttpSession session, Submission submission | |
submissionMap.put(flow, id); | ||
session.setAttribute(SUBMISSION_MAP_NAME, submissionMap); | ||
} | ||
|
||
/** | ||
* Determines if the user should be redirected due to a locked submission. | ||
* | ||
* @param screen The current screen name. | ||
* @param submission The submission object. | ||
* @param flowName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this say: |
||
* @return true if the user should be redirected, false otherwise. | ||
*/ | ||
public boolean shouldRedirectDueToLockedSubmission(String screen, Submission submission, String flowName) { | ||
FlowConfiguration flowConfig = getFlowConfigurationByName(flowName); | ||
boolean submissionIsLocked = this.formFlowConfigurationProperties.isSubmissionLockedForFlow(flowName); | ||
|
||
if (submissionIsLocked) { | ||
boolean isSubmissionSubmitted = submission.getSubmittedAt() != null; | ||
boolean isCurrentScreenAfterSubmit = flowConfig.getLandmarks().getAfterSubmitPages().contains(screen); | ||
return isSubmissionSubmitted && !isCurrentScreenAfterSubmit; | ||
} | ||
return false; | ||
} | ||
} |
This file contains 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
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.
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.
user can can submit
should readuser can submit