com.ibm.openpages.api.service

## Interface ITBRuleService

-     public interface ITBRuleService

  Provides service for OpenPages rules engine. The rules engine allows the user to define their own execution conditions and rule variables to launch executable workflows.

  The service provides API to: - create/fetch/update/delete rule definitions - start a rule on a resource - rule the rule

  Since:
    8.1

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `ITBRuleDefinition` | `createRuleDefinition(ITBRuleDefinition ruleDefinition)` Creates a rule definition
    `void` | `deleteRuleDefinitions(java.util.Set<Id> ruleDefinitionIds)` Deletes rule definitions by IDs
    `ITBRuleDefinition` | `discardDraftRuleDefinition(Id ruleDefinitionId)` Discard the draft content of the rule definition.
    `void` | `enableAsyncCalculations(boolean enabled)` Enables or disables asynchronous calculations.
    `void` | `enableRuleDefinitions(java.util.Set<Id> ruleDefinitionIds, boolean enabled)` enable or disable rule definitions by IDs
    `int` | `estimateStartingCalculationsInBulk(Id ruleDefinitionId)` Returns estimated count that would meet the criteria to run the calculation in bulk
    `java.util.List<ITBRuleDefinition>` | `evaluateRules(java.util.List<ITBRuleDefinition> rules, Id resourceId)` Evaluates a list of rules against a resource and returns the valid rules.
    `void` | `executeRules(java.util.List<ITBRuleDefinition> rules, Id resourceId)` Evaluates and executes a list of rules on a resource.
    `java.util.Map<Id,java.util.Set<Id>>` | `getAsyncCalculationRequests(java.util.Set<Id> resourceIds)` Returns the resources in the asynchronous calculation queue.
    `java.util.Map<Id,TBCalcCounts>` | `getCalcStats(java.util.Set<Id> calcDefIds)` Returns the statistics of the calculations such as how many resources are in the queue for asynchronous calculation, or how many resources have calculation errors for a given calculation definition.
    `ITBRuleDefinition` | `getRuleDefinition(Id ruleDefinitionId, boolean draft)` Returns a rule definition by ID
    `ITBRuleDefinition` | `getRuleDefinition(java.lang.String name, Id typeDefinitionId, boolean draft)` Returns a rule definition by name, type definition ID
    `ITBRuleDefinition` | `getRuleDefinitionByVersionId(Id versionId)` Returns the rule definition by the version ID
    `java.util.List<ITBRuleDefinition>` | `getRuleDefinitions()` Deprecated.
    `java.util.List<ITBRuleDefinition>` | `getRuleDefinitions(Id ruleDefinitionId)` Returns the published and draft versions of the rule definition if they exist.
    `TBRuleDefinitionList` | `getRuleDefinitions(ITBRuleDefinitionFindOptions ruleDefinitionFindOptions)` Returns list of rule definitions based on the criteria defined by the `ITBRuleDefinitionFindOptions`
    `java.util.List<ITBRuleDefinition>` | `getRuleDefinitionsByRuleType(TBRuleDefinitionType type)` Returns the latest published version of all `ITBRuleDefinitions`s by `TBRuleDefinitionType` that are currently enabled.
    `java.util.List<ITBRuleDefinition>` | `getRuleDefinitionsByType(Id objectType)` Returns the latest version of all `ITBRuleDefinition`s by object type
    `ITBRuleFactory` | `getRuleFactory()` Returns a new rule factory object.
    `java.util.List<ITBRuleDefinition>` | `getRunnableRules(Id objectType, TBRuleDefinitionType ruleType)` Get all runnable rules for an object type
    `void` | `hardDeleteRuleDefinitions(java.util.Set<Id> ruleDefinitionIds)` Hard-deletes rule definitions by IDs.
    `void` | `processAsyncCalculations(java.util.Set<Id> resourceIds, boolean synchronous)` Requests asynchronous calculations of the given resources to handle earlier than others by increasing the priority.
    `IGRCObject` | `processCalculationsOnDemand(IGRCObject object)` Evaluates applicable rules for a resource's fields and returns the object with calculated values set, but does not persist the calculated values.
    `ITBRuleDefinition` | `publishRuleDefinition(Id ruleDefinitionId)` Publish the draft content of the rule definition, so it can be used during the resource creation or the user's submission.
    `Id` | `startCalculationsInBulk(BulkRunCalculationsOptions options)` Starts calculations on any objects that meet the following criteria, through a long running process - on the object type of the calculation - object is unlocked - the object meets the applicability criteria of the calculation definition
    `ITBRuleDefinition` | `updateRuleDefinition(ITBRuleDefinition ruleDefinition)` Updates a rule definition.
    `void` | `validateRuleDefinition(ITBRuleDefinition ruleDefinition)` Validates the given rule definition and throws an `TBRuleException` when there is an issue.

