Class Simulation

Object
DomainObject
PersistedObject
PartitionedObject
AbstractCalculable
CalculableObject
MatrixableCalculableObject
Simulation
All Implemented Interfaces:
Calculable, HasCalculableObjectItems, JobNameProvider, JobSettingsProvider, UserGroupRestrictedObject

@Entity public class Simulation extends MatrixableCalculableObject implements UserGroupRestrictedObject, JobSettingsProvider
A Simulation (type code SIM) is a what-if test of an existing Pricelist or PriceGrid: it recalculates the base document's items into its own line items, without changing the base document. It uses the same logic names as the base document, but each logic, Company Parameter table (read via api.vLookup or a BoM) and Manual Price List can resolve to a Simulation Only version. When several versions with the same name exist, the one with the newest Valid From (not after the target date) wins; at an equal Valid From an Active version wins over a Simulation Only one. Simulation Only versions are further limited by getSimulationSet().

A Simulation logic calculates one line item at a time (api.currentItem() returns the SimulationItem); the Simulation header is not passed to it as an object. The self binding holds baseCO and baseCOType, plus basePricelistId and basePricelistType for a Simulation based on a Price List. api.contextTypedId() returns the Simulation's typed id, while api.contextName() returns the base document's label and api.previousContext(sku) reads the base document's items.

To read a Simulation from a logic, use api.findSimulations(targetDate, name); api.getSimulationSummaryQuery() reads its summary, and CalculationFlowActionBuilder#addSimulationAction(label).setCalculate(true) calculates it from a Calculation Flow. Line items have the type code SIMI (XSIMI for a Matrix base document, see getBaseCOType()) and reference their Simulation by the simulationId field.

A Simulation based on a Price List can be converted into a new Price List (not approved yet) in the UI or via the REST command simulationmanager.convert2pl; there is no api.* call for it.

