Class WizardProcessor

java.lang.Object
nz.org.riskscape.wizard.WizardProcessor

public class WizardProcessor extends Object

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

    Constructors
    Constructor
    Description
    WizardProcessor(nz.org.riskscape.engine.pipeline.ExecutionContext context, Survey survey)
    Construct a new empty processor for the given survey
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Update the build state to reflect the given answer, skipping any proceeding optional or hidden questions and then any trailing hidden questions after
    nz.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 against
    The current QuestionTree for the processor, building a new one of the current one is empty/complete.
    The survey being processed.
    boolean
     
    boolean
     
    boolean
    skip(Question skip)
    Skip the given question, including any follow up hidden questions.
    boolean
    Skip the given list of questions, including any follow up hidden questions.
    void
    Rewind the processor to the previously answered question, skipping hidden questions and clearing failures.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WizardProcessor

      public WizardProcessor(nz.org.riskscape.engine.pipeline.ExecutionContext context, Survey survey)

      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

      public Survey getSurvey()

      The survey being processed.

    • getQuestionTree

      public QuestionTree 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

      public List<Question> 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

      public boolean 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 after

      Returns:
      true if the change and all surrounding hidden changes succeeded
    • skip

      public boolean skip(Question 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

      public boolean skipAll(List<Question> toSkip)

      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

      public IncrementalBuildState getBuildState()
    • getFailures

      public List<nz.org.riskscape.problem.Problem> getFailures()