Package Import

This pane includes functions that import and configure rule packages.

From the tabs bar, select Configure > Rules then click on the Package Import accordion pane on the right.

Configuring a Package consists of declaring certain objects available to all Rules in the Package.

Such a declaration consists of specifying an appropriate Java code in the allotted text box. 

To make configuration of the Packages easier, insert blocks of predefined code (on the right side of the frame there is a small vertical toolbar with buttons).

The following actions are available for each Package:

  • Import specific classes
  • Insert variables
  • Insert functions

The Rules programmer can write the Rule's code to directly call the objects that are set up for the Package containing the Rule.

Importing a class into a Package adds a class to a Rule without having to specify the entire path.

For example, after importing the class UserBean() into the Package, it is possible to directly write UserBean() instead of com.engiweb.profilemanager.common.bean.UserBean().

Package Editor

An administrator familiar with programming languages can insert any object in the Package by writing the code directly in the text box.

A Package Editor is also available to assist administrators to accomplish this task.

The Editor uses the following buttons, located on the right-hand side of the text box:
  • New import New Import
  •  New variable New Variable
  • New function New Function

Variables usually support objects that are already instanced with global visibility to all the Rules of the Package; if, for example, there is an object that contains all the parameters required to connect to the DB, the object can be assigned to an "sql" variable (always visible to the Package's Rules) and can be used in the Rule code, as shown in figure above.

Lastly, it is possible to create Functions that always have global visibility to all the rules of a package. For example, if several rules request an operation for the arithmetic average of two numbers, this can be created directly in the Package instead of in each single rule.

Import a Class

To import a class, click on New import New Import button in the vertical toolbar on the right-hand side of the Package Imports pane.

The Classes window opens (figure below) with a list of available classes

Choose a class, then click Ok.

The Java code corresponding to the selected class is written in the text area on the right-hand side of the Replace With... window.

Enter a New Variable

To insert a new variable, click on New variable New Variable in the vertical toolbar on the right-hand side of the Package Imports accordion pane.

The text box displays the code corresponding to the declaration of a new variable.

The code is parametric and thus must be edited in the allotted spaces, defined by the characters <>.

Insert the object (specify entire system path) in the space <your class here>.

Insert a variable name in the space <variable name>; this name can then be used in every Rule of the Package.

Enter a New Function

To insert a new function click on New function New Function in the vertical toolbar on the right-hand side of the Package Imports accordion pane.

The text box displays the code corresponding to the declaration of a new variable.

The code is parametric and thus must be edited in the allotted spaces, defined by the characters <>.

Edit the parameters as follows:

  • Replace <return Type> with the type of objects that result from processing the function (e.g. an integer, a string, a class, etc.).
  • Replace <args here> with the list of parameters given to the function at input.
  • {} needs to contain the body of the function, i.e., all the code that implements the function.