Example, looking up the Simulations based on a specific Price List:


 def sims = api.find("SIM", 0, 0, null, ["id", "label", "baseCO"], Filter.equal("baseCO", "123.PL"))
 def sim = sims ? sims[0] : null
 
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    The kind of document a Simulation is based on, as classified by baseCalculableType().

    Nested classes/interfaces inherited from class MatrixableCalculableObject

    MatrixableCalculableObject.ListType

    Nested classes/interfaces inherited from class PersistedObject

    PersistedObject.BatchDelete, PersistedObject.BulkloadFilterCheckCallback, PersistedObject.ComputedFieldMapping, PersistedObject.ComputedFields, PersistedObject.HardDelete, PersistedObject.ImportManagerEnabled, PersistedObject.PersistedObjectMeta, PersistedObject.VirtualField, PersistedObject.VirtualFieldMapping, PersistedObject.VirtualFields, PersistedObject.VirtualSearchFields, PersistedObject.VirtualSortFields
  • Field Summary

    Fields inherited from class AbstractCalculable

    FIELD_CALCDATE, FIELD_CALCMESSAGES, FIELD_CALCSTARTDATE, FIELD_STATUS, MAX_CALCULATION_MESSAGE_LENGTH, MAX_CALCULATION_MESSAGE_THRESHOLD

    Fields inherited from class PartitionedObject

    FIELD_PARTITION, FIELD_PARTITIONID, PARTITION_FILTER_NAME, PARTITION_FILTER_PARAM

    Fields inherited from class PersistedObject

    FIELD_CREATEDATE, FIELD_CREATEDBY, FIELD_DELETEDATE, FIELD_DELETEDBY, FIELD_ID, FIELD_ISDELETED, FIELD_LASTUPDATEBY, FIELD_LASTUPDATEDATE, FIELD_VERSION

    Fields inherited from interface UserGroupRestrictedObject

    FIELD_USERGROUPEDIT, FIELD_USERGROUPVIEWDETAILS
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Classifies getBaseCO() as based on a Price List or a Price Grid.
    The typed id (for example "123.PL" or "123.PG") of the Pricelist or PriceGrid this Simulation is based on.
    MatrixableCalculableObject.ListType
    Whether the base document is a plain, per-SKU document or a Matrix one with an extra dimension.
    The id of the PriceGrid this Simulation is based on, derived from getBaseCO() (not from the value last passed to setBasePriceGridId(Long): that setter only stages a value for validate(ValidationVisitor, PersistedObjectService) to fold into getBaseCO(), it does not change what this getter returns until validation has run).
    The id of the Pricelist this Simulation is based on, derived from getBaseCO() (not from the value last passed to setBasePricelistId(Long): that setter only stages a value for validate(ValidationVisitor, PersistedObjectService) to fold into getBaseCO(), it does not change what this getter returns until validation has run).
    Intended to hold the typed id of the base document used by the last calculation, so that a change of getBaseCO() can be detected on the next run.
    JobStatusTracker.TrackerType
    The kind of background job tracker used by default when this Simulation's calculation runs.
    For a Matrix Simulation, whether to calculate every secondary key (key2) returned by the matrix logic.
    Class<? extends ElementAttributeMeta>
    The attribute-metadata type describing extension/attribute metadata for this Simulation's line items.
    Class<? extends AbstractSimulationItem>
    The concrete line item type backing this Simulation's items: SimulationItem for a plain, per-SKU base document, MatrixSimulationItem for a Matrix base document (see getBaseCOType()).
    static Class<? extends AbstractSimulationItem>
    getItemClassS(MatrixableCalculableObject.ListType type)
    The concrete line item type for a Simulation of the given list type.
    Equivalent to getItemListFilterFieldS(): the entity field name used to look up this Simulation's line items.
    static String
    The field on a line item (SIMI / XSIMI) that references its Simulation, for example api.find("SIMI", 0, 0, null, ["sku"], Filter.equal("simulationId", simulationId)).
    The job-type discriminator used for background calculation job naming/routing.
    MatrixableCalculableObject.ListType
    Equivalent to getBaseCOType().
    int
    getShotgunThreshold(PersistedObjectService objService, JobStatusTracker jst)
    The minimum job size (see jobSize(PersistedObjectService, JobStatusTracker, int)) above which the calculation framework switches into shotgun (distributed) mode instead of a single sequential run, when isShotgunEnabled(PersistedObjectService) allows it.
    The Simulation Set that selects which Simulation Only logics, Company Parameter tables and Manual Price Lists this Simulation may use: only those with the same Simulation Set, or with none, are considered.
    The ids of the Simulation Only logics (PricingFormula) used by this Simulation's calculation, recorded by the calculation.
    The ids of the Simulation Only Company Parameter tables (LookupTable) read via api.vLookup or a BoM by this Simulation's calculation, recorded by the calculation.
    boolean
    Whether, for a Price-List-based Simulation, the item set to calculate should be re-derived from the base Price List's product filter criteria rather than reusing the base Price List's existing items.
    The User Group(s) whose members may edit and delete this Simulation.
    The User Group(s) whose members may view this Simulation's details.
    boolean
    A shorthand for ListType.MATRIX.equals(getBaseCOType()), useful where a full switch over getBaseCOType() is not needed.
    boolean
    isShotgunEnabled(PersistedObjectService txn)
    Whether "shotgun mode" (distributed calculation spread across multiple worker agents/pods rather than run sequentially) is allowed for this Simulation at all.
    boolean
    Whether "shotgun mode" (distributed calculation spread across multiple worker agents/pods rather than run sequentially) is enabled for this Simulation.
    int
    jobSize(PersistedObjectService objectService, JobStatusTracker tracker, int runNumber)
    The size of this Simulation's current calculation run: the number of line items the run is expected to process.
    void
    setBaseCO(String baseCO)
    Sets the Price List or Price Grid this Simulation is based on.
    void
    setBaseCOType(MatrixableCalculableObject.ListType baseCOType)
    Sets the list type of the base document.
    void
    setBasePriceGridId(Long basePriceGridId)
    Stages the given id as this Simulation's base Price Grid.
    void
    setBasePricelistId(Long basePricelistId)
    Stages the given id as this Simulation's base Price List.
    void
    setCalculatedBaseTypedId(String calculatedBaseTypedId)
    Records the typed id of the base document used by the last calculation (see getCalculatedBaseTypedId()).
    void
    setIgnoreSecKeyFiltering(Boolean ignoreSecKeyFiltering)
    Sets whether to calculate every secondary key returned by the matrix logic (see getIgnoreSecKeyFiltering()).
    void
    setShotgunModeEnabled(Boolean shotgunModeEnabled)
    Sets whether shotgun (distributed) mode is enabled for this Simulation.
    void
    setSimulationSet(String simulationSet)
    Sets the Simulation Set (see getSimulationSet()).
    void
    setUsedSimulationFormulas(Set<Long> usedSimulationFormulas)
    Records the Simulation Only logics used by this Simulation's calculation (see getUsedSimulationFormulas()).
    void
    setUsedSimulationLookups(Set<Long> usedSimulationLookups)
    Records the Simulation Only Company Parameter tables used by this Simulation's calculation (see getUsedSimulationLookups()).
    void
    setUseFilterCriteria(Boolean useFilterCriteria)
    Sets whether the items of a Price List based Simulation are selected by the base Price List's product filter.
    void
    Sets the User Group(s) whose members may edit and delete this Simulation (see getUserGroupEdit()).
    void
    Sets the User Group(s) whose members may view this Simulation's details (see getUserGroupViewDetails()).
    boolean
    validate(ValidationVisitor validationVisitor, PersistedObjectService objService)
    Validates this Simulation before it is saved, in addition to the base validation of the superclass.

    Methods inherited from class MatrixableCalculableObject

    anyToRecalculation

    Methods inherited from class CalculableObject

    getEffectiveTargetDate, getKeepManualOverrides, getNumberOfItems, getWriteOnlyChangedItems, itemsStateChanged, setKeepManualOverrides, setNumberOfItems, setWriteOnlyChangedItems

    Methods inherited from class AbstractCalculable

    calculationDate, calculationStartDate, getCalculationConcurrencyKey, getCalculationDate, getCalculationMessages, getCalculationMessagesAsList, getCalculationStartDate, getJobName, getLabel, getLocale, getStatus, getTargetDate, isAnonymousCalculable, setCalculationDate, setCalculationMessages, setCalculationMessages, setCalculationStartDate, setLabel, setLocale, setStatus, setTargetDate

    Methods inherited from class PartitionedObject

    addUniqueConstraint, getLoginNameByUserId, getPartition, setPartition, toString

    Methods inherited from class PersistedObject

    auditOperation, bumpVersion, canAdd, canDelete, canEdit, canEdit, canRead, canReadElements, createDate, entityIsHardDeleted, entityIsMassDeletable, entityIsSafeInserted, entityIsSafeInserted, getBulkloadMap, getBusinessKey, getCreateDate, getCreatedBy, getDbColumnNameForField, getDeleteDate, getDeletedBy, getId, getLastUpdateBy, getLastUpdateDate, getSensitiveFields, getSignificantFields, getTypeCode, getTypedId, getVersion, getVirtualSearchFieldMappings, getVirtualSortFieldMappings, isAudited, isDeleted, isHardDeleted, isVirtualSearchField, lastUpdateDate, notifyOnBusinessKeyChange, onBusinessKeyChange, onDelete, onRefreshed, onSavedOrUpdated, onSaveOrUpdate, setCreateDate, setCreateDateShouldBeIgnored, setCreateDateTime, setCreatedBy, setDeleted, setDeleteDate, setDeletedBy, setId, setLastUpdateBy, setLastUpdateDate, setLastUpdateDateTime, setTypedId, setVersion, userGroupEditBulkloadFilter, userGroupEditBulkloadFilter

    Methods inherited from class DomainObject

    deepCopy, getNewMidnightDate, getNewMidnightDateTime, isMidnight, isMidnight, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonDeserialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerialize, jsonSerializedSizeOK, jsonSerializeToBytes, jsonSerializeToBytes, setToDayEnd, setToDayEnd, setToMidnight, setToMidnight, setToMidnightAsLocalDateTime, toPropertyMap, truncatedToString

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface JobSettingsProvider

    getAgentOption1
  • Constructor Details

    • Simulation

      public Simulation()
  • Method Details

    • getBasePricelistId

      public Long getBasePricelistId()
      The id of the Pricelist this Simulation is based on, derived from getBaseCO() (not from the value last passed to setBasePricelistId(Long): that setter only stages a value for validate(ValidationVisitor, PersistedObjectService) to fold into getBaseCO(), it does not change what this getter returns until validation has run).

      Note: basePricelistId is not a stored field; it is derived from baseCO. Filtering on it with api.find or api.stream throws IllegalStateException; filter on getBaseCO() instead, for example Filter.equal("baseCO", "123.PL").

      Returns:
      The base Price List's id, or null if this Simulation is based on a Price Grid instead.
      Throws:
      UnsupportedOperationException - Via baseCalculableType(), if getBaseCO() does not identify a Pricelist or PriceGrid.
    • getBasePriceGridId

      public Long getBasePriceGridId()
      The id of the PriceGrid this Simulation is based on, derived from getBaseCO() (not from the value last passed to setBasePriceGridId(Long): that setter only stages a value for validate(ValidationVisitor, PersistedObjectService) to fold into getBaseCO(), it does not change what this getter returns until validation has run).

      Note: basePriceGridId is not a stored field; it is derived from baseCO. Filtering on it with api.find or api.stream throws IllegalStateException; filter on getBaseCO() instead, for example Filter.equal("baseCO", "123.PG").

      Returns:
      The base Price Grid's id, or null if this Simulation is based on a Price List instead.
      Throws:
      UnsupportedOperationException - Via baseCalculableType(), if getBaseCO() does not identify a Pricelist or PriceGrid.
    • setBasePriceGridId

      public void setBasePriceGridId(Long basePriceGridId)
      Stages the given id as this Simulation's base Price Grid. Has no effect on getBasePriceGridId() or getBaseCO() by itself; takes effect only the next time validate(ValidationVisitor, PersistedObjectService) runs, which folds it into getBaseCO() as "<id>.PG".
      Parameters:
      basePriceGridId - The id of the Price Grid to base this Simulation on.
    • setBasePricelistId

      public void setBasePricelistId(Long basePricelistId)
      Stages the given id as this Simulation's base Price List. Has no effect on getBasePricelistId() or getBaseCO() by itself; takes effect only the next time validate(ValidationVisitor, PersistedObjectService) runs, which folds it into getBaseCO() as "<id>.PL".
      Parameters:
      basePricelistId - The id of the Price List to base this Simulation on.
    • getBaseCO

      public String getBaseCO()
      The typed id (for example "123.PL" or "123.PG") of the Pricelist or PriceGrid this Simulation is based on. This is the field getBasePricelistId() and getBasePriceGridId() are derived from, and the one to filter on directly from a calculation logic (see the note on those getters).
      Returns:
      The base document's typed id.
    • setBaseCO

      public void setBaseCO(String baseCO)
      Sets the Price List or Price Grid this Simulation is based on.
      Parameters:
      baseCO - The typed id (for example "123.PL" or "123.PG") of the Price List or Price Grid to base this Simulation on.
    • getBaseCOType

      public MatrixableCalculableObject.ListType getBaseCOType()
      Whether the base document is a plain, per-SKU document or a Matrix one with an extra dimension. This also determines the line item type returned by getItemClass().
      Returns:
      The base document's list type. Defaults to ListType.SIMPLE when none has been set.
    • setBaseCOType

      public void setBaseCOType(MatrixableCalculableObject.ListType baseCOType)
      Sets the list type of the base document. Every calculation overwrites it with the base document's current list type, so a value set by hand does not last.
      Parameters:
      baseCOType - The list type of the base document (plain or Matrix).
    • baseCalculableType

      public Simulation.SimulationType baseCalculableType()
      Classifies getBaseCO() as based on a Price List or a Price Grid.
      Returns:
      Simulation.SimulationType.PriceList or Simulation.SimulationType.PriceGrid.
      Throws:
      UnsupportedOperationException - If getBaseCO() does not identify a Pricelist or PriceGrid.
    • getListType

      public MatrixableCalculableObject.ListType getListType()
      Equivalent to getBaseCOType().
      Overrides:
      getListType in class MatrixableCalculableObject
      Returns:
      The base document's list type. Defaults to ListType.SIMPLE when none has been set.
    • getCalculatedBaseTypedId

      public String getCalculatedBaseTypedId()
      Intended to hold the typed id of the base document used by the last calculation, so that a change of getBaseCO() can be detected on the next run. Currently the calculation does not populate it, so it is normally null. Not meant to be used directly in Groovy.
      Returns:
      The base document's typed id recorded for the last calculation, normally null.
    • setCalculatedBaseTypedId

      public void setCalculatedBaseTypedId(String calculatedBaseTypedId)
      Records the typed id of the base document used by the last calculation (see getCalculatedBaseTypedId()). Not meant to be used directly in Groovy.
      Parameters:
      calculatedBaseTypedId - The base document's typed id to record for the last calculation.
    • getSimulationSet

      public String getSimulationSet()
      The Simulation Set that selects which Simulation Only logics, Company Parameter tables and Manual Price Lists this Simulation may use: only those with the same Simulation Set, or with none, are considered. When null, only Simulation Only elements without a Simulation Set are used.
      Returns:
      The Simulation Set name, or null if none is assigned.
    • setSimulationSet

      public void setSimulationSet(String simulationSet)
      Sets the Simulation Set (see getSimulationSet()).
      Parameters:
      simulationSet - The Simulation Set name to assign, or null to use only Simulation Only elements without a Simulation Set.
    • getUsedSimulationFormulas

      public Set<Long> getUsedSimulationFormulas()
      The ids of the Simulation Only logics (PricingFormula) used by this Simulation's calculation, recorded by the calculation. When the Simulation is converted into a Price List with object conversion enabled, these logics are switched to Active. Not meant to be used directly in Groovy.
      Returns:
      The set of used logic ids, or null if none are recorded.
    • setUsedSimulationFormulas

      public void setUsedSimulationFormulas(Set<Long> usedSimulationFormulas)
      Records the Simulation Only logics used by this Simulation's calculation (see getUsedSimulationFormulas()). Not meant to be used directly in Groovy.
      Parameters:
      usedSimulationFormulas - The ids of the Simulation Only logics used, or null to clear the set.
    • getUsedSimulationLookups

      public Set<Long> getUsedSimulationLookups()
      The ids of the Simulation Only Company Parameter tables (LookupTable) read via api.vLookup or a BoM by this Simulation's calculation, recorded by the calculation. When the Simulation is converted into a Price List with object conversion enabled, these tables are switched to Active. Not meant to be used directly in Groovy.
      Returns:
      The set of used Company Parameter table ids, or null if none are recorded.
    • setUsedSimulationLookups

      public void setUsedSimulationLookups(Set<Long> usedSimulationLookups)
      Records the Simulation Only Company Parameter tables used by this Simulation's calculation (see getUsedSimulationLookups()). Not meant to be used directly in Groovy.
      Parameters:
      usedSimulationLookups - The ids of the Simulation Only Company Parameter tables used, or null to clear the set.
    • getUseFilterCriteria

      public boolean getUseFilterCriteria()
      Whether, for a Price-List-based Simulation, the item set to calculate should be re-derived from the base Price List's product filter criteria rather than reusing the base Price List's existing items. Has no effect when the base document is a Price Grid.
      Returns:
      true if the product filter criteria should be used to select items, false otherwise (including when unset).
    • setUseFilterCriteria

      public void setUseFilterCriteria(Boolean useFilterCriteria)
      Sets whether the items of a Price List based Simulation are selected by the base Price List's product filter.
      Parameters:
      useFilterCriteria - Whether to re-derive the item set from the base Price List's product filter criteria.
    • isShotgunModeEnabled

      public boolean isShotgunModeEnabled()
      Whether "shotgun mode" (distributed calculation spread across multiple worker agents/pods rather than run sequentially) is enabled for this Simulation. Defaulted from the base document's own shotgun mode setting the first time this Simulation is validated (see validate(ValidationVisitor, PersistedObjectService)), and can be overridden afterwards.
      Returns:
      true if shotgun mode is enabled, false otherwise (including when unset).
    • setShotgunModeEnabled

      public void setShotgunModeEnabled(Boolean shotgunModeEnabled)
      Sets whether shotgun (distributed) mode is enabled for this Simulation.
      Parameters:
      shotgunModeEnabled - Whether shotgun mode should be enabled for this Simulation, or null to let it be defaulted from the base document on the next validation.
    • getUserGroupEdit

      public String getUserGroupEdit()
      The User Group(s) whose members may edit and delete this Simulation. Users with the USERGROUP_OVERRIDE permission bypass the restriction.
      Specified by:
      getUserGroupEdit in interface UserGroupRestrictedObject
      Returns:
      A User Group unique name or a comma-separated list of them, or null if editing is not restricted by User Group.
    • setUserGroupEdit

      public void setUserGroupEdit(String userGroup)
      Sets the User Group(s) whose members may edit and delete this Simulation (see getUserGroupEdit()).
      Specified by:
      setUserGroupEdit in interface UserGroupRestrictedObject
      Parameters:
      userGroup - A User Group unique name or a comma-separated list of them, or null to remove the restriction.
    • getUserGroupViewDetails

      public String getUserGroupViewDetails()
      The User Group(s) whose members may view this Simulation's details. Members of the edit User Group(s) (getUserGroupEdit()) may view the details too, and users with the USERGROUP_OVERRIDE permission bypass the restriction.
      Specified by:
      getUserGroupViewDetails in interface UserGroupRestrictedObject
      Returns:
      A User Group unique name or a comma-separated list of them, or null if viewing is not restricted by User Group.
    • setUserGroupViewDetails

      public void setUserGroupViewDetails(String userGroup)
      Sets the User Group(s) whose members may view this Simulation's details (see getUserGroupViewDetails()).
      Specified by:
      setUserGroupViewDetails in interface UserGroupRestrictedObject
      Parameters:
      userGroup - A User Group unique name or a comma-separated list of them, or null to remove the restriction.
    • getIgnoreSecKeyFiltering

      public Boolean getIgnoreSecKeyFiltering()
      For a Matrix Simulation, whether to calculate every secondary key (key2) returned by the matrix logic. When false (the default), only the secondary keys that already exist for the SKU in the base document are calculated.
      Returns:
      true if every secondary key returned by the matrix logic is calculated, false (also when unset) if they are limited to the base document's secondary keys.
    • setIgnoreSecKeyFiltering

      public void setIgnoreSecKeyFiltering(Boolean ignoreSecKeyFiltering)
      Sets whether to calculate every secondary key returned by the matrix logic (see getIgnoreSecKeyFiltering()).
      Parameters:
      ignoreSecKeyFiltering - Whether to calculate every secondary key returned by the matrix logic instead of only the base document's secondary keys, for a Matrix Simulation.
    • isMatrix

      public boolean isMatrix()
      A shorthand for ListType.MATRIX.equals(getBaseCOType()), useful where a full switch over getBaseCOType() is not needed.
      Overrides:
      isMatrix in class MatrixableCalculableObject
      Returns:
      true if the base document is a Matrix document, false otherwise.
    • validate

      public boolean validate(ValidationVisitor validationVisitor, PersistedObjectService objService)
      Validates this Simulation before it is saved, in addition to the base validation of the superclass. Folds a value staged via setBasePriceGridId(Long) or setBasePricelistId(Long) into getBaseCO(); rejects a getBaseCO() that does not resolve to an existing calculable object (only Price List and Price Grid bases are supported by the calculation); and, when shotgun mode has never been set on this Simulation, copies the base document's shotgun mode setting. Not meant to be used directly in Groovy.
      Overrides:
      validate in class AbstractCalculable
      Parameters:
      validationVisitor - Receives a validation error on each of the baseCO, basePriceGridId, and basePricelistId fields when the base document cannot be resolved. May be null, in which case errors are simply not recorded.
      objService - Used to resolve getBaseCO() to its actual Price List or Price Grid, and to delegate to the superclass validation. When null, only the superclass validation runs.
      Returns:
      true if this Simulation is valid, false otherwise.
    • getItemClass

      public Class<? extends AbstractSimulationItem> getItemClass()
      The concrete line item type backing this Simulation's items: SimulationItem for a plain, per-SKU base document, MatrixSimulationItem for a Matrix base document (see getBaseCOType()). Used generically by item-management code to instantiate and query this Simulation's line items. Not meant to be used directly in Groovy.
      Specified by:
      getItemClass in interface HasCalculableObjectItems
      Returns:
      The line item class corresponding to getBaseCOType().
    • getItemClassS

      public static Class<? extends AbstractSimulationItem> getItemClassS(MatrixableCalculableObject.ListType type)
      The concrete line item type for a Simulation of the given list type. Not meant to be used directly in Groovy.
      Parameters:
      type - The list type to resolve.
      Returns:
      SimulationItem.class for SIMPLE, MatrixSimulationItem.class for MATRIX.
    • getItemListFilterField

      public String getItemListFilterField()
      Equivalent to getItemListFilterFieldS(): the entity field name used to look up this Simulation's line items. Not meant to be used directly in Groovy.
      Specified by:
      getItemListFilterField in interface HasCalculableObjectItems
      Returns:
      "simulationId".
    • getItemListFilterFieldS

      public static String getItemListFilterFieldS()
      The field on a line item (SIMI / XSIMI) that references its Simulation, for example api.find("SIMI", 0, 0, null, ["sku"], Filter.equal("simulationId", simulationId)). The method itself is not meant to be used directly in Groovy; use the field name "simulationId" instead.
      Returns:
      "simulationId".
    • getItemAttributeMetaClass

      public Class<? extends ElementAttributeMeta> getItemAttributeMetaClass()
      The attribute-metadata type describing extension/attribute metadata for this Simulation's line items.
      Specified by:
      getItemAttributeMetaClass in interface HasCalculableObjectItems
      Returns:
      SimulationItemAttributeMeta.class.
    • getDefaultTrackerType

      public JobStatusTracker.TrackerType getDefaultTrackerType()
      The kind of background job tracker used by default when this Simulation's calculation runs. Not meant to be used directly in Groovy.
      Specified by:
      getDefaultTrackerType in class AbstractCalculable
      Returns:
      TrackerType.SIMULATION.
    • getJobType

      public String getJobType()
      The job-type discriminator used for background calculation job naming/routing. Not meant to be used directly in Groovy.
      Specified by:
      getJobType in interface JobSettingsProvider
      Returns:
      This Simulation's type code, "SIM".
    • isShotgunEnabled

      public boolean isShotgunEnabled(PersistedObjectService txn)
      Whether "shotgun mode" (distributed calculation spread across multiple worker agents/pods rather than run sequentially) is allowed for this Simulation at all. Not meant to be used directly in Groovy.
      Specified by:
      isShotgunEnabled in interface JobSettingsProvider
      Parameters:
      txn - Unused by this implementation; present for the JobSettingsProvider contract.
      Returns:
      isShotgunModeEnabled().
    • getShotgunThreshold

      public int getShotgunThreshold(PersistedObjectService objService, JobStatusTracker jst)
      The minimum job size (see jobSize(PersistedObjectService, JobStatusTracker, int)) above which the calculation framework switches into shotgun (distributed) mode instead of a single sequential run, when isShotgunEnabled(PersistedObjectService) allows it. The threshold is set for the whole instance (default 5000) and can be overridden per partition by an application property. Not meant to be used directly in Groovy.
      Specified by:
      getShotgunThreshold in interface JobSettingsProvider
      Parameters:
      objService - Used to resolve the configured threshold.
      jst - The job status tracker for the current calculation run.
      Returns:
      The shotgun mode threshold for this run.
    • jobSize

      public int jobSize(PersistedObjectService objectService, JobStatusTracker tracker, int runNumber)
      The size of this Simulation's current calculation run: the number of line items the run is expected to process. Used by the calculation framework both to decide whether to switch into shotgun (distributed) mode (compared against getShotgunThreshold(PersistedObjectService, JobStatusTracker)) and, once in shotgun mode, to size the number of worker pods. Not meant to be used directly in Groovy.

      Resolution order: the count of items already marked for recalculation, then, only if the tainted-recalculation flag is set, the count of tainted items, then, for a follow-up pass (runNumber > 0), the count of dirty items, then the base document's own item count.

      Specified by:
      jobSize in interface JobSettingsProvider
      Parameters:
      objectService - Used to count line items and to look up the base document when the size cannot be resolved from the tracker.
      tracker - The job status tracker for the current calculation run, supplying job parameters.
      runNumber - The current pass number of a multi-pass calculation (0 for the first pass).
      Returns:
      The number of line items this run is expected to process.