Class LivePriceGridAction<T extends Help>

Object
Action
LivePriceGridAction<T>
All Implemented Interfaces:
Help

public class LivePriceGridAction<T extends Help> extends Action
This action starts calculation of selected Live Price Grid (LPG) for all SKUs or restricted set of SKUs. It's a programmatic version of the same action available in UI. As such it allows user to schedule the action in calculation flow formula.

Obtain it with CalculationFlowActionBuilder.addLivePriceGridAction(String). The action calculates the LPG that has this label and is valid at the target date of the Calculation Flow, unless ignoreTargetDate(Boolean) is set. It starts the job only when the logic calls setCalculate(true). If no LPG matches the label, no job starts and the Calculation Flow does not report an error. An LPG that belongs to another object is skipped, because only the calculation of that object can calculate it.

Example, recalculating two products only:


 actionBuilder.addLivePriceGridAction('LPG 1')
     .restrictToSkus(['MB-0001', 'MB-0002'])
     .setCalculate(true)
 
See Also:
  • Constructor Details

    • LivePriceGridAction

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

    • setCalculate

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

      public LivePriceGridAction<T> setPriority(int priority)
      Sets the priority of the calculation job that this action starts. A value outside the range from 0 to 9 is replaced with 0.
      Parameters:
      priority - Default is 0 (lowest user-definable priority). Max value is 9.
      Returns:
      this action, for further configuration
    • setDistributedCalculationThreshold

      public LivePriceGridAction<T> setDistributedCalculationThreshold(int threshold)
      Sets a job-individual threshold to start a distributed calculation. Please note: Any values below 1000 may very well be counter-productive and make the job slower!

      If you do not set it, or set 0, the job uses the threshold of the partition.

      Parameters:
      threshold - The number of items that need to be part of the job in order to execute it in distributed mode.
      Returns:
      this action, for further configuration
    • restrictToSkus

      public LivePriceGridAction<T> restrictToSkus(List<String> skus)
      Restricts LPG calculation to a list of specified SKUs. If you do not call this method, or pass an empty list, all items are calculated. Passing null does not clear a list set by an earlier call.

      The recalculation of the listed items behaves like the calculation of a single item in the LPG.

      Parameters:
      skus - list of SKUs to process
      Returns:
      this action, for further configuration
      See Also:
    • withFormulaParameters

      public LivePriceGridAction<T> withFormulaParameters(HashMap<String,Object> formulaParameters)
      Allows you to add parameters entering to the calculation.

      The logic of the LPG reads each value as an input, for example input.amount. A later call replaces the parameters of an earlier call. A parameter named targetDate and parameters with a null value are ignored.

      Example:

      
       actionBuilder.addLivePriceGridAction('LPG 1')
           .withFormulaParameters([amount: 42, city: 'New York'])
           .setCalculate(true)
       
      Parameters:
      formulaParameters - Parameters as key and value pairs.
      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:
    • setNextJobs

      public LivePriceGridAction<T> setNextJobs(List<ChainedJobInfo> jobs)
      Defines subsequent follow-on jobs. A next job starts when the calculation job of this action has finished. If that job fails, a next job starts only when its executeOnError is true. Each next job can have next jobs of its own.

      Example:

      
       import net.pricefx.common.dto.ChainedJobInfo
      
       def nextJob = new ChainedJobInfo()
       nextJob.setTargetObject('38.CFS')
       nextJob.setExecuteOnError(false)
      
       actionBuilder.addLivePriceGridAction('LPG 1')
           .setNextJobs([nextJob])
           .setCalculate(true)
       
      Parameters:
      jobs - List of ChainedJobInfo objects
      Returns:
      this action, for further configuration
      See Also:
    • ignoreTargetDate

      public LivePriceGridAction<T> ignoreTargetDate(Boolean ignore)
      Sets whether the action also considers LPGs that are not yet valid at the target date of the Calculation Flow. With true, the action takes the LPG with this label that has the latest target date.
      Parameters:
      ignore - Default is false (CF job will ignore LPG that is not yet valid).
      Returns:
      this action, for further configuration
    • getObjectName

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

      public String getLivePriceGridLabel()
      Gets the label of the LPG that this action calculates.
      Returns:
      the label passed to CalculationFlowActionBuilder.addLivePriceGridAction(String)
    • getCalculate

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

      public List<String> getRestrictToSkus()
      Gets the SKUs set with restrictToSkus(List).
      Returns:
      the SKUs, an empty list if the calculation is not restricted
    • getFormulaParameters

      public HashMap<String,Object> getFormulaParameters()
      Gets the parameters set with withFormulaParameters(HashMap).
      Returns:
      the parameters, an empty map if none were set
    • getPriority

      public int getPriority()
      Gets the priority set with setPriority(int).
      Returns:
      the priority, 0 if it was not set
    • getDistributedCalculationThreshold

      public int getDistributedCalculationThreshold()
      Gets the threshold set with setDistributedCalculationThreshold(int).
      Returns:
      the threshold, 0 if it was not set
    • getNextJobs

      public List<ChainedJobInfo> getNextJobs()
      Gets the follow-on jobs set with setNextJobs(List).
      Returns:
      the follow-on jobs
    • getIgnoreTargetDate

      public Boolean getIgnoreTargetDate()
      Gets whether the action also considers LPGs that are not yet valid.
      Returns:
      true after ignoreTargetDate(true), otherwise false
      See Also:
    • toString

      public String toString()
      Returns a text representation of this action for debugging.
      Overrides:
      toString in class Object
      Returns:
      a text that contains the label of the LPG, the calculate flag, the SKUs and the parameters of this action