Class ModelCalculationAction<T extends Help>

Object
Action
ModelCalculationAction<T>
All Implemented Interfaces:
Help

public final class ModelCalculationAction<T extends Help> extends Action
This action calculates a Model Object: a range of its steps, or one of the actions declared in its Model Class. Obtain it with CalculationFlowActionBuilder.addModelCalculationAction(String), which takes the unique name of the model. It starts the calculation only when the logic calls setCalculate(true).

If nothing is specified, all the steps of the model will be calculated.

If both action and steps are specified, then only the action will be executed.

The calculation runs with the access rights of the user who created the model. If no model has this unique name, no calculation starts and the Calculation Flow does not report an error. If the calculation cannot start, for example because a running calculation locks the model or because the model was submitted or approved, the Calculation Flow reports an error.

See Also:
  • Constructor Details

    • ModelCalculationAction

      public ModelCalculationAction(T backLink, Invocations<MethodInvocationRecord> invocations, String modelUniqueName)
      Not intended for public use. An action created with this constructor is not added to the Calculation Flow, so it never runs. Use actionBuilder.addModelCalculationAction() instead.
      See Also:
  • Method Details

    • action

      public ModelCalculationAction<T> action(String actionName)
      Execute one of the actions declared in the ModelObject's ModelClass. This clears the step range set by the other methods.

      Example:

      
       actionBuilder.addModelCalculationAction('modelUniqueName')
           .action('anActionDeclaredInTheModel')
           .setCalculate(true)
       
      Parameters:
      actionName - the name of the action as declared in the Model Class
      Returns:
      the instance of ModelCalculationAction
      Since:
      10.3 Bee's Knees
      See Also:
    • allSteps

      public ModelCalculationAction<T> allSteps()
      Sets the calculation range of the model to all steps (sets fromStep and toStep to null).

      Example:

      
       actionBuilder.addModelCalculationAction("modelUniqueName")
                .allSteps()
                .setCalculate(true)
       return
       
      Returns:
      the instance of ModelCalculationAction
      Since:
      10.1 - Bee's Knees
      See Also:
    • oneStep

      public ModelCalculationAction<T> oneStep(String step)
      Calculates the step of the model.

      Example:

      
       actionBuilder.addModelCalculationAction("modelUniqueName")
                .oneStep("stepName")
                .setCalculate(true)
       return
       
      Parameters:
      step - the step to be calculated
      Returns:
      the instance of ModelCalculationAction
      Since:
      10.1 - Bee's Knees
      See Also:
    • fromFirstStep

      public ModelCalculationAction<T> fromFirstStep()
      Sets the calculation range of steps of the specified model, beginning with the first step (included). Sets fromStep to null. Used together with toStep(String).

      Example:

      
       actionBuilder.addModelCalculationAction("modelUniqueName")
                .fromFirstStep()
                .toStep("StepName3")
                .setCalculate(true)
       return
       
      Returns:
      the instance of ModelCalculationAction
      Since:
      10.1 - Bee's Knees
      See Also:
    • fromStep

      public ModelCalculationAction<T> fromStep(String step)
      Sets the calculation range of steps of the specified model, beginning with the specified step (included). Used together with toStep(String) or toLastStep().

      Example:

      
       actionBuilder.addModelCalculationAction("modelUniqueName")
                .fromStep("StepName2")
                .toStep("StepName3")
                .setCalculate(true)
       return
       
      Parameters:
      step - the name of the step to start the calculation with
      Returns:
      the instance of ModelCalculationAction
      Since:
      10.1 - Bee's Knees
      See Also:
    • toLastStep

      public ModelCalculationAction<T> toLastStep()
      Sets the calculation range of steps of the specified model, ending with the last step (included). Sets toStep to null. Used together with fromStep(String).

      Example:

      
       actionBuilder.addModelCalculationAction("modelUniqueName")
                .fromStep("StepName2")
                .toLastStep()
                .setCalculate(true)
       return
       
      Returns:
      the instance of ModelCalculationAction
      Since:
      10.1 - Bee's Knees
      See Also:
    • toStep

      public ModelCalculationAction<T> toStep(String step)
      Sets the calculation range of steps of the specified model, ending with the specified step (included). Used together with fromStep(String) or fromFirstStep().

      Example:

      
       actionBuilder.addModelCalculationAction("modelUniqueName")
                .fromStep("StepName2")
                .toStep("StepName3")
                .setCalculate(true)
       return
       
      Parameters:
      step - the name of the step to end the calculation with
      Returns:
      the instance of ModelCalculationAction
      Since:
      10.1 - Bee's Knees
      See Also:
    • setCalculate

      public ModelCalculationAction<T> setCalculate(Boolean calculate)
      Whether the action is valid and should be triggered or not.
      Parameters:
      calculate -
      • true - calculation of the model is started as background process
      • false - calculation of the model is NOT started at all
      Returns:
      this action, for further configuration
    • back

      public T back()
      Returns the builder that added this action, so that the logic can add the next action in the same chain.
      Returns:
      the actionBuilder that added this action
      See Also:
    • getObjectName

      public String getObjectName()
      Not intended for public use.
      Returns:
      the name of the builder that added this action, followed by ".ModelCalculationAction"
    • getModelUniqueName

      public String getModelUniqueName()
      Gets the unique name of the model that this action calculates.
      Returns:
      the unique name passed to CalculationFlowActionBuilder.addModelCalculationAction(String)
    • getCalculate

      public boolean getCalculate()
      Gets whether this action starts the calculation of the model.
      Returns:
      true after setCalculate(true), otherwise false
      See Also:
    • getFromStep

      public Optional<String> getFromStep()
      Gets the step that the calculation range starts with.
      Returns:
      the step, or an empty Optional when the range starts at the first step
    • getToStep

      public Optional<String> getToStep()
      Gets the step that the calculation range ends with.
      Returns:
      the step, or an empty Optional when the range ends at the last step
    • getAction

      public String getAction()
      Gets the action set with action(String).
      Returns:
      the name of the action, or null when the action calculates steps
    • toString

      public String toString()
      Returns a text representation of this action for debugging.
      Overrides:
      toString in class Object
      Returns:
      a text that contains the unique name of the model, the step range, the action and the calculate flag of this action