Class SubflowFieldPreparer

java.lang.Object
formflow.library.pdf.SubflowFieldPreparer
All Implemented Interfaces:
DefaultSubmissionFieldPreparer

@Component public class SubflowFieldPreparer extends Object implements DefaultSubmissionFieldPreparer
This preparer takes the Submission and the subflow map from a given `pdf-map.yaml` file and iterates over each subflow in the given subflow map to create an expanded map of data that can be used to populate the subflow related PDF fields. It also takes into account any action placed on a given subflow and will run the action to manipulate subflow data before created the aforementioned expanded map. For example given the following subflow map:
 income:
   totalIterations: 3
   subflows:
     - income
   inputFields:
     exampleInput: EXAMPLE_PDF_FIELD
     otherExampleInput: ANOTHER_EXAMPLE_PDF_FIELD
     exampleCheckboxField:
       firstValue: FIRST_VALUE_PDF_FIELD
       secondValue: SECOND_VALUE_PDF_FIELD
 

and the Submission `inputData`:

   {
     income: [
       {
         exampleInput: "exampleInput value",
         otherExampleInput: "otherExampleInput value"
         exampleCheckboxField: ["firstValue", "secondValue"]
       },
       {
         exampleInput: "exampleInput value 2",
         otherExampleInput: "otherExampleInput value 2"
         exampleCheckboxField: ["firstValue", "secondValue"]
       }
     ]
   }
 
The resulting expanded map would be:
   {
     exampleInput_1: "exampleInput value",
     exampleInput_2: "exampleInput value 2",
     otherExampleInput_1: "otherExampleInput value",
     otherExampleInput_2: "otherExampleInput value 2"
     exampleCheckboxField_1[]: ["firstValue", "secondValue"],
     exampleCheckboxField_2[]: ["firstValue", "secondValue"]
   }
 

This allows us to add the expanded subflow map to the submission's inputData ultimately creating one big flattened map of all data from top level inputs and from subflows.

  • Constructor Details

    • SubflowFieldPreparer

      public SubflowFieldPreparer()
  • Method Details

    • prepareSubmissionFields

      public Map<String,SubmissionField> prepareSubmissionFields(Submission submission, PdfMap pdfMap)
      This will prepare the SubmissionFields for all the data across all the subflows specified in the PdfMap.
      Specified by:
      prepareSubmissionFields in interface DefaultSubmissionFieldPreparer
      Parameters:
      submission - the submission
      pdfMap - the field mappings from the pdf-map.yaml file
      Returns:
      a map of field name to SubmissionField
    • setActionManager

      public void setActionManager(ActionManager actionManager)
      Set the ActionManager explicitly. Generally the ActionManager is AutoWired in, but in the event that it can't be, or we want to override it, this provides the ability to do that.
      Parameters:
      actionManager - ActionManager to use