Introduction to the Expression Builder How to Use the Expression Builder What You Need to Know About Working with Expressions

4-58 Oracle Fusion Middleware Users Guide for Oracle Business Rules Figure 4–69 Using Duration Methods in a Rule Figure 4–70 Adding a Rule Using Duration Function

4.10 Working with Expression Builder

Use the expression builder to create and edit expressions for Oracle Business Rules.

4.10.1 Introduction to the Expression Builder

You can access the expression builder from different parts of Rules Designer, including in the Edit Globals dialog, and in the conditions area when you work with conditions in Decision Tables, and when you enter rules and Decision Tables in advanced mode with free form expressions selected. Working with Rulesets and Rules 4-59 Figure 4–71 shows the Rules Designer expression builder. Figure 4–71 Rules Designer Expression Builder

4.10.2 How to Use the Expression Builder

In the expression builder when you double-click items in the Variables or Functions navigation trees, or in the Operators tab, or in the Constants tab, this inserts the item into the expression in the Expression area. You can also create or edit expressions directly by entering text in the Expression area. When you enter an expression, note that Variables are valid assignment targets and Constants are not valid assignment targets. Thus, you should use both tabs if you are unsure what type of item you want to add to the expression you are building. Specify an argument for a selected function by placing the cursor inside the function in the Expression field and double-clicking the expression or function to insert. For example, place the cursor inside the parentheses of a function and select a variable. This inserts the variable in the expression at the cursor position.

4.10.3 What You Need to Know About Working with Expressions

XML fact types allow XML Schema types, elements, and attributes to be used when writing rules. Elements and types defined in XML Schema can be imported into the data model and can then be used to create rules and Decision Tables, just as with Java fact types and RL Fact types. The mapping between the XML Schema definition and the XML Fact types uses the Java Architecture for XML Binding JAXB. By default, Oracle Business Rules uses the JAXB 2.0 shipped with the Oracle Application Server. JAXB as defined in JSR-222 provides a mapping between the types, names, and conventions in an XML Schema definition and the available types, allowed names and 4-60 Oracle Fusion Middleware Users Guide for Oracle Business Rules conventions in Java. For example, an element named order-id and of type xsd:integer is mapped to a Java Bean property named orderID of type BigInteger and xsd:int type maps to Java int. You can use expressions in Oracle Business Rules. Expressions allow arithmetic using the operators , +, , , and other supported operators on primitive numerics, for example double, int, and the numeric types Integer, Long, Short, Float, Double BigDecimal, and BigInteger that are available in the built-in dictionary. For more information on supported primitive numerics, see Oracle Fusion Middleware Language Reference Guide for Oracle Business Rules. Expressions allow casting between any two numeric types, for example, shortBigInteger1 + Long2 . Example 4–3 shows a few additional sample expressions. The expression processor uses the XPathXquery rules for type promotion XML Path Language XPath 2.0. For example, BigDecimal is promoted to floatdouble; type promotion going the other direction requires a cast, except for literals such as 3.3. Example 4–3 Sample Expressions in Actions with Types and Casting assign new double db = 3.3 assign new BigDecimal bd = 3.3 no cast required assign db = bd no cast required assign bd = BigDecimaldb cast is required

4.11 Using Bucketsets as Constraints for Options Values in Rules