Computing initial values for properties

To compute the initial value of a business-specific rule property, you implement an interface to compute property initial values and associate it with a rule model property through a key.

About this task

For example, if you have two properties, creationDate and expirationDate, attached to an artifact, you can compute and set the creationDate property to the current date, and set the expirationDate property to five years after the current date.

Procedure

To compute the initial value of a property:

  1. Implement the interface IlrInitialValue. This interface provides a method to retrieve the initial value of a property:
    
    getInitialValue(IlrElement element, String propertyName)
    
  2. Open the extension model file in which you defined the property.
  3. In the Rule Model Extension Editor, right-click the property for which you want to compute the initial value and then click New Child  > Annotation.

    The tree displays a new Annotation item.

  4. Select the Annotation item, and, in the Properties view, set these properties:
    • Set the Id property to initialValueCallback.

    • Set the Value property to a key that you use in Rule Designer or Decision Center to reference the implementation of the interface IlrInitialValue.

  5. Save the extension model file.

Results

In XML, you associate the property to the key that references the implementation as follows:


<?xml version="1.0" encoding="UTF-8"?>
<model:extension-model xmlns:model="http://ilog.rules.brms.extension/model" 
name="myExtension" nsURI="http://ilog.rules.brms.extension/myExtension">
  <add-property className="BusinessRule">
    <property extractable="true" name="creationDate" type="Date">
      <annotation id="initialValueCallback" value="datesHandlerID"/>
    </property>
    <property extractable="true" name="expirationDate" type="Date">
      <annotation id="initialValueCallback" value="datesHandlerID"/>
    </property>
  </add-property>
</model:extension-model>

You have implemented the calculation of an initial value for a property. You can now integrate it into Rule Designer or Decision Center.

Integration into Rule Designer

Integration into Decision Center

Create a Rule Designer plug-in with an initial value callback extension point.

Integrating initial values for properties into Rule Designer

Repackage the Decision Center archive to integrate and declare the classes for computing property initial values.