Class WizardProcessor
Drives the survey process in an asynchronous and mutable way so that it can be reused in various contexts and hiding most of the details of how the questions in the survey are turned in to a pipeline.
-
Constructor Summary
ConstructorDescriptionWizardProcessor
(nz.org.riskscape.engine.pipeline.ExecutionContext context, Survey survey) Construct a new empty processor for the given survey -
Method Summary
Modifier and TypeMethodDescriptionboolean
applyAnswer
(Answer answer) Update the build state to reflect the given answer, skipping any proceeding optional or hidden questions and then any trailing hidden questions afternz.org.riskscape.engine.bind.BindingContext
nz.org.riskscape.engine.pipeline.ExecutionContext
List<nz.org.riskscape.problem.Problem>
Returns the list of questions to be considered next, hiding those that are hidden or those that must be answered after a required one.nz.org.riskscape.engine.Project
The project this survey is being processed againstThe current QuestionTree for the processor, building a new one of the current one is empty/complete.The survey being processed.boolean
isDone()
boolean
isFailed()
boolean
Skip the given question, including any follow up hidden questions.boolean
Skip the given list of questions, including any follow up hidden questions.void
undo()
Rewind the processor to the previously answered question, skipping hidden questions and clearing failures.
-
Constructor Details
-
WizardProcessor
Construct a new empty processor for the given survey
- Parameters:
context
- and executionContext to use for all processing, realizing and binding
-
-
Method Details
-
isFailed
public boolean isFailed()- Returns:
- if processing failed on the last change. Note that if this is true, the most recent build state will be rubbish and an undo will be required before trying again
-
getProject
public nz.org.riskscape.engine.Project getProject()The project this survey is being processed against
-
getSurvey
The survey being processed.
-
getQuestionTree
The current QuestionTree for the processor, building a new one of the current one is empty/complete. Note that this shouldn't be used for driving the processor, just for UI/information purposes
-
isDone
public boolean isDone()- Returns:
- true if there are no more questions to answer
-
getBindingContext
public nz.org.riskscape.engine.bind.BindingContext getBindingContext()- Returns:
- a binding context for converting user input in to RiskScape objects
-
getNextQuestions
Returns the list of questions to be considered next, hiding those that are hidden or those that must be answered after a required one.
-
applyAnswer
Update the build state to reflect the given answer, skipping any proceeding optional or hidden questions and then any trailing hidden questions after
- Returns:
- true if the change and all surrounding hidden changes succeeded
-
skip
Skip the given question, including any follow up hidden questions.
- Returns:
- true if it succeeded, false if skipping failed, e.g. if it was a hidden question that couldn't be applied
- Throws:
IllegalArgumentException
- if the question can't be skipped
-
skipAll
Skip the given list of questions, including any follow up hidden questions.
- Returns:
- true if it succeeded, false if skipping one of the questions failed, such as a hidden question that couldn't be applied
- Throws:
IllegalArgumentException
- if one of the questions can't be skipped
-
undo
public void undo()Rewind the processor to the previously answered question, skipping hidden questions and clearing failures.
-
getExecutionContext
public nz.org.riskscape.engine.pipeline.ExecutionContext getExecutionContext() -
getBuildState
-
getFailures
-