- - ### Method Detail

    - #### getRuleDefinitions

          java.util.List<ITBRuleDefinition> getRuleDefinitions(Id ruleDefinitionId)

      Returns the published and draft versions of the rule definition if they exist.
      Parameters:
        `ruleDefinitionId` -
      Returns:

    - #### getRuleDefinitions

          java.util.List<ITBRuleDefinition> getRuleDefinitions()

      Deprecated.
      Returns the latest version of all `ITBRuleDefinition`s. Used by object manager. Probably a temporary method until getRuleDefinitions(IRuleDefinitionFindOptions ruleOptions) is implemented.
      Returns:

    - #### getRuleDefinitionsByType

          java.util.List<ITBRuleDefinition> getRuleDefinitionsByType(Id objectType)

      Returns the latest version of all `ITBRuleDefinition`s by object type
      Parameters:
        `objectType` - the rule definitions applicable to a specific type
      Returns:

    - #### getRuleDefinitionsByRuleType

          java.util.List<ITBRuleDefinition> getRuleDefinitionsByRuleType(TBRuleDefinitionType type)

      Returns the latest published version of all `ITBRuleDefinitions`s by `TBRuleDefinitionType` that are currently enabled. Rule Definition types are: create, standard, calculation
      Parameters:
        `type` -
      Returns:
      Since:
        8.2

    - #### getRuleDefinitions

          TBRuleDefinitionList getRuleDefinitions(ITBRuleDefinitionFindOptions ruleDefinitionFindOptions)

      Returns list of rule definitions based on the criteria defined by the `ITBRuleDefinitionFindOptions`
      Returns:

    - #### getRuleDefinitionByVersionId

          ITBRuleDefinition getRuleDefinitionByVersionId(Id versionId)

      Returns the rule definition by the version ID
      Parameters:
        `versionId` -
      Returns:
      Since:
        8.2

    - #### getRuleDefinition

          ITBRuleDefinition getRuleDefinition(java.lang.String name,
                                              Id typeDefinitionId,
                                              boolean draft)

      Returns a rule definition by name, type definition ID
      Parameters:
        `name` -
        `typeDefinitionId` -
        `draft` -
      Returns:

    - #### getRuleDefinition

          ITBRuleDefinition getRuleDefinition(Id ruleDefinitionId,
                                              boolean draft)

      Returns a rule definition by ID
      Parameters:
        `ruleDefinitionId` -
        `draft` -
      Returns:

    - #### getRunnableRules

          java.util.List<ITBRuleDefinition> getRunnableRules(Id objectType,
                                                             TBRuleDefinitionType ruleType)

      Get all runnable rules for an object type
      Parameters:
        `objectType` -
        `ruleType` -

    - #### createRuleDefinition

          ITBRuleDefinition createRuleDefinition(ITBRuleDefinition ruleDefinition)

      Creates a rule definition
      Parameters:
        `ruleDefinition` -
      Returns:

    - #### updateRuleDefinition

          ITBRuleDefinition updateRuleDefinition(ITBRuleDefinition ruleDefinition)

      Updates a rule definition. Note that the updated rule is not used by the workflow on a resuorce until it is published. It creates or updates a draft of the rule definition behind the scene.
      Parameters:
        `ruleDefinition` -
      Returns:

    - #### deleteRuleDefinitions

          void deleteRuleDefinitions(java.util.Set<Id> ruleDefinitionIds)

      Deletes rule definitions by IDs
      Parameters:
        `ruleDefinitionIds` -

    - #### hardDeleteRuleDefinitions

          void hardDeleteRuleDefinitions(java.util.Set<Id> ruleDefinitionIds)

      Hard-deletes rule definitions by IDs. Unlike `deleteRuleDefinitions(Set)`, this API will completely remove the rule definition and its associated rule/activity instances from the database, so there is not way to recover it.
      Parameters:
        `ruleDefinitionIds` -

    - #### publishRuleDefinition

          ITBRuleDefinition publishRuleDefinition(Id ruleDefinitionId)

      Publish the draft content of the rule definition, so it can be used during the resource creation or the user's submission.
      Parameters:
        `ruleDefinitionId` -
      Returns:
      Since:
        8.2

    - #### discardDraftRuleDefinition

          ITBRuleDefinition discardDraftRuleDefinition(Id ruleDefinitionId)

      Discard the draft content of the rule definition. No change to the last published version of the rule definition.
      Parameters:
        `ruleDefinitionId` -
      Returns:
      Since:
        8.2

    - #### enableRuleDefinitions

          void enableRuleDefinitions(java.util.Set<Id> ruleDefinitionIds,
                                     boolean enabled)

      enable or disable rule definitions by IDs
      Parameters:
        `ruleDefinitionIds` -
        `enabled` -

    - #### executeRules

          void executeRules(java.util.List<ITBRuleDefinition> rules,
                            Id resourceId)

      Evaluates and executes a list of rules on a resource.
      Parameters:
        `rules` -
        `resourceId` -

    - #### evaluateRules

          java.util.List<ITBRuleDefinition> evaluateRules(java.util.List<ITBRuleDefinition> rules,
                                                          Id resourceId)

      Evaluates a list of rules against a resource and returns the valid rules.
      Parameters:
        `rules` -
        `resourceId` -

    - #### processCalculationsOnDemand

          IGRCObject processCalculationsOnDemand(IGRCObject object)

      Evaluates applicable rules for a resource's fields and returns the object with calculated values set, but does not persist the calculated values.
      Parameters:
        `object` -
      Returns:
      Since:
        8.2

    - #### getRuleFactory

          ITBRuleFactory getRuleFactory()

      Returns a new rule factory object.
      Returns:

    - #### getAsyncCalculationRequests

          java.util.Map<Id,java.util.Set<Id>> getAsyncCalculationRequests(java.util.Set<Id> resourceIds)

      Returns the resources in the asynchronous calculation queue.
      Parameters:
        `resourceIds` - - set of resources to test if they have asynchronous calculation requests.
      Returns:
      Since:
        8.2

    - #### enableAsyncCalculations

          void enableAsyncCalculations(boolean enabled)

      Enables or disables asynchronous calculations. It updates the registry setting, so other cluster server would honor it. Also it wakes up the asynchronous calculation thread when it is idle.
      Parameters:
        `enabled` -
      Since:
        8.2

    - #### processAsyncCalculations

          void processAsyncCalculations(java.util.Set<Id> resourceIds,
                                        boolean synchronous)

      Requests asynchronous calculations of the given resources to handle earlier than others by increasing the priority. The background processor will pick up the calculations from the queue based on the priority. Note that if the calculation of the given resource depends on other one's calculation, their priority is set higher, too. If it is synchronous call, the API returns when all the requested resource's calculations are completed. Otherwise, the API returns the control immediately after the priority of given resources are raised.
      Parameters:
        `resourceId` -
      Since:
        8.2

    - #### getCalcStats

          java.util.Map<Id,TBCalcCounts> getCalcStats(java.util.Set<Id> calcDefIds)

      Returns the statistics of the calculations such as how many resources are in the queue for asynchronous calculation, or how many resources have calculation errors for a given calculation definition.
      Parameters:
        `calcDefIds` - : a set of calculation definition IDs to get the statistics. If the parameter is null or empty, it returns statistics for all the calculation definitions.
      Returns:
        a map of statistics whose key is calculation definition IDs
      Since:
        8.2

    - #### validateRuleDefinition

          void validateRuleDefinition(ITBRuleDefinition ruleDefinition)

      Validates the given rule definition and throws an `TBRuleException` when there is an issue.
      Parameters:
        `ruleDefinition` -
      Since:
        8.2

    - #### startCalculationsInBulk

          Id startCalculationsInBulk(BulkRunCalculationsOptions options)

      Starts calculations on any objects that meet the following criteria, through a long running process - on the object type of the calculation - object is unlocked - the object meets the applicability criteria of the calculation definition
      Parameters:
        `options` -
      Since:
        8.2

    - #### estimateStartingCalculationsInBulk

          int estimateStartingCalculationsInBulk(Id ruleDefinitionId)

      Returns estimated count that would meet the criteria to run the calculation in bulk
      Parameters:
        `ruleDefinitionId` -
      Since:
        8.2

Licensed Materials - Property of IBM
OpenPages with Watson (PID: 5725-D51)
© Copyright IBM Corporation 2013, 2021. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.