15 Using Expressions to Control Data

This chapter describes how to use expressions to evaluate and change the data stored in a data object.

This chapter includes the following sections:

15.1 Introduction to Expressions

Expressions allow you to perform calculations on data objects.

Using Oracle Business Process Composer, you can define and edit expressions in the following contexts:

  • Conditional sequence flows

  • Complex gateways

  • Timer events

  • Data associations

  • Notification tasks

Expressions do not allow you to directly reassign the values to data objects. However, you can use expressions to change the values passed to and from the implementation of a sequence flow. See Introduction to Data Associations for more information.

15.1.1 Introduction to the Expression Editor

The expression editor provides a simple way of creating expressions by allowing you to select data objects and operators from a list and insert them into your expression. You can also enter the expression manually if necessary.

Figure 15-1 shows the expression editor user interface.

Figure 15-1 Oracle Business Process Composer Expression Editor

Description of Figure 15-1 follows
Description of "Figure 15-1 Oracle Business Process Composer Expression Editor"

Table 15-1 The Expression Editor User Interface

Area Description

Expression field

Contains the text of the expression. You can edit this field directly, or use the Insert Into Expression tool.

Insert Into Expression

Inserts the selected data object or operator into the expression.

Data Object and Operator Chooser

Contain tabbed panes that allow you to select the data object or operator you want to insert into the expression.

Description tab

Provides a description of the selected operator.

Errors

Displays errors in the current expression.

15.1.2 Types of Expressions

Oracle Business Process Composer supports the following types of expressions:

  • Simple

  • Plain text

  • XML Literal

15.1.3 Simple Expressions

Simple expressions are defined using a basic expression language supported by Oracle Business Process Management (Oracle BPM).

15.1.3.1 Operator Types

Simple expressions support the following operator types:

  • Arithmetic Operators

  • Unary Operators

  • Equality and Relational Operators

  • Conditional Operators

You can use these operators to write expressions and conditions to define your process flow. Generally these expressions perform their calculations based on the data objects in your process. You can write expressions and conditions using the value of the data objects, but you cannot modify their value.

The following examples of expressions use operators:

  • totalAmount - discount

  • activationCount > 3

  • unitsSold <= 1200

Table 15-2, Table 15-3, Table 15-4, and Table 15-5 describe the supported operators in the simple expression builder.

Table 15-2 Arithmetic Operators

Operator Name Description

+

Addition

Adds numeric data types.

Concatenates Strings.

-

Subtraction

Subtracts numeric data types.

*

Multiplication

Multiplies numeric data types.

/

Division

Divides numeric data types.

rem

Remainder

Calculates the remainder of a division in which the divisor does not exactly divide the dividend.

( )

Precedence

Indicates the order of evaluation of an arithmetic expression.

Table 15-3 Unary Operators

Operator Name Description

+

Plus

Has no effect in the value of the numeric operand. Use it to indicate explicitly that a certain value is positive.

-

Minus

Negates an arithmetic expression.

*

Not

Logical complement operator. Negates the value of a boolean expression.

Table 15-4 Equality and Relational Operators

Operator Name Description

= or ==

Equal

Returns true is the first operand equals the second operand.

!=

Not Equal

Returns true is the first operand is not equal to the second operand.

>

Greater Than

Returns true if the first operand is greater than the second operand.

>=

Greater Than or Equal to

Returns true if the first operand is greater than or equal to the second operand.

<

Less Than

Returns true if the first operand is less than the second operand.

<=

Less Than or Equal to

Returns true if the first operand is less than or equal to the second operand.

Table 15-5 Conditional Operators

Operator Name Description

and

Conditional And

Returns true if both operands evaluate to true.

or

Conditional Or

Returns true if either operand evaluates to true.

15.1.3.2 Operator Precedence

Operator precedence indicates the order in which the compiler evaluates them. You can change operator precedence in an expression by using parenthesis.

In Oracle BPM the operator precedence is:

  • Addition, Subtraction

  • Multiplication, Division, Remainder

  • Plus and Minus

  • Less than, Greater Than, Less Than or Equal to, Greater Than or Equal to

  • Equal, Not Equal

  • Not

  • Conditional And

  • Conditional Or

15.2 Working with Expressions

Using Oracle Business Process Composer, you can create and edit expressions for conditional sequence flows and for data associations.

The following sections describe how to define expressions using Business Process Composer.

15.2.1 How to Define a Simple Expression for a Conditional Sequence Flow

Using Oracle Business Process Composer, you can create and edit expressions for conditional sequence flows. Conditional sequence flows use expression to determine the flow of your process.

To define an expression for a conditional sequence flow:

  1. Open your process.

  2. Ensure that the project is in edit mode.

  3. Click the edit icon for the conditional sequence flow you want to edit.

  4. Click Implementation.

  5. Click Edit.

    The expression editor window displays.

  6. Add any required data objects and operators.

    To add a data object to an expression:

    1. Select the Data Objects tab.

    2. Select a data object from the list.

      If you add a basic data object that is part of a complex data objects, expand the complex data object and select the basic data object.

    3. Click Insert Into Expression

    To add an operator to an expression:

    1. Select the Operators tab.

    2. From the expandable list, select the operator you want to add.

    3. Click Insert Into Expression.

  7. Click the Error tab, then verify that there are no errors in your expression.

  8. Click OK.

  9. Click Apply Changes in the Implementation tab.

15.2.2 How to Define a Simple Expression in Data Associations

Using Oracle Business Process Composer, you can create and edit expressions for data associations. Data associations use expressions to alter the values of data objects passed as inputs and outputs.

To define an expression within a data association input or output:

  1. Open your process.

  2. Ensure that the project is in edit mode.

  3. Right-click a flow object within your process then select Data Associations.

  4. Click Launch Expression Builder.

  5. Add any required data objects and operators.

    To add a data object to an expression:

    1. Select the Data Objects tab.

    2. Select a data object from the list.

      If you add a basic data object that is part of a complex data object, expand the complex data object and select the basic data object.

    3. Click Insert Into Expression

    To add an operator to an expression:

    1. Select the Operators tab.

    2. From the expandable list, select the operator you want to add.

    3. Click Insert Into Expression.

  6. Click the Error tab, then verify that there are no errors in your expression.

  7. Click OK.