Defining the context Object
Defining the context Object
You can define the context object of a BPL business process from the Context tab of the Business Process Designer. You can click the magnifying glass to launch the Finder Dialog for each of the following fields:
-
Request Class — Choose the class of the incoming request for this process.
-
Response Class — Choose the class of the response returned by this process.
-
Context Superclass — Use this option to provide custom context properties, in a different way than adding to the Context properties list, described next. To use Context Superclass, create a custom subclass of Ens.BP.ContextOpens in a new tab. In this subclass, define class properties to use as context properties. Use the name of this class as the value of Context Superclass in the business process. Then when you create <assign> actions, for example, you can choose these custom properties in addition to the standard properties of the context object.
You can add to the list of Context properties by clicking the plus sign to launch the Business Process Context Property wizard. Then enter values in the following fields:
-
Property Name — Must be a valid identifier.
-
Choose if the property data is one of the following: Single Value, List Collection, or Array Collection
-
Property Type — Type of this property including parameters.
Enter a data type class name in the Type field or click the magnifying glass to browse for a class you want to use as a data type.
-
Default Value (ignored for collections) — Enter an initial expression for a single value data type.
-
Instantiate — Select this check box for object-valued properties if you want the object to be instantiated when it is created.
-
Description — Enter an optional description of the context property.
Click OK to save your changes, Cancel to discard them. The Business Process Designer generates the necessary <context> and <property> elements in the BPL code.
To set property parameters such as MINVAL, MAXVAL, MINLEN, MAXLEN, or others in the Business Process Designer, add data type parameters to a context property when you first add the property, or at any subsequent time, by inserting a comma-separated list of parameters enclosed in parentheses after the data type class name. That is, rather than simply entering %StringOpens in a new tab or %IntegerOpens in a new tab, you can enter data types such as:
%String(MAXLEN=256) %Integer(MINVAL=0,MAXVAL=100) %String(VALUELIST=",Buy,Sell,Hold")
The Business Process Designer generates the necessary <parameters> element in the BPL code.
Once you have defined properties on the context object, you can refer to them anywhere in BPL using ordinary dot syntax and the property name, as in: context.MyData
For reference details, see the following resources:
-
Typically you choose the property type from the system library of data types described in “Data Types” in Using Caché Objects. These include %StringOpens in a new tab, %IntegerOpens in a new tab, %BooleanOpens in a new tab, etc.
-
System data types have optional parameters. For details, see the Parameters section in the chapter “Data Types” in Using Caché Objects. These include the MINLEN and MAXLEN parameters that set the minimum and maximum allowed lengths of a %StringOpens in a new tab property. The default maximum %StringOpens in a new tab length is 50 characters; you can reset this by setting the MAXLEN for that %StringOpens in a new tab property to another value.
By default, the ruleContext passed to the rule is the business process execution context. If you specify a different object as a context, there are some restrictions on this object: It must have a property called %Process of type Ens.BusinessProcessOpens in a new tab; this is used to pass the business process calling context to the rules engine. You do not need to set the value of this property, but it must be present. Also, the object must match what is expected by the rule itself. No checking is done to ensure this; it is up to the developer to set this up correctly.