Beruflich Dokumente
Kultur Dokumente
Page ii
TABLE OF CONTENTS
Table Of Contents ....................................................................................................................................................... ii Preface ........................................................................................................................................................................7 Intended Audience .................................................................................................................................................7 System Requirements ............................................................................................................................................7 Technical Support...................................................................................................................................................7 Corticon Business Rules Management Product Documentation ...........................................................................7 Using the Business Rules Modeling Studio.................................................................................................................8 Installation..............................................................................................................................................................8 Studio Components................................................................................................................................................8 File Suffixes ........................................................................................................................................................8 Starting Studio........................................................................................................................................................9 Initial Toolbar .....................................................................................................................................................9 Initial Menubar Options.................................................................................................................................. 10 File Menu .................................................................................................................................................... 10 Edit Menu ................................................................................................................................................... 11 Project Menu .............................................................................................................................................. 12 Vocabulary, Rulesheet, Ruleflow, Ruletest Menus .................................................................................... 12 Window Menu ............................................................................................................................................ 12 Help Menu .................................................................................................................................................. 13 The File Tab ..................................................................................................................................................... 13 The Active Studio Window.............................................................................................................................. 14 Window Tabs .............................................................................................................................................. 14 File Naming Restrictions ................................................................................................................................. 14 Importing Studio Files from Earlier Versions .................................................................................................. 15 The Rule Project ...................................................................................................................................................... 16 Creating a Rule Project ........................................................................................................................................ 16 The Rule Project Explorer Window ................................................................................................................. 17 The Vocabulary ........................................................................................................................................................ 19 The Vocabulary.................................................................................................................................................... 19 Creating a Vocabulary ......................................................................................................................................... 19 The Vocabulary Window ..................................................................................................................................... 20 Vocabulary Menubar Options......................................................................................................................... 21 File Menu .................................................................................................................................................... 21 Edit.............................................................................................................................................................. 21 Search Menu............................................................................................................................................... 21 Project Menu .............................................................................................................................................. 21 Vocabulary Menu ....................................................................................................................................... 21 Window Menu ............................................................................................................................................ 22 Help Menu .................................................................................................................................................. 22 Vocabulary Toolbar ......................................................................................................................................... 22 Context-Sensitive Right-Click Pop-up Menu ................................................................................................... 23 Populating a New Vocabulary ............................................................................................................................. 23
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page iii
The Vocabulary Tree View .............................................................................................................................. 23 Vocabulary Properties .................................................................................................................................... 24 Vocabulary Node Naming Restrictions ........................................................................................................... 24 Adding Nodes to the Vocabulary Tree View ................................................................................................... 25 Domain Nodes: Adding and Editing Domains and their Properties ........................................................... 25 Entity Nodes: Adding and Editing Entities and their Properties.............................................................. 26 Attribute Nodes Adding and Editing Attributes and their Properties ..................................................... 27 Association Nodes: Adding and Editing Associations and their Properties................................................ 28 Editing an Association ................................................................................................................................ 30 Renaming a Vocabulary Node .................................................................................................................... 30 Saving a New Vocabulary................................................................................................................................ 31 Opening an Existing Vocabulary ..................................................................................................................... 31 Modifying a Vocabulary .................................................................................................................................. 32 Creating a Vocabulary Report ......................................................................................................................... 32 The Rulesheet .......................................................................................................................................................... 33 Rulesheet Window .............................................................................................................................................. 33 Creating a New Rulesheet............................................................................................................................... 34 Rulesheet Menubar ........................................................................................................................................ 36 File Menu .................................................................................................................................................... 36 Edit Menu ................................................................................................................................................... 36 Search Menu............................................................................................................................................... 36 Project Menu .............................................................................................................................................. 36 Rulesheet Menu ......................................................................................................................................... 36 Window Menu ............................................................................................................................................ 39 Help Menu .................................................................................................................................................. 39 Rulesheet toolbar ........................................................................................................................................... 39 Context-Sensitive Right-Click Pop-up Menus ................................................................................................. 40 Rulesheet Tab Pop-up Menu ...................................................................................................................... 40 Rulesheet Pop-up Menu - Row................................................................................................................... 41 Rulesheet Pop-up Menu - Column ............................................................................................................. 42 Rulesheet Sections .......................................................................................................................................... 42 Scope .......................................................................................................................................................... 42 Filters .......................................................................................................................................................... 43 Nonconditional Rules ................................................................................................................................. 43 Rules ........................................................................................................................................................... 44 Rule Statements Window ............................................................................................................................... 44 Ref............................................................................................................................................................... 45 ID ................................................................................................................................................................ 46 Post ............................................................................................................................................................. 46 Alias ............................................................................................................................................................ 46 Text ............................................................................................................................................................. 46 Rule Name .................................................................................................................................................. 46 Rule Link ..................................................................................................................................................... 46 Source Name .............................................................................................................................................. 47 Source Link ................................................................................................................................................. 47 Category ..................................................................................................................................................... 47 Comments .................................................................................................................................................. 47
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page iv
Using the Business Vocabulary to Build Rules ................................................................................................ 47 Using the Operator Vocabulary to Build Rules ............................................................................................... 47 Literal Terms, Functions & Operations ....................................................................................................... 47 Naming Rulesheets ......................................................................................................................................... 48 Deleting Rulesheets ........................................................................................................................................ 48 Saving a New Rulesheet .................................................................................................................................. 49 Validating and Optimizing a Rulesheet ........................................................................................................... 49 Creating a Rulesheet Report ........................................................................................................................... 50 Closing a Rulesheet ......................................................................................................................................... 50 Saving a Modified Rulesheet .......................................................................................................................... 50 The Ruleflow ............................................................................................................................................................ 51 Ruleflow Window ................................................................................................................................................ 51 Creating a New Ruleflow ................................................................................................................................ 51 Naming Ruleflows ........................................................................................................................................... 53 Adding Ruleflows ............................................................................................................................................ 53 Deleting Ruleflows .......................................................................................................................................... 53 Saving a New Ruleflow.................................................................................................................................... 54 Ruleflow Menubar .......................................................................................................................................... 54 File Menu .................................................................................................................................................... 54 Edit Menu ................................................................................................................................................... 54 Search Menu............................................................................................................................................... 54 Project Menu .............................................................................................................................................. 54 Ruleflow Menu ........................................................................................................................................... 54 Window Menu ............................................................................................................................................ 54 Help Menu .................................................................................................................................................. 54 Ruleflow toolbar ............................................................................................................................................. 55 Context-Sensitive Right-Click Pop-up Menus ................................................................................................. 55 Ruleflow Tab Pop-up Menu ........................................................................................................................ 55 Ruleflow Window Pop-up Menu ................................................................................................................ 55 Ruleflow Object Pop-up Menu ................................................................................................................... 58 Ruleflow Window............................................................................................................................................ 59 Rulesheets .................................................................................................................................................. 59 Connectors ................................................................................................................................................. 59 Subflows ..................................................................................................................................................... 60 Service Call-Outs ......................................................................................................................................... 60 Iteration .......................................................................................................................................................... 60 Enabling & Disabling Iteration for Rulesheets............................................................................................ 60 Enabling and Disabling Iteration for Subflows ........................................................................................... 61 Ruleflow Tools Palette .................................................................................................................................... 61 Renaming a Ruleflow and/or Saving a Ruleflow to a Different Location ....................................................... 62 Creating a Ruleflow Report ............................................................................................................................. 62 Closing a Ruleflow ........................................................................................................................................... 63 Ruleflow Properties Tab ...................................................................................................................................... 63 Ruleflow Sub-tab............................................................................................................................................. 64 Rule Vocabulary .......................................................................................................................................... 64 Work Document Entity ............................................................................................................................... 64 Major and Minor Version Numbers ........................................................................................................... 64
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page v
Version Label .............................................................................................................................................. 64 Effective and Expiration Dates ................................................................................................................... 64 Total Number of Rules................................................................................................................................ 65 Comments Sub-tab ......................................................................................................................................... 65 Rulers & Grid Sub-tab ..................................................................................................................................... 66 The Ruletest............................................................................................................................................................. 67 The Ruletest Window .......................................................................................................................................... 67 Creating a New Ruletest ................................................................................................................................. 67 Ruletest Menubar ........................................................................................................................................... 70 File Menu .................................................................................................................................................... 70 Edit Menu ................................................................................................................................................... 70 Search Menu............................................................................................................................................... 70 Project Menu .............................................................................................................................................. 70 Ruletest Menu ............................................................................................................................................ 70 Window Menu ................................................................................................................................................ 73 Help Menu ...................................................................................................................................................... 73 Ruletest Toolbar.............................................................................................................................................. 73 Context-Sensitive Right-Click Pop-up Menus ................................................................................................. 74 Ruletest Tab Pop-up Menu Options ........................................................................................................... 74 Testsheet Window Pop-up Menu Options ................................................................................................. 74 Sample Testsheet Node Pop-up Menu....................................................................................................... 75 Testsheet Tabs ................................................................................................................................................ 75 Populating the Input Panel ............................................................................................................................. 75 Adding Entities to the Test Tree ................................................................................................................. 76 Creating Associations in the Test Tree ....................................................................................................... 76 Assigning Attribute Values in the Test Tree ............................................................................................... 77 Automatically Generating a Test Tree ........................................................................................................ 77 Executing Tests ............................................................................................................................................... 78 Sequence of Message Posting ........................................................................................................................ 79 Sorting Messages ............................................................................................................................................ 79 Using the Expected Panel ............................................................................................................................... 79 Expected Panel Output Results Match Expected Exactly ........................................................................ 80 Expected Panel Different Values Output than Expected......................................................................... 80 Expected Panel Fewer Values Output than Expected ............................................................................. 81 Expected Panel - More Values Output than Expected ............................................................................... 81 Expected Panel All Problems ................................................................................................................... 82 Format of Output Data ................................................................................................................................... 82 Creating Multiple Test Scenarios on the Same Testsheet .............................................................................. 83 Creating Multiple Test Scenarios as a Set of Testsheets ................................................................................ 84 Creating a Sequential Test Using Multiple Testsheets ................................................................................... 84 Naming Testsheets ......................................................................................................................................... 86 Adding Testsheets........................................................................................................................................... 86 Associating One Child Entity with More Than One Parent ............................................................................. 88 Saving Ruletests .............................................................................................................................................. 89 Importing an XML or SOAP Document to a Testsheet.................................................................................... 89 Exporting a Testsheet to an XML Document .................................................................................................. 90 A Sample Testsheet Exported to XML ........................................................................................................ 90
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page vi
Exporting a Testsheet to a SOAP Message ..................................................................................................... 90 Creating a Ruletest Report.............................................................................................................................. 91 Exiting Corticon Studio ........................................................................................................................................ 91 Appendix A: Keyboard Shortcuts Available in Studio ............................................................................................. 93 Appendix B: Corticon Studio and Server 5.2 Technical Publications ...................................................................... 94
Page 7
PREFACE
INTENDED AUDIENCE
The Studio Quick Reference Guide briefly describes the main features of Studio, where they are located in the user interface and how to use them. It is intended for use by anyone who models business rules using Studio. This document assumes that you have a general understanding of your Windows environment. For assistance with Windows basic commands not fully described in this manual, please consult your Microsoft Windows manual or online help system. Additional documentation may also be found at www.microsoft.com.
SYSTEM REQUIREMENTS
Corticon Studio 5.2 requires: Microsoft Windows 2000, XP, Vista, 7 32-bit (64-bit compatible) The Eclipse plug-in version requires Eclipse 3.5.2 or above Java Runtime Engine 1.6.0 or higher (included)
Hardware requirements include: Pentium M-class CPU or higher 512 MB RAM (1 GB recommended) 200 MB disk space (full install)
TECHNICAL SUPPORT
For Corticon Business Rules Management product support, call +1 650.212.2424 ext 200, or email support@corticon.com.
Page 8
STUDIO COMPONENTS
Studio files consist of four major types: 1. Vocabulary: a structured dictionary containing all necessary business terms and relationships between them used by the business rules. 2. Rulesheet: a set of conditions and actions and plain language statements written from a common business Vocabulary. 3. Ruleflow: a set of one or more Rulesheets organized for sequential execution. Once a Ruleflow has been saved and deployed to the Business Rules Server, it is called a Decision Service. 4. Ruletest: a set of one or more Testsheets containing sample data used for testing Rulesheets and Ruleflows. Like Rulesheets, Ruletests also use a common Vocabulary model. A Rule Project may contain any number of Vocabularies, Rulesheets, Ruleflows or Ruletests. Following construction and testing within Studio, a Rulesheet must be saved before it can be tested by a Ruletest. Ruleflows must be saved before they can be deployed to Corticon Server. Deployment and integration is covered in greater detail in the Server Integration & Deployment Guide. A quick introduction to this topic is provided in the Server Deployment Tutorial.
File Suffixes
The four types of files listed above have the following file types or file suffixes:
.ecore the Vocabulary. .ers the Rulesheet. Multiple Rulesheets may use the same Vocabulary, but each
Ruleflow.
Page 9
STARTING STUDIO
Initial Toolbar
The initial Studio toolbar displays the basic tools that you will need to create a new Vocabulary, Rulesheet, Ruleflow, or Ruletest files, or open existing files. At this point, many of the menubar options and toolbar buttons have limited functionality, but they will be described here because they are options which are commonly available to all open files.
Creates a new Corticon Studio 5.2 resource (also called an asset). Create a new Rule Project Create a new Rule Vocabulary Create a new Ruleflow. Create a new Rulesheet Create a new Ruletest Create a new Folder Saves any changes to the active file Prints the active file Disables the selection Moves a Custom Data Type (CDT) enumerated Label/Value row up in the list. See the Rule Modeling Guides Building the Vocabulary chapter for more info on CDTs. Moves a Custom Data Type (CDT) enumerated Label/Value row down in the list. See the Rule Modeling Guides Building the Vocabulary chapter for more info on CDTs. Inserts a new Column into the active file Removes the selected Column(s) from the active file Inserts 15 Columns at the end of the active file Inserts a new Row into the active file Removes the selected Row from the active file Inserts 15 Rows at the end of the active file
Page 10
Page 11
This option is grayed out when no files are open. Print Switch Workspace Allows you to print the currently active file. This option is grayed out when no files are open. Displays the Workspace Launcher dialog box, which allows you to navigate to projects stored in Workspaces other than the default Corticon Workspace directory. Allows you to import resources, including Corticon 4.x assets, from your file system into an existing project. See Importing Files from Earlier Versions. Allows you to export Corticon 5.2 resources to your local file system. Displays a Properties dialog for the open Vocabulary. This option is grayed out when no files are open. As files are opened and closed, a running list of the previous 4 files will be displayed here. Clicking a file name will open it. Closes all open Studio components and exits the application.
Import
Exit
Edit Menu Undo Redo Cut Copy Paste Delete Select All Insert Row Remove Row Add Rows to End Insert Column Remove Column Undoes the previous action Re-performs the previous action after if it was undone Cuts the selection and places it in the Clipboard Copies the selection into the Clipboard Pastes the contents of the Clipboard Deletes the selection Applicable to Ruleflows only. See Ruleflow section. Inserts a new Row into the active file Removes the selected Row from the active file Inserts 15 Rows at the end of the active file Inserts a new Column into the active file Removes the selected Column(s) from the active file
Page 12
Inserts 15 Columns at the end of the active file Moves a Custom Data Type (CDT) enumerated Label/Value row up in the list. See the Rule Modeling Guides Building the Vocabulary chapter for more info on CDTs. Moves a Custom Data Type (CDT) enumerated Label/Value row down in the list. See the Rule Modeling Guides Building the Vocabulary chapter for more info on CDTs. Disables the selection Disabled in Corticon 5.2
Move Down
Opens a closed Rule Project selected in the Rule Project Explorer window Closes a Rule Project selected in the Rule Project Explorer window.
Vocabulary, Rulesheet, Ruleflow, Ruletest Menus These menus appear in the toolbar when the various Studio files are active. Each of these is described in the sections that follow. Window Menu Open Perspective Rule Modeling Other Resets the Studio layout to the default windows most commonly used during modeling If you have created and saved custom perspectives, you can open them in the list displayed when this option is selected Opens the Error Log window Opens the Localization window Opens the Problems window Opens the Properties window for the active file Opens the Rule Messages window
January 13, 2012
Show View > Error Log Localization Problems Properties Rule Messages
Page 13
Rule Operators Rule Project Explorer Rule Statements Rule Vocabulary Other Customize Perspective Save Perspective As Reset Perspective Close Perspective Close All Perspectives Preferences
Opens the Rule Operators window Opens the Rule Project Explorer window Opens the Rule Statements window Opens the Rule Vocabulary window Allows you to customize some of the menus and options Allows you to arrange the windows within Studio and save their layout. Resets the Studio layout to the default windows Closes the open perspective Closes all open perspectives Allows switching between Rule Modeling and Integration Deployment modes of Studio. Integration Deployment mode includes all functionality of Rule Modeling mode plus the ability to map Vocabularies to external data such as XML and Java business objects. Locating and loading your Studio license is also performed in this window.
Help Menu Key Assist Contents About Displays a pop-up menu of shortcut keys that can be utilized within Studio. Displays the Studio Online Help. Displays Studio product, version, build, and copyright information.
Page 14
the windows controls. 1. 2. 3. 4. File type and name Minimize the files window Maximize files window Close the files window
Window Tabs Each window tab contains information about the windows status: This window is the active Studio file, and its save status is up-to-date This window is not active. Clicking on it will cause it to become active This window is the active Studio file, but recent changes have not yet been saved. As soon as the file is saved, the asterisk before the windows tab name will disappear. The small red square overlaying the windows file type icon indicates there is an error somewhere in the window. Look in the Problems window for more information (Window>Show View>Problems in the Studio menubar) The small yellow triangle overlaying the windows file type icon indicates there is a warning somewhere in the window. Look in the Problems window for more information (Window>Show View>Problems in the Studio menubar)
Page 15
File names may contain or start with almost any alphanumeric character and most special characters - the Save or Save As dialog will inform you if you choose a prohibited character, as shown below. File names may not begin with a space, but may contain spaces in subsequent character positions.
Page 16
Or, click the down arrow to the right of the New icon Project.
Either method will launch the New Project wizard, shown below.
Page 17
Make sure the Use default location checkbox is checked 1 and enter a name for your project in the Project name field. Notice that the path to your new Rule Project is automatically appended to Studios default workspace folder to define its Location. Click Finish to create your new Rule Project.
You can also choose to create your new Project in a different Workspace by using the Browse button to locate and select it. January 13, 2012
Page 18
Now that we have created a Rule Project, we can turn our attention to creating a Vocabulary that well use to model our Business Rules.
Page 19
THE VOCABULARY
THE VOCABULARY
A Vocabulary is used to build rule models in a Rulesheet or test cases in a Ruletest (see the Rulesheet and Ruletest sections of this manual). Once a Vocabulary is open, other Studio options, including a Vocabulary option in the menubar and relevant toolbar icons, become available. Vocabulary files have the file suffix .ecore.
CREATING A VOCABULARY
Well use the same general process to create a new Vocabulary that we used to create our first new Rule Project. Follow these steps to create a new Vocabulary: 1. Select File>New>Rule Vocabulary from the Studio menubar OR 2. click the down arrow to the right of the New icon select Rule Vocabulary. on the Studio toolbar and
Either method will launch the Create a New Vocabulary wizard, illustrated below.
Page 20
3. Select the parent Rule Project for the new Vocabulary by highlighting the Example_Project folder we just created. 4. Enter a name for the new Vocabulary in the File name field. It is not necessary to type the file extension .ecore (we used Cargo here). 5. Click Finish to create your new Vocabulary. It is now displayed in the new Rule Vocabulary window (A), in the Rule Project Explorer window (B), and as the open file and active tab in the Cargo.ecore window (C). The window sizes have been adjusted to fit on the page.
C B
Page 21
The Vocabulary window, i.e., the window with a tab containing the name of your Vocabulary file (C, above), provides all the tools you need to create a new or modify an existing Vocabulary.
Studio 5.2 Quick Reference Guide Clear Java Class Metadata Localize
Page 22
Report
Window Menu These options are the same as for the initial Studio Help Menu These options are the same as for the initial Studio
Vocabulary Toolbar
When a Vocabulary window is active, the following additional options become available on the toolbar:
Same as Vocabulary>Add Domain in the menubar. Same as Vocabulary>Add Entity in the menubar. Same as Vocabulary>Add Attribute. Same as Vocabulary>Add Association in the menubar.
The Creating a Vocabulary chapter in the Rule Modeling Guide contains more details on the Vocabulary modeling process, including the use of these options.
Page 23
Page 24
Vocabulary Properties
Each type of node in the Vocabulary (including the name) has its own types of properties. These properties are displayed immediately to the right of the node simply by clicking on the node name or icon.
The Vocabularys name node properties consist of Custom Data Types definitions. Please refer to the Building the Vocabulary chapter of the Rule Modeling Guide for complete details regarding the creation and use of Custom Data Types.
No two Entities in the same Domain may have the same node name (caseinsensitive).
Page 25
Names of Operators (e.g., sum, size, month, now, today, etc.) or Extended Operators (if any) may not be used as Entity or Domain node names. They may be used as Attribute or Association Role node names. Custom Data Type names may not use the names of any of the base data types (e.g., string, decimal, boolean, etc.). See the Rule Modeling Guides chapter Creating the Vocabulary for more information about Custom Data Types. Names of aliases in the Scope section may not match (case-sensitive) the node names of Entities in the Vocabulary. No two Attributes/Association Role nodes in the same Entity may have the same name (case-insensitive). No two Domains within another Domain may have the same node name (caseinsensitive). No two root-level Domains may have the same node name (case-insensitive).
Page 26
Entity Nodes: Adding and Editing Entities and their Properties 1. Select the name node in the Vocabulary tree to add a new Entity node to the root level of the tree. Or, select the newly created Domain node to add a new Entity to the Domain. 2. Right-click to display the pop-up menu and choose Add Entity OR Choose Vocabulary>Add Entity from the menubar OR Choose from the toolbar 3. Select the Entity in the Vocabulary tree to display its properties. 4. Assign property values as shown below:
Note: this window is shown as it appears when in Rule Modeling mode. Integration Deployment mode adds fields which are explained in the Server Integration & Deployment Guide. Property Entity Name Value Assign a name to the entity. By default, this will be prefilled as Entity_x, where x is an automatically determined unique number. As with Domains, double-clicking the node in the tree view will also open an editing box. Name changes made in either the node or the property will update in both places Not used in Studio 5.2. Optional. The Vocabulary model contains extensive support for inheritance concepts. For more information on using this feature, please refer to the Rule Modeling Guide, Creating the Vocabulary chapter.
Other properties are visible while in Integration Deployment mode; see the Server Integration & Deployment Guide for details.
Page 27
Attribute Nodes Adding and Editing Attributes and their Properties 1. Select any Entity node in the Vocabulary tree view. 2. Right-click to display the pop-up menu and choose Add Attribute OR Choose Vocabulary>Add Attribute from the menubar OR Choose from the toolbar 3. Select an Attribute on the Vocabulary tree view to display its properties. 4. Assign property values as described in the following table.
Note: this window is shown as it appears when in Rule Modeling mode. Integration Deployment mode adds fields which are explained in the Server Integration & Deployment Guide. Property Attribute Name Value Assign a name to the new Attribute. As with Domain and Entity nodes, double-clicking the node in the tree view will also open an editing box. Name changes made in either the node or the property will update in both places Enter the data type of the attribute. The default value is String. Other available data types: Boolean, Decimal, DateTime, Date, Integer and Time. All types are described in the Rule Language Guide and in the Rule Modeling Guides Creating the Vocabulary chapter. A mandatory attribute cannot have a value of null. This setting affects the members of the values sets shown in Rulesheet drop-downs. For example, an attribute whose Mandatory value is No will always include a null value selection in its Rulesheet drop-downs. Choose the attributes Mode from the drop-down list. Base attributes exist or are used by systems outside Corticon, and are included in the XML schemas and contracts generated by the Deployment Console. Base attributes map directly to an element in the XML CorticonRequest/Response documents or object properties processed by the Server in production. Extended Transient attributes are derived fields; they exist only during rule execution and are not part of XML schemas generated by the Deployment Console. They do not need to be included in the XML
January 13, 2012
Data Type
Mandatory
Mode
Page 28
CorticonRequest documents or objects, and they are not included in the XML CorticonResponse documents or objects produced by the Server in deployment. Likewise, they cannot be dragged into a Ruletests Input column because they are created as output. Extended Persistent attributes refer to a special technical feature described in the examples found in
<corticon_install_dir>\Samples\Dynamic Schema.
Association Nodes: Adding and Editing Associations and their Properties To add a new Association node: 1. Select an Entity in the Vocabulary tree view. 2. Right-click to display the pop-up menu and choose Add Association. OR Choose Vocabulary>Add Association from the menubar. OR Choose from the toolbar. 3. Complete the Association window as shown in the following table: Note: this window is shown as it appears when in Rule Modeling mode. Integration Deployment mode adds fields which are explained in the Server Integration & Deployment Guide. Property Source Entity Name Value An association relates two entities. Studio refers to one entity as the source and the other as the target. Choose the name of the supplier from the drop-down list, which includes the entity names already defined in this Vocabulary. Choose the name of the 2nd entity the target entity from the drop down list. Select the combination of radio buttons that describe the desired relationship between the two entities. The possible combinations are: One-To-Many. This is the default and is shown as 1* in the properties. This means that a given instance of the supplier entity may be related to multiple instances of the target entity. In the Vocabulary tree view, a one-to-many association is shown by the icon to the right.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 29
One-To-One. This is shown as 11. This means that a given instance of the supplier entity may be related to a single instance of the target entity. In the Vocabulary tree view, a one-to-one association is shown by the icon to the right. Many-To-One. This is shown as *1. This means that multiple instances of the supplier entity may be related to a single instance of the target entity. In the Vocabulary tree view, a many-to-one association is shown by the icon to the right. Many-To-Many. This is shown as **. This means that multiple instances of the supplier entity may be related to multiple instances of the target entity. In the Vocabulary tree view, a many-to-many association is shown by the icon to the right. Mandatory. Also known as optionality. Select this box if at least one instance of the source or target MUST be present in data sent to the Corticon Server to be processed by rules using this Vocabulary. Role Names Role names are useful when two entities share more than one association. Custom role names can give each association a unique, descriptive name. Source-To-Target provides a name for the association from the perspective of the source entity. Target-To-Source provides a name for the association from the perspective of the target entity. Bidirectional. Select Bidirectional if you want the association to be traversable (visible) in both directions within the Vocabulary. This means that associations between two entities are visible from each entity in the Vocabulary tree view. This option provides the most flexibility when writing rules. Source Entity Target Entity. Use this option to prevent the association from the Target entity to the Source entity from being displayed in the Vocabulary tree view. This option prevents a rule from being written using the scope
Target_entity.source_entity.attribute.
Navigability
Source Entity Target Entity. Use this option to prevent the association from the Source entity to the Target entity from being displayed in the Vocabulary tree view. This prevents a rule from being written using the scope
Source_entity.target_entity.attribute.
See the Rule Modeling Guide for more information on using associations in rule modeling.
Page 30
Editing an Association 1. Select an association on the Vocabulary tree to display its properties. 2. Edit properties as described above.
Renaming a Vocabulary Node 1. Double-click on the node name or icon to display an editing box. 2. Type the desired new node name and press Enter.
Page 31
Page 32
Modifying a Vocabulary
1. Highlight the Vocabulary Editor tab to enter edit mode. 2. Select any node to display its properties. 3. Modify node properties as described above.
Page 33
THE RULESHEET
A Rulesheet is a file that contains a set of business rules. By organizing these rules, it becomes a self-contained, independent unit of automated decision-making. A Rule Project can include any number of Rulesheets. Following test and validation, one or more Rulesheets may be packaged in a Ruleflow (see The Ruleflow chapter) and deployed into a production environment (described in the Server Integration & Deployment Guide). Once packaged in a Ruleflow and deployed and available to other IT systems, we refer to the Ruleflow as a Decision Service. Because a Rule Project may contain multiple Rulesheets, there are two methods of navigating between open Rulesheets within Studio: Double-clicking on any Rulesheet name in the Rule Project Explorer window opens that Rulesheet and makes it active. Clicking on any Rulesheet tab makes that Rulesheet active.
Multiple Rulesheets may be open in Studio simultaneously, although only one may be active at any given time. A Rulesheet file has the suffix .ers.
RULESHEET WINDOW
Opening a Rulesheet or making a Rulesheet the active Studio window causes the Studio menubar and toolbar to display the tools needed to begin working with rules.
Page 34
3. Highlight the Rule Project you would like to associate the new Rulesheet with in the list (or enter it manually in the Enter or select parent folder: field. 4. Enter a file name for the Rulesheet in the File name: field. Click Next > to continue.
Page 35
5. In this step you must select the Vocabulary to associate the Rulesheet to. A Rulesheet can only be associated with one Vocabulary. Here, we simply expand the Example_Project folder and highlight the Cargo.ecore file we created earlier. As you create additional Vocabulary files within a Rule Project, they become available for selection from this list.
Page 36
6. Accept the default Presentation Metaphor of Decision Table and click Finish. Your new Rulesheet is now displayed in the Rule Project Explorer window (A) and in a new Rulesheet window with a tab of the given name (B).
A Rulesheet menubar and toolbar replace the Vocabulary menubar and toolbar and you are now ready to begin modeling your rules.
Rulesheet Menubar
Many of the functions provided by the menubar are also accessible through the toolbar. When a menubar option has an equivalent toolbar icon, the icon is shown alongside. File Menu These options are the same as for the Vocabulary file type Edit Menu These options are the same as for the Vocabulary file type Search Menu These options are the same as for the Vocabulary file type Project Menu These options are the same as for the Vocabulary file type Rulesheet Menu Logical Analysis >
Page 37
Creates a graphic that shows the execution sequence of the rules in the active Rulesheet. Your default graphic viewer should launch to display the diagram, and a copy of the file will be saved to
<corticon_install_dir>\Studio\plugins\c om.corticon.services_5.2.0\DepGraph
Creates a graphic that shows the logical dependencies of the data created in the Rulesheet. This is different than an Execution Sequence Diagram in that it does not show the sequence of rule execution. Your default graphic viewer should launch to display the diagram, and a copy of the file will be saved to
<corticon_install_dir>\Studio\plugins\c om.corticon.services_5.2.0\DepGraph
Clear Analysis Results Check for Logical Loops Check for Completeness Check for Conflicts Enable Conflict Filter Previous Conflict
Removes highlighting that resulted from checking for conflicts and completeness. Performs logical loop detection across all rules in all Rulesheets in the active Project. Highlights incompleteness in the active Rulesheet. Highlights conflict between two or more rules in the active Rulesheet. A toggle that either hides or shows all rule columns not part of the current conflict. Highlights the previous conflict in the sequence. This option is grayed out until you perform a conflict check. Highlights the next conflict in the sequence. This option is grayed out until you perform a conflict check. Highlights the first conflict in the sequence. This option is grayed out until you perform a conflict check. Highlights the last conflict in the sequence. This option is grayed out until you perform a conflict check. Advanced functionality described in the Rule Modeling Guide, Dependency & Looping chapter
Next Conflict
First Conflict
Last Conflict
Page 38
Threshold Expand Rules Collapse Rules Compress Rules Creates multiple simple rules from each complex rule. Reverses the Expand Rules function. Detects overlapping conditions between rules and combines columns to produce a smaller number, but logically equivalent, set of rule columns. Causes rule columns that have been expanded into component rules (also called sub-rules) to be renumbered from left to right. A toggle that switches between the advanced and simple Rulesheet views.
Renumber Rules
Preconditions are Filter expressions that stop Rulesheet execution if not satisfied by at least one piece
of data. For more information, see the Filters chapter of the Rule Modeling Guide.
Minimum Filter
Applies only to Filter expressions, enabling behavior described in the Filters chapter of the Rule Modeling Guide. Default. This option affects the active Rulesheet only. Causes rules to execute without re-evaluation or reexecution (no looping). For more information about this processing mode, see the Rule Modeling Guide. Allows only multi-rule inter-dependencies to reevaluate and re-execute. This option affects the active Rulesheet only. For more information about this processing mode, see the Rule Modeling Guide. Allows all rule dependencies (including selfdependencies) to re-evaluate and re-execute. This option affects the active Rulesheet only. For more information about this processing mode, see the Rule Modeling Guide. Opens the Rulesheet localization window. See the Localization section of the Rule Modeling Guide for more information. Creates an HTML report and launches your browser for viewing. See Creating a Rulesheet Report.
Advanced Inferencing
Localize
Report
Page 39
Window Menu These options are the same as for the Vocabulary file type Help Menu These options are the same as for the Vocabulary file type
Rulesheet toolbar
Many of the functions provided by the toolbar are also accessible through the menubar.
Toggles to the advanced or simple Rulesheet views. New Rulesheets are initially shown in the simple view. Natural Language view. Clicking this icon will enable Natural Language view of the active Rulesheet. See the Rule Modeling Guide for more information about this feature. Expands conditions and actions to display all component rules (those containing no dashes). Same as menubar option Rulesheet>Rule Column(s)>Expand Rules. Collapses conditions and actions to hide component rules and show only general rules (those containing dashes). Same as menubar option Rulesheet>Rule Column(s)>Collapse Rules. Compresses conditions and actions to eliminate redundancies within general and component rules. Same as menubar option Rulesheet>Rule Column(s)>Compress Rules. Clears the colored highlights that appear when an conflict or completeness check is performed. Same as menubar option Rulesheet>Logical Analysis>Clear Analysis Results. Performs logical loop detection. Same as menubar option Rulesheet>Logical Analysis>Check for Logical Loops. Performs completeness check. Same as menubar option Rulesheet>Logical Analysis>Check for Completeness. Performs conflict check. Same as menubar option Rulesheet>Logical Analysis>Check for Conflicts. Highlights the first conflict in a set. This button is grayed out until you perform an conflict check. Same as menubar option Rulesheet>Logical Analysis>First Conflict. Highlights the previous conflict in a set. This button is grayed out until you perform an conflict check. Same as menubar option Rulesheet>Logical Analysis>Previous Conflict. Highlights the next conflict in a set. This button is grayed out until you perform an conflict check. Same as menubar option Rulesheet>Logical Analysis>Next Conflict. Highlights the last conflict in a set. This button is grayed out until you perform an conflict check. Same as menubar option Rulesheet>Logical Analysis>Last Conflict.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 40
Enables the conflict Filter, which hides all rule columns not part of the current conflict. This feature is a toggle the filter is disabled when the red funnel icon is visible. Same as menubar option Rulesheet>Logical Analysis>Conflict Filter. Once enabled, the conflict Filter icon appears like this. Same as menubar option Rulesheet>Logical Analysis>Conflict Filter. Click to disable.
The options available in these pop-up menus depend on which Rulesheet section or section the mouse is over when it is right-clicked. Not all options are available for all sections. Rulesheet Tab Pop-up Menu The Rulesheet Tab Pop-up menu, appearing when a Rulesheet tab is right-clicked, is shown to the right. The right-click pop-up menus are context-sensitive, meaning not all options will be available at all times.
Restore Move Size Minimize Maximize Makes the entire Rulesheet window moveable for relocating into other sections of Studio Assists in resizing the Rulesheet window by providing highlighted bars for dragging. Collapses the entire Rulesheet window. Clicking the Rulesheet tab returns it to its original size and position Expands the Rulesheet window to fill the entire screen
Page 41
Closes the Rulesheet. You will be asked to save any changes Closes any other tabs that may be open. You will be asked to save any changes Closes all open Vocabulary, Rulesheet, Ruleflow, and Ruletest windows Opens a copy of the existing Rulesheet window
Many of the options in the Rulesheet Tab Pop-up Menu rearrange the Studio view, or perspective. If you want to revert to the original, default view, select Window>Reset Perspective from the Studio menubar. Rulesheet Pop-up Menu - Row Right-clicking in a row within a Rulesheet causes a pop-up menu to appear with the following options: A sample Rulesheet Pop-up menu when you right-click within a row is shown to the right. These options repeat several of those found in the Studio menubar and toolbar, as described previously.
The right-click pop-up menus are context-sensitive, meaning not all options are available for all active sections of the Rulesheet. For example, this pop-up menu displays options available for condition and action rows.
Page 42
Rulesheet Pop-up Menu - Column Right-clicking in a column within a Rulesheet causes a pop-up menu to appear with the following options: A sample Rulesheet Pop-up menu when you right-click within a column is shown to the right. These options repeat several of those found in the Studio menubar and toolbar, as described previously.
The right-click pop-up menus are context-sensitive, meaning not all options are available for all active sections of the Rulesheet. For example, this pop-up menu displays options available for condition and action columns.
Rulesheet Sections
The Rulesheet window is divided into several sections, each with a specific use in creating business rules. Scope This section is visible only when the Advanced View icon on the Studio toolbar is clicked.
Scope section, showing an Entity and its alias
The Scope section provides a reduced set of Vocabulary terms with which to
Page 43
build a Rulesheet. The Scope section can be populated directly by dragging and dropping Vocabulary elements into it, or indirectly, by dragging and dropping Vocabulary nodes onto other Rulesheet sections. Once a node is visible in the Scope section, it can be dragged and dropped to other Rulesheet sections henceforth. For those Entities in the Scope section, aliases can be defined by double-clicking the Entity to open an edit box. An alias replaces the fully qualified entity name wherever it is used in the Rulesheet, and serves as a sort of local name for use in that Rulesheet only. See the Rule Modeling Guide for details on scope, context and Rulesheet aliases. Filters This section is visible only when the Advanced View icon on the Studio toolbar is clicked.
Filters are boolean expressions 2 that are applied to data before rule columns are evaluated. Before using this section, we recommend reading the Filters chapter of the Rule Modeling Guide.
Nonconditional Rules This section is visible in all Rulesheet views, both Simple and Advanced
Column 0 in the Conditions/Actions section of the Rulesheet is special because the Conditions rows are grayed-out and unusable. Expressions may only be modeled in the Action rows. Logically, this means that all Actions modeled in Column 0 are unconditionally executed. In other words, no Conditions must be satisfied in order for these Actions to execute.
2
Boolean expressions are those expressions which resolve or reduce to a true or false answer. In other words, for given test data, the expression is either true or false. For more discussion of boolean expressions, see the Rule Language Guide January 13, 2012
Page 44
Each Action row in Column 0 acts as a separate, independent rule. In earlier versions of Corticon Studio, a separate Nonconditional Rules section contained this type of logic. In version 5.2, Nonconditional rules appear as Actions in Column 0. Each Action row constitutes a separate Nonconditional rule. Rules This section of the Rulesheet organizes Conditions, Values and Actions in a table format.
Conditions (quadrant 1) and Actions (quadrant 2) are organized in the decision table shown above. Sets of Conditions and Actions are tied together to form rules by the vertical columns spanning the two right quadrants (3 & 4) of this section. The cells in a vertical rule column (highlighted in blue) specify the Condition rows which must be satisfied (determined by the cell values in quadrant 3) necessary to execute or fire the Action rows (determined by the cell values in quadrant 4). The illustration above contains the model of the sample business rule: if a cargos volume is less than 300, then assign its packaging a value of Pallet.
Page 45
Rule Statements serve as documentation or elaboration on the meaning and intent of business rules modeled in the Rulesheet. Linking the plain-language description of a business rule in the Rule Statement section to its formal model in the other sections can provide important insight into rule operation during testing and deployment. Here, rule statement #2 is an informal description of the rule logic modeled in the Rulesheet column #2, as shown above. When a Rule Statement row is clicked, the corresponding Columns or Action rows will highlight in orange in the Rulesheet. When a Rulesheet column is selected, the corresponding Rule Statement will highlight in orange. Ref This field is mandatory when linking Rule Statements to their Rulesheet columns (the rule models). Rule Statements have a many-to-many relationship with Rulesheet columns. In other words, a Rule Statement may be reused for multiple Columns, and multiple Rule Statements may be expressed for a single Column. Entries in the Ref column serve to establish the relationship between the Rule Statements and Rulesheet columns. The various options are summarized below: Ref 1 1:3 {1,3} 0 A0 B1 C1 A1:B2 { A1 , B2 } 1:B2 A:2 The Rule Statement is linked or connected to: Column 1 Columns 1,2 and 3 Columns 1 and 3 Column 0 Action Row A in Column 0 Action Row B in Column 1 Action Row C in Column 1 Action Rows A and B in Columns 1 and 2 Action Row A in Column 1 and Action Row B in Column 2 invalid invalid
Page 46
When a colon (:) character is used to indicate that a range of Action cells is linked to the Rule Statement, then the left-hand and right-hand sides of the : must have the same form: both [column][row], both [column], or both [row] values. When they do not, the values will turn red, as shown in the last two rows above. ID This column is optional. It allows you to link Rule Statements to external source documentation using a code or ID number. Post This field is mandatory if you want the Rule Statement to appear as a Rule Message during Rulesheet execution (called posting the Rule Statement). Three severity levels are available: Info, Warning, and Violation. These severity levels have no intrinsic meaning - you can use them however you want. In a Studio Ruletest, Rule Messages with Info severity are color-coded green, Warnings yellow, and Violations red. Alias This field is mandatory if you want the Rule Statement posted during Rulesheet execution. All posted Rule Messages must be attached or linked to a Vocabulary entity. The choice of entity to post to is usually based on the entity being tested or acted upon in the associated rule. Text Technically, this field is optional, but posting a Rule Statement with no text results in an empty Rule Message. In order to have a meaningful posted Rule Message, we recommend entering plain language business rule statement in this field. Even when you dont plan to post messages during Rulesheet execution, creating a clear, concise version of the rule model is considered a best practice in rule modeling. Rule Name This field is optional. It allows you to assign custom names to the Rule Statements and the rule models they link to. Rule Link This field is optional. When a rule model has external documentation, you can enter an absolute path to a file on your local system to link it to.
Page 47
Source Name This field is optional. It allows you to reference the name of the source material the rule originates from. Source Link This field is optional. It allows you to link to the source material the rule originates from using an absolute path to a local file. Category This field is optional. It allows you to assign a category name to each Rule Statement and the rule model it links to. Comments This field is optional. It allows you to enter any comments for this Rule Statement and rule model it links to.
You can use either the TAB key to move from cell to cell within a row or the ARROW keys to move between rows within the Rulesheet grid. To move to another section in the Rulesheet, click on a cell within that section. Dragging and dropping is shown in this Guide as a dotted orange line, with an orange circle indicating the drag origin, and an orange diamond indicating the drag destination.
Page 48
Not all operators may be used in all types of rules or in all parts of the Rulesheet refer to the Rule Language Guide for complete details. 1. Click the General or Attribute Operators folders, or click the plus sign beside a category, to expand them. 2. Select the desired operator and drag and drop it onto the Rulesheet.
Naming Rulesheets
Rulesheets may be named when created and renamed by File>Save As
Deleting Rulesheets
Deleting Rulesheets is performed using one of the following methods: Right-click the Rulesheet in the Rule Project Explorer window and select Delete from the pop-up menu Select the Rulesheet in the Rule Project Explorer window and hit the Delete key.
Page 49
Page 50
Closing a Rulesheet
1. Close the Rulesheet using on its tab or the File>Close in the menubar. 2. Choose Yes to save any changes and close the file.
Page 51
THE RULEFLOW
A Ruleflow is a way of aggregating and organizing Rulesheets into a single unit of automated decision-making. It is a flow diagram depicting a set of one or more Rulesheets that have been validated using tools introduced earlier in this manual. A Ruleflow may be assembled from as many Rulesheets as you want, provided that all the Rulesheets use the same Vocabulary file. In other words, a Ruleflow can have only one associated Vocabulary. Following test and validation, a Ruleflow may be deployed into a production environment (described in the Server Integration & Deployment Guide). Once deployed and available to other IT systems, we refer to a Ruleflow as a Decision Service. In Studio, an individual Rulesheet may be tested using a Ruletest. But in order to deploy a Rulesheet to Corticon Server, it must be packaged as a Ruleflow. Only Ruleflows are deployable to Corticon Server and invocable as Decision Services. The Ruleflow concept, new in Corticon Studio 5, is intended to facilitate Rulesheet reuse - any Rulesheet can be included in as many Ruleflows as desired. In earlier versions of Corticon Studio, reusing a Rulesheet required cutting and pasting, or recreating it, into multiple Rule Set files. Ruleflow files have the suffix .erf.
RULEFLOW WINDOW
Opening a Ruleflow or making a Ruleflow the active Studio window causes the Studio menubar and toolbar to display the tools needed to begin working with Ruleflows.
Page 52
2. Highlight the Project you would like to associate the new Ruleflow with on the Project list (or enter it manually in the Enter or select parent folder: field. 3. Enter a file name for the Ruleflow in the File name: field. Click Next > to continue.
4. Select the Vocabulary to associate the Ruleflow to. A Ruleflow can only be associated with one Vocabulary. Here, we simply expand the Example_Project folder and highlight the Cargo.ecore file, which was created earlier in the Creating a Vocabulary section. As you create additional Vocabulary files within a Project they
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 53
become available for selection from this list for use with this or other Ruleflows that you create.
5. Your new Ruleflow is now displayed in the Rule Project Explorer window (A) and in a new Ruleflow window with tab of the given name (B). A Rulesheet menubar and toolbar replace the Vocabulary menubar and toolbar and you are now ready to begin modeling your rules.
Naming Ruleflows
As noted earlier, you name your Ruleflows during the Ruleflow creation process. As always, Ruleflow names, just like any other Studio files, must adhere to and comply with the guidelines shown in the File Naming Restrictions section of this document.
Adding Ruleflows
To add additional Ruleflows to a Rule Project, select File>New>Ruleflow from the menubar and repeat the steps recounted earlier in the Ruleflow creation process. Alternatively, you can select New>Ruleflow from the toolbar or highlight a file in the Rule Project Explorer file list and select New>Ruleflow from the pop-up menu to create additional Ruleflows.
Deleting Ruleflows
A Ruleflow can be deleted by highlighting it in the Rule Project Explorer file list and selecting Edit>Delete from the menubar, or by right-clicking the file in the Rule Project Explorer file list and selecting Delete from the pop-up menu.
Page 54
Ruleflow Menubar
Many of the functions provided by the menubar are also accessible through the toolbar. When a menubar option has an equivalent toolbar icon, the icon is shown alongside. File Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Edit Menu With the following exception, these options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Select All Search Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Project Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Ruleflow Menu Properties Report Opens the Ruleflow properties window, usually at the bottom of the Studio window Creates an HTML report and launches your browser for viewing. See Creating a Ruleflow Report. Selects all Ruleflow objects
Window Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Help Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types
Page 55
Ruleflow toolbar
A few special toolbar icons, shown below inside orange boxes, are inserted into the standard Studio toolbar when the Ruleflow is the active window. Many of the functions provided by the toolbar are also accessible through the menubar.
Opens the Ruleflow properties window, usually at the bottom of the Studio window Zooms the Ruleflow window to magnification selected
The options available in these pop-up menus depend on where within the Ruleflow the mouse is when it is right-clicked. Ruleflow Tab Pop-up Menu The Ruleflow tab pop-up menu has the same options as the other tab pop-ups, including the Rulesheet. Ruleflow Window Pop-up Menu Right-clicking within a Ruleflow window will cause a pop-up menu to display with the following options:
Page 56
A sample Ruleflow Window Pop-up menu, that is displayed when you right-click within the Ruleflow window, is shown to the right.
All right-click pop-up menus are context-sensitive, meaning not all options are available for all active sections of the Ruleflow.
File > Save as Image File Print Select > All All Shapes All Connectors Arrange All View > Grid Ruler Page Breaks Recalculate Page Breaks Snap to Grid Same as Studio toolbar Selects objects as follows: Selects all objects in the Ruleflow Selects all shapes in the Ruleflow Selects all connectors in the Ruleflow Arrange all objects in the Ruleflow displays a light gray grid overlay in the Ruleflow window displays rulers on the X and Y axes of the Ruleflow window displays breaks in the Ruleflow window when the window is larger than the size of the page updates breaks when changes are made to the Ruleflow window assists in aligning Ruleflow shapes to the overlay grid (whether visible or not) displays a light gray grid overlay in the Ruleflow window
Page 57
Zoom > Zoom In Zoom Out Zoom to 100% Zoom to Fit Fit to Width Fit to Height Fit to Selection Align > Align Left Align Center Align Right Align Top Align Middle Align Bottom Auto Size Make Same Size Both Height Width Order > Bring to Front Send to Back Bring Forward
Changes the magnification of the Ruleflow diagram in the follow ways: increases magnification reduces magnification reverts to default magnification changes magnification to fit selection changes magnification to fit the selections width changes magnification to fit the selections height changes magnification to fit the selections height and width
Aligns the left edges of all selected objects Aligns the centerlines (vertically) of all selected objects Aligns the right edges of all selected objects Aligns the top edges of all selected objects Aligns the centerlines (horizontally) of all selected objects Aligns the bottom edges of all selected objects
Resizes selected Rulesheet block icons to be the same size Resizes selected Rulesheet block icons to be the same height Resizes selected Rulesheet block icons to be the same width Brings the selected object to the front of the diagram Sends the selected object to the back of the diagram Brings the selected object one level closer to the front of the diagram
January 13, 2012
Page 58
Send Backward
Sends the selected object one level further to the back of the diagram
Ruleflow Object Pop-up Menu Right-clicking within a Ruleflow window will cause a pop-up menu to display. The options available in the pop-up menu depend on the object selected, but most contain the following: A sample Ruleflow Object Pop-up menu, that is displayed when you right-click on a Ruleflow object, is shown to the right.
The right-click pop-up menus are context-sensitive, meaning not all options are available for all active sections of the Ruleflow. This pop-up menu displays options available for condition and action rows.
File > Save as Image File Align > Align Left Align Center Align Right Align Top Align Middle Align Bottom Auto Size Make Same Size Both Height Resizes selected Rulesheet block icons to be the same size Resizes selected Rulesheet block icons to be the same height Aligns the left edges of all selected objects Aligns the centerlines (vertically) of all selected objects Aligns the right edges of all selected objects Aligns the top edges of all selected objects Aligns the centerlines (horizontally) of all selected objects Aligns the bottom edges of all selected objects
Page 59
Width Order > Bring to Front Send to Back Bring Forward Send Backward
Resizes selected Rulesheet block icons to be the same width Brings the selected object to the front of the diagram Sends the selected object to the back of the diagram Brings the selected object one level closer to the front of the diagram Sends the selected object one level further to the back of the diagram
Ruleflow Window
Ruleflow diagrams are displayed within the Ruleflow window. The objects that comprise or populate a Ruleflow window include: Rulesheets Rulesheets are the core objects in a Ruleflow. By arranging and organizing Rulesheets in the Ruleflow, you can specify execution sequence of the Rulesheets and control the iteration (if desired) of the Rulesheets. Ruleflows serve as a kind of deployable container for Rulesheets. Rulesheets remain the basic unit of decision making, but they become much more reusable when combined in different ways in different Ruleflows. For example, Rulesheet sample.ers can be included in many Ruleflows, each of which may have its own use in different business processes or applications. This is a serviceoriented approach (SOA) to using Rulesheets, which is compatible with the SOA design practices commonly in use in modern IT system development. Rulesheets may be designated for iteration by clicking the iteration icon which appears when you hover the mouse cursor over a Rulesheet object in the Ruleflow window. Connectors Connectors are the objects that serve to connect or stitch Rulesheets together and control their sequence of execution. If a connector is drawn from Rulesheet sample1.ers to sample2.ers, then when a deployed Ruleflow is invoked, it will execute the rules in sample1.ers first, followed by the rules in sample2.ers.
Page 60
Subflows Subflows provide yet another level of reusability of Ruleflow objects. A Subflow may contain many Rulesheets and connectors - it essentially becomes a package of these objects that can be copied and pasted and re-used within the Ruleflow. Subflows may also be designated for iteration, so that all the objects in the Subflow are re-executed until the values derived by their constituent rules cease changing. Service Call-Outs Service Call-outs are a type of extension to a Ruleflow, and require significant Java development expertise. The method for building Service Call-outs is documented in detail in the Extensions User Guide. Service Call-outs are enabled by your Corticon license. If you do not see the Service Callout icon in your Studios Ruleflow editor palette (see below), then your license does not enable Service Call-outs.
Iteration
Iteration may be enabled for Rulesheet and Subflow objects in a Ruleflow. When an object is set to iterate, it will repeatedly re-execute until the values derived by the objects rules cease to change. Once values in the object cease changing, the iteration stops and execution continues to the next (as determined by the Connectors) object, which may be either another Rulesheet or Subflow. Enabling & Disabling Iteration for Rulesheets To enable iteration for Rulesheets, hover your mouse cursor over the Rulesheet block icon. You should see a circular icon appear in a call-out pop-up window. Move your mouse to click the circular icon, and the icon will appear inside the Rulesheet block icon, underneath the Rulesheets name label, as shown below:
To disable iteration, click on the circular icon and hit the Delete key.
Page 61
Enabling and Disabling Iteration for Subflows To enable iteration for Subflows, hover your mouse cursor over the Subflow blocks title section. You should see a circular icon appear in a call-out pop-up window. Move your mouse to click the circular icon, and the icon will appear near the bottom of the Subflow block icon. To disable iteration, click the circular icon and hit the Delete key Logical loop processing options within a Rulesheet do not result in a circular icon appearing on the Rulesheet object within the Ruleflow.
Page 62
Once a tool has been selected, it remains selected until you perform the action. To perform the same action again, re-select the tool.
Page 63
Closing a Ruleflow
1. Close a Ruleflow using the on the Ruleflow tab, by rightclicking the tab and selecting Close from the pop-up menu or by selecting File>Close on the menubar. 2. Choose Yes to save any changes if you have modified the Ruleflow in any way prior to closing it.
Page 64
Ruleflow Sub-tab
Rule Vocabulary Use this field to change the Vocabulary referenced by this Ruleflow. Notice that the location of the Rule Vocabulary associated with the Ruleflow is automatically entered for you in the Rule Vocabulary field. You can change this value by selecting Browse and choosing a different Vocabulary, if necessary. Work Document Entity The Work Document Entity drop-down menu allows you to choose from among the existing entities in your Vocabulary and designate one of them the Work Document Entity. The Work Document Entity provides the root for XML schemas generated in the Deployment Console. Rule Modelers generally need not be concerned with this setting, as it relates to the Ruleflow deployment on Corticon Server. Major and Minor Version Numbers Major Version numbers for Ruleflows are optional and are assigned manually. Minor Version numbers are automatically incremented each time a Ruleflow is saved. A Minor version number may also be incremented manually. When we use different version numbers to label identically named Ruleflows, the Server keeps them straight in memory, and responds correctly to requests for the different (Major) versions. In other words, an application or process can use (or call) different (Major) versions of the same Ruleflow simply by including the (Major) version number in the request message. The details of how this works at the Server level are technical in nature and are described in the Server Integration & Deployment Guide. A plain-text description of this version can be added in the Ruleflow Version Label field, immediately below the Ruleflow Minor Version field. Version numbers may be manually raised anytime but never lowered. Version Label Optional. Give the version a unique text label. Effective and Expiration Dates Effective and Expiration dates are optional for Ruleflows and can be assigned singly or in pairs. When we use different Effective and Expiration dates to describe identically named Ruleflows, the Server keeps them straight in memory, and responds correctly to requests for the different dates. In other words, an application or process can use
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 65
different versions of the same Ruleflow depending on date criteria. The details of how this works at the Server level are technical in nature and are described in the Server Integration & Deployment Guide. Effective and Expiration Dates may be assigned using the same window as above. Clicking on the Effective Date or Expiration Date drop-down displays a calendar:
Effective Date and Expiration Date Times are entered in their respective Time fields. Total Number of Rules Counts the total number of rules in all the Rulesheets included in this Ruleflow. For Column numbers 1 and higher, each enabled column is counted as one rule. For Column 0, each enabled Action row is counted as one rule.
Comments Sub-tab
Selecting the Comments link within the Properties window allows you to add comments to your Ruleflows, as shown below:
Page 66
Page 67
THE RULETEST
THE RULETEST WINDOW
A Ruletest is the mechanism within Studio for creating use cases or test scenarios of sample data and sending them to a Rulesheet or Ruleflow for processing. Ruletests consist of one or more Testsheets which test independent Rulesheets or Ruleflows, or can be linked together to test a succession of Rulesheets or Ruleflows to simulate a process sequence. Opening a Ruletest or making a Ruletest the active Studio window causes the Studio menubar and toolbar to display the tools needed to test Rulesheets and Ruleflow. Rulesheets, as individual files, may only be tested using a Studio Ruletest. In order to deploy and test using Corticon Server, Rulesheets must be packaged as Ruleflows before they can be executed. Ruleflows may be tested both in Studio using Ruletests and on Server using standard request messages.
Page 68
2. Select the parent folder for the new Ruletest, in our example Example_Project. This will associate the Ruletest with the Example_Project project and display it in the Rule Project Explorer window along with the other files in that project. 3. Enter a file name for the new Ruletest, in our example Example_Ruletest. 4. Click Next > to continue and display the Select Test Subject dialog box, shown below. Here, you select the Rulesheet or Ruleflow that is to be tested. Youll be presented with 2 lists of available test subjects, both Local and Remote. The Local test subjects are the Rulesheets and Ruleflows available in your active Project. The Remote section contains a list of remote Corticon Server instances that Studio is aware of 3. If these remote Servers are running, and if Studio has network access to them, then clicking Update list will tell these remote Servers to report which Ruleflows are currently deployed to them and available for execution. You can select one from the list.
The list of remote services Studio is aware of is configured in Studios properties. Please see the CcDeployment.properties section of the Server Integration & Deployment Guide for more details Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 69
Page 70
7. The new Ruletest should appear as a new node in the Rule Project Explorer tree (A), a new window with the chosen Ruletest name as its tab name (B). The new Ruletest will also have a Testsheet tab (C). A Testsheet tab is divided into 3 vertical panels: Input, Output, and Expected. In the graphic above, Expected is not shown. 8. You can easily change the Ruletests test subject by double-clicking on the current test subject, immediately below the Testsheet tab (C). This will re-open the Select Test Subject window, where you can change your selection.
Ruletest Menubar
The Ruletest menubar includes the same File, Edit, Search, Window and Help options as shown in Rulesheet menubar, in addition to a Ruletest menubar and toolbar containing specialized Ruletest options. Many of the functions provided by the menubar are also accessible through the toolbar. When a menubar option has an equivalent toolbar icon, the icon is shown alongside. File Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Edit Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Search Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Project Menu These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types Ruletest Menu Testsheet > Add Testsheet Remove Testsheet Link To Previous Testsheet Inserts a new Testsheet. Deletes the specified Testsheet. Linking a Testsheet to a previous Testsheet causes the Input panel of the 2nd Testsheet to be populated with the date from the Output panel of the 1st.
Page 71
Change Test Subject Cut Testsheet Copy Testsheet Paste Testsheet Rename Testsheet Move Backward Move Forward Move To Beginning Move To End
Opens a window that allows you to select a new Rulesheet or Ruleflow to test. Cut the active Testsheet Copy the active Testsheet Paste the active Testsheet Displays an entry window to change the Testsheet name Moves the selected Testsheet tab one tab towards the beginning of the Ruletest. Moves the selected Testsheet tab one tab towards the end of the Ruletest. Moves the selected Testsheet tab directly to the start of the Ruletest. Moves the selected Testsheet tab directly to the end of the Ruletest. Import a valid CorticonRequest XML document into Studio as a Ruletest. Set to Null Go to Entity Sort Entities resets the selected Testsheet tree node to null Displays an entity when an association tree node is selected Sorts entity nodes alphabetically by name. One entity must be selected. Displays the Ruletest Properties window
Page 72
Exports the active Testsheets Input pane as a 4 CorticonRequest XML document Exports the active Testsheets Input pane as a CorticonRequest XML document with SOAP envelope Constructs the minimum Input data structure necessary to test the chosen Rulesheet. Uses the Rulesheets scope for guidance. Exports the active Testsheets Output pane as a CorticonResponse XML document Exports the active Testsheets Output pane as a CorticonResponse XML document with SOAP envelope Copies the data in the Output panel to the Expected panel. Exports the active Testsheets Expected pane as a CorticonResponse XML document Exports the active Testsheets Expected pane as a CorticonResponse XML document with SOAP envelope Create a WSDL directly from the Input pane of a Ruletest. For more information about using WSDLs to integrate Decision Services, see Server Integration & Deployment Guide.
Output > Export Response XML Export Response SOAP Copy to Expected Expected > Export Response XML Export Response SOAP Export WSDL
CorticonRequest and CorticonResponse documents are the standard messages passed to and from Corticon Server. See Server Integration & Deployment Guide for more information. January 13, 2012
Page 73
Compiles the Ruletest target without executing it. Compiles (if needed) and executes Ruletest
Reruns the color-coded validation of the Output and Expected data. See Using the Expected Panel. Executes all Testsheets in the Ruletest. Creates an HTML report and launches your browser for viewing. See Creating a Ruletest Report.
Window Menu
These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types
Help Menu
These options are the same as for the Vocabulary, Rulesheet, and Ruleflow file types
Ruletest Toolbar
When a Ruletest is the active Studio window, the Studio toolbar will adjust to show additional, Ruletest-specific options.
Same as Ruletest>Testsheet>Add Testsheet Same as Ruletest>Testsheet>Remove Testsheet Same as Ruletest>Testsheet>Link to Previous Testsheet Same as Ruletest>Testsheet>Change Test Subject Same as Ruletest>Testsheet>Cut Testsheet Same as Ruletest>Testsheet>Copy Testsheet Same as Ruletest>Testsheet>Paste Testsheet
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 74
Same as Ruletest>Testsheet>Rename Testsheet Same as Ruletest>Testsheet>Move Backward Same as Ruletest>Testsheet>Move Forward Same as Ruletest>Testsheet>Move to Beginning Same as Ruletest>Testsheet>Move to End Same as Ruletest>Testsheet>Data>Output>Copy to Expected Same as Ruletest>Testsheet>Output Validation>Validate Same as Ruletest>Testsheet>Deploy Same as Ruletest>Testsheet>Run Test
Page 75
Sample Testsheet Node Pop-up Menu A sample Testsheet Node Pop-up menu is shown to the right.
Testsheet Tabs
A Ruletest is comprised of Input, Output and Expected panels. Ruletests you create are displayed in the Rule Project Explorer window. You can navigate between open Testsheets by clicking the Testsheets tab to make it active.
Page 76
Adding Entities to the Test Tree Drag and drop entity nodes from the Rule Vocabulary window onto the Testsheet as shown to the right. When creating new root-level entities, the nodes may be dropped anywhere on the Input panel of the Testsheet. Entities may be deleted by pressing the Delete key or by selecting Delete from the right-click pop-up menu. Creating Associations in the Test Tree Creating an association adds an instance of the selected entity in the Testsheet, but this is different from creating an instance of a root-level entity by itself (without forming the association to the parent entity). An association creates a link between entities; if this did not exist, there would be no direct relationship between them. To create an association: 1. Drag and drop the association for the desired child entity directly on top of the parent entity, as indicated by the orange line in this illustration, from the Rule Vocabulary window into the Input panel. 2. Verify the child entity has the appropriate indented structure underneath the parent entity, indicating the association has been created correctly.
Page 77
Be careful to follow precisely the orange line in these illustrations, which shows that the association must be dragged from the Vocabulary and dropped directly onto the yellow entity icon to which it is being associated. Dropping the association on an empty or incorrect portion of the Testsheet will produce a message informing you that the association request was ignored. Assigning Attribute Values in the Test Tree 1. Double-click the desired term to open a data entry box 2. Type test data in the box and press Return to enter the data, or 3. Press Tab to advance the entry box to the next attribute, and press Return to open its data entry box.
Attributes not used in a scenario may be deleted by selecting them and pressing the Delete key or by selecting Delete from the right-click pop-up menu. Multiple attributes may be selected using Shiftclick and Ctrl-click to select contiguous and non-contiguous groups, respectively. In the illustration above, the attributes of aircraft[1] have not been deleted, just collapsed and hidden from view. Automatically Generating a Test Tree When creating a Ruletest, its important to provide the input data required by the Rulesheet being tested. Without the necessary input data, the rules cannot create the expected output. Creating a test tree manually can be tedious for very large Rulesheet test subjects. Studio provides a way to simplify and speed up the process. Generate Test Tree is an option in Studio menu Ruletest>Testsheet>Data>Input that automatically analyzes the Vocabulary terms used by the Rulesheet and generates the corresponding tree structure in the Input pane of the Testsheet. The input of specific data values for the attributes still must be performed manually, but the tree structure is created automatically. When a Vocabulary association between two entities is one-to-many, then the Generate Test Tree feature will create 2 instances (copies) in the tree. You can add more to test a larger collection, or delete them to test a smaller collection. You can always edit the resulting test tree by adding or removing terms.
Page 78
Executing Tests
Before a Ruletest can be executed, the corresponding Rulesheets (whether being tested directly or as contained in Ruleflows) must be compiled. This compilation process does not occur until the Ruletest is run. Depending on how many Rulesheets and rules must be compiled, this compilation step may take a few seconds. Each time a change is made to a rule in a Rulesheet referenced by the Ruletest, the rules will need to be re-compiled. This recompilation will occur automatically when Run Test is selected. This will cause a brief delay in execution while the new compilation is performed. Once a Ruletest has been executed, it will rerun without recompiling as long as the rules have not changed since the last execution. Changing the Input test data does not require recompilation. To compile rules without running them, a special Deploy toolbar option is provided: . This is a different sequence of events than that performed by earlier versions of Corticon Studio. In versions 4.x and earlier, the compilation step occurred whenever a Rule Set was saved, so rules were already compiled when a Ruletest was executed. This resulted in longer save times, but shorter test execution times. The sequence in Studio 5.2 results in shorter save times, but longer test execution times. The overall sum of both save and test execution steps remains the same, however. 1. Execute the test by choosing Ruletest>Testsheet>R un Test or toolbar. on the
2. Check the outcome of the test in the Results panel. 3. Test results are displayed in regular type style. Parts of the test tree (nodes) modified by the Server are shown in bold black text. Any errors are shown in red.
Page 79
4. Posted rule statements appear in the Rule Messages window at the bottom of the Testsheet. In addition to the Message and Severity columns, the box also displays the Entity node to which the rule statement has been posted. In the example above, the Rule Message displayed was posted, or linked to Cargo[1]. This means that it was the data contained in Cargo[1] which caused the rule corresponding to the posted Rule Statement to fire. 5. Make any necessary adjustments to the Rulesheet, save and re-test by repeating steps 1-5.
Sorting Messages
Messages posted by rules and displayed in the Rule Messages window are a useful tool for understanding and troubleshooting Rulesheet execution. Messages displayed can be sorted in the following ways: When the Severity header is clicked, the messages sort by severity level first (Info then Warning then Violation), then in order of generation, with earlier messages posted higher in the table. When the Message header is clicked, the messages sort in order or generation, with the first message generated displayed in the first row. When the Entity header is clicked, the messages sort in ascending order by entity name/number, then in order of generation.
When any Rule Message row is clicked, the corresponding Entity highlights in the Output panel above. This provides a convenient way of navigating among the data in a large data set, rather than vertically scrolling.
Page 80
Expected Panel Output Results Match Expected Exactly In the example below, both packaging values are shown in bold text, indicating that these values were changed by the rules. Because all colors are black, the Output data is consistent with the Expected data.
Expected Panel Different Values Output than Expected In the example shown below, the expected value of Cargo[1] packaging value is Container, but the Ruletest produced an actual value of Pallet. Since the Output does not match the Expected data, the text is colored red.
Page 81
Expected Panel Fewer Values Output than Expected In the example below, Cargo[2] is included in the Input and Expected trees, but did not appear in the Output tree. Because data was expected but not produced, the difference is colored green.
Expected Panel - More Values Output than Expected In the example below, Cargo[2] was produced in the Output, but was not anticipated by the Expected panel. For this reason, the difference is colored blue.
Page 82
Expected Panel All Problems All the problems and differences described individually above are combined below to show how a real Ruletest (with many problems) may appear.
Page 83
Page 84
Page 85
2. Assume we want to test 3 Ruleflows (named Cargo, Cargo2 and Cargo3) in sequence. 3. Create a new Ruletest as before and link it to Ruleflow cargo.erf as usual. See step 1 of Executing Tests. 4. Execute the Ruletest to generate data in the Output panel. 5. Add a new Testsheet using and link it to Ruleflow cargo2.erf. 6. Link this new Testsheet to the previous Testsheet using . The data from the Output panel of the previous Testsheet should appear in the Input panel of the new Testsheet. 7. Repeat for as many new Testsheets as needed to model the sequence. You can execute one sheet at a time by selecting from the toolbar, or execute all at once by selecting Ruletest>Run All Tests from the menubar
Page 86
Naming Testsheets
When you add a new Testsheet, it is assigned a default name of Untitled_X, where X is a sequential number. You can rename each Testsheet tab for easy reference. Unnamed Testsheet tabs will be saved with the default name. 1. You can either select Ruletest>Testsheet>R ename Testsheet from the menubar or the right-click pop-up menu, or select the Rename Testsheet icon from the Ruletest toolbar to display the Rename Test Tab dialog box. 2. Type the new name in the space provided and press or click Enter. 3. Like Rulesheets and Vocabularies, Test and Testsheet names must comply with the guidelines described in File Naming Restrictions.
Adding Testsheets
1. You can either select Ruletest>Testsheet>A dd Testsheet from the menubar or the rightclick pop-up menu, or select the Add Testsheet icon from the Ruletest toolbar to display the Select Test Subject dialog box.
Page 87
2. Select the Rulesheet to associate with the new Ruletest and click OK. Studio creates a new Testsheet tab at the end of the current set of tabs, assigns the new tab a system-generated name, and automatically selects the new tab.
Page 88
addition to
FlightPlan[1], drag aircraft as
shown to the right, and press the CTRL key as you drop it. 5. A pop-up window will ask you to select the Aircraft you are linking to. In this case, select Aircraft[1] and click OK.
Page 89
6. Verify the child entity has the appropriate indented structure underneath both parent entities, indicating the two associations have been created correctly. 7. Notice that data for aircraft[1] is only entered once, under the FlightPlan[1] entity, even though it is associated with both FlightPlans. 8. In large Testsheets, it may be difficult to locate the original instance of aircraft[1]. Clicking on any copy and choosing Ruletest>Go To Entity from the menubar will automatically locate the original instance.
Saving Ruletests
When you save a new test, the Save Window displays. Follow the instructions shown in Saving a New Rulesheet to save your test scenario. When you save an existing test, the system automatically saves it to the existing name (*.ert). To save the Ruletest to another name, choose File>Save As from the menu.
Page 90
A Sample Testsheet Exported to XML The sample XML file shown below is a direct export of the Input Testsheet created in Populating the Input Testsheet section. Notice the hierarchical structure. Consult the Server Integration & Deployment Guide for more information about the sections of the XML document, including the important decisionServiceName parameter shown in line 2 of the CorticonRequest tag, below.
Page 91
Page 92
When you close the Studio (select File>Exit from the menu), you are prompted to save all open Vocabulary, Rulesheet, Ruleflow, and Ruletest files. If you choose to exit without first saving your files, any changes you made since opening them will be lost.
Page 93
Page 94
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
CORTICON
Business Rules Modeling Studio 5.2 Installation Guide
TABLE OF CONTENTS
Table of Contents ................................................................................................................................................. ii Installing the Business Rules Modeling Studio .................................................................................................... 3 Preface ........................................................................................................................................................... 3 Corticon Business Rules Management Product Documentation .................................................................. 3 Documentation Conventions......................................................................................................................... 3 Installation Environment ............................................................................................................................... 4 Option 1 Windows Application ............................................................................................................ 4 Option 2 Eclipse Plug-in ....................................................................................................................... 4 Option 1: Installing Studio as a Windows Application ......................................................................................... 5 About the Studio Installer ............................................................................................................................. 5 System Requirements.................................................................................................................................... 5 Technical Support .......................................................................................................................................... 5 Before Installing Corticon Studio................................................................................................................... 6 Corticon Studio Setup Wizard ....................................................................................................................... 6 Startup Screen......................................................................................................................................... 7 License Agreement ................................................................................................................................. 8 Choose Install Folder............................................................................................................................... 8 Changing Installation Directory .............................................................................................................. 9 Choose Install Set .................................................................................................................................... 9 Pre-Installation Summary ..................................................................................................................... 10 Installation Status ................................................................................................................................. 10 Completing the Installation .................................................................................................................. 11 Desktop Shortcuts ................................................................................................................................. 11 Changing Studio Memory Allocation .................................................................................................... 12 Program Removal ........................................................................................................................................ 12 Option 2: Installing Studio as an Eclipse Plug-in ................................................................................................ 13 Supported Configurations ........................................................................................................................... 13 Installation Instructions ............................................................................................................................... 13 Appendix A: Enabling Studio Internationalization ............................................................................................. 24 Displaying Studio in your locale of choice ............................................................................................ 24 Creating a new language bundle .......................................................................................................... 24 Switching Operating System Locales .................................................................................................... 25 Appendix B: Corticon Studio and Server 5.2 Product Documentation ............................................................. 27
Page 3
DOCUMENTATION CONVENTIONS
Corticon documentation uses the following conventions: Document names are shown in bold face italic type: Studio Installation Guide. Screen, button and window names are shown in bold face type: Custom Setup screen. Important information such as Notes, Tips and Warnings are shown in this color scheme: Tools Notes and Tips Warnings
Hyperlinks are underlined and shown in blue: the cursor changes to a hand: System Requirements. File names, code and user-defined information are shown as: Installing.pdf. Menu options are indicated using bold text and arrows: File>Save denotes the selection of the Save option from the File menu.
Page 4
INSTALLATION ENVIRONMENT
There are 2 primary methods of installing Studio. Your choice will depend on your technical background and your current development environment.
Page 5
SYSTEM REQUIREMENTS
Corticon Studio 5.2 requires: Microsoft Windows 2000, XP, Vista, 7 32-bit (64-bit compatible) The Eclipse plug-in version requires Eclipse 3.5.2 or above Java Runtime Engine 1.6.0 or higher (included)
Hardware requirements include: Pentium M-class CPU or higher 512 MB RAM (1 GB recommended) 200 MB disk space (full install)
TECHNICAL SUPPORT
For Corticon product support, contact +1 650.212.2424 ext. 200 or email support@corticon.com
Page 6
Page 7 Before performing the installation, we highly recommend temporarily disabling any anti-virus and anti-spyware software that may be running on your machine. This software often prevents or interferes with proper installation.
Startup Screen
The first screen of the Studio Setup Wizard appears briefly and requires no action on your part.
This is the second main screen of the Studio Setup Wizard. Click Next to continue.
Page 8
License Agreement
This screen displays the Corticon Standard License Agreement. Use the scroll bar at the right of the screen to read through this agreement. When you are finished and agree to the terms, choose I accept the terms in the license agreement. Click Next to continue.
If you are installing Corticon Studio on Microsoft Vista or Windows 7, the default installation location may appear as C:\Corticon. Regardless of default, be sure to select an Install Folder for which you have full read and write access rights. If you install Studio to Program Files in a Windows Vista or 7 environment without Administrator rights, Studio may not function correctly.
Page 9
Page 10
Pre-Installation Summary
In the Pre-Installation Summary, ensure that your installation location has enough disk space to accommodate the Studio components. Click Install to continue.
Installation Status
This screen displays a status bar as the necessary Studio files are being copied to your computer.
Page 11
Desktop Shortcuts
The installation program will not create an Studio shortcut on your desktop, but if you would like to create one, follow these steps: 1. Go to
<corticon_insta ll_dir>\Studio
2. Right-click
Studio.exe
Page 12
memory setting). By default, the Xmx setting is 350m, which means 350Mb.
PROGRAM REMOVAL
Remove earlier versions using the standard Windows utility Add or Remove Programs, which can be found in the Control Panel option on your Start menu. This screen shows the Add or Remove Programs utility, with the Studio application highlighted. 1. Click Remove to proceed with the removal.
2. Confirm you wish to remove. Track progress of the removal. Once complete, restart the installer and return to the beginning of this manual.
Page 13
INSTALLATION INSTRUCTIONS
1. If you dont already have a Java JDK installed, download and install the desired JDK from the Oracle Java website http://www.oracle.com/technetwork/java (important: it is necessary to install a JDK as opposed to JRE). 2. If you dont already have an Eclipse installation, download the Galileo version of Eclipse from www.eclipse.org. Unzip the file into your Eclipse directory (e.g., C:\eclipse). 3. Obtain a copy of Corticon_e_UpdateSite.zip and unzip it to a temporary installation directory (e.g., C:\CorticonLocalSite). If you have a ClearCase development view, you can create this file by invoking the build.xml ant target updatesite. 4. Start the Eclipse IDE by double-clicking on eclipse.exe in the C:\eclipse directory. The system will prompt for a workspace location
Page 14
5. Either accept the default location or choose a different location if desired. Click OK to continue. The system will display the Welcome View.
Studio 5.2 Installation Guide 6. Close the Welcome View, then select menu item Help>Install New Software...
Page 15
7. Click the Add button and the system will display the Add Site dialog:
Studio 5.2 Installation Guide 8. Click Local... and navigate to the C:\CorticonLocalSite directory:
Page 16
9. Click OK and assign your new site any name of your choosing:
Studio 5.2 Installation Guide 11. Select Corticon Studio>Corticon Business Rules Modeling Studio
Page 17
Page 18
12. Click Next > and the system will analyze the dependences and show the complete set of features to be installed, including GMF, GEF and EMF
Studio 5.2 Installation Guide 13. Click Next > to review the licenses
Page 19
Studio 5.2 Installation Guide 14. Select I accept the terms of the license agreement and click Finish
Page 20
15. When the system displays the Security Warning dialog box, click OK
Page 21
16. When the system prompts regarding certifications, select Eclipse.org and click OK
17. The system will install all of the necessary plug-ins. When the system is finished, press Yes to restart your Eclipse session
Page 22
18. Once Eclipse restarts, verify the installation by selecting menu item Help>About Eclipse SDK, then press the Installation Details button
19. Note that Corticon Business Rules Modeling Studio has been successfully installed
Page 23
20. Exit from Eclipse and create a Windows icon shortcut on your Windows desktop to make it easier to launch eclipse.exe. Update the Target and Start In fields as shown:
21. The Target field command line parameters should specify the proper JDK (e.g., -vm c:\jdk1.6.0_20\bin), and should increase the memory heap settings for optimal performance (e.g., -vmargs Xms256m Xmx1024m). Example:
C:\eclipse\eclipse.exe -vm c:\jdk1.6.0_20\bin -vmargs Xms256m Xmx1024m
22. Use your new shortcut to restart Corticon Studio, and you should be able to switch to the Rule Modeling Perspective and create your first Rule Project. Happy rule modeling!
Page 24
In order for Studio to display its user interface in your chosen locale, two requirements must be satisfied: 1. A language bundle or template must be created for your chosen language and installed in CcI18nBundles.jar, both Studio and all deployed Server installations. 2. Your operating system must be running in your chosen locale when Studio starts up.
Page 25
Use the Add... button to add the desired languages. Note: the operating system may prompt you to insert the installation media in order to complete the installation.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 26
Next, you must change you regional settings so that your machines locale specifies the non-English language youve installed. You must change both the Standards and formats specification and the Location specification. For example, to enable Japanese, choose the specifications shown below:
Testing the Setup Start Studio in the normal manner, and invoke the open dialog window by selecting menu option File>Open. If the installation was successful, buttons on the dialog (and other key static text labels) should be presented in the selected regions language. To create Studio assets in a different locale, see the Localization chapter of the Rule Modeling Guide.
Page 27
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
Corticon Business Rules Modeling Studio 5.2 Tutorial Basic Rule Modeling
2012 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved. These materials and all Progress software products are copyrighted and all rights are reserved by Progress Software Corporation. The information in these materials is subject to change without notice, and Progress Software Corporation assumes no responsibility for any errors that may appear therein. The references in these materials to specific platforms supported are subject to change. Actional, Apama, Artix, Business Empowerment, Business Making Progress, Corticon, Corticon (and design), DataDirect (and design), DataDirect Connect, DataDirect Connect64, DataDirect Technologies, DataDirect XML Converters, DataDirect XQuery, DataXtend, Dynamic Routing Architecture, Empowerment Center, Fathom, Fuse Mediation Router, Fuse Message Broker, Fuse Services Framework, IONA, Making Software Work Together, Mindreef, ObjectStore, OpenEdge, Orbix, PeerDirect, Powered by Progress, PowerTier, Progress, Progress DataXtend, Progress Dynamics, Progress Business Empowerment, Progress Empowerment Center, Progress Empowerment Program, Progress OpenEdge, Progress Profiles, Progress Results, Progress Software Business Making Progress, Progress Software Developers Network, Progress Sonic, ProVision, PS Select, RulesCloud, RulesWorld, Savvion, SequeLink, Shadow, SOAPscope, SOAPStation, Sonic, Sonic ESB, SonicMQ, Sonic Orchestration Server, SpeedScript, Stylus Studio, Technical Empowerment, WebSpeed, Xcalia (and design), and Your Software, Our TechnologyExperience the Connection are registered trademarks of Progress Software Corporation or one of its affiliates or subsidiaries in the U.S. and/or other countries. AccelEvent, Apama Dashboard Studio, Apama Event Manager, Apama Event Modeler, Apama Event Store, Apama Risk Firewall, AppsAlive, AppServer, ASPen, ASP-in-a-Box, BusinessEdge, Cache-Forward, CloudEdge, DataDirect Spy, DataDirect SupportLink, Fuse, FuseSource, Future Proof, GVAC, High Performance Integration, ObjectStore Inspector, ObjectStore Performance Expert, OpenAccess, Orbacus, Pantero, POSSE, ProDataSet, Progress Arcade, Progress CloudEdge, Progress Cloudware, Progress Control Tower, Progress ESP Event Manager, Progress ESP Event Modeler, Progress Event Engine, Progress RFID, Progress RPM, Progress Responsive Cloud, Progress Responsive Process Management, Progress Software, PSE Pro, SectorAlliance, SeeThinkAct, Shadow z/Services, Shadow z/Direct, Shadow z/Events, Shadow z/Presentation, Shadow Studio, SmartBrowser, SmartComponent, SmartDataBrowser, SmartDataObjects, SmartDataView, SmartDialog, SmartFolder, SmartFrame, SmartObjects, SmartPanel, SmartQuery, SmartViewer, SmartWindow, Sonic Business Integration Suite, Sonic Process Manager, Sonic Collaboration Server, Sonic Continuous Availability Architecture, Sonic Database Service, Sonic Workbench, Sonic XML Server, The Brains Behind BAM, WebClient, and Who Makes Progress are trademarks or service marks of Progress Software Corporation and/or its subsidiaries or affiliates in the U.S. and other countries. Java is a registered trademark of Oracle and/or its affiliates. Any other marks contained herein may be trademarks of their respective owners.
Note The Decision Services that you build using Studio may be deployed as executable, standards-based services available to other software applications via Java, .NET, or SOAP messaging. Corticon Decision Services are in use today across the globe, automating many high-volume decisionintensive processes. See the Server Integration & Deployment Guide or the Server Deployment Tutorial for instructions on how to deploy and integrate the Decision Services you build here.
This Basic Rule Modeling Tutorial provides an introduction to the Corticon Business Rules Modeling Studio 5.2. You will learn how to capture rules from business specifications, model the rules, analyze them for logical errors, and test the execution of your rules; all without programming. Your goal is to create a Decision Service: A group of rules that captures the logic of a single decision-making step completely and unambiguously. In one sense, a Decision Service (when managed with Corticon Studio) is a business-friendly model of your rules (i.e., your decision-making logic). In another sense, a Decision Service is a powerful asset, allowing you to automatically process the rules as a part of business transactions.
Note This Tutorial is designed for hands-on use. We recommend that you type along with the instructions and illustrations presented.
1. Scope the business problem. Ask the question: What decision are we trying to make?
2. Discover the business rules. Ask the question: How do we make the decision?
Scope
Discover
3. Model the business rules. Using Corticon Studio, logically express the rules.
5. Test the business rules. Using Corticon Studio, test rule execution to ensure expected business results.
Test
Model
Analyze
Note Steps 2-6 are repeated when rules change. This tutorial includes two iterations through the lifecycle, including an initial implementation and subsequent change cycle. Deployment is covered in a separate tutorial (see Server Deployment Tutorial and Server Integration & Deployment Guide).
4. Analyze the business rules. Using Corticon Studio, ensure that the rules are complete, consistent and free of logical errors.
Deploy
6. Deploy the business rules. Using Corticon Server, automate the rules across enterprise applications.
Table of Contents
The Business Process & Rules The Business Problem Page 6 Discover New Rules Page 7 Page 44
Scope
Discover
Test
Create a New Ruletest Set Up the Test Scenario Execute the Ruletest Verify the Test Results Save the Ruletest Modify the Ruletest Page 34 Page 37 Page 40 Page 41 Page 43 Page 55
Model
Analyze
Check for Conflicts Resolve Conflict Errors Check for Completeness Resolve Completeness Errors Save the Rulesheet Check New Rules for Conflicts Page 25 Page 28 Page 29 Page 30 Page 33
Deploy
Summary Page 52
Page 56
Scope
Note The example used in this Tutorial was developed from a business problem in which an air cargo company loads cargo of various sizes and weights into containers, then onto its fleet of aircraft prior to shipment. To operate safely, the company must ensure that an aircraft is never loaded with cargo that exceeds an aircrafts capabilities. Flight plans are created by the company that assign cargo shipments to containers, then containers to aircraft. Part of the flight plan creation process involves verifying that no plan violates any safety or operational rule. The air cargo company desires to improve the quality and efficiency of the flight planning process by modeling and automating business rules using Corticons Business Rule Management System.
Scope
Collect Cargo
Package Cargo
Ship Cargo
Action Next, determine which process steps involve decisions. Any step involving a decision is a candidate for automation using Corticon. In this process, all three steps involve decisions, in addition to physical labor. The scope of this tutorial is the Package Cargo step, which involves the decision about what container to use for various cargo, based upon such criteria as the cargos weight, volume and contents. Today, the packaging decision is made by our shipping personnel based upon their experience. The problem is that some people make better decisions than others, which leads to inconsistent practices. We want to use Corticon to standardize and automate the packaging decision.
Discover
Now that we have scoped our problem, we need to discover our business rules. Note To discover our business rules, we simply ask: How do we make this decision? For this case, we ask How do we package cargo? We ask this question to the people who perform and manage this step in the process. They often provide the answer in the form of a policy or procedure manual, or simply as a set of rules that they follow. Sometimes the rules are embedded in the code of our legacy systems. In other cases, the rules are not documented and found only in the heads of our people. In all cases, we will capture the discovered rules directly into Corticon Studio.
Collect Cargo
Package Cargo
Ship Cargo
Cargo weighing <= 20,000 kilos must be packaged in a standard container. Cargo with volume > 30 cubic meters must be packaged in an oversize container.
Model
Action Open Corticon Studio Double click on the Studio icon in your Corticon installation directory
OR Note You first need to install the software. Refer to the Studio Installation Guide for detailed instructions. Choose Programs > Corticon > Corticon Business Rules Modeling Studio from the Start menu.
Note For further details and reference information not presented here, you can choose Help > Contents and Index from the Studio menubar or click the icon on the Studio toolbar.
Model
10
Switch Workspaces
Action Your initial workspace will be empty. Switch to a new workspace (where this Tutorials sample files are located) by choosing File > Switch Workspace from the Studio menubar.
11
12
Model
Note The first step in modeling business rules is to build a Vocabulary, which includes the Model terms referenced by our business rules (such as aircraft and flight plan). Using Studio, you can define or edit Vocabularies, or import Vocabularies from existing object models, class diagrams, database schemas, or XML schemas. In this case, we opened an existing model created in Studio. Once you open a Vocabulary, you can see it in the upper left Rule Vocabulary window. In addition, you can edit the Vocabulary in the upper right editor window. Later in this Tutorial, we will edit the Vocabulary. First, we will model some rules using the Vocabulary provided. We model rules using a Rulesheet.
Action Open an existing Vocabulary by double-clicking Cargo.ecore in the Rule Project Explorer window.
13
Model
Action Take a moment to explore the Rule Operators, which are located in a tab to the lower left, adjacent to the Rule Project Explorer tab.
Note While the Rule Vocabulary contains our nouns (the things we reference in our business rules), the Rule Operators contain our verbs (the actions we take in our business rules). Corticon Studio comes with a rich set of operators for manipulating data, similar to the Excel function library. In addition, programmers can add new Extended Operators through an API (e.g., to perform a new statistical function or to make a call out). See Appendix D of the Rule Language Guide for more information.
14
Model
Action To create a new Rulesheet, select File > New > Rulesheet from the Studio menubar.
15
Select Tutorial as the Parent Folder and enter Cargo as the File name. Click Next. Now, select Cargo.ecore as the Vocabulary to associate with your new Rulesheet and click Finish to complete the process.
16
Model
5 1
Note Rulesheets contain sections for specific parts of rules. Sets of Conditions (label 1) and Actions (label 2) are tied together by the vertical columns on the right to form rules. For example, rule column 1 (label 3) is read as if Applicants skydiver value is true, then assign High to Applicants riskRating. We say that this column provides the model or implementation of the rule statement (label 4). Column 0 (label 5) is used to define calculation rules that contain Actions, but no Conditions (see Rule Modeling Guide for examples).
17
Model
Action Enter the plain-language business rule into the Rule Statements section of the Rulesheet as shown. You can copy and paste from the text above.
18
Model
Action Drag the Cargo.weight term from the Vocabulary and drop it in Row a of the Conditions pane, as shown.
Note Well use an orange dotted line to indicate dragging and dropping. Drag from the orange circle, and drop on the orange diamond.
Note Our first rule evaluates a condition and takes an action if and only if the condition is satisfied. Therefore, we will use the Conditions and Actions panes to model the rule.
19
Model
Continue modeling the first rule: Cargo weighing <= 20,000 kilos must be packaged in a standard container.
Action Next we type a value for cargo weight in cell 1a (row a, column 1). Type <=20000 in the cell. Dont use commas in values because commas are reserved to indicate multiple values.
20
Model
Action Now drag the appropriate term from the Vocabulary and drop it in row A of the Actions section. Next, define the action for rule 1 by selecting standard in the drop-down menu within Actions row A of column (rule) 1. The drop-down menu options were defined in the Vocabulary, which we will edit later. This action assigns the value of standard to the Cargo.container attribute.
21
Model
Note Reference numbers logically link rows in the Rule Statements section to columns in the Conditions/Actions section notice how clicking on Rule Statement Ref 1 causes column 1 to highlight. The highlighting reminds you that column 1 is the model of the rule (expressed in plainlanguage) in Rule Statement Ref 1.
22
Model
Action Finally, save your Rulesheet by selecting File > Save from the Studio menubar (or clicking the Save button).
Note When saved, Studio places a dash in the empty cells, meaning that the condition is ignored. The conditions and actions in a column are anded together. For example, rule 1 reads: Cargo weighing less than or equal to 20,000 kilos, ignoring volume, must be packaged in a standard container.
23
Model
Note When you define a Post, an icon appears in the Post Message(s) row of the Rulesheet.
Action To Post, select the appropriate Severity Level from the drop-down box in the Post column. (in this case, select Info) . You must also select an Alias for the Rule Statement to post. The Alias defines what Entity the Rule Statement is posted to (in this case, select Cargo, which is the only option).
24
Analyze
Now that we have finished modeling our rules, it is time to analyze our rules for logical errors. Very often, initial business rule specifications are ambiguous and incomplete. By ambiguous, we mean that the rules are conflicting under certain scenarios. By incomplete, we mean that the rules fail to address all possible scenarios. Prior to automating your rules, it is critical to eliminate logical errors in order to ensure that our decision service provides correct, consistent results. We call this Rule Referential Integrity. Studio provides unique and powerful features to help you ensure Rule Referential Integrity. These features will be explored in this Analyze phase of the rule management lifecycle.
Click on the Check for Conflicts icon on the Studio toolbar. OR Action Be sure your Cargo.ers tab is selected (colored blue), then Check for Conflicts. Choose Rulesheet > Logical Analysis > Check for Conflicts from the Studio menubar.
25
Identify Conflicts
Note Columns containing conflicts are shaded in pink. This indicates that one or more conflicts exist between the pink rules.
Analyze
26
Analyze
Note When the rules are expanded, the source of the conflict becomes obvious. In scenarios with cargo weight <=20000 and cargo volume > 30, our rules are in conflict, defining mutually exclusive actions (assigning both standard and oversize containers). To get your rules right, this scenario must be addressed!
When expanded, rule 1 is represented as two columns (1.1 and 1.2), and rule 2 is represented as two columns (2.1 and 2.2). Expansion shows all of the logical possibilities for each rule. Rule 1 states Cargo weighing <= 20,000 pounds, ignoring volume, must be packaged in a standard container. Studio recognizes that there are only two possible ranges for volume (<=30 and >30), which we see in the expanded state.
27
Analyze
First, collapse your rules back to the original state by clicking on the Collapse Rules icon on the Studio toolbar.
Action Next, override Rule 1 with Rule 2. In the Overrides row, from the overriding rule, select the column number of the rule to be overridden. Multiple selections can be made by holding the CTRL key.
Action Now, click the Check for Conflicts button again, and you will see that the conflict has been resolved. With the override, Rule 2 now means Use oversized containers when volume is >30, even when weight is <=20,000.
28
Analyze
Click on the Check for Completeness icon on the Studio toolbar. OR Choose Rulesheet > Logical Analysis > Check for Completeness from the Studio menubar.
Action This message window informs us that our rules were incomplete. We missed one scenario. Click OK to dismiss the window.
29
Analyze
The Completeness Checking algorithm calculates the set of all possible mathematical combinations of all values in all conditions. The algorithm then compares this set of possible combinations to those already specified in the Rulesheet and automatically inserts missing combinations of conditions as new columns. These new columns are shaded in green.
Note The Completeness Check adds condition values, but does not choose actions thats our job as rule modelers.
Lets define a new Rule Statement for this (formerly) missing scenario: Cargo weighing > 20,000 kilos, with volume <= 30 cubic meters, must be packaged in a heavyweight container.
30
Analyze
First, add the new Rule Statement for rule 3. Next, define an action in rule cell 3a. In this case, select heavyweight as the container option. Last, post an Info message to the Cargo entity as we did for the first two rules. Your Rulesheet should look like the one below.
Note Dont forget to add enter the Rule Statement Reference to link it with the corresponding column. In this example, incompleteness was resolved by specifying an action for column 3, along with adding a new Rule Statement. Once resolved, remove the green highlighting by clicking the Clear Analysis Results button on the Studio toolbar.
31
Analyze
Click on the Check for Logical Loops icon on the Studio toolbar. OR
Choose Rulesheet > Logical Analysis > Check for Logical Loops from the Studio menubar.
Note This is a very simple Rulesheet and contains no logical loops. Of note, while unintended logical loops are problematic, sometimes logical loops are a useful technique for solving complex inferencing problems that require recursive reasoning. You can learn more in the Rule Modeling Guide.
32
Analyze
33
The Analyze phase helped to ensure the logical integrity of our rules. The Test phase helps to ensure that our rules give us the correct business results. Lets move on to testing. First, were going to define a test case for each one of our rules below by defining some input values and expected results. Corticon Studio allows us to pre-define our expected results and then highlights any variances in our test results. The table below defines one test case for each rule.
Test
Test Rule 1 Input Values Cargo.weight Cargo.volume Expected Results Cargo.container standard 1000 10
Test Rule 2
Test Rule 3
1000 40
oversize
heavyweight
34
Test
1. Select File > New > Ruletest on the Studio menubar OR 2. Use the New icon on the toolbar by selecting the down arrow to the right of the icon and select Ruletest.
35
Action Select the appropriate Rulesheet as your Test Subject. For our example, we want to use the Cargo Rulesheet within our Tutorial project directory. Click Finish to display the new Ruletest.
Note You can disregard the Remote Servers and Remote Decision Service panes - if you are interested in those, please refer to the Server Deployment Tutorial for more information.
36
Test
Action Drag the Cargo entity from the Vocabulary and drop it anywhere in the Ruletests Input and Expected panes, as shown. Cargo [1] on the Ruletests Input and Expected panes represents one instance or example of the Cargo entity.
Note As you can see, your new Ruletest is associated with the appropriate Rulesheet. This ensures that your Ruletest scenario will be tested by the right rules.
Note Changes you make to any Studio file will cause an asterisk character to appear in the files tab. This is a reminder to us to save the file.
37
Test
Action First, remove unneeded attributes by selecting them and pressing the Delete key. Shift-click and Ctrlclick are also supported for multi-selecting contiguous and non-contiguous attributes, respectively. We will remove the manifestNumber attribute as it is not needed to test these rules.
Action Next, add test data for test #1 to the Testsheet, per the table above. Double-click on the desired term to open a data entry box. When complete, your Ruletest should look like this.
38
Test
30000 20
heavyweight
Enter the remaining test data as shown to complete the Input pane of the Ruletest. You can easily duplicate the first test scenario by selecting Cargo [1], copying it, then pasting it below. Repeat for both the Input and Expected panes Also, select the expected container values from the drop-downs that appear when the container attribute is clicked. Your Ruletest should look like the one below.
39
Action Run the Ruletest. Running the Ruletest sends the data on the Input Testsheet to the rule engine embedded within Studio. The rule engine fires the appropriate rules and displays the results in the Output pane.
Click on the Run Test icon on the Studio toolbar. OR Choose Ruletest > Testsheet > Run Test from the Studio menubar.
Note The first time rules are executed, they are automatically compiled from the rule model into an optimized executable form, then deployed into the engine, which may take a few seconds. Once deployed, the rules will execute much faster on subsequent tests.
40
All unchanged terms and values in the Ruletests Output pane are displayed in normal style. Any terms altered by rules, including their parent entities, are shown in bold text.
Note Messages shown in the Rule Messages pane are produced by using the Post command in your Rule Statements. Severity indicates whether a message contains information, warnings or violations. Message contains the Rule Statement text. Entity shows the entity to which this message is bound or linked. When we select the Cargo[1] entity within the Output pane, the third rule message is highlighted, showing the audit trail of rules that fired for that entity (in this case only one rule fired for Cargo[1]).
41
Note Here we see that the Cargo[2] entity and the container attribute are colored red in both the Output and Expected panes, indicating that our Output results differ from our Expected results. Change Cargo[2] Expected container value back to oversize before saving the Ruletest on the next page. Studio automatically highlights differences in values in red in both the Output and Expected panes. Other types of differences are also highlighted. Unexpected entities in the Output pane are highlighted in blue. And missing entities are highlighted green within the Expected pane. More details about color codes are included in the Studio Quick Reference Guide.
42
43
When the time comes to change your rules, youll be glad you decided to model and manage them in Corticon Studio.
Test Model
Lets go through another development lifecycle, starting with the discovery of a new business rule.
Analyze Deploy
Collect Cargo
Package Cargo
Ship Cargo
Initial Rules: Cargo weighing <= 20,000 kilos must be packaged in a standard container. Cargo with volume > 30 cubic meters must be packaged in an oversize container. Added after Completeness Check: Cargo weighing > 20,000 kilos, with volume <= 30 cubic meters, must be packaged in a heavyweight container. New Rule (to add now): Cargo requiring refrigeration must be packaged in a reefer container.
44
Action Enter the new Rule Statement from the previous page. This will guide us when we model the new rule.
Note To model this rule, we will need to add two terms to the current Vocabulary. First, we need to add a new attribute to the Cargo entity to define whether the Cargo requires refrigeration or not (well call this needsRefrigeration). Second, well need to add reefer as another possible selection option for the container attribute.
45
If already open , select the Cargo.ecore tab. If not open: Select Cargo.ecore from the Recent File list at the bottom of the File menu OR Use the File > Open File menu option OR Double-click on the file in the Rule Project Explorer pane.
46
Action
Action
Highlight the Cargo entity and choose the Add Attribute icon on the toolbar. OR Highlight the Cargo entity and choose Vocabulary > Add Attribute from the Studio menubar.
47
Action Change the attribute name to needsRefrigeration and set the data type to Boolean.
First, double click on the attribute name to type over its initial default value.
48
Select the container attribute and note the Data Type: containerType. This is a custom data type that defines a set of allowable values for container (an enumerated set).
To define custom data types, you must first click on the root node of the Vocabulary, noted by the open book icon
Next, click on the containerType entry. This will display the enumerated set in the rightmost table, if available.
Note Custom data types is a powerful capability that allows you to define rules at the level of the Vocabulary that are reused anywhere the Vocabulary terms are used. You can learn more about custom data types in the Rule Modeling Guide.
49
Click on the Save icon on the Studio toolbar. Action Save the Vocabulary and exit the Vocabulary Editor pane. OR Choose File > Save from the Studio menubar.
50
Action Now that the Vocabulary contains the new terms required by the new rule, complete the model as shown below.
Action Be sure to include Reference links from the Rule Statements to the columns containing the new rule models. And, add Post and Alias.
51
Action
Rule analysis is an iterative process. Whenever we add or change our rules, it is necessary to re-analyze. In this case, adding a single new rule has caused three new conflicts, one with each of our three existing rules. You can step through multiple conflicts, and filter the Rulesheet to view only the conflicting rules, via the buttons to the right of the Conflict Check button:
52
Action Reefer containers are only available for standard and heavyweight, but not for oversize loads. Thus, lets set rule 4 to override rules 1 & 3, and rule 2 to override rules 1 & 4. You can select multiple values in the override cell by holding down the Ctrl key. When complete, your Rulesheet should look like this:
53
54
Action Your last step is to modify your test case to test the new rule. First save your rules. Next, in Ruletest Cargo.ert, first copy and paste Cargo[1] to create Cargo[4], in both the Input and Expected panes. Next, drag and drop the needsRefrigeration attribute from your Vocabulary onto both Cargo[4] entities. In both panes, set the value of needsRefrigeration to true. Next, in the Expected pane, change the value of container to reefer. Last, execute the test. Your Ruletest should look like this:
55
Summary
Congratulations! You have now completed two full iterations of the Corticon development lifecycle, and understand the basic concepts of rule modeling, analysis, and testing in Studio.
Note
Scope
Discover
To learn advanced rules modeling techniques, see the Advanced Rules Modeling Tutorial.
Test
Model
Analyze
Deploy
Note To learn how to deploy rules, see the Tutorial for Corticon Server Deploying Web Services.
56
A step-by-step introduction to modeling, analyzing, and testing rules and decisions in Studio 5.2. Recommended for all new users. An intro to more advanced modeling concepts and practices in Studio 5.2. For users who want a more thorough introduction to Studio 5.2s capabilities. A step-by-step introduction to installing the Server as a Web Services server and deploying and exposing decisions as Web Services.
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
57
Corticon Business Rules Modeling Studio 5.2 Tutorial Advanced Rule Modeling
2012 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved. These materials and all Progress software products are copyrighted and all rights are reserved by Progress Software Corporation. The information in these materials is subject to change without notice, and Progress Software Corporation assumes no responsibility for any errors that may appear therein. The references in these materials to specific platforms supported are subject to change. Actional, Apama, Artix, Business Empowerment, Business Making Progress, Corticon, Corticon (and design), DataDirect (and design), DataDirect Connect, DataDirect Connect64, DataDirect Technologies, DataDirect XML Converters, DataDirect XQuery, DataXtend, Dynamic Routing Architecture, Empowerment Center, Fathom, Fuse Mediation Router, Fuse Message Broker, Fuse Services Framework, IONA, Making Software Work Together, Mindreef, ObjectStore, OpenEdge, Orbix, PeerDirect, Powered by Progress, PowerTier, Progress, Progress DataXtend, Progress Dynamics, Progress Business Empowerment, Progress Empowerment Center, Progress Empowerment Program, Progress OpenEdge, Progress Profiles, Progress Results, Progress Software Business Making Progress, Progress Software Developers Network, Progress Sonic, ProVision, PS Select, RulesCloud, RulesWorld, Savvion, SequeLink, Shadow, SOAPscope, SOAPStation, Sonic, Sonic ESB, SonicMQ, Sonic Orchestration Server, SpeedScript, Stylus Studio, Technical Empowerment, WebSpeed, Xcalia (and design), and Your Software, Our TechnologyExperience the Connection are registered trademarks of Progress Software Corporation or one of its affiliates or subsidiaries in the U.S. and/or other countries. AccelEvent, Apama Dashboard Studio, Apama Event Manager, Apama Event Modeler, Apama Event Store, Apama Risk Firewall, AppsAlive, AppServer, ASPen, ASP-in-a-Box, BusinessEdge, Cache-Forward, CloudEdge, DataDirect Spy, DataDirect SupportLink, Fuse, FuseSource, Future Proof, GVAC, High Performance Integration, ObjectStore Inspector, ObjectStore Performance Expert, OpenAccess, Orbacus, Pantero, POSSE, ProDataSet, Progress Arcade, Progress CloudEdge, Progress Cloudware, Progress Control Tower, Progress ESP Event Manager, Progress ESP Event Modeler, Progress Event Engine, Progress RFID, Progress RPM, Progress Responsive Cloud, Progress Responsive Process Management, Progress Software, PSE Pro, SectorAlliance, SeeThinkAct, Shadow z/Services, Shadow z/Direct, Shadow z/Events, Shadow z/Presentation, Shadow Studio, SmartBrowser, SmartComponent, SmartDataBrowser, SmartDataObjects, SmartDataView, SmartDialog, SmartFolder, SmartFrame, SmartObjects, SmartPanel, SmartQuery, SmartViewer, SmartWindow, Sonic Business Integration Suite, Sonic Process Manager, Sonic Collaboration Server, Sonic Continuous Availability Architecture, Sonic Database Service, Sonic Workbench, Sonic XML Server, The Brains Behind BAM, WebClient, and Who Makes Progress are trademarks or service marks of Progress Software Corporation and/or its subsidiaries or affiliates in the U.S. and other countries. Java is a registered trademark of Oracle and/or its affiliates. Any other marks contained herein may be trademarks of their respective owners.
The Basic Rule Modeling Tutorial provided you with an introduction to the Corticon Studio, the easiest way to manage and automate your business rules. You learned how to capture rules from business specifications, model the rules, analyze them for logical errors and test the execution of your rules; all without programming. Unlike the Basic Rule Modeling Tutorial, this manual does not attempt to capture or reproduce the mechanics of rule modeling. Instead, you will learn the concepts underlying some of Studios more complex and powerful functions, including: Using Scope and Defining Aliases in rules Understanding Collections Using String, DateTime, and Collection operators Modeling formulas and equations in rules Using Filters Sequencing Rulesheets in a Ruleflow Testing at rule, Rulesheet and Ruleflow levels.
Note As you already know, the Ruleflows that you build using Studio may be deployed as executable, standards-based Decision Services that can be used by other software applications via Java Messaging or XML Web Services. Decision Services are in use today across the globe, automating many high-volume decision-intensive processes. See the Tutorial for Corticon Server Deploying Web Services for instructions on how to deploy and test as Decision Services the Ruleflows you build here.
Note This Tutorial is designed for hands-on use. We recommend that you type along with the instructions and illustrations presented. Screenshots in this Tutorial will be cleanest and sharpest when printed using a Postscript printer driver (usually identified by PS in the printer name).
Table of Contents
p. 1 Building the Vocabulary Create an ER Diagram The Barcode System Our New Vocabulary High-Level Business Process Low-Level Business Process Organizing the Business Rules Defining Scope Modeling the 1st Rulesheet 1st Rulesheet Completed Modeling the 2nd Rulesheet 2nd Completed Rulesheet Modeling the 3rd Rulesheet 3rd Rulesheet Completed Summary Appendix A Tech. Pubs p. 2 p. 5 p. 10 p. 11 p. 12 p. 13 p. 14 p. 16 p. 18 p. 31 p. 32 p. 51 p. 52 p. 60 p. 61 p. 62
Discover
Test the 1st Rulesheet Summary The Test Results Testing the 2nd Rulesheet Summary The Test Results Testing the 3rd Rulesheet Summary The Test Results p. 19 p. 30 p. 36 p. 50 p. 56 p. 59
Test
Model
Analyze
Logical Analysis and Validation are not demonstrated in this Tutorial in order to minimize duplication with the Basic Rule Modeling Tutorial. Please also see the Rule Modeling Guide for more information on Logical Analysis and Validation features of Corticon Studio.
Deploy
See the Tutorial for Corticon Server Deploying Web Services and the Server Integration & Deployment Guide for more information about deploying Ruleflows as Decision Services.
The owner of a chain of grocery stores intends to build and install a system of business rule-based smart cash registers in all of its branches. Some branches are large supermarkets, and some are smaller convenience stores, which sell gasoline and other essentials. In addition to minimum cash register functionality (adding up the prices of items in a customers shopping cart, for example) the new system will also include the ability to apply promotional rules, rules that determine coupon generation, loyalty program rules, and special warning rules to alert the cashier to take certain actions. Because every item in every store has a bar-coded label, the systems scanner will be able to determine complete information about each item, such as which department the item comes from. To foster customer loyalty and drive additional sales, a Preferred Shopper program will be launched in conjunction with the installation of the new business rule-based cash registers. Shoppers who enroll in the program will be issued Preferred Shopper membership cards (one card per household) to present to the cashier at check-out time. Benefits of the Preferred Shopper program include: A Preferred Shopper earns 2% cash back on all purchases at any branch The Preferred Shopper account will track the accumulated cash back and allow the shopper to apply it to any visits total amount. The cashier will ask a Preferred Shopper if he/she would like to apply a cash back balance to his/her current purchase Once a Preferred Shopper chooses to apply his cash back balance, the cumulative cash back total maintained by the system will be reset to zero, and the accumulation of cash back begins anew with the customers next purchase. A Preferred Shopper will be eligible for special promotions and coupons as defined below: Preferred Shoppers receive a coupon for one free balloon for every item purchased from the Floral department Expiration date: none Preferred Shoppers receive a coupon for $2 off their next purchase when 3 or more Soda/Juice items are purchased in a single visit. Expiration date: one year from date of issue Preferred Shoppers receive a coupon for 10% off their next gasoline purchase at any chain-owned convenience store with any purchase of $75 or more. Expiration date: 3 months from date of issue In compliance with local, state and federal laws, the chain needs to ensure that all purchases of liquor (any items from the Liquor department) are made by shoppers 21 or older. A simple alert or warning to the cashier will be sufficient to prompt an ID check.
The owner of a chain of grocery stores intends to build and install a system of business rule-based smart cash registers in all of its branches. Some branches are large supermarkets, and some are smaller convenience stores, which sell gasoline and other essentials. In addition to minimum cash register functionality (adding up the prices of items in a customers shopping cart, for example) the new system will also include the ability to apply promotional rules, rules that determine coupon generation, loyalty program rules, and special warning rules to alert the cashier to take certain actions. Because every item in every store has a bar-coded label, the systems scanner will be able to determine complete information about each item, such as which department the item comes from. To foster customer loyalty and drive additional sales, a Preferred Shopper program will be launched in conjunction with the installation of the new business rule-based cash registers. Shoppers who enroll in the program will be issued Preferred Shopper membership cards (one card per household) to present to the cashier at check-out time. Benefits of the Preferred Shopper program include: A Preferred Shopper earns 2% cash back on all purchases at any branch The Preferred Shopper account will track the accumulated cash back and allow the shopper to apply it to any visits total amount. The cashier will ask a Preferred Shopper if he/she would like to apply a cash back balance to his/her current purchase Once a Preferred Shopper chooses to apply his cash back balance, the cumulative cash back total maintained by the system will be reset to zero, and the accumulation of cash back begins anew with the customers next purchase. A Preferred Shopper will be eligible for special promotions and coupons as defined below: Preferred Shoppers receive a coupon for one free balloon for every item purchased from the Floral department. Expiration date: none. Preferred Shoppers receive a coupon for $2 off their next purchase when 3 or more Soda/Juice items are purchased in a single visit. Expiration date: one year from date of issue. Preferred Shoppers receive a coupon for 10% off their next gasoline purchase at any chain-owned convenience store with any purchase of $75 or more. Expiration date: 3 months from date of issue. In compliance with local, state and federal laws, the chain needs to ensure that all purchases of liquor (any items from the Liquor department) are made by shoppers 21 or older. A simple alert or warning to the cashier will be sufficient to prompt an ID check.
Identifying the Terms of the Scenario Compiling a list of terms based on our findings within the previous slide, the following assumptions can be made and can be used to build a Fact Model or an ER Diagram. A Customer may be a Preferred Shopper and have a Preferred Shopper account that is identified by swiping their Preferred Card at checkout A Preferred Shopper account has a Card Number A Preferred Shopper account holds a Cash-Back Balance One Preferred Shopper account may be used by anyone in a family A Customer uses a Shopping Cart to carry items A Customer has a Name An Item has a Name An Item has a Price An Item has a Bar-coded Label An Item is located in a Department A Shopping Cart contains the Items a Customer purchases during each visit A Shopping Cart has a Total Amount A Cash-Back Bonus is calculated using the Shopping Carts Total Amount and is deducted from the Total Amount upon Customer request Coupons are issued to shoppers A Coupon has a Description A Coupon has an Expiration Date A Coupon has an Issue Date
Type of Term
Data Type
Attribute Mode
attribute of Customer attribute of Customer Entity attribute of Item attribute of Item attribute of Item attribute of Item Entity attribute of Shopping Cart attribute of Shopping Cart attribute of Shopping Cart attribute of Shopping Cart attribute of Shopping Cart Entity attribute of PreferredAccount attribute of PreferredAccount Entity attribute of Coupon attribute of Coupon attribute of Coupon
String Boolean
Attribute Mode Most of these attributes use Base mode because their values will be sent in to the rules or sent back from the rules. In other words, base attributes are what carry values to and from the client application. Extended Transient mode is used when an attributes value is assigned or derived by rules, but not sent in from or back to the client application. Well discuss this more later in this tutorial.
ShoppingCart totalAmount cashBackEarned savings useCashBack checkID PreferredAccount cardNumber cumulativeCashBack Coupon issueDate description expirationDate
String Decimal
base base
Create an ER Diagram
Create an ER Diagram
The Entity-Relationship (ER) Diagram below is a graphical depiction of the entities and their respective attributes, as well as the associations (relationships) between entities, that we will be using in our Vocabulary during this exercise.
Define Entities
Entities Based on our ER Diagram, we will need to build Customer, Coupon, ShoppingCart, Item, and PreferredAccount (our main business terms) into our Vocabulary.
10
Entities have properties or characteristics that distinguish them from other Entities, and which distinguish one instance of an Entity from another instance of the same Entity. We call these Attributes. Obviously, all customers cant be the same customer, so how do we distinguish between them? By defining attributes that will hold the values of each customers name, etc
11
Some attributes are little more than intermediate or temporary value holders. We dont need to return these values in a response, or save them in a database. In Studio, Extended Transient attributes fill this purpose. Because an extended transient is not part of the Decision Services response message, its presence (or absence) in the Vocabulary or rules does not affect the technical integration with the Decision Service in runtime. Therefore, a Rule Modeler may add/remove extended transients to/from the Vocabulary without fear of upsetting the runtime integration. In our example, the cashBackEarned attribute will serve as an intermediate value, helping to calculate other attribute values that will be included in the Decision Services response message (Base attributes).
Note A Shopping Cart has the Extended Transient attribute cashBackEarned. Its value will be based on the totalAmount of the items purchased in the shopping cart.
12
Associations between entities allow us to define relationships between them. In our example, each individual Customer will have his/her own shopping cart, most likely with different items in each cart. How do we distinguish between them? By associating a unique instance of a shopping cart with each Customer who visits our store. Over successive visits, a customer may have several shopping carts.
13
The Barcode System As part of our scenario, the following tables display the Barcode key and the codes for various departments within a store. We will make use of the codes during our rule modeling to identify items being purchased from specific departments. Produce Canned Goods Grocery Store Barcode Key sample barcode: xxyyyzzzzz xx yyy zzzzz store code department code item number Meat Deli Frozen Foods Soda/Juice Floral Bakery Housewares Detergent & Cleaning Supplies School Supplies Liquor
Grocery Store Department Codes Department Code 260 265 270 275 280 285 290 295 300 305 310 291
Page 14 10
Action From the previous pages, we have everything needed to build a Vocabulary that incorporates the key facts and relationships in our Scenario. If necessary, refer to the Basic Rule Modeling Tutorial and the Studio Quick Reference Guide to review the mechanics of building the Vocabulary in Studio. The Rule Modeling Guides Building the Vocabulary chapter contains more detail on the steps followed up to this point.
15
Customer arrives
Customer shops
Checkout
Customer departs
Note At a high level, this is the basic process followed by every customer making purchases at a store. While there may be several steps involved in this process, we as rule modelers are most concerned with those steps where decisions are made. In this case, the Checkout step contains the rule-based decisions that are built into the stores cash registers. On the next page, well drill down into the Checkout step and define more detail about the rules inside.
16
Customer arrives
Customer Shops
Checkout
Customer departs
Note If a natural sequence or flow of logical steps can be identified within a single decision step, it often makes sense to organize the steps using separate Rulesheets for each logical step, then combining them into a Ruleflow. Well do that in this Scenario.
Note According to the Scenario, there are a few general categories of activity performed by rules during the Checkout step: 1) Identify warning/alert situations. 2) Calculate totals, apply promotions and generate coupons. 3) Apply cash back (if applicable).
Raise Alerts
17
Raise Alerts
Liquor purchases (any items from the Liquor department) can only be made by shoppers 21 or older
Preferred Shoppers receive a coupon for one free balloon for every item purchased from the Floral department. Expiration date: none Preferred Shoppers receive a coupon for $2 off their next purchase when 3 or more Soda/Juice items are purchased in a single visit. Expiration date: one year from date of issue Preferred Shoppers receive a coupon for 10% off their next gasoline purchase at any chain-owned convenience store with any purchase of $75 or more. Expiration date: 3 months from date of issue Preferred Shoppers earn 2% cash back on all purchases at any branch A Preferred Shopper account will track the accumulated cash back and allow the customer to apply it to reduce any visits total amount. The cashier will ask a Preferred Shopper if he/she would like to apply a cash back balance to his/her current purchase. Once a Preferred Shopper chooses to apply his cash back balance, the cumulative cash back total maintained by the system will be reset to zero, and the accumulation of cash back begins anew with the customers next purchase.
18
Action Once an approach has been chosen, we need to choose the perspective in the Vocabulary that best represents the terms required by the rules themselves. This perspective may change from Rulesheet to Rulesheet. For this first Rulesheet, beginning with Customer as the root entity and working with the associated shoppingCart and its items makes sense because its a Customers transaction that is processed by the checkout process step. The contents of the transaction are the shoppingCart and its associated items.
19
Defining Scope
Action Display the Scope section of the Rulesheet by clicking the icon in Studios toolbar, or select Rulesheet>Advanced View from Studio's menubar. Drag and drop the Customer entity and then the highlighted shoppingCart (the one associated with Customer) into the Scope pane of the Rulesheet. Action
Enter an Alias for this term by double-clicking it. Lets call a customers shopping cart their currentCart. Henceforth, when we model rules involving a customers shopping cart, well use the alias currentCart.
Note Scope is a powerful and important concept. It helps us tell the Corticon rule engine which data to use when evaluating and executing rules In our example, we want the cash register system to process not just any shopping cart, but customers shopping carts. This ownership role between a customer and his shopping cart is what the association means. Well incorporate this association in the rules we build by using the alias that represents it. Scope is such an important concept that we devote an entire chapter to it in the Rule Modeling Guide.
Action Weve also named this Rulesheet checks as a way of reminding ourselves of the overall organization: this Rulesheet will perform any necessary checks and raise alerts as required. Rulesheets can be renamed or saved to another location by selecting the Save As option on the File menu and renaming the Rulesheet and/or selecting the Project folder where you want to move it, if necessary.
3 20
Defining Scope
Action
We know from the cardinality of the association between ShoppingCart and Item that one shopping cart can contain many items. So it may prove convenient to define another alias that represents all of the items in a customers shopping cart. We do this by dragging the associated item from the Vocabulary to the Scope window, dropping it on shoppingCart, and giving it an alias name by double-clicking it and typing items in the entry box. Assigning meaningful alias names is good practice and using the plural form of item reminds us that the alias represents all of the items in the customers shopping cart. Using aliases is optional in many cases they serve to simplify and shorten rule expressions. But in certain cases, using aliases is mandatory. Applying collection operators to sets or collections of data in rules requires the use of aliases. Since well be working with the collection of items in a customers shopping cart a bit later, we must have the items alias defined and ready.
Note Aliases will always insert themselves automatically when terms are dragged and dropped from the Scope section or Vocabulary window to the Rulesheet. Since all Studio expressions are casesensitive, its better to drag and drop terms instead of typing them manually less chance of errors!
21
In order to model the 1st business rule, we need to be able to identify items in a customers shopping cart that come from the Liquor department. We know an items department is identified by the 4th thru 6th characters in the items barCode. Using the items alias, weve added a rule in an Actions row of Column 0 using the .substring operator to determine the department code for an item. Remember that the alias items represents the collection of all items associated with a customers shopping cart. So this rule will evaluate and process every item in a customers shopping cart, extract the department code for each, and then assign that code to the items department attribute. For all items in a given customers shopping cart, this rule will execute once per item. This iteration is a natural behavior of the rule engine: it will automatically process all data that matches the rules scope. As terms are dragged from the Vocabulary, they are automatically added to the Scope window. Over time, the Scope window becomes a reduced version of our Vocabulary, containing only those terms used by the rules in that Rulesheet.
22
Ordinarily, wed check for Conflicts and Completeness before testing with data. But these are meaningful only for columns containing Conditions. Since Column 0 has no Conditions, its not necessary to perform these checks now. The steps for performing these checks, and taking any necessary corrective actions, are detailed in the Basic Rule Modeling Tutorial and will not be repeated in this guide.
Action It is critical to drop the items from the Vocabulary into the Input panel of the Ruletest in the order indicated so that we duplicate the Scope of the rule which will be processing this data. First, drag and drop the Customer entity into the Input panel. Then, drop the shoppingCart entity onto the Customer entity. Finally, drag and drop the item entity onto the shoppingCart entity twice. When finished, enter test data as shown. Finally, execute the Ruletest.
3 4
23
Test Results Our first rule has worked as expected! Characters 4-6 have been successfully parsed from each items barCode and assigned to its department attribute.
Testing as you go By modeling a rule and then immediately testing it, weve demonstrated good Studio modeling practice. Testing right away will help expose flaws in our rules before we build too many.
24
25
Rule Models vs. Business Rules There isnt always a one-to-one correlation between the Business Rules defined in a business scenario and the corresponding rules modeled in Studio. Often, as we see in this example, one Business Rule requires more than one rule in Studio. This is normal. A good guideline is to keep your individual rule models relatively simple and let them work together to perform more complex logic defined by the Business Rules. In this first Rulesheet, two rule columns work together to accomplish the goal of the Scenarios check ID Business Rule.
26
Adding to Scope
Action
Next, lets add an alias to represent a customers Preferred Account. Not all customers will have Preferred Accounts, but those who do will have an associated preferredCard. Remember from our initial scenario, customers holding a preferredCard are eligible for various promotions, such as coupons for discounts on gasoline purchases. The account alias defined here prepares us to examine the collection it represents in the next rule.
Note The account alias represents a potential collection, that is, a customer will have a Preferred Card only if they have a Preferred Account. And the many-toone cardinality of the association means a customer will have at most one account. Other customers (as with a family) may share the same Preferred Account. For Customers who dont have Preferred Accounts, the alias account represents an empty collection (the collection contains no elements).
27
Action Now well add a second Condition/Action rule that checks if the customer has a Preferred Card account. Weve modeled a boolean condition in row b that does this using the notEmpty collection operator. If the account alias is not empty, we know the customer has such an account.
28
29
30
Finally, well add one more Action to Column 0 that will calculate the totalAmount of all items in a customers shopping cart. This is accomplished by using the sum operator to add up the price attributes of all elements in the items alias, then assigning that value to the totalAmount attribute.
Note Adding Rule Statements is good practice, even if you dont post them as messages.
31
Lets test our third, and final, rule on this Rulesheet. In the Input Testsheet shown here, we have a customer with two items in his shopping cart. Does our third rule provide us with the totalAmount for the items in the Customers shopping cart?
32
Results A lot has happened here First, note that our rules to determine if a) an ID check is required and b) if the customer is a Preferred Card holder still work as before. Its always good to doublecheck cumulative test results to make sure nothing has broken along the way. Also, notice that the totalAmount attribute has returned a value of 8.98, which is the correct sum of the prices of items 1 and 2. Our third rule has also worked as we expected!
33
34
35
Now its time to apply some promotions to our Preferred Account holders when they spend a pre-defined amount of money or buy items from specific departments at our store. According to the Scenarios Business Rules, these promotions vary, but include discounts, rebates, or even free gifts when items are purchased in specific amounts or from specific departments. The promotions will change frequently modeling them in Corticon will make future changes much easier. Lets create a second Rulesheet (well call it coupons) and model our rules to reflect these promotions for our Preferred Account holder customers. When multiple Rulesheets are included in a Ruleflow (a single .erf file), the Rulesheets will execute in a sequence determined by their Rulesheet order in the Ruleflow Editor. For more information about sequencing Rulesheets as well as additional details on the Ruleflow Editor, see the Studio Quick Reference Guide.
Raise Alerts
Preferred Shoppers earn 2% cash back on all purchases at any branch Preferred Shoppers receive a coupon for one free balloon for every item purchased from the Floral department. Expiration date: none Preferred Shoppers receive a coupon for $2 off their next purchase when 3 or more Soda/Juice items are purchased in a single visit. Expiration date: one year from date of issue Preferred Shoppers receive a coupon for 10% off their next gasoline purchase at any chain-owned convenience store with any purchase of $75 or more. Expiration date: 3 months from date of issue
36
Scope Revisited
Scope Revisited Create the Scope for the new coupons Rulesheet as shown below.
First, a customers shopping cart is still assigned an alias of currentCart, just like on the checks Rulesheet. But on the coupons Rulesheet we have created two new aliases to define the currentCart.item perspective of our data. For now, well simply define the two aliases allItems and SodaItems to represent the same perspective, but well differentiate between them shortly. As before, the account alias still represents the preferredCard account associated with our customer.
Note When creating Ruletests that need to process multiple Rulesheets in sequence, be sure to choose your Ruleflow as the Test Subject during the Ruletest Creation Wizard process. That will ensure that all Rulesheets are processed in the correct sequence and allow values derived on prior Rulesheets to be used in subsequent Rulesheets. Ruleflow The Rulesheet processing sequence is visible here in the Ruleflow diagram at the right. For a complete discussion of the Ruleflow Editors purpose and functionality, please refer to the Quick Reference Guide.
37
Filter Expressions
Filters
Filters A Filter expression acts to limit or reduce the data in working memory to only that subset whose members satisfy the expression. A filter does not permanently remove or delete any data, it simply excludes data from evaluation by the rules in the same Rulesheet. We often say that data satisfying the Filter expression survives the filter. Data that does not satisfy the expression is said to be filtered out. Data that has been filtered out is ignored by other rules in the same Rulesheet. Data filtered out in one Rulesheet is not also filtered out in other Rulesheets unless you include the Filter expression in those Rulesheets, too.
Customers who are not Preferred Card holders are not eligible for the promotions defined in the original business rules. So we want to exclude non-preferred customers from evaluation by the Rulesheet. The Filter expression shown below filters out all non-preferred customers by allowing only those customers with isPreferredMember attribute value of true to pass (survive). Those customers whose isPreferredMember attribute value is not true are filtered out and not evaluated by other rules on this Rulesheet.
Note Filter expressions can behave in ways more complex and powerful than the simple filter shown here. An entire chapter in the Rule Modeling Guide is devoted to them.
38
Parameterizing Rules Often, its desirable to use another Vocabulary attribute (a parameter) to hold a value, such as the percentage used in this formula, rather than hard-coding it (as in 0.02). If the value of an attribute such as cashBackRate is derived by other rules or maintained in an external database then it can be changed without changing this rule. For more information on parameterization techniques, see the Rule Modeling Guide.
39
Heres a simple test for Action row A in column 0. Weve added a few items to the shoppingCart and entered prices for each of them. According to the rule we are testing, the shopping cart of a preferred cardholder should earn cash back equal to 2% of the totalAmount in the shopping cart.
40
Results Notice that the totalAmount attribute now has a value of $98.99 and the cashBackEarned attribute has been assigned a value of $1.9798, or 2% of $98.99. Our rule has worked as expected!
41
42
For this test, weve entered a totalAmount of $100 for the shoppingCart and a cumulativeCashBack amount of $10. Weve already tested this Ruleflows ability to sum up the prices of each individual item to calculate a totalAmount, so we wont test that Rulesheet now.
Test the Rule When building Ruletests, its easy to forget that a Rulesheets Filters, if not satisfied, may prevent your rules from executing. The Rulesheet being tested here has a Filter expression that filters out all customers who arent Preferred Card members, so we needed to include an associated preferredCard entity in our test to ensure the Filter is satisfied, and our new rule model has a chance to execute!
43
Test Results As you can see in the Results Testsheet below, the cashBackEarned has been calculated as $2, and cumulativeCashBack amount has been incremented from its original value of $10 to a new value of $12. Our rule model works as expected!
44
The first Condition on our Rulesheet is used to identify any items purchased from department 290, the Floral Department. For each item identified, we want to give the customer a coupon (using the .new operator) for a free balloon. Notice the assignment of the value 12/31/9999 to the expirationDate attribute, which is a common way to indicates that the expiration date is essentially indefinite. There are other ways to accomplish this. For example, the entity Coupon might have a boolean attribute named expires, to which a true or false value could be assigned inside the .new expression.
45
Test for the Floral Department In this Ruletest, we want to make sure that when an item has been purchased from the Floral Department (department 290 according to the code table) that a new Coupon is created entitling the customer to one free balloon. The coupons expiration date should also be created, though here we use a date that makes this coupon essentially non-expiring.
Test Results Notice we also set cumulativeCashBack to 0 for this test. The formula (in Action row B, column 0) depends on a real value of cumulativeCashBack to increment. If its initial value is null, the rule will not fire. More discussion on null values and their effects on rule execution can be found in the Troubleshooting chapter of the Rule Modeling Guide.
46
Department 290 has been recognized and the informational message has been posted. Also, our new Coupon entity has been created, displaying a value of One Free Balloon in the description attribute and 12/31/9999 in the expirationDate attribute, indicating that the coupon will not expire (practically speaking). Also, note the new Message posted by our new rule: it contains the value of allItems.name embedded inside. The syntax to embed attributes is shown in the Rule Statement and is discussed in more detail in the Rule Language Guide, Special Syntax chapter.
47
Filters Continued The next Business Rule to be modeled creates a $2 off coupon when a customer buys 3 or more items from the Soda Department. When determining whether any items from the Floral Department were in the shopping cart, we used the allItems alias in Condition/Action rule 1. But to determine if 3 or more items were purchased from the Soda department, we wont count all items in the shopping cart, just those from the Soda Department. To help us, well use the SodaItems alias we defined earlier in the Scope section. To reduce the collection of items in the shopping cart to only those we want to count, we will use a Filter expression to filter the SodaItems alias. Filters row 2 ensures that the surviving members of the SodaItems alias all have a department value of 285, which is that part of the barCode that identifies the Soda Department. If you drag item from the Vocabulary window, you may need to edit the spelling to the SodaItems alias. This is a case where dragging the SodaItems alias directly from the Scope window may be more convenient, although doing so requires you to type .department manually.
48
Condition Row 2 The size operator counts the number of elements in the SodaItems collection of data. If 3 or more, then the $2 off coupon is issued to the customer. Please refer to the Rule Language Guide for more details about the size operator, and all other operators available within Studio. Action Row 2 The expirationDate attribute derives its value from use of the .addYears operator, set here to 1, so we know that the coupon will expire one year from its date of issuance.
49
Test for the Soda Department To test this rule, our shopping cart must contain 3 or more items from the Soda Department (department 285). When the condition determines that 3 or more Soda items are present (counted using the size operator) then the action will fire and generate the appropriate coupon.
50
The items from the Soda Department have been identified and counted, the Coupon has been added with a $2 off next purchase description and an expirationDate of 04/02/2009 (which is 1 year from the date this test was run), and the informational message has been posted. Coupon rule 2 works as expected!
51
The third condition on our Rulesheet is used to identify when a customers totalAmount exceeds the $75 threshold prescribed in the scenario and award a new coupon (again, using the .new operator) for 10% off a future gasoline purchase at our stores gas pumps. The expirationDate attribute derives its value from the .addMonths operator, set here to 3, so the coupon will expire three months from its date of issue. As always, best practice recommends adding the corresponding Rule Statement, explaining in clear language what the business rule does.
52
53
54
55
The previous Rulesheet calculated the cashBack earned by a Preferred Card member for each purchase and incremented the members cumulativeCashBack amount. Now, lets give the shopper the option of using the money in his cumulativeCashBack account to reduce his total amount at checkout time. Well assume that at time of checkout, the cashier asks the shopper if he wants to apply his cumulativeCashBack amount to the current purchase totalAmount. If the shopper says Yes, then we assume the shopping carts useCashBack attribute is true. If the shopper answers No then the attribute is false. If useCashBack is true, then we need to deduct it from the totalAmount, thereby reducing the amount the shopper pays. Finally, when a shopper applies the balance in his cumulativeCashBack account, we need to reset that balance to zero.
Raise Alerts
A Preferred Shopper account will track the accumulated cash back and allow the customer to apply it to any visits total amount. The cashier will ask a Preferred Shopper if he/she would like to apply a cash back balance to his/her current purchase Once a Preferred Shopper chooses to apply his cash back balance, the cumulative cash back total maintained by the system will be reset to zero, and the accumulation of cash back begins anew with the customers next purchase.
56
Rulesheet 3 Scope Now we will build our third and final Rulesheet and call it use_cashBack. Notice that with the addition of this third Rulesheet, we can complete our Ruleflow Diagram indicating execution sequence of the 3 Rulesheets. Because the rules on this Rulesheet deal with a preferred shoppers cart, we only need a few aliases to represent these perspectives of our data.
57
Filters
Filters The first thing we want to accomplish with this Rulesheet is to make sure we only evaluate preferred customers since only they are eligible for the cash back and bonus incentives. The expression in Filters row 1 of the Rulesheet filters out those customers that are not preferred members (because they dont have a Preferred Card).
58
We only need to create one Condition/Action rule here, with one Condition and a few Actions. As you can see in the illustration below, we only want to process the currentCart when the shopper has chosen to apply his or her cashBack balance to the current purchase, in other words, when useCashBack = true. Then, well deduct the cumulativeCashBack balance from totalAmount, as shown below. In keeping with our model/test approach, well test the rule before adding more to it. Also, well postpone adding a Rule Statement until we have completed the rule model.
59
Use Cash Back Test For this test, we have manually entered $9.24 in the preferred customers cumulativeCashBack attribute and indicated that the she wants to apply this balance towards todays totalAmount (useCashBack = true) According to our first Condition/Action rule, the cumulativeCashBack should first be incremented by the new cashBack earned by todays purchase, then subtracted from the totalAmount to arrive at the final price.
60
Test Results The Output panel shows the new cashBackEarned ($1.64) added to cumulativeCashBack ($10.88) and subtracted from totalAmount ($71.60). We also see some of those values embedded in the 3rd Message displayed at the bottom. But were not done. We still need to reset the cumulativeCashBack attribute to 0. Lets modify the rule to add the necessary logic.
61
Before we reset cumulativeCashBack to 0, lets ensure our preferred customer is aware of her savings today. Lets assign the value of cumulativeCashBack to the attribute named savings. Well assume that this savings value will be printed on a receipt, displayed on a screen, or by some other mechanism made visible to the shopper. Then, following this assignment, we can safely reset the cumulativeCashBack value to 0, ready to begin accumulating new cashBack beginning with the preferred shoppers next purchase. Adding a Rule Statement completes this business rule model.
62
Test Results Using the same Input Testsheet as in the previous test, we can see that cumulativeCashBack is now 0, and savings has the value previously held by cumulativeCashBack. We also receive the new Message below explaining what has happened. Our final rule works as expected! Since this was a cumulative test, we also can verify that the entire Ruleflow (all 3 Rulesheets) work as expected. The Scenario has now been fully modeled and tested.
63
Completed Rulesheet 3 Heres our third, and final, completed Rulesheet! While these Rulesheets successfully model the Scenarios Business Rules, they are not complete from a logical standpoint. Studios Completeness Check will reveal incompletenesses in each of the 3 Rulesheets. The Completeness Check and the other Studio Logical Analysis and Validation tools are covered in more detail in the Basic Rule Modeling Tutorial and in a special chapter in the Rule Modeling Guide. Identifying and resolving incompletenesses or conflicts in these rules are left to you.
64
Congratulations on completing the Corticon Advanced Rule Modeling Tutorial! We hope you have found this tutorial useful in your quest to get the most out of Corticon Studio, the best business rule modeling system in the business. You have learned to incorporate some of Studios more powerful functionality into your rule modeling process, including: Diagramming a Vocabulary Based on the necessary items identified during analysis of a Business Problem, weve shown you how to diagram a Vocabulary using an ER Diagram from which you can confidently create a valid Studio Vocabulary for use in rules modeling and testing. Scope and Aliases Scope helps us tell the Corticon rules engine which data to use when evaluating and executing rules. Using Scope to incorporate associations between entities, and defining Aliases to represent it in your rules, establishes the context in which your data is analyzed. Collections and Collection Operators You now know that a Collection is often comprised of one entity associated with one or more other entities, which we call elements of the collection, and that Collection Operators are used to analyze groups of entities rather than individuals. Studio contains a number of Collection Operators which operate on the Collections you create and its mandatory to use them with Aliases that represent those collections. Condition/Action Column 0 Weve shown you how to use the this portion of a Rulesheet to perform mathematical calculations which can contribute data to other rules in the Rulesheet, or in downstream Rulesheets in the same Ruleflow. Filters Youve learned that a Filter expression acts to limit or reduce the data being evaluated to only that subset whose members satisfy the expression. A filter does not permanently remove or delete any data, it simply excludes data from evaluation by other rules in the same Rulesheet. Sequencing Rulesheets using Ruleflows If a natural sequence or flow of logical steps can be identified within a single decision step, it often makes sense to organize the flow using separate Rulesheets for each logical step. Rulesheets will execute in a sequence determined by their order in the Ruleflow. Using multiple Rulesheets helps us both visualize our logic and maintain and reuse it more easily. Extended Transient Attributes You are now aware that some attributes are little more than intermediate or temporary value holders. We dont need to return these values in a response, or save them in a database. In Studio, a special type of attribute called Extended Transient fills this purpose. Embedding Attributes within Rule Statements Weve shown you how you can embed attributes within Rule Statements and the proper syntax to use when doing so. Rule Statement Messaging Weve explained the value of Studios Rule Statement Messaging for use in posting messages of business significance (as in the ID check alert) as well as for feedback during testing. Even when Rule Statements are not posted, they are useful as documentation.
65
A step-by-step introduction to modeling, analyzing, and testing rules and decisions in Studio 5.2. Recommended for all new users. An intro to more advanced modeling concepts and practices in Studio 5.2. For users who want a more thorough introduction to Studio 5.2s capabilities. A step-by-step introduction to installing the Server as a Web Services server and deploying and exposing decisions as Web Services.
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
66
CORTICON
Business Rules Modeling Studio 5.2 Rule Modeling Guide
Page iii
TABLE OF CONTENTS
Table of Contents ...................................................................................................................................................... iii Preface ........................................................................................................................................................................1 Intended Audience .................................................................................................................................................1 Corticon Business Rules Management Product Documentation ...........................................................................1 Documentation Conventions .................................................................................................................................1 Corticon Studio Technical Support.........................................................................................................................1 Building the Vocabulary..............................................................................................................................................2 Purpose of the Vocabulary.....................................................................................................................................2 Starting from Scratch .........................................................................................................................................4 Designing the Vocabulary ......................................................................................................................................5 Step 1 Identify the Terms ................................................................................................................................5 Step 2 Separating the Generic Terms from the Specific .................................................................................5 Step 3 Assembling and Relating the Terms.....................................................................................................5 Step 4 Diagramming the Vocabulary ..............................................................................................................6 Modeling the Vocabulary in Studio........................................................................................................................8 Custom Data Types ............................................................................................................................................. 10 Data Type Name ............................................................................................................................................. 11 Base Data Type ............................................................................................................................................... 11 Enumeration ................................................................................................................................................... 11 Constraint Expression ..................................................................................................................................... 11 Label and Value ............................................................................................................................................... 12 Using Custom Data Types in the Vocabulary .................................................................................................. 14 Using Enumerated Custom Data Types in Rulesheets .................................................................................... 15 Using Enumerated Custom Data Types in Ruletests....................................................................................... 15 Using Non-Enumerated Custom Data Types in Rulesheets and Ruletests ..................................................... 16 Using Custom Data Types in Extended Operators .......................................................................................... 17 Upgrading Enumerated Values Sets in 3.x and 4.x to Custom Data Types in 5.x ........................................... 17 Domains .............................................................................................................................................................. 19 Support for Inheritance....................................................................................................................................... 22 Inherited Attributes ........................................................................................................................................ 24 Inherited Associations..................................................................................................................................... 24 Controlling the Tree View ............................................................................................................................... 24 Using Aliases with Inheritance ........................................................................................................................ 25 Inheritances Effects on Rule Execution.......................................................................................................... 26 Inheritance and Java Object Messaging ......................................................................................................... 28 Test Yourself:....................................................................................................................................................... 30 Rule Scope & Context .............................................................................................................................................. 34 Rule Scope ........................................................................................................................................................... 40 Aliases ................................................................................................................................................................. 44 Scope and Perspectives in the Vocabulary Tree ................................................................................................. 45 Roles .................................................................................................................................................................... 47 Technical Aside.................................................................................................................................................... 54
Page iv
Test Yourself:....................................................................................................................................................... 55 Rule Writing Techniques Logical Equivalents ....................................................................................................... 61 Filters vs. Conditions ........................................................................................................................................... 61 Boolean Condition vs. Values Set........................................................................................................................ 62 Exclusionary Syntax......................................................................................................................................... 63 Using other in Condition Cells ..................................................................................................................... 65 Use of Ranges in Condition Cells ......................................................................................................................... 66 Alternatives to Value Ranges .............................................................................................................................. 67 Standard Boolean Constructions ........................................................................................................................ 68 Test Yourself:....................................................................................................................................................... 69 Collections ............................................................................................................................................................... 71 Understanding How Studio Handles Collections ................................................................................................ 71 Visualizing Collections ......................................................................................................................................... 71 A Basic Collection Operator ................................................................................................................................ 72 Filtering Collections............................................................................................................................................. 73 Using Aliases to Represent Collections ............................................................................................................... 73 Special Collection Operators ............................................................................................................................... 83 Universal Quantifier ........................................................................................................................................ 83 Existential Quantifier ...................................................................................................................................... 85 Another Example Using the Existential Quantifier ......................................................................................... 88 Test Yourself:....................................................................................................................................................... 95 Rules Containing Calculations & Equations ............................................................................................................. 99 Terminology ........................................................................................................................................................ 99 Operator Precedence .......................................................................................................................................... 99 Datatype Compatibility and Casting ................................................................................................................. 100 Datatype of an Expression ............................................................................................................................ 103 Defeating the Parser ..................................................................................................................................... 104 Manipulating Datatypes with Casting Operators ......................................................................................... 105 Supported Uses of Calculation Expressions ...................................................................................................... 106 Calculation as a Comparison in a Precondition ............................................................................................ 107 Calculation as an Assignment in a Noncondition.......................................................................................... 108 Calculation as a Comparison in a Condition ................................................................................................. 108 Calculation as an Assignment in an Action ................................................................................................... 110 Unsupported Uses of Calculation Expressions.................................................................................................. 110 Calculations in Value Sets and Column Cells ................................................................................................ 110 Calculations in Rule Statements ................................................................................................................... 111 Test Yourself:..................................................................................................................................................... 111 Rule Dependency: Chaining and Looping .............................................................................................................. 114 What is Rule Dependency? ............................................................................................................................... 114 Forward Chaining .............................................................................................................................................. 114 Rulesheet Processing: Modes of Looping ......................................................................................................... 115 Types of Loops .............................................................................................................................................. 116 Looping Controls in Studio ................................................................................................................................ 120
Page v
Identifying Loops........................................................................................................................................... 121 Looping Example ............................................................................................................................................... 123 Problem......................................................................................................................................................... 123 Solution ......................................................................................................................................................... 123 Using Conditions as a Processing Threshold ..................................................................................................... 127 Test Yourself:..................................................................................................................................................... 130 Filters & Preconditions .......................................................................................................................................... 132 What is a Filter? ................................................................................................................................................ 132 Maximum Filters ........................................................................................................................................... 134 Minimum Filters ............................................................................................................................................ 135 What is a Precondition? .................................................................................................................................... 137 Summary of Filter and Preconditions Behaviors .......................................................................................... 142 Performance Implications of the Precondition Behavior ............................................................................. 142 Using Collection Operators in a Filter ............................................................................................................... 142 Location Matters ........................................................................................................................................... 144 Multiple Filters on Collections .......................................................................................................................... 147 Filters that use OR ............................................................................................................................................. 150 Collection Operations & Minimum Filters .................................................................................................... 150 Test Yourself:..................................................................................................................................................... 151 Recognizing and Modeling Parameterized Rules .................................................................................................. 154 Parameterized Rule where a specific attribute is a variable (or parameter) within a general business rule ... 154 Parameterized Rule where a specific business rule is a parameter within a generic business rule ................. 155 Populating an AccountRestriction table from a Sample User Interface ........................................................... 158 Warning! ........................................................................................................................................................... 160 Test Yourself:..................................................................................................................................................... 160 Logical Analysis and Optimization ......................................................................................................................... 161 Testing, Analysis and Optimization ................................................................................................................... 161 Scenario Testing ............................................................................................................................................ 161 Rulesheet Analysis & Optimization ............................................................................................................... 161 Traditional Means of Analyzing Logic ............................................................................................................... 162 Flowcharts ..................................................................................................................................................... 163 Test Databases .............................................................................................................................................. 165 Using Studio to Validate Rulesheets ................................................................................................................. 168 Expanding Rules ............................................................................................................................................ 168 The Conflict Checker ..................................................................................................................................... 170 The Completeness Checker........................................................................................................................... 173 Automatically Determining the Complete Values Set .................................................................................. 174 Automatic Compression of the New Columns.............................................................................................. 174 Limitations of the Completeness Checker .................................................................................................... 174 Renumbering Rules ....................................................................................................................................... 176 Letting the Expansion Tool work for you: Tabular Rules .............................................................................. 178 Memory Management .................................................................................................................................. 180 Logical Loop Detection ...................................................................................................................................... 180 Optimizing Rulesheets ...................................................................................................................................... 181
Page vi
The Compress Tool ....................................................................................................................................... 181 Producing Characteristic Rulesheet Patterns ............................................................................................... 183 Compression Creates Sub-Rule Redundancy ................................................................................................ 186 Effect of Compression on Corticon Server Performance ............................................................................. 187 Test Yourself:..................................................................................................................................................... 187 Ruleflow Versioning & Effective Dating................................................................................................................. 190 Setting a Ruleflow Version ................................................................................................................................ 190 Setting Effective and Expiration Dates .............................................................................................................. 190 Major and Minor Versions ................................................................................................................................ 191 Test Yourself:..................................................................................................................................................... 191 Localizing Corticon Studio ..................................................................................................................................... 192 Localizing the Vocabulary ................................................................................................................................. 192 Localizing the Rulesheet.................................................................................................................................... 193 Working with Rules in Natural Language .............................................................................................................. 194 Modeling and Managing Rules using Server Console ........................................................................................... 196 Lifecycle Management in Server Console ......................................................................................................... 196 Creating a New Decision Service Version ..................................................................................................... 196 Opening the New Version ............................................................................................................................. 197 Modifying the New Version .......................................................................................................................... 197 Promoting the New Version to Live .............................................................................................................. 198 Removing the Version from Live................................................................................................................... 198 The Studio Reporting Framework ......................................................................................................................... 199 How Studio Creates Reports ............................................................................................................................. 199 Customizing the XSLT Stylesheets................................................................................................................. 199 Troubleshooting Rulesheets and Ruleflows .......................................................................................................... 200 Where did the problem occur? ......................................................................................................................... 200 Using Studio to reproduce the behavior ........................................................................................................... 200 Running a Studio Ruletest............................................................................................................................. 201 Analyzing Ruletest Results ............................................................................................................................ 202 Identifying the Breakpoint ............................................................................................................................ 203 At the Breakpoint .......................................................................................................................................... 204 No Partial Rule Firing .................................................................................................................................... 205 Initializing Null Attributes ............................................................................................................................. 205 Troubleshooting Corticon Server Problems.................................................................................................. 206 Test Yourself...................................................................................................................................................... 211 Appendix A: Standard Boolean Constructions ..................................................................................................... 214 AND ................................................................................................................................................................... 214 NAND................................................................................................................................................................. 216 OR ...................................................................................................................................................................... 217 XOR.................................................................................................................................................................... 218 NOR ................................................................................................................................................................... 219
Page vii
XNOR ................................................................................................................................................................. 220 Appendix B: Extended Transients in the Vocabulary ........................................................................................... 221 Building the Vocabulary .................................................................................................................................... 221 Appendix C: Corticon Studio and Server 5.2 Product Documentation................................................................. 222 Appendix D: Answers to Test Yourself Questions ................................................................................................. 223 Building the Vocabulary .................................................................................................................................... 223 Rule Scope & Context........................................................................................................................................ 226 Rule Writing Techniques Logical Equivalents................................................................................................. 228 Collections ......................................................................................................................................................... 230 Rules Containing Calculations & Equations ...................................................................................................... 231 Rule Dependency: Dependency & Inferencing ................................................................................................. 233 Preconditions & Filters ...................................................................................................................................... 234 Recognizing & Modeling Parameterized Rules ................................................................................................. 235 Logical Analysis & Optimization ........................................................................................................................ 236 Ruleflow Versioning & Effective Dating ............................................................................................................ 238 Troubleshooting Rulesheets ............................................................................................................................. 238
Page 1
PREFACE
INTENDED AUDIENCE
The Rule Modeling Guide is intended for use by business analysts and others who will use Corticon Business Rules Modeling Studio to build and test rules. It provides the theory and concepts necessary to acquire a deeper understanding of rule design, allowing the rule modeler and developer to fully leverage Studios unique and advanced capabilities. This document assumes that you are familiar with using various thirdparty software packages and operating environments.
DOCUMENTATION CONVENTIONS
Corticon documentation uses the following conventions: Document names are shown in bold face italic type: Studio Installation Guide. Screen, button and window names are shown in bold face type: Custom Setup screen. Important information such as Notes, Tips and Warnings are shown in this color scheme:
Tools Notes and Tips Warnings
Hyperlinks are underlined and shown in blue: the cursor changes to a hand: Building the Vocabulary. File names, code, and user-defined information are shown as: Installing.pdf. Menu options are indicated using bold text and arrows: File>Save denotes the selection of the Save option from the File menu.
Page 2
In these two rules, itemSubTotal is the intermediate or transient term. We may never use itemSubTotal by itself; instead, we may only create it for purposes of subsequent derivations, as in the calculation of orderTotal in rule #2. Since a transient attribute may be the result of a very complicated rule, it may be convenient to create a Vocabulary term for it and use it whenever rewriting the complex rule would be awkward or unclear. Also see Appendix B, Extended Transients in the Vocabulary. Provides a federated data model that consolidates entities and attributes from various enterprise data resources. This is important because a companys data may be stored in many different databases in many different physical locations. Corticon believes that rule modelers need not be concerned with where data is, only how it is used in the context of building and evaluating business rules. The decision management system should ensure that proper links are maintained between the Vocabulary and the underlying data. We often refer to this concept as abstraction the complexities of an enterprises data storage and retrieval systems have been hidden so that only the aspects relevant to rule writing are presented to the rule modeler.
Page 3
Provides a built-in library of literal terms and operators that can be applied to entities or attributes in the Vocabulary. This part of the Vocabulary, the lower half of the Vocabulary window shown in Figure 1, is called the Operator Vocabulary because it provides many of the verbs (the operators) needed in our business rules. Many standard operators such as the mathematical functions { +, -, *, /} and comparator functions {<, >, =} as well as more specialized functions are contained within this portion of the Vocabulary. See the Rule Language Guide for descriptions and examples of all operators available, as well as detailed instructions for extending the library.
Defines a schema that supplies the contract for sending data to and from a Corticon Decision Service (Rulesheets deployed in production). Since XML messaging is used to carry data to and from the rules for evaluation, data must be organized in a pre-defined structure that can be understood and processed by the rules. An XML schema that accomplishes this purpose can be automatically generated directly from the Vocabulary. This schema is called a Vocabulary-Level service contract and details can be found in the Server Integration & Deployment Guide.
An important point about the Vocabulary: there does not need to be a one-to-one correlation between terms in the Vocabulary and terms in the enterprise data model. In other words, there may be terms in the data model that are not included in or referenced by rules such terms need not be included in the Vocabulary. Conversely, the Vocabulary may include terms (such as extended transient attributes) that are used only in rules these terms need not be present in the data model. Two guiding principles: If the rule modeler desires to use a particular term in a business rule, then that term must be part of the Vocabulary. This can include terms that exist only within the Vocabulary these are the transient attributes introduced above.
Page 4
If a rule produces a value that must be retained, persisted, or otherwise saved in a database (or other means external to the rules), then that Vocabulary term must also be present in the enterprise data model. There are many methods for linking or mapping these Vocabulary terms with corresponding terms in the data model, but a discussion of these methods is technical in nature and is not included in this manual.
There are two basic starting points for creating a Vocabulary: starting from an existing data model or starting from scratch. We will start by examining the latter since it is typically more challenging.
Analyze the chosen scenario and/or existing business rules in order to identify the relevant terms and the relationships between these terms. We refer to statements expressing the relevant terms and relationships as facts and recommend developing a Fact Model to more clearly illustrate how they fit together. We will use a simple example to show the creation of a Fact Model and its subsequent development into a Vocabulary for use in Studio.
Page 5
Rule Modeling Guide An aircraft carries a cargo shipment. A flight plan schedules cargo for shipment on an aircraft. A cargo shipment has a weight. A cargo shipment has a manifest number. An aircraft has a tail number. An aircraft has a maximum cargo weight. A 747 is a type of aircraft.
Page 6
And so on Notice that some of these facts describe how one term relates to another term; for example, an aircraft carries a cargo shipment. This usually provides a clue that the terms in question, aircraft and cargo shipment, are entities and are two of the primary terms we are interested in identifying. Also notice that some facts describe what Business Rule Solutions, LLC (BRS) calls has a relationships; for example, an aircraft has a tail number, or a cargo has a weight. This type of relationship usually identifies the subject (aircraft) as an entity and the object (tail number) as an attribute of that entity. By continuing the analysis, we discover that the problem reduces to a Vocabulary containing 3 main entities, each with its own set of attributes: Entity: aircraft Attributes: aircraft type, max cargo weight, max cargo volume, tail number Entity: cargo shipment
Page 7
The UML Class diagram contains the same type of information, and may be more familiar to you:
Its not a requirement to construct diagrams or models of the Vocabulary before building it in Studio. But it can be very helpful in organizing and conceptualizing the structures and relationships, especially for very large and complex Vocabularies. The BRS Fact Model and UML Class Diagram are appropriate
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 8
because they remain sufficiently abstracted from lower-level data models which contain information not typically required in a Vocabulary.
It may be convenient to use a naming convention to distinguish transient attributes from base; for instance, we might add a lowercase letter d to the start of totalWeight to indicate it is a derived attribute. However, we caution against modifying the names of terms too much, since the intent is to express them in a language accessible to business users, not just developers. Associations between entities have role names that are assigned when building the associations in the UML class diagram or Vocabulary Editor. Default role names simply duplicate the entity name with the first letter in lowercase. For example, the association between the Cargo and FlightPlan entities would have a role name of flightPlan as seen by the Cargo entity, and cargo as seen by the FlightPlan entity. Roles are useful in clarifying context in a rule a topic covered in more detail within the Scope chapter. Associations between entities can be directional (one-way) or bi-directional (two-way). If the association between FlightPlan and Aircraft were directional (with FlightPlan as the source entity and Aircraft as target), we would only be able to write rules that traverse from FlightPlan to Aircraft, but not the other way. This means that a rule may use the Vocabulary term flightPlan.aircraft.tailNumber but may not use
Some earlier versions of Studio 4.x used only 5 main datatypes: Date and Time were subtypes of the DateTime type. Upgrading from these versions will automatically convert datatypes to those used in v5.x.
Page 9
association in either direction, which clearly allows us more flexibility in writing rules. Therefore, it is strongly recommended that all associations be bi-directional whenever possible. New associations are bi-directional by default. Associations also have cardinality, which indicates how many instances of a given entity may be associated with another entity. For example, in our air cargo scenario, each instance of FlightPlan will be associated with only one instance of Aircraft, so we can say that there is a one-to-one relationship between FlightPlan and Aircraft. The practice of specifying cardinality in the Vocabulary deviates from the UML Class modeling technique because the act of assigning cardinality can be viewed as defining a constraint-type rule. For example, a flightPlan schedules exactly one aircraft and one cargo shipment is a constraint-type business rule that can be implemented in a Studio Rulesheet as well as embedded in the associations within a Vocabulary. In practice, however, it may often be more convenient to embed these constraints in the Vocabulary, especially if they are unlikely to change in the future. Another consideration when creating a Vocabulary is whether derived attributes must be saved (or persisted) external to Studio, for example, in a database. It is important to note that while the structure of your Vocabulary may closely match your data model (often persisted in a relational database), the Vocabulary is not required to include all of the database entities/tables or attributes/columns, especially if they will not be used for writing rules. Conversely, our Vocabulary may contain attributes that are used only as transient variables in rules and that do not correspond to fields in an external database. Finally, the Vocabulary must contain all of the entities and attributes needed to build rules in Studio that reproduce the decision points of the business process being automated. This will most likely be an iterative process, with multiple Vocabulary changes being made as the rules are built, refined, and tested. It is very common to discover, while building rules, that the Vocabulary does not contain necessary terms. But the flexibility of Studio permits the rule developer to update or modify the Vocabulary immediately, without programming.
Page 10
Note: in Figure 4, Studio is shown in Rule Modeling mode. If in Integration Deployment mode, the Property Name column will contain additional rows. For more information on Integration Deployment mode, see the Server Integration & Deployment Guide.
Page 11
Enumeration
If yes is selected in this field, the Constraint Expression field (next field to right) becomes disabled (grayed out) and the Label and Value columns are enabled. Values for the Label and Value columns must be entered - see the Label and Value section below for more information. If Enumeration is no, then the Constraint Expression field is enabled and the Label and Value columns are disabled.
Constraint Expression
Constraint expressions are optional for non-enumerated custom data types, but if none are used then the custom data type probably isnt necessary because it reduces to a base attribute with a custom name. For custom data types which are not enumerated, you can define an expression to constrain the range of acceptable values. All Constraint Expressions must be Boolean expressions, in other words they must return or resolve to a boolean value of true or false. The supported syntax is the same as Filter expressions with the following rules and exceptions: we use the keyword value to represent the Custom Data Type value. logical connectors such as and and or are supported parentheses may be used to form more complex expressions The expression may include references to Base and Extended Operators which are compatible with the Base Data Type chosen. No Collection operators may be referenced in the expression. There should be NO references to keyword null. This is because null represent lack of value and is not a real value. The Constraint Expression is intended to constrain the value space of the data type and expressions such as attribute expression <> null do not belong in it. An attribute that must not have a null value can be so designated by selecting Yes in its Mandatory property value.
Page 12
Constraint Expression
Meaning
Integer values greater than 5 Decimal values greater than or equal to 10.2 Decimal values between 1.1 (exclusive) and 9.9 (inclusive) DateTime values between 1/1/2000 12:30:00 PM (inclusive) and 1/2/2000 11:00:00 AM (exclusive) Time values between 1:00:00 PM (inclusive) and 2:00:00 PM (inclusive) String values of minimum 6 characters in length that contain at least a 1 or 2
Page 13
PrimeNumbers is an Integer-based, enumerated custom data type with Value-only set members.
Page 14
.
Figure 11 Custom Data Type, example 6
BoyNames is a String-based, enumerated custom data type with Value-only set members.
or Move Down
Page 15
Notice in Figure 12 that custom data type packingType is shown in the drop-down as a sub-category of the String-based data type. The other custom data types will be grouped with their base data types as well. Multiple attributes may use the same custom data type.
Those enumerated custom data types having Labels can also be used in Condition or Action expressions of the form:
Figure 14 Using special "hash" syntax to specify a custom data type label
Page 16
Then, after assigning it to the Vocabulary attribute Cargo.weight, its used in a Rulesheet Condition row as shown below:
Page 17
Notice in Figure 17 that the 300000 entry violates the Constraint Expression of the custom data type assigned to Cargo.weight, but does not turn red or otherwise indicate a problem. The indication comes when data is entered for the attribute in a Ruletest, as shown below:
Notice that the small yellow warning icon indicates a problem in the attribute, entity, and both Ruletest tabs. Such an error is hard to miss! Also, an Warning message will appear in the Problems tab (if open and visible) as shown below. If the Problems tab is closed, you can display it by selecting Window>Show View>Problems from the Studio menubar.
A Warning will not prevent you from running the Ruletest. However, an Error, indicated by a small red icon , will prevent the Ruletest execution. You must fix any errors before testing.
Upgrading Enumerated Values Sets in 3.x and 4.x to Custom Data Types in 5.x
Vocabularies created in Corticon BRMS 4.x may include Possible Values Sets defined for attributes. If such a Vocabulary is imported into Corticon Studio 5.2, these Possible Values Sets will be converted into custom data types according to the following process. Values in Studio 4.x Possible Value Set Name (from Lookup Table) fields are mapped directly to Studio 5.2 custom data types. Should a v4.x attribute have a Possible Value Set Name (from Lookup Table) value, then this value is mapped directly to the Studio 5.2 attributes Data Type property value.
Page 18
If the v4.x attributes Possible Values property is not empty, then the upgrade process proceeds as follows: 1. If the Studio 4.x attributes Possible Values contain only literal values (which may include null or other) then a new enumerated custom data type will be created in the Studio 5.2 Vocabulary as follows: a. Create a custom data type called <AttributeName>Type. In the event this name already exists, then the name will be made unique by adding _1, _2, etc. b. Set the Base Data Type of the Studio 5.2 custom data type to the value of the v4.x attributes Data Type. c. Set the Enumeration value to Yes d. Populate the Values list with the Possible Values of the v4.x attribute, excluding null and other. e. Set the Data Type of the Studio 5.2 attribute to the newly created custom data type. 2. Otherwise, analyze the old Possible Values and determine the minimum possible value allowed and the maximum possible value allowed. If both minimum and maximum values are infinite then the set is unbounded. a. If the set is unbounded on both ends then: i. Set the Data Type of the upgraded attribute to the Data Type of the old attribute and ignore the Possible Values definition. b. Otherwise: i. Create a Custom Data Type called <AttributeName>Type. In the event the Custom Data Type already exists, the name can be made unique by adding _1, _2, ii. Set the Base Type of the newly created type to the Data Type of the old attribute iii. If the set has a lower and/or upper bound then add a Constraint Expression using the corresponding template below:. 1. value > <MinValue> 2. value >= <MinValue> 3. value < <MaxValue> 4. value <= <MaxValue> 5. value in (<MinValue>..<MaxValue>) 6. value in (<MinValue>..<MaxValue>] 7. value in [<MinValue>..<MaxValue>) 8. value in [<MinValue>..<MaxValue>]
Page 19
Studio 4.x Integer attribute named oddNos with Possible Values = {1,3,5,7,null,other}. Qualifies for step 1 above. Upon upgrade, a Studio 5.2 enumerated custom data type is created named oddNosType of Base Type Integer and the Value entries = {1,3,5,7} Upgrade Example B Studio 4.x Decimal attribute named temperature with Possible Values = {<=98.6,99.0,>=100.0,null}. Qualifies for 2.a This set is unbounded. Therefore, no custom data type is created. The Studio 5.2 attribute temperature receives Data Type = Decimal. Upgrade Example C Studio 4.x Integer attribute named age with Possible Values = {>0,20,30,<=120,null,other}. Qualifies for 2.b.iii.7 Ignoring null and other, this is a constrained range with lower bound 0 (exclusive) and upper bound 120 (inclusive). Upon upgrade, a custom data type is created named ageType with Base Type = Decimal with the following Constraint Expression: value in [0..120). Values 20, 30, null, and other are ignored.
DOMAINS
Occasionally, it may be necessary or desirable to include more than one entity of the same name in a Vocabulary. This can be accomplished using Domains 2. Domains allow us to bundle one or more entities in a sub-set within the Vocabulary, allowing us to reuse entity names so long as the entity names are unique within each Domain. Additional Domains, also called sub-Domains, can be defined within other Domains. To create Domains in a Vocabulary, select Vocabulary>Add Domain from the Studio menubar or click from the Studio toolbar, as shown in Figure 20.
Technical analogs to Domains are packages in the Java world and namespaces in the XML world.
Page 20
Youll see a new folder icon appear in the Vocabulary tree - assign it a name. The example in Figure 21 shows a Vocabulary with 2 Domains, US_Fleet and WW_Fleet:
Notice that the entity Aircraft appears in each Domain, using the same spelling and containing slightly different attributes (FAAnumber vs. ICAOnumber). Notice too that the Association role names from FlightPlan to Aircraft have been named manually to ensure uniqueness: one is now USaircraft and the other is WWaircraft.
Page 21
When using entities from domains in a Rulesheet, its important to ensure uniqueness, which means aliases must be used to distinguish one entity from another.
In Figure 22, both Aircraft entities have been dropped into the Scope section of the Rulesheet. But because their names are not unique, an error icon appears. Also, the fully qualified domain name has been added after each to distinguish them. By fully qualified, we mean the ::US_Fleet:: designator that follows the first Aircraft and ::WW_Fleet:: that follows the second. But it would be inconvenient (and ugly) to use these fully qualified names in Rulesheet expressions. So we require that you define a unique alias for each. The aliases will be used in the Rulesheet expressions, as shown in Figure 23.
Domains in a Ruletest When using Vocabulary terms in a Ruletest, just drag and drop them as usual. Youll notice that they are automatically labeled with the fully qualified name, as shown in Figure 24.
Page 22
In Figure 25, we see a UML model that includes inheritance. The solid-headed arrow symbol indicates that the Employee class is a descendant of the Person class, and therefore inherits some of its properties. Specifically, the Employee class inherits the age and name attributes from Person. In other words, Employee has all the same attributes of a Person plus two of its own, hireDate and
Page 23
Modeling this UML Class Diagram as a Studio Vocabulary is straightforward. All Entities, Attributes and Associations are created as per normal practice. To incorporate the elements of inheritance, we only need add one additional setting for each of the descendant entities, as shown in Figure 26:
Once all descendant entities have been configured to inherit from their proper ancestor entities, we can save the Vocabulary and view it in the Rule Vocabulary window:
Page 24
Notice that many of the term names and icons are varying shades of gray - these color codes help us to understand the inherited relationships that exist in the Vocabulary.
Inherited Attributes
Attributes with names displayed in solid black type, such as Customer.loyaltyNumber in Figure 27, are native attributes of that entity. Attributes with names displayed in dark gray type, such as Customer.age, are inherited attributes from the ancestor entity (in the case of Customer, Person).
Inherited Associations
Inherited Associations are a bit more complicated. An entity may be directly associated with another entity or that entitys descendants. An entity may also inherit an association from its ancestor. Using the example shown in Figure 26 and Figure 27 above, lets dissect each of these combinations.
Customer.aircraft is a direct association between Customer and Aircraft entities. No inheritance is involved, so the association icon is black and the rolename is black Customer.operator (Equipment) is an association inherited from Customers ancestor entity Person, which has a direct association with Equipment and the rolename operator in our Vocabulary (the UML Class Diagram in Figure 26 shows the rolename as operates because
it is more conventional in UML to use verbs as rolenames, whereas nouns usually make better rolenames in a Corticon Vocabulary). Because the association is inherited from the ancestors direct association, the icon is dark gray and the rolename is black.
Equipment (which we can see equally well in the expanded operator rolename) has several associations with Person. One of these is a direct association with the Person entity. In this case, both association icon and rolename are black. But Equipment also has associations with descendants of the Person entity, specifically Employee, Customer, and Pilot. We call
these filtered associations, and display their rolenames as dark gray. Finally, Customer has another association with operator (Aircraft) because Aircraft is a descendant of Equipment. So we combine the inherited dark gray icon and the filtered dark gray rolename to display this association.
Page 25
Person and Equipment are associated (using named roles), but what relationship does Employee have with Equipment or Aircraft, if any? In version 5.2, Studio also supports inherited
associations3.
Page 26
A Ruletest provides an instance of Employee and an instance of Pilot. Recall from the Vocabulary that Pilot is a descendant of Employee, which means it inherits its attributes and associations. But more importantly from a rule execution perspective, a Pilot will also be affected by any rules that affect an Employee. This is shown in Figure 32:
Page 27
Using inheritance can be an efficient and powerful way to write rules on many different types of employees, such as pilots, gate agents, baggage handlers, mechanics, etc, without needing to write individual rules for each. Inherited Association A similar test demonstrates how associations are inherited during rule execution. In this case, we test Employee.hireDate to see whos qualified to operate a piece of Equipment. The += syntax used by the Action row is explained in more detail in the Rule Language Guide.
Page 28
Now in , we provide a sample Equipment entity, one Employee, and one Pilot. Both hireDates satisfy the rules Condition (the Pilot inheriting hireDate from its Employee ancestor as before). When the Employee is added to the operators collection alias, an instance of the association between Equipment and Employee is created. But what may be surprising is that the same occurs for Pilot, which also has an association to Equipment that it inherited from Employee!
Page 29
Figure 35 How the Vocabulary Incorporates Inheritance from a Java Object Model
When a collection of Java objects are passed into the engine through the JOM API, the Java translator determines how to map them to the internal Entities using the following algorithm: Naming conventions used in the graphic above: DS = Decision Service JO = Java Object in input collection JC = Java Class for the JO and any of its direct or indirect ancestors JI = Java Interfaces implemented directly or indirectly by JO E = A Vocabulary Entity with no descendents found in DS context AE = An Ancestor Entity (one with descendents) found in DS context CDO = In memory Java Data Object created by Corticon for use in rule execution
For each E: If there is a JO whose JC or JI is mapped to E then Instantiate a CDO for E and link to JO Put CDO in E bucket Traverse Es inheritance hierarchy one level up For each AE discovered in current level: Put CDO in AE bucket If E has another level of inheritance hierarchy, repeat last step
Page 30
This design effectively attempts to instantiate the minimum number of CDOs possible and morphs them into playing multiple Entity roles. Ideally, no duplicate copies of input data exists in the engines working memory thus avoid data synchronization issues.Test Yourself
TEST YOURSELF:
Answers are provided in Appendix D 1. 2. 3. 4. 5. Give 3 functions of the Vocabulary. True or False: All Vocabulary terms must also exist in the object or data model? True or False: All terms in the object or data model must also exist in the Vocabulary? True or False: In order to create the Vocabulary, an object or data model must already exist. The Vocabulary is an __________ model, meaning many of the real complexities of an underlying data model are hidden so that the rule author can focus on only those terms relevant to the rules. The UML model that contains the same types of information as a Vocabulary is called a ______________ What are the three components (or nodes) of the Vocabulary? Which of the following are acceptable attribute names? hair_color 9. hairColor HairColor hair color
6.
7. 8.
10. Which of the three Vocabulary components can hold an actual value? 11. What are the five main data types used by Vocabulary attributes? 12. Which colors are used in the Base attribute icon? 13. Which colors are used in the Extended Transient attribute icon? 14. What is the purpose of an Extended Transient Vocabulary term?
Rule Modeling Guide 15. Associations are ________________ by default. 16. Association icons indicate: optionality singularity cardinality musicality 17. Which of the following icons represents a one-to-many association?
Page 31
18.
19.
If an association is one-directional from the Source entity to the Target entity, then which term is not available in the Vocabulary? Target.attribute Target.source.attribute Source.target.attribute Source.attribute
20.
The default role name of an association from the Source entity to the Target entity is: role1 source target theTarget
22. Create a Studio Vocabulary for the model sketched in 22. 23. List the (4) steps in generating a Vocabulary from scratch. 24. Cardinality of an association determines: a. The number of possible associated entities. b. The number of attributes for each entity. c. The number of associations possible within an entity. d. The number of attributes for each association. 25. The Vocabulary terms are the nouns of Corticon rules. What are the verbs?
Page 32
26. What Corticon document contains the complete list of all Vocabulary Operators, descriptions of their usage, and actual examples of use in Rulesheets? 27. True or False. In addition to the supported vocabulary data types, you can create any type of custom data type you want? 28. You must name your custom data type. Which of the following are not custom data type naming convention requirements? a. Can not match any other vocabulary entity names b. May match other Custom Data Type Names c. Base Data Type names may not be re-used. d. The name must comply with the standard entity naming rules. 29. True or False. The Enumeration section of the Custom Data Types exposses the Label/Value columns and allows you to create a list of acceptable value rows. 30. Selecting no in the Enumeration section of the Custom Data Types enables the Contraint Expression. Give an example of a Constraint Expression: _______________________________________ 31. True or False. Constraint Expressions must be equivalent to a Boolean expression to be vaild. 32. In an Enumeration, are both the Label and Value columns required? 33. When you create Enumerated Custom data Types, which of the following are acceptable entries for the Value column: 12/12/2011 12/12/2011 Airbus Airbus
34. Name an advantage to using Enumerated Custom Data Types when it comes to testing your rules in a Ruletest. 35. Explain what Domains do in the Vocabulary? 36. True or False. If you use a Domain, then you will be required to create an alias for each unique Entity/Domain pair? 37. True or False. Inheitance can be modeled in a Vocabulary.
Rule Modeling Guide 38. In the following vocabulary, which Entities have native attributes and which Entities has inherited attributes?
Page 33
39. Give two examples of inherited attributes from the vocabulary above: ______________ ______________
40. True or False. Using Inheritance can be a way to write efficient and powerful rules. For example, one rule could be used to modify the cadence attribute for all the entities in the Vocabulary example above.
Page 34
According to this Vocabulary, an Aircraft is related to a Cargo shipment through a FlightPlan. In other words, it is the FlightPlan that connects or relates an Aircraft to its Cargo shipment. The Aircraft, by itself, has no direct relationship to a Cargo shipment unless it is scheduled by a FlightPlan; or, no Aircraft may carry a Cargo shipment without a FlightPlan. Similarly, no Cargo shipment may be transported by an Aircraft without a FlightPlan. These facts constitute business rules in and of themselves and constrain creation of other rules because they define the Vocabulary well use to build all subsequent rules in this scenario. Also recall that the company wants to build a system that automatically checks flight plans to ensure no scheduling rules or guidelines are violated. One of the many business rules that need to be checked by this system is:
With our Vocabulary created, we can build this rule in the Studio. As with many tasks in Studio, there is often more than one way to do something. Well explore two possible ways to build this rule one correct and one incorrect.
Page 35
To begin with, well write our rule using the root-level terms in the Vocabulary. In Figure 37 below, column #1 (the true Condition) is the rule we are most interested in weve added the false Condition in column #2 simply to show a logically complete Rulesheet.
Please refer to the Embedding Attributes in Posted Rule Statements section of the Rule Language Guide for additional details regarding the syntax introduced in the Rule Statements portion of Figure 10, above. We can build a Ruletest to test the rule using the Cargo companys actual data, as follows: The company owns 3 Aircraft, 2 747s and a DC-10, each with different tail numbers. The 3 Aircraft are shown in Figure 11. Each box represents a real-life example (or instance) of the Aircraft term from our Vocabulary.
Page 36
These Aircraft give the company the ability to schedule 3 Cargo shipments each night {there is another business rule implied here an Aircraft must not be scheduled for more than one flight per night, but we wont address this now because it is not relevant to the discussion}. On a given night, the Cargo shipments look like those shown below. Again, like the Aircraft, these Cargo shipments represent specific instances of the generic Cargo term from the Vocabulary.
Finally, our sample business process manually matches specific aircraft and cargo shipments together as three flightplans, shown below. This organization of data is consistent with the structure and constraints implicit in our Vocabulary.
Page 37
Figure 40 The 3 FlightPlans with their related Aircraft and Cargo instances
We can construct a Ruletest (Figure 41) so that the companys actual data will be evaluated by the rule. Since the rule used root-level Vocabulary terms in its construction, we will use root-level terms in the Ruletest as well:
Page 38
Note the messages returned by the Ruletest. Recall that the intent of the rule is to verify whether a given Flightplan is in violation by scheduling a Cargo shipment that is too heavy for the assigned Aircraft. But we already know there are only three Flightplans. And we also know, from examination of Figure 40, that the combination of aircraft N1003 and cargo 625C does not appear in any of our three Flightplans. So why was this combination, one that does not actually exist, evaluated? For that matter, why has the rule fired nine times when only three sets of Aircraft and
Rule Modeling Guide Cargo were present? The answer lies in the way we defined our rule, and in the way the Server evaluated it.
Page 39
We gave the Ruletest three instances of both Aircraft and Cargo. Studio treats Aircraft as a collection or set of these three specific instances. When Studio encounters the term Aircraft in a rule, it applies all instances of Aircraft found in the Ruletest (all three instances in this example) to the rule. Since both Aircraft and Cargo have three instances, there are a total of nine possible combinations of the two terms. See Figure 43: The set of these nine possible combinations is called a cross product, Cartesian product, or tuple set in different disciplines. We tend to use crossproduct when describing this outcome.
One pair, the combination of manifest 625B and plane N1003 (shown as the red arrow in Figure 43), is indeed illegal, since the plane, a DC-10, can only carry 150,000 lbs, while the cargo weighs 175,000 lbs. But this pairing does not correspond to any of the three FlightPlans created. Many of the other combinations evaluated (five others, to be exact) are not represented by real flight plans either. So why did Studio bother to perform three times the necessary evaluations? It is because our rule, as implemented in Figure 37, does not capture the essential elements of scope and context. We want our rule to express the fact that we are only interested in evaluating the CargoAircraft pair for each FlightPlan, not for all possible combinations. How do we express this desire in our rule? We use the associations included in the Vocabulary. Refer to Figure 44, below:
Page 40
In Figure 44, weve rewritten the rule using the aircraft and cargo terms from inside the FlightPlan term 4. This is significant. It means we want the rule to evaluate the Cargo and Aircraft terms only in the context of a FlightPlan. For example, on a different night, the Cargo company might have eight Cargo shipments assembled, but only the same three planes on which to carry them. In this scenario, three flight plans would still be created. Should the rule evaluate all eight Cargo shipments, or only those three associated with actual flight plans? From the original business rule, it is clear we are only interested in evaluating those Cargo shipments in the context of actual flight plans. To put it differently, the rules application is limited to only those Cargo shipments assigned to a specific Aircraft via a specific FlightPlan. We express these relationships in the Rulesheet by including the FlightPlan term in the rule, so that cargo.weight is properly expressed as FlightPlan.cargo.weight, and Aircraft.maxCargoWeight is properly expressed as FlightPlan.aircraft.maxCargoWeight. By attaching FlightPlan to the terms aircraft.maxCargoWeight and cargo.weight, we have indicated mandatory traversals of the associations between FlightPlan and the other two terms, Aircraft and Cargo. This instructs Corticon Server to evaluate the rule using the intended context. In writing rules, its extremely important to understand the context of a rule and the scope of the data to which it will be applied.
RULE SCOPE
Because the rule is evaluating both Cargo and Aircraft in the context of a FlightPlan, we say that the rule has scope, which means that the rule evaluates only that data which matches the rules scope. This has an interesting effect on the way the rule is evaluated. When the rule is executed, its
By inside we mean the aircraft and cargo terms that appear when the FlightPlan term is opened in the Vocabulary tree, as shown by the orange circles in Figure 44.
Page 41
scope ensures that the Server evaluates only those pairings that matches the same FlightPlan. This means that a cargo.weight will only be compared to an aircraft.maxCargoWeight if both the cargo and the aircraft share the same FlightPlan. This simplifies rule expression greatly, because it eliminates the need for us to specify which FlightPlan we are talking about for each Aircraft-Cargo combination. When a rule has context, the system takes care of this matching automatically by sending only those Aircraft-Cargo pairs that share the same FlightPlan to be evaluated by the rule. And, since Studio automatically handles multiple instances as collections 5, it sends all pairs to the rule for evaluation. To test this new rule, we need to structure our Ruletest differently to correspond to the new structure of our rule and reflect the rules scope. For more information on the mechanics of creating associations in Ruletests, also refer to the Set Up the Ruletest Scenario section in the Basic Tutorial for Corticon Studio Modeling Rules and the Creating Associations chapter in the Studio Quick Reference Guide. Finally, one FlightPlan is created for each Aircraft-Cargo pair. This means a total of three FlightPlans are generated each night. Using the terms in our Vocabulary and the relationships between them, we have the possibilities shown in Figure 40. The rule will evaluate these combinations and identify any violations.
See the following chapter, Collections, for a more detailed discussion of this topic.
Page 42
What is the expected result from this Ruletest? If the results follow the same pattern as in the first Ruletest, we might expect the rule to fire nine times (three Aircraft evaluated for each of three Cargo shipments). But refer to Figure 46 and you will see that the rule, in fact, fired only 3 times and only for those Aircraft-Cargo pairs that are related by common FlightPlans. This is the result we want. The Ruletest shows that there are no FlightPlans in violation of our rule.
Page 43
One final point about scope: it is critical that the context you choose for your rule supports the intent of the business decision you are modeling. At the very beginning of our example, we stated that the purpose of the application is to check flightplans that have already been created. Therefore, the context of our rule was chosen so that the rules design was consistent with this goal no aircraftcargo combinations should be evaluated unless they are already matched up via a common flightplan. But what if our business purpose had been different? What if the problem we are trying to solve was modified to: Of all possible combinations of aircraft and cargo, determine which pairings must not be
Page 44
included in the same FlightPlan. The difference here is subtle but important. Before, we were identifying invalid combinations of pre-existing FlightPlans. Now, we are trying to identify invalid combinations from all possible cargo-aircraft pairings. This other rule might be the first step in a screening or filtering process designed to discard all the invalid combinations. In this case, the original rule we built, root-level context, would be the appropriate way to implement our intentions, because now we are looking at all possible combinations prior to creating new FlightPlans.
ALIASES
To clean up and simplify rule expression, Studio allows you to declare aliases in the Rulesheet. Using an alias to express scope results in a less cluttered Rulesheet. To define an alias, you must first shift to the Advanced View of the Rulesheet. This shift is detailed in the Studio Quick Reference Guide. If rules have already been modeled in the Rulesheet, then the Scope window will already contains those Vocabulary terms used in the rules so far. If rules have not yet been modeled, then the Scope window will be empty. Regardless, to define an alias, simply double-click to the immediate right of the term and type a unique name in the entry box, as shown below:
Once an alias has been defined, then any subsequent rule modeling in the Rulesheet will automatically substitute the alias for the Vocabulary term it represents. In Figure 48, notice that the terms in the Condition rows of the Rulesheet do not show the FlightPlan term - because the alias plan substitutes for FlightPlan. The small c in cargo and a in aircraft provide other clues that these terms exist within the context of the FlightPlan term defined in the Scope window.
Page 45
Once an alias is defined, any new Vocabulary term dropped onto the Rulesheet will be automatically abbreviated accordingly. For example, dragging and dropping FlightPlan.cargo.weight onto the Rulesheet will result in plan.cargo.weight being displayed. Aliases work in all sections of the Rulesheet, including the Rule Statement section at the bottom. Also, modifying an alias name defined in the Scope section will cause the name to update everywhere it is used in the Rulesheet. But rules modeled without aliases will not update automatically if aliases are defined later. So if you expect to use aliases, define them before beginning your rule modeling - that way theyll appear automatically when you drag and drop from the Vocabulary or Scope windows.
Page 46
Vocabulary Tree
Description This portion of the Vocabulary tree can be visualized as the branch diagram shown to the right. Because this piece of the Vocabulary begins with the FlightPlan root, the branches also originate with the FlightPlan root or trunk. The FlightPlans associated cargo and aircraft terms are branches from the trunk. Any rule expression that uses FlightPlan, FlightPlan.cargo, or FlightPlan.aircraft is using scope from this perspective of the Vocabulary tree. This portion of the Vocabulary tree begins with Aircraft as the root, with its associated flightPlan branching from the root. A cargo, in turn, branches from its associated flightPlan. Any rule expression that uses Aircraft, Aircraft.flightPlan, or Aircraft.flightPlan.cargo is using scope from this perspective of the Vocabulary tree. This portion of the Vocabulary tree begins with Cargo as the root, with its associated flightPlan branching from the root. An aircraft, in turn, branches from its associated flightPlan. Any rule expression that uses Cargo, Cargo.flightPlan, or Cargo.flightPlan.aircraft is using scope from this perspective of the Vocabulary tree.
Branch Diagram
Page 47
Scope can also be thought of as hierarchical, meaning that a rule written with scope of Aircraft applies to all root-level Aircraft data. And other rules using some piece (or branch) of the tree beginning with root term Aircraft, including Aircraft.flightPlan and Aircraft.flightPlan.cargo, also apply to this data and its associated collections. Likewise, a rule written with scope of Cargo.flightPlan does not apply to root-level FlightPlan data. This provides an alternative explanation for the different behaviors between the Rulesheets in Figure 37 and Figure 44. The rules in Figure 37 are written using different root terms and therefore different scopes, whereas the rules in Figure 44 use the same FlightPlan root and therefore share common scope.
ROLES
Using roles in the Vocabulary can often help to clarify rule context. To illustrate this point, we will use a slightly different example. The UML class diagram for a new (but related) sample Vocabulary is shown in Figure 50.
As shown in this class diagram, the entities Person and Aircraft are joined by an association. However, can this single association sufficiently represent multiple relationships between these entities? For example, a prior Fact Model might state that a pilot flies an aircraft and a passenger rides in an aircraft both pilot and passenger are descendants6 of the entity Person. Furthermore, we can see that, in practice, some instances of Person may be pilots and some may be passengers. This is important because it suggests that some business rules may use Person in its pilot context, and others may use it in its passenger context. How do we represent this in the Vocabulary and rules we build in Studio?
See Support for Inheritance in the Vocabulary chapter for details about how Corticon supports inheritance.
Rule Modeling Guide Lets examine this problem in more detail. Assume we want to implement two new rules:
Page 48
We call these rules cross-entity because they include more than one entity (both Aircraft and Person) in their expression. Unfortunately, with our Vocabulary as it is, we have no way to distinguish between pilots and passengers, so there is no way to unambiguously implement these 2 rules. This class diagram, when imported into Studio, appears in Figure 51 as a Vocabulary:
However, there are several ways to modify this Vocabulary to allow us to implement these rules. Well discuss these methods and examine the advantages and disadvantages of each. Use Inheritance Use two separate entities for Pilot and Passenger instead of a single Person entity. This may often be the best way to distinguish between pilots and passengers, especially if the two types of Person reside in different databases or different database tables (an aspect of deployment that rule modelers may not be aware of). Also, if the two types of Person have some shared and some different attributes (Pilot may have attributes like licenseRenewalDate and typeRating while Passenger may have attributes like farePaid and seatSelection) then it may make sense to set up entities as descendants of a common ancestor entity (such as Employee). Add an Attribute to Person If the two types of person differ only in their type, then we may decide to simply add a personType (or similar) attribute to the entity. In some cases, personType will have the value of pilot, and sometimes it will have the value of passenger. The advantage of this method is that it is flexible: in the future, persons of type manager or bag handler or air marshal can easily be added. Also, this construction may be most consistent with the actual structure of the employee database or
Page 49
database table and maintains a normalized model. The disadvantage comes when the rule modeler needs to refer to a specific type of Person in a rule. While this can be accomplished using any of the filtering methods discussed in Rule Writing Techniques, they are sometimes less convenient and clear than the final method, discussed next. Use Roles A role is a noun that labels one end of an association between two entities. For example, in our PersonAircraft Vocabulary, the Person may have more than one role, or more than one kind of relationship, with Aircraft. An instance of Person may be a pilot or a passenger; each is a different role. To illustrate this in our UML class diagram, we add labels to the associations as follows:
When the class diagram is imported into Studio, it appears as the Vocabulary below:
Notice the differences between Figure 53 and Figure 51 in Figure 53, Aircraft contains 2 associations, one labeled passenger and the other pilot, even though both associations relate to the same Person entity. Also notice that we have updated the cardinalities of both Aircraft Person associations to one-to-many.
Page 50
Written using roles, the first rule appears below. There are a few aspects of the implementation to note: Use of aliases for Aircraft and Aircraft.pilot (plane and pilotOfPlane, respectively). Aliases are just as useful for clarifying rule expressions as they are for shortening them. The rule Conditions evaluate data within the context of the plane and pilotOfPlane aliases, while the Action posts a message to the plane alias. This enables us to act on the aircraft entity based upon the attributes of its associated pilots. Note that Condition row b uses a special operator (->size) that counts the number of pilots associated with a plane. This is called a collection operator and is explained in more detail in the following chapters.
To demonstrate how Studio differentiates between entities based on rule scope, well construct a new Ruletest that includes a single instance of Aircraft and 2 Person entities, neither of which has the role of pilot.
Page 51
Despite the fact that there are two Person entities, both of whom are members of the Flight Crew department, the system recognizes that neither of them have the role of pilot (in relation to the Aircraft entity), and therefore generates the violation message shown. If we create a new Input Ruletest, this time with both persons in the role of pilot, we see a different result as shown in Figure 56:
Page 52
Finally, the rules are tested with one pilot and one passenger:
Page 53
Figure 57 Ruletest with one Person entity in each of Pilot and Passenger roles
We see that despite the presence of two Person elements in the collection of test data, only one satisfies the rules scope pilot associated with aircraft. As a result, the rules determine that one pilot is insufficient to fly a 747, and the violation message is displayed. These same concepts apply to the DC-10/Passenger business rule, which will not be implemented here.
Page 54
TECHNICAL ASIDE
Understanding Rule Associations and Scope as Relationships Between Tables in a Relational Database Although it is not necessary for the rule modeler or developer to understand database theory, a business or systems analyst who is familiar with it may have already recognized that the preceding discussion of rule scope and context is an abstraction of basic relational concepts. Actual relational tables that contain the data for our Cargo example might look like the following:
Aircraft tailNumber* N1001 N1002 N1003 aircraftType maxCargoWeight 747 747 DC-10 200,000 200,000 150,000 Cargo manifestNumber* volume 625A 625B 625C 300 300 300 weight 100,000 175,000 150,000
FlightPlan flightNumber* 101 102 103 tailNumber N1001 N1002 N1003 manifestNumber 625A 625B 625C
Each table in Figure 58 has a column that serves as a unique identifier for each row (or record). In the case of the Aircraft table, the tailNumber is the unique identifier for each Aircraft record this means that no two Aircraft can have the same tailNumber. ManifestNumber is the unique identifier for each Cargo record. These unique identifiers are known as primary keys. Given the primary key, a particular record can always be found and retrieved. A common notation uses an asterisk character (*) to indicate those table columns that serve as primary keys. If a Vocabulary has been connected to an external database using Direct Database Access features, then you may notice asterisks next to attributes, indicating their designation as primary keys. See the Server Integration and Deployment Guide, Direct Database Access chapter for complete details. Notice that the FlightPlan table contains columns that did not appear in our Vocabulary. Specifically, tailNumber and manifestNumber exist in the Aircraft and Cargo entities, respectively, but we did not include them in the FlightPlan Vocabulary entity. Does this mean that our original Vocabulary was wrong or incomplete? No - the extra columns in the FlightPlan table are really duplicate columns from the other two tables tailNumber came from the Aircraft table and manifestNumber came from the Cargo table. These extra columns in the FlightPlan table are called foreign keys because they are the primary keys from other tables. They are the mechanism for creating relations in a relational database.
Page 55
For example, we can see from the FlightPlan table that flightNumber 101 (the first row or record in the table) includes Aircraft of tailNumber N1001 and Cargo of manifestNumber 625A. The foreign keys in FlightPlan serve to link or connect a specific Aircraft with a specific Cargo. If the database is queried (using a query language like SQL, for example), a user could determine the weight of Cargo planned for Aircraft N1001 by traversing the relationships from the Aircraft table to the FlightPlan table, we discover that Aircraft N1001 is scheduled to carry Cargo 625A. By traversing the FlightPlan table to the Cargo table, we discover that Cargo 625A weighs 100,000 lbs. Matching the foreign key in the FlightPlan table with the primary key in the Cargo table makes this traversal possible. The Corticon Vocabulary captures this essential feature of relational databases, but abstracts it in a way that is friendlier to non-programmers. Rather than deal with concepts like foreign keys in our Vocabulary, we talk about associations between entities. Traversing an association in the Vocabulary is exactly equivalent to traversing a relationship between database tables. When we use a term like Aircraft.tailNumber in a rule, Studio creates a collection of tailNumbers from all records in the Aircraft table. This collection of data is then fed to the rule for evaluation. If however, the rule uses FlightPlan.aircraft.tailNumber, then Studio will create a collection of only those tailNumbers from the Aircraft table that have FlightPlans related to them it identifies these aircraft instances by matching the tailNumber in the Aircraft table with the tailNumber (foreign key) in the FlightPlan table. If the Aircraft table contains 7 instances of aircraft (i.e., 7 unique rows in the table), but the FlightPlan table contains only 3 unique instances of flight plans, the term FlightPlan.aircraft.tailNumber will create a collection of only 3 tail numbers those instances from the Aircraft table which have flight plans listed in the FlightPlan table. In database terminology, the scope of the rule determines how the tables are joined. When FlightPlan is used as the scope for our rule, Studio automatically ensures that the collection of data contains matching foreign keys. Thats why, when we rewrote the rule using proper scope, the rule only fired 3 times there are only 3 examples of Aircraft-Cargo combinations where the keys match. This also explains why, prior to using scope, the rule produced 6 spurious and irrelevant outcomes 6 combinations of Aircraft and Cargo that were processed by the rule do not, in fact, exist in the FlightPlan table. While the differences in processing requirements are not extreme in our simple example, for a large company like Federal Express, with a fleet of hundreds of aircraft and several thousand unique cargo shipments every day, the system performance differences could be enormous.
TEST YOURSELF:
Use the following Vocabulary to answer the next questions. Answers are provided in Appendix D.
Page 56
41. How many root-level entities are present in the Vocabulary? 42. Which of the following terms are allowed by the Vocabulary? Movie.roles Actor.roles DVD.actor Award.movie
43. Which of the following terms are not allowed by the Vocabulary?
Page 57
Movie.oscar
Movie.supplier
Movie.roles.actor Movie.dVD.extras
44. Which Vocabulary term represents the following phrases? a. A movies Oscars b. A movies roles c. An actors roles d. A DVDs distributor e. A movies DVD extras f. An actors Oscars 45. Which of the following terms represents the phrase an actor in a role of a movie Movie.roles.dVD Actor.roles.movie DVD.actor.movie Actor.movie.roles
46. Since the association between Actor and Role is bidirectional, we can use both Actor.roles and _____________ in our rules. 47. Which two entities are associated with each other by more than one role? 48. What are the role names? 49. Besides roles, how else could these two relationships be represented in the Vocabulary to convey the same business meaning? 50. What is the advantage of using roles in this way? 51. When more than role is used to associate two entities, each role name must be: friendly unique colorful melifluous
52. True or False. Rules evaluate only data that shares the same scope 53. Write a conditional expression in a Rulesheet for each of the following phrases: a. If a movies DVD has deleted scenes b. If an actor played a role in a movie winning an Oscar c. If the DVD is an import
Rule Modeling Guide d. If the Movie was released more than 50 years before the DVD e. If the actor ever played a leading role f. If the movie was nominated for a Golden Globe g. If the Distributor offers any drama DVDs
Page 58
Given the rule Disney animated classics are priced in the high tier, answer the following questions: 54. Which term should be used to represent Movie? 55. Which term should be used to represent DVD? 56. True or False. The following Rulesheet correctly relates the Movie and DVD entities?
57. Given our business intent, how many times do we want the rule to fire given the Input Testsheet below?
Page 59
58. Given the Ruletest Input above, how many times does the rule actually fire? 59. Assume we update the Rulesheet to include another rule, as shown below. Answer the following questions:
Page 60
a. Assuming the same Ruletest Input as question 57, what result do we want for Cinderella? b. What result do we want for Toy Story? c. What results do we get when the Test is executed? d. How many times does each rule fire? e. How many total rule firings occurred? f. This set of combinations is called a ________________ g. Does our result make business sense? h. What changes should be made to the Rulesheet so that it functions as we intend? 60. True or False. Whenever our rules contain scope, we must define aliases in the Scope section of the Rulesheet. 61. Scope is another way of defining a specific _______________ in the Vocabulary 62. If you change the spelling of an alias in the Scope section, then everywhere that alias is used in the Rulesheet will: turn red be deleted be updated be ignored
63. True or False. The spelling of an alias may be the same as the Vocabulary entity it represents?
Page 61
In Figure 59, the value of an Aircrafts maxCargoWeight attribute is assigned by column 0 in the Conditions/Actions pane (what we sometimes call a Nonconditional rule because it has no Conditons). The Filter acts as a master conditional expression because only Aircraft that satisfy the Filter, i.e., only those aircraft of aircraftType = 747, successfully pass through to be evaluated by rule column 0, and are assigned a maxCargoWeight of 200,000. This effectively filters out all non-747 aircraft from evaluation by rule column 0. If this Filter were not present, all Aircraft, regardless of aircraftType, would be assigned a maxCargoWeight of 200,000 lbs. Using this method, additional Rulesheets may be used to assign different maxCargoWeight values for each aircraftType. The Filter section may be thought of as a convenient way to quickly add the same conditional expression or constraint to all other rules in the same Rulesheet. We can also achieve the same results without using Filters. Figure 60 shows how we use a Condition/Action rule to duplicate the results of the previous Rulesheet. The rule is restated as an if-
Page 62
then type of statement: if the aircraftType is 747, then its maxCargoWeight equals 200,000 lbs.
Regardless of how you choose to express logically equivalent rules in a Rulesheet, the results will also be equivalent 7. That said, there may be times when it is advantageous to choose one way of expressing a rule over another, at least in terms of the visual layout, organization and maintenance of the business rules and Rulesheets. The example discussed in the preceding paragraphs was very simple because only one Action was taken as a result of the Filter or Condition. In cases where there are multiple Actions that depend on the evaluation of one or more Conditions, it may make the most sense to use the Filters section. Conversely, there may be times when using a Condition makes the most sense, such as the case where there are numerous values for the Condition that each require a different Action or set of Actions as a result. In our example above, there are different types of Aircraft in the companys fleet, and each has a different maxCargoWeight value assigned to it by rules. This could easily be expressed on one Rulesheet by using a single row in the Conditions section. It would require many Rulesheets to express these same rules using the Filters section. This leads us to the next topic of discussion.
While the logical result may be identical, the time required to produce those results may not be. See Optimizing Rulesheets in the Logical Validation chapter of this Guide for details.
Page 63
Figure 61 Rulesheet Illustrating use of Multiple values in the same Condition Row
By using different values in the column cells of Condition and Action rows in Figure 61, we can write multiple rules (represented as different columns in the table) for different Condition-Action combinations. Expressing these same rules using Boolean expressions would require many more Condition and Action rows, and would fail to take advantage of the semantic pattern these three rules share.
Exclusionary Syntax
The following examples are also logically equivalent:
Page 64
Notice Figure 64 uses the unary function not, described in more detail in the Rule Language Guide, to negate the value 747 selected from the Values set. Once again we see that the same rule can be expressed in different ways on the Rulesheet, with identical results. It is left to the rule modeler to decide which way of expressing the rule is preferable in a given situation. We recommend, however, avoiding double negatives. Most people find it easier to understand attribute=T instead of attribute<>F, even though logically the two expressions are equivalent 8.
assumes bi-value logic. If tri-value logic is assumed (such as for a non-mandatory attribute), meaning the null value is available in addition to true and false, then these two expressions are not equivalent. If attribute = null, then the truth value of attribute<>F is true while that of attribute=T is false.
Page 65
The term other provides a simple way of specifying any value other than any of those specified in other Cells of the same Conditions row. Figure 66, below, illustrates how we can use other in our example.
Page 66
In Figure 66, we added a new rule (column 4) that assigns a maxCargoWeight of 50000 to any aircraftType other than the specific values identified in the cells in Condition row a (for example, a 727). Our Rulesheet is now complete because all possible Condition-Action combinations are explicitly defined by columns in the decision table.
Figure 67 Rulesheet Using Value Ranges in the Column Cells of a Condition Row
In this example, we are assigning a maxCargoWeight value to each Aircraft depending on the flightNumber value from the FlightPlan that the Aircraft is associated with. The value range 101..200 represents all values (Integers in this case) between 101 and 200, including the range endpoints 101 and 200. This is an inclusive range in that the starting and ending values are included in the range. Studio also gives you the option of defining value ranges where one or both of the endpoints are exclusive, meaning that they are not included in the range of values this is the same idea as the difference between greater than and greater than or equal to. Figure 68 shows the same Rulesheet shown in Figure 67, but with one difference: we have changed the value range 201..300 to (200..300]. The starting parenthesis ( indicates that the starting value for the range, 200, is exclusive it is not included in the range. The ending bracket ] indicates that the ending value is inclusive. Since flightNumber is an Integer value and there are therefore no fractional values allowed, 201..300 and (200..300] are equivalent.
Page 67
Listed below are all of the possible combinations of parenthesis and bracket notation for value ranges and their meanings:
As illustrated in columns 2-3 of Figure 67 and column 2 of Figure 68, if a value range has no enclosing parentheses or brackets, it is assumed to be inclusive. It is therefore not necessary to use the [..] notation for a closed range in Studio; in fact, if you try to create a value range with [..] in Studio, the square brackets will be automatically removed. However, should either end of a value range have a parenthesis or a bracket, then the other end must also have a parenthesis or a bracket. For example, x..y) is not allowed, and is properly expressed as [x..y). Value ranges can also be used in the Filters section of the Rulesheet. See the Rule Language Guides Special Syntax chapter for full details on usage.
Page 68
The rules in Figure 69 are identical to the rules in Figure 67 and Figure 68, but are expressed using a series of three Boolean Conditions. Recall that in a decision table, values aligned vertically in the same column represent ANDed Conditions in the rule. So rule 1, as expressed in column 1, reads: if flightNumber is not greater than 100 and flightNumber is not greater than 200 and flightNumber is not greater than 300, then its maxCargoWeight must equal 50,000 lbs. Expressing this rule in friendlier, more natural English, we might say: An Aircrafts max cargo weight must be 50,000 lbs when flight number is less than or equal to 100. This is how the rule is expressed in the Rule Statements section in Figure 69. The same rules may also be expressed using a series of Rulesheets with the applicable range of flightNumber values constrained by Filters. Studio gives you the flexibility to express and organize your rules any number of possible ways as long as the rules are logically equivalent, they will produce identical results when executed. In the case of rules involving numeric value ranges as opposed to discrete numeric values, the value range option allows you to express your rules in a very simple and elegant way. It is especially useful when dealing with Decimal type values.
Page 69
TEST YOURSELF:
Answers are provided in Appendix D 64. Filters act as master rules for all other rules in the same Rulesheet that share the same _________. 65. An expression that evaluates to a True or False value is called a _________ expression. 66. True or False. Condition row values sets must be complete. 67. True or False. Action row values sets must be complete. 68. The special term __________ can be used to complete any Condition row values set. 69. What operator is used to negate a Boolean expression? 70. If a Boolean expression is written in a Condition row, what values are automatically entered in the Values set when Enter is pressed? 71. A Filter expression written as Entity.boolean1=T is equivalent to (circle all that apply)
Entity.boolean 1 Entity.boolean1<> F Entity.boolean1= F not (Entity.boolean1=F)
72.
Of all alternatives listed in Question 71, which is the best choice? Why?
73. Describe the error (if any) in each of the following value ranges. Assume all are used in Conditions values sets. a. {110, other} b. {1..a, other} c. {a..other} d. {1..10, 5..20, other} e. {1..10, [10..20), other} f. {red, green, blue} g. {<0, 0..15, >3}
Rule Modeling Guide 74. True or False. The special term other may be used in Action row values sets.
Page 70
75. Using best practices discussed in this chapter, model the following rules on a single Rulesheet a. If the part is in stock and it has a blue tag, then the parts discount is 10% b. If the part is in stock and it has a red tag, then the parts discount is 15% c. If the part is in stock and it has a yellow tag, then the parts discount is 20% d. If the part is in stock and it has a green tag, then the parts discount is 25% e. If the part is in stock and it has any other color tag, then the parts discount is 5% 76. True or False. A Nonconditional rule is equivalent to an Action expression with no Condition. 77. True or False. A Nonconditional rule is governed by any Preconditions on the same Rulesheet.
Page 71
COLLECTIONS
UNDERSTANDING HOW STUDIO HANDLES COLLECTIONS
Support for using collections is extensive in Studio in fact, the integration of collection support in the Rules Language is so seamless and complete, the rule modeler will often discover that rules are performing multiple evaluations on collections of data beyond what he/she anticipated! This is partly the point of a declarative environment the rule modeler need only be concerned with what the rules do, rather than how they do it. How the system actually iterates or cycles through all the available data during rule execution should not be of concern. As we saw in previous examples, a rule with term FlightPlan.aircraft was evaluated for every instance of FlightPlan.aircraft data delivered to the rule, either by an XML message or by a Ruletest (which are really the same thing, as the Ruletest simply serves as a quick and convenient way to create XML payloads and send them to the rules). A rule is expressed in Studio the same way regardless of how many instances of data are to be evaluated by it contrast this to more traditional procedural programming techniques, where for-do or while-next type looping syntax is often required to ensure all relevant data is evaluated by the logic.
VISUALIZING COLLECTIONS
Collections of data may be visualized as discrete portions, subsets, or branches of the Vocabulary tree a parent entity associated with a set of child entities, which we call elements of the collection. Looking back at the role example from a previous chapter, the collection of pilots can be illustrated as:
In Figure 70, the aircraft entity is the parent of the collection, while each pilot is a child element of the collection. As we saw in the role example, this collection is expressed as aircraft.pilot in CRL. It is important to reiterate that this collection contains scope we are seeing the collection of pilots as they relate to this aircraft. Or, put more simply, we are seeing a plane and its 2 pilots, arranged in a way that is consistent with our Vocabulary. Whenever a rule exists that contains or uses this same scope, it will also automatically evaluate this collection of data. And if there are multiple collections with the same scope (for example, several aircraft, each with its own collection of pilots), then the rule will automatically evaluate all those collections, as well. In our lexicon, evaluate has a different meaning than fire. Evaluate means that a rules scope and Conditions will be compared to
Rule Modeling Guide the data to see if they are satisfied. If they are satisfied, then the rule fires and its Actions are executed.
Page 72
Collections can be much more complex than this simple pilot example. For instance, a collection can comprise more than one type or level of association:
This collection is expressed as parent.child.grandchild in CRL 9. Now lets look at a simple collection operator and understand how it works given the collection in Figure 70.
Studio requires that all rules containing collection operators use unique aliases to represent the collections. Using aliases to represent collections is described in greater detail in this chapter. A more accurate expression of the rule above becomes:
plane.pilot -> size
or
plane.crewsize = plane.pilot -> size
The parent and child nomenclature is a bit arbitrary. Assuming bidirectional associations, a child from one perspective could also be a parent in another. A complete description of size can be found in the Rule Language Guide
10
Rule Modeling Guide where plane is an alias for the collection of pilots on aircraft.
Page 73
FILTERING COLLECTIONS
The process of screening specific elements from a collection is known as filtering, and the Studio supports filtering by a special use of Filter expressions. Please see the Filters & Preconditions chapter of this manual for more details.
Page 74
The association between Security and SecInfo is 1..* (one-to-many) since there are multiple instances of SecInfo data (multiple days of historical data) for each Security. In our scenario, we will use three rules to determine a securitys rank:
Finally, rules will be used to assign a rank based on the total weight. It is interesting to note that although the rules refer to a securitys closing price, volume, and rule weights, these attributes are actually properties of the SecInfo entity. Rulesheets that accomplish these tasks are shown in the next two figures.
In Figure 73 above, we see two business rules expressed in a total of four rule models (one for each possible outcome of the two business rules). The rules themselves are straightforward, but the shortcuts (alias values) used in these rules are different than any we have seen before. In the Scope section, we see the following:
Page 75
Security is the scope for our Rulesheet, which is not a new concept. But then we see that there are two aliases for the SecInfo entities associated with Security: secinfo1 and secinfo2. Each of these aliases represents a separate but identical collection of the SecInfo entities associated with Security. In this Rulesheet, we constrain each alias by using Filters; in a later example, we will see
how more loosely constrained aliases can represent many different elements in a collection when the Corticon Server evaluates rules. In this specific example, though, one instance of SecInfo represents the current business day (today) and the other instance represents the previous business day (today.addDays(-1) 11). Once the aliases are created and constrained, we can use them in our rules where needed. In Figure 73, we see that the use of aliases in the Conditions section allows comparison of closePrice and volume values from one specific SecInfo element (the one with todays date) of the collection with another (the one with yesterdays date). Figure 75 shows a second Rulesheet which uses a Nonconditional rule to calculate the sum of the partial weights from our model rules as determined in the first Rulesheet, and Conditional rules to assign a rank value between 1 and 4 to each security based on the sum of the partial weights. Since we are only dealing with data from the current day in this Rulesheet (as specified in the Filters), only one instance of SecInfo per Security applies and we do not need to use aliases.
11
For more details on the .addDays operator, please refer to the Rule Language Guide
Page 76
We can test our new rules using a Ruleflow to combine the two Rulesheets. In a Ruletest which executes the Ruleflow, we would expect to see the following results: 1. The Security.secInfo collection that contains data for the current business day (we expect that this collection will reduce to just a single secinfo element, since only one secinfo element exists for each day) should be assigned to alias secinfo1 for evaluating the model rules. 2. The SecInfo instance that contains data for the previous business day (again, the collection filters to a single secinfo element for each Security) should be assigned to alias secinfo2 for evaluating the model rules. 3. The partial weights for each rule, sum of partial weights, and resulting rank value should be assigned to the appropriate attributes in the current business days SecInfo element. A Ruleflow constructed for testing the ranking model rules is shown in Figure 77.
Page 77
In Figure 77, we have added one Security object and three associated SecInfo objects from the Vocabulary. The current day at the time of the Ruletest is 5/14/2003, so the three SecInfo objects represent the current business day and two previous business days. The third business day is included in this Ruletest to verify that the rules are using only the current and previous business days none of the data from the third business day should be used if the rules are executing correctly. Based on the values of closePrice and volume in our two SecInfo objects being tested, we expect to see the highest rank of 4 assigned to our security in the current business days SecInfo object.
Page 78
We see the expected results produced above. Both closePrice and volume for 11/12/2008 were higher than the values for those same attributes on 11/11/2008; therefore, both rule1Weight and rule2Weight attributes were assigned their high values by the rules. Accordingly, the totalWeight value calculated from the sum of the partial weights was the highest possible value and a rank of 4 was assigned to this security for the current day. As previously mentioned, the example above was tightly constrained in that the aliases were assigned to two very specific elements of the referenced collections. What about the case where there are multiple instances of an entity that you would like to evaluate with your rules? We will discuss just such an example next. Our second example is also based on our security ranking scenario but, in this example, the rank assignment that was accomplished in Figure 73 will be done in a different way. Instead, we would like to rank a number of securities based on their relative performance to one another, rather than against a preset ranking scheme like the one in Figure 73. In the rules for our new example, we will compare the totalWeight value that is determined for each security for the current business day against the totalWeight of every other security, and determine a rank based on this comparison of totalWeight values. A Rulesheet for this alternate method of ranking securities is shown in the next figure.
Page 79
In these new ranking rules, we have created aliases to represent specific instances of Security and their associated collections of SecInfo. As in the previous example, Filters constrain the aliases, most notably in the case of the SecInfo instances, where we filter secInfo1 and secInfo2 for a specific value of busDay (todays date). However, we have only loosely constrained our Security instances we merely have a Filter that prevents the same element of Security from being compared to itself (when sec1 = sec2). No other constraints are placed on the Security aliases. Its important to note that we are not assigning specific, single elements of Security to our aliases. Instead, we are instructing the Server to evaluate all allowable combinations (i.e., all those combinations that satisfy the 1st Filter) of Security elements in our collection in each of the aliases (sec1 and sec2). For each allowable combination of Security elements, we will compare the totalWeight values from the associated SecInfo element for busDay = today, and increment the rank value for the first SecInfo element (secinfo1) by 1 if its totalWeight is greater than that of the second SecInfo object (secinfo2). The end result should be the relative performance ranking of each security that we desire.
Page 80
Figure 80 shows a Ruletest constructed to test these ranking rules. In our data, we have added four Security elements and an associated secInfo element for each (its important to note that each alias will represent ALL 4 security elements AND their associated secInfo elements). The current day at the time of the Ruletest is 2/9/2009, so each Security.secInfo.busDay attribute is given the value of 2/9/2009 (if we had included additional secinfo elements in each collection, theyd have earlier dates, and therefore would be filtered out by the Preconditions on each alias). We have initially set (or initialized) each Security.secInfo.rank equal to 1, so that the lowest ranked security will still have a value of 1 12. The values of totalWeight for the SecInfo objects are all different; therefore, we expect to see each security ranked between 1 and 4 with no identical rank values.
12
The lowest ranked security will be the one that loses all comparisons with the other securities, i.e., its weight is less than the weights of all other securities. If a securitys weight is less than all the other security weights, its rank will never be incremented by the rule, so its rank will remain 1.
Page 81
Note: If there were multiple Security.secInfo elements (multiple securities) with the same totalWeight value for the same day, then we would expect the final rank assigned to these objects to be the same as well. Further, if there were multiple Security.secInfo entities sharing the highest relative totalWeight value in a given Ruletest, then the highest rank value possible for that Ruletest would be lower than the number of securities being ranked, assuming we initialize all rank values at 1.
Page 82
As seen in Figure 81, our Ruletest results are as expected. The security with the highest relative totalWeight value ends the Ruletest with the highest rank value after all rule evaluation is complete. The other securities are also assigned rank values based on the relative ranking of their
Page 83
totalWeight values. The individual rule firings that resulted in these outcomes are highlighted in the
message section at the bottom of the results sheet. It is interesting to note that nowhere in the rules is it stated how many security entities will be evaluated. This is another example of the ability of the declarative approach to produce the desired outcome without requiring explicit, procedural instructions.
Universal Quantifier
The meaning of the universal quantifier is that a condition enclosed by parentheses is evaluated (i.e., its truth value is determined) for all instances of an entity or collection. This is implemented as the forAll operator in the Operator Vocabulary. Well demonstrate this operator with an example created using the Vocabulary from our security ranking model. Note that these operators act on collections, so all the examples shown will declare aliases in the Scope section.
Page 84
The exact meaning of this Condition is that for the collection of SecInfo elements associated with a Security (represented and abbreviated by the alias secInfo), evaluate if the expression in parentheses (secinfo.rank >= 3) is true for all elements. The result of this Condition is Boolean because it can only return a value of true or false. Depending on the outcome of the evaluation, a value of either High or Low will be assigned to the rating attribute of our Security entity and the corresponding Rule Statement will be posted as a message to the user. Figure 83 shows a Ruletest constructed to test our for all Condition rules.
In this Ruletest, we are evaluating a collection of three SecInfo elements associated with a Security entity. Since the rank value assigned in each SecInfo object is at least 3, we should expect that our for all Condition will evaluate to true and a rating value of High will be assigned to
Page 85
our Security object when the Ruletest is run through Corticon Server. This outcome is confirmed in the Ruletest results shown in Figure 84.
Existential Quantifier
The other special operator available is the existential quantifier. The meaning of the existential quantifier is that there exists at least one element of a collection for which a given condition evaluates
Page 86
to true. This logic is implemented in the Rulesheet using the ->exists operator from our Operator Vocabulary. As in our last example, we can construct a Rulesheet to determine the rating value for a Security entity by evaluating a collection of associated SecInfo elements with the existential quantifier. In this new example, we will use volume rather than rank to determine the rating value for the security. The Rulesheet for this example is shown in Figure 85.
Notice again the required use of an alias to represent the collection being examined. The exact meaning of the Condition in this example is that for the collection of SecInfo elements associated with a Security (again represented by the secinfo alias), determine if the expression in parentheses (secinfo.volume > 1000) holds true for at least one Secinfo element. Depending on the outcome of the exists evaluation, a value of either High Volume or Normal Volume will be assigned to the rating attribute of our Security object and the corresponding Rule Statement will be posted as a message to the user. Figure 86 shows a Ruletest constructed to test our exists Condition rules.
Page 87
Once again, we evaluate a collection of 3 SecInfo elements associated with a single Security entity. Since the volume attribute value assigned in at least one of the SecInfo objects (secInfo[2]) is greater than 1000, we should expect that our exists Condition will evaluate to true and a rating value of High Volume will be assigned to our Security object when the Ruletest is run through Corticon Server. This outcome is confirmed in the Ruletest shown in Figure 87.
Page 88
Page 89
covered by the policy referenced by the claim. Claims that are classified as invalid will be rejected, and will not be processed for payment. From this short description, we extract our primary business rule statement: 1. A claim is valid if the driver and vehicle involved in a claim are both listed on the policy against which the claim is submitted.
In order to implement our business rule, we propose the UML Class Diagram shown in Figure 88. Note the following aspects of the diagram: A Policy may cover one or more Drivers A Policy may cover one or more Vehicles A Policy may have zero or more Claims submitted against it The Claim entity has been denormalized to include driverName and vehicleVin. 13
This model imports into Studio as the Vocabulary shown in Figure 89:
13 Alternatively, the Claim entity could have referenced Driver.name and Vehicle.vin (by adding associations between Claim and both Driver and Vehicle), respectively, but the denormalized structure is probably more representative of a real-world scenario.
Page 90
Figure 89 Vocabulary
Model the following rules in Studio as shown in Figure 90: 1. For a claim to be valid, the drivers name and vehicle ID listed on the claim must also be listed on the claims policy. 2. If either the drivers name or vehicle ID on the claim is not listed on the policy, then the claim is not valid.
Page 91
This appears very straightforward. But a problem arises when there are multiple drivers and/or vehicles listed on the policy in other words, when the policy contains a collection of drivers and/or vehicles. Our Vocabulary permits this scenario because of the cardinalities we assigned to the various associations. We demonstrate this problem with the Ruletest in Figure 91:
Page 92
Figure 91 Ruletest
Notice in Figure 92 that there are 3 drivers and 3 vehicles listed on (associated with) a single policy. When we run this Ruletest, we see the results:
Page 93
Figure 92 Ruletest
As we see from the Ruletest results, the way Studio evaluates rules involving comparisons of multiple collections means that the validClaim attribute may have inconsistent assignments sometimes true, sometimes false (as in this Ruletest). It can be seen from the table below that, given the Ruletest data, 4 of 5 possible combinations evaluate to false, while only one evaluates to true. This conflict arises because of the nature of the data evaluated, not the rule logic, so Studios Conflict Check 14 feature does not detect it.
Claim. driverName Joe Claim.policy .driver.name Joe Claim. vehicle Vin 123-ABC Claim.policy. vehicle.vin 123-ABC Rule 1 fires X Rule 2 fires Rule 3 fires validClaim True
14
The Conflict Checker is discussed in more detail in the Logical Analysis chapter of this manual
Page 94
Joe Joe
X X X X
This logic tests for the existence of matching drivers and vehicles within the two collections. If matches exist within both, then the validClaim attribute evaluates to true, otherwise validClaim is false. Lets use the same Ruletest data as before to test these new rules. The results are shown below:
Page 95
Figure 94 Ruletest
Notice that only one rule has fired, and that validClaim has been assigned the value of true. This implementation achieves the desired result.
TEST YOURSELF:
Answers are provided in Appendix D. 78. Children of a Parent entity are also known as ____________ of a collection. 79. True or False. All collections must have a parent entity 80. True or False. Root-level entities may form a collection 81. True or False. A collection operator must operate on a collection alias. 82. List 3 Collection operators and describe what they do.
Rule Modeling Guide 83. Which reference contains usage details and examples for every collection operator?
84.
Page 96
85. In the syntax in question 84, which term is the collection alias? 86. If items is an alias representing the LineItem entities associated with an Order entity, then what would you expect the cardinality of this association to be? 87. Is Order.lineItem.pricesum an acceptable replacement for the syntax in Question 84? Why or why not? 88. If you are a Vocabulary designer and want to prevent rule authors from building rules with LineItem.order terms, what can you do to prevent it? 89. When collection operators are NOT used in a Rulesheet, aliases are (circle all that apply) Optional Mandatory Colorful Convenient
90. If a Nonconditional rule states LineItem.price = 100, and my Input Testsheet contains 7 LineItem entities, then a collection of data is processed by this rule. Is a collection alias required? Why or why not? 91. Which collection operator is known as the Universal Quantifier? 92. Which collection operator is known as the Existential Quantifier? For questions 93-95, refer to the following Vocabulary
Page 97
93. Write expressions for each of the following phrases: a. If an actor has had more than 3 roles b. If a movie has not been released on DVD c. If a movie has at least one DVD with deleted scenes d. If a movie won at least one Golden Globe e. If the movie had more than 15 actors
Rule Modeling Guide f. If theres at least 100 copies available of a movie g. If theres less than 2 copies available of a movie h. If the DVD can be obtained from more than 1 supplier 94. Which entities could be grandchildren of Movie? 95. Which entites could be children of Role? 96. Describe the difference between ->forAll and ->exists operators. 97. Describe the difference between ->notEmpty and ->isEmpty operators. 98. Why are aliases required to represent collections?
Page 98
Page 99
TERMINOLOGY
First well introduce some terminology that will be used throughout this chapter. In the most basic expression
A = B
We define A to be the Left-hand Side (LHS) of the expression, and B to be the Right-hand Side (RHS). The equals sign is an Operator, and is included in the Operator Vocabulary in Studio. But even so simple an expression has its complications. For example, does this expression compare the value of A to B in order to take some action, or does it instead assign the value of B to A? In other words, is the equals operator performing a comparison or an assignment? This is a common problem in programming languages, and a common solution is to use two different operators to distinguish between the two meanings. For example the symbol == may signify a comparison operation, whereas := may signify an assignment. In Studio, such special syntax is unnecessary because the Rulesheet itself helps to clarify the logical intent of the rules. For example, typing A=B into a Rulesheets Condition row (and pressing Enter) automatically causes the Values set {T,F} to appear in the rule column cell drop-down lists. This indicates that the rule modeler has written a comparison expression, and Studio expects a value of true or false to result from the comparison. A=B, in other words, is treated as a test is A equal to B or isnt it? On the other hand, when A=B is entered into an Action or Nonconditional row (Actions rows in Column 0), it becomes an assignment. In an assignment, the RHS of the equation is evaluated and its value is assigned to the LHS of the equation. In this case, the value of B is simply assigned to A. As with other Actions, we have the ability to activate or deactivate this Action for any column in the decision table (numbered columns in the Rulesheet) simply by checking the box that automatically appears when the Actions cell is clicked. In the Rule Language Guide, the equals operator (=) is described separately in both its assignment and comparison contexts.
OPERATOR PRECEDENCE
Operator precedence, or the order in which Studio evaluates multiple operators in an equation, is defined by the table in Appendix B of the Rule Language Guide. This table specifies for example, that 2*3+4 evaluates to 10 and not 14 because the multiplication operator * has a higher precedence than the addition operator +. It is a good practice, however, to include clarifying parentheses even when Studio does not require it. This equation would be better expressed as (2*3)+4. Note the addition of parentheses here does not change the result. When expressed as 2*(3+4), however, the result becomes 14.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 100
15
The exception to this rule is the comparison or assignment of an Integer to a Decimal. A Decimal can safely contain the value of an Integer without using any special casting operations.
Page 101
Figure 96 shows a set of Action rows that illustrate the importance of data type compatibility in assignment expressions:
Lets examine each of the Action rows to understand why each is valid or invalid. A this expression is valid because the data types of the LHS and RHS sides of the equation are compatible (theyre both Boolean). B this expression is invalid and turns red because the data types of the LHS and RHS sides of the equation are incompatible (the LHS resolves to a DateTime and the RHS resolves to a String). C this expression is invalid and turns red because the data types of the LHS and RHS sides of the equation are incompatible (the LHS resolves to a String and the RHS resolves to a DateTime). D this expression is valid because the data types of the LHS and RHS sides of the equation are compatible even though they are different! This is an example of the one exception to our general rule regarding data type compatibility: Decimals can safely hold Integer values. E this expression is invalid and turns red because the data types of the LHS and RHS sides of the equation are incompatible (the LHS resolves to a Boolean and the RHS resolves to a Decimal). Here, the tool tip provides essentially the same information. Note that the Problems window contains explanations for the red text shown in the Rulesheet.
Rule Modeling Guide Figure 97 shows a set of Conditional expressions that illustrate the importance of data type compatibility in comparisons:
Page 102
Lets examine each of these Conditional expressions to understand why each is valid or invalid: a This comparison expression is valid because the data types of the LHS and RHS sides of the equation are compatible (theyre both Strings). Note that Studio confirms the validity of the expression by recognizing it as a comparison and automatically entering the Values set {T,F} in the Values column. b This comparison expression is invalid because the data types of the LHS and RHS sides of the equation are incompatible (the LHS resolves to a String and the RHS resolves to a DateTime). Note that, in addition to the red text, Studio emphasizes the problem by not entering the Values set {T,F} in the Values column. c This comparison expression is invalid because the data types of the LHS and RHS sides of the equation are incompatible (the LHS resolves to a Boolean and the RHS resolves to a Decimal). d This comparison expression is valid because the data types of the LHS and RHS sides of the equation are compatible. This is another example of the one exception to our general rule regarding data type compatibility: Decimals may be safely compared to Integer values. e This comparison expression is valid because the data types of the LHS and RHS sides of the equation are compatible. Like example 4, this illustrates the one exception to our general rule regarding data type compatibility: Decimals may be safely compared to Integer values. Unlike an
Page 103
assignment, however, whether the Integer and Decimal types occupy the LHS or RHS of a comparison is unimportant.
Datatype of an Expression
Its important to emphasize that the idea of a data type applies not only to specific attributes in the Vocabulary, but to entire expressions. Our examples above have been simple, and the data types of the LHS or the RHS of an equation simply correspond to the data types of those single attributes. But the data type to which an expression resolves may be a good deal more complicated.
Again, well examine each assignment to understand what is happening: A The RHS of this equation resolves to an Integer data type because the .dayOfWeek operator 16 extracts the day of the week from a DateTime value (in this case, the value held by attribute date1) and returns it as an Integer between 1 and 7. Since the LHS also has an Integer data type, the assignment operation is valid. B The RHS of this equation resolves to an Integer because the .size operator counts the number of characters in a String (in this case the String held by attribute string1) and returns this value as an Integer. Since the LHS also has an Integer data type, the assignment operation is valid. C The RHS of this equation resolves to a Boolean because the ->isEmpty collection operator examines a collection (in this case the collection of Entity2 children associated with parent Entity1, represented by collection alias e2) and returns true if the collection is empty (has no elements) or false if it isnt. Since the LHS also has a Boolean data type, the assignment operation is valid. D The RHS of this equation resolves to a Boolean because the ->exists collection operator examines a collection (in this case, e2 again) and returns true if the expression in parentheses is
16
The .dayOfWeek operator and others used in these examples are described fully in the Rule Language Guide
Page 104
satisfied at least once, and false if it isnt. Since the LHS also has a Boolean data type, the assignment operation is valid. E the RHS of this equation resolves to an Integer because the ->sum collection operator adds up the values of all occurrences of an attribute (in this case, integer2) in a collection (in this case, e2 again). Since the LHS has a Decimal data type, the assignment operation is valid. This is the lone case where type casting occurs automatically.
In Figure 99 above, we see an assignment expression where both LHS and RHS return Integers under all circumstances. But making a minor change to the RHS throws this result into confusion:
The minor change of adding a division step to the RHS expression has a major effect on the data type of the RHS. Prior to modification, the RHS always returns an Integer, but an odd Integer! When we divide an odd Integer by 2, a Decimal always results. The Parser is smart, but not smart enough to catch this problem.
Page 105
When the rule is executed, what happens? How does the Server react when the rule instructs it to force a Decimal value into an attribute of type Integer? The Server responds by truncating the Decimal value. For example if integer2 has the value of 2, then the RHS returns the Decimal value of 2.5. This value is truncated to 2 and then assigned to integer1 in the LHS. When we focus on this rule here, alone and isolated, its relatively easy to see the problem. But in a complex Rulesheet, it may be difficult to uncover this sort of problem. Your only clue to its existence may be numerical test results that dont match the expected values. To be safe, its usually a good idea to ensure the LHS of numeric calculations has a Decimal data type so no data is inadvertently lost through truncation.
Returning to Figure 97, we use these casting operators to correct some of the previous problems:
Page 106
Casting operators have been used in Nonconditional rules N.2 and N.3 to make the data types of the LHS and RHS match. Notice however, that no casting operator exists to cast a Decimal into a Boolean data type.
Page 107
Indicates whether the FlightPlan has been approved or cleared for operation. The total amount of all Aircraft and Cargo weights for this FlightPlan. The distance the Aircraft is expected to fly. The amount of fuel actually loaded on the Aircraft assigned to this FlightPlan.
Figure 104 - Table of New Attributes Added to the Basic Tutorial Vocabulary
In Figure 105 above, a numeric calculation is used as a comparison in the Filters section of the Rulesheet. The LHS of the expression essentially calculates the average pressure exerted by the total cargo load on the floor of the aircraft (sum of the cargo weights divided by the sum of the cargo containers footprints). This result is compared to the RHS, which is simply the literal value 5. We might expect to see this type of calculation in a set of rules that deals with special cargos where a lot of weight is concentrated in a small area. This might, for example, require the use of special aircraft with sturdy, reinforced cargo bay floors. Such a Filter expression might be the first step in handling cargos that satisfy this special criterion.
Page 108
The example shown in Figure 106 uses a calculation in the RHS of the assignment to derive the total weight carried by an Aircraft on the FlightPlan, where the total weight equals the weight of the fuel plus the weight of all Cargos onboard plus the empty weight of the Aircraft itself. The portion
plan.fuel * 0.13368 * 50.4
converts a fuel load measured in gallons into a weight measured in pounds conversion factors of 0.13368 cubic feet per gallon and 50.4 pounds per cubic foot of jet fuel have been used here. This portion is then added to:
load.weight -> sum
which, of course, is equal to the sum of all Cargo weights loaded onto the Aircraft associated with this FlightPlan. The final sum of the fuel, cargo, and Aircraft weights is assigned to the FlightPlans planWeight. Note the parentheses used here are not required the calculation will produce the same result without them they have been added for improved clarity.
Subsequent Rulesheets means Rulesheets executed later in a Ruleflow. The concept of a Ruleflow is addressed in the Studio Quick Reference Guide.
17
Page 109
In Condition row a, planWeight is compared to the aircrafts grossWeight to make sure the aircraft is not overloaded. An overloaded aircraft must not be allowed to fly, so the approved attribute is assigned a value of false. This has the advantage of being both clear and easy to reuse the term planWeight, once derived, may be used anywhere to represent the data produced by the calculation. It is also much simpler and cleaner to use a single attribute in a rule expression than it is a long, complicated equation. But this does not mean that the equation cant be modeled in a Conditional expression, if desired. The example shown in Figure 108 places the calculation in the LHS of the Conditional comparison to derive planWeight and compare it to grossWeight all in the same expression.
This approach might be preferable if the results of the calculation were not expected to be reused, or if adding an attribute like planWeight to the Vocabulary were not desirable or possible. Often, attributes like planWeight are very convenient intermediaries or holders to carry calculated values that will be used in other rules in a Rulesheet. In cases where such attributes are conveniences only, and are not used by external applications consuming a Rulesheet, they may be designated as
Page 110
extended transient attributes in the Vocabulary, which causes their icons to change from blue/yellow to orange/yellow. More details on extended transient attributes are included in Appendix B of this manual.
Figure 109, above, shows two rules that each make an assignment to maxFuel, depending on the type of aircraft. In rule 1, the maxFuel load for 747s is derived by subtracting maxCargoWeight and emptyWeight from grossWeight. In rule 2, maxFuel for DC-10s is simply assigned the literal value 100,000.
Page 111
Likewise, including equation syntax within curly brackets along with other Vocabulary terms is also not permitted. Doing so may cause your text to turn red, as shown in the following:
However, even if the syntax does not turn red, you should still not attempt to perform calculations in Rule Statements it may cause unexpected behavior. When red, the tool tip should give you some guidance as to why the text is invalid. In this case, the exponent operator (**) is not allowed in an embedded expression.
TEST YOURSELF:
Answers are provided in Appendix D. 99. What are the two possible meanings of the equals operator =? In which sections of the Rulesheet is each of these meanings applicable? 100. What is the result of each of the following equations? a. 10 + 20 / 5 4 b. 2 * 4 + 5 c. 10 / 2 * 6 8 d. 2 ** 3 * (1 + 2)
Rule Modeling Guide e. -5 * 2 + 5 * 2 101. Is the following assignment expression valid? Why or why not? Entity1.integer1 = Entity1.decimal1
Page 112
102. What is the data type of each of the following expressions based on the scope shown below?
a. e1.dateTime1.year b. e1.string1.toUpper c. e2 -> forAll (integer1 = 10) d. e2.decimal1 -> avg e. e1.boolean1 f. e1.decimal1 > e1.decimal2 g. e2.string2.contains(abc) 103. Write valid or invalid for each of the following assignments a. e1.decimal1 = e2.integer1 b. e2.decimal2 = e2.string2 c. e1.integer1 = e2.dateTime1.day d. e2.integer1 = e2 -> size e. e1.boolean2 = e2 -> exists (string1 = abc) f. e2.boolean2 = e1.string1.toBoolean g. e1.boolean2 = e2 -> isEmpty 104. The part of Studio that checks for syntactical problems is called the __________.
Rule Modeling Guide 105. True or False. If an expression typed in Studio does not turn red, then the expression is guaranteed to work as expected. Referring to the following illustration, answer questions 106 through 108:
Page 113
106. What does Filters row 1 test? 107. What does Conditions row a test? Is there a simpler way to accomplish this same thing using a different operator available in the Corticon Rule Language? 108. Write a Rule Statement for rule column 1. (Assume that the only action required for this rule is to post a Warning message as shown.) 109. True or False. The following sections of the Rulesheet accept equations and calculations: a. Scope b. Rule Statements c. Condition rows d. Action rows e. Column 0 f. Condition cells g. Action cells h. Filters
Page 114
FORWARD CHAINING
The first step in learning to use looping is to understand how it differs from normal inferencing behavior of executing rules, whether executed by Corticon Studio or Server. When a Rulesheet is compiled (either by Studio during a Ruletest execution, or by Server during deployment), a dependency network for the rules is automatically generated. Corticon Studio and Server uses this network to determine the order in which rules fire in runtime. For example, in the simple rules below, the proper dependency network is 1 2 3 4. 1. If value = A, then set value = B 2. If value = B, then set value = C 3. If value = C, then set value = D 4. If value = D, then set value = B This is not to say that all three rules will always fire for a given test clearly a test with B as the initial value will only cause rules 2, 3, and 4 to fire. But the dependency network ensures that rule 1 is always evaluated before rule 2, and rule 2 is always evaluated before rule 3, and so on. This mode of Rulesheet execution is called Optimized Inferencing, meaning the rules execute in the optimal sequence determined by the dependency network generated by the compiler. Optimized Inferencing is the default mode of rule processing for all Rulesheets. Optimized Inferencing processing is a powerful capability that enables the rule modeler to break up complex logic into a series of smaller, less complex rules. Once broken up into smaller or simpler rules, the logic will be executed in the proper sequence automatically, based on the dependencies determined by the compiler. An important characteristic of Optimized Inferencing processing: the flow of rule execution is singlepass, meaning a rule in the sequence is evaluated once and never revisited, even if the data values (or data state) evaluated by its Conditions change over the course of rule execution. In our example above, this effectively means that rule execution ceases after rule 4. Even if rule 4 fires (with resulting value = B), the second rule will not be revisited, re-evaluated, or re-fired even though its Condition (If value = B) would be satisfied by the current value (state). We can force rule 2 to be re-evaluated only if a one of Studios looping processing modes is enabled for the Rulesheet. Remember, just because sequential processing occurs automatically does not mean looping will occur too. Looping and its enablement are discussed next.
Page 115
Also note the circular icon to the immediate left of the Conditions header (see orange arrow). If the rule engine is permitted to loop through the rules above, the following events occur: Given a value of A as the initial data, the Condition in rule 1 will be satisfied and the rule will fire, setting the value to B. The 2nd rules Condition is then satisfied, so the value will advance (or be reset) to C, and so on, until the value is once again B after the 4th rule fires. Up to this point, the rule engine is exhibiting standard, Optimized Inferencing behavior. Now heres the new part: the value (state) has changed since the 2nd rule last fired, so the rule engine will re-evaluate the Condition, and, finding it satisfied, will fire the 2nd rule again, advancing the value to C. The 3rd rule will also be re-evaluated and re-fired, advancing the value to D, and so on. This sequence is illustrated in Figure 114. Heres the key to understanding looping: when a looping processing mode is enabled, rules will be continually re-evaluated and re-fired in a sequence determined by their dependency network as long as data state has changed since their last firing. Once data state no longer changes, looping will cease. Notice that the last column of the table indicates the number of loop iterations the first loop does not begin until rule 2 fires for the second time. The first time through the rules (steps 1-4) does not count as the first loop iteration because the loop does not actually start until step 5.
step # 1
Input value A
Rule fired 1
Output value B
Loop Iteration
Page 116
Types of Loops
Infinite Loops In the example above, looping between rules 2, 3 and 4 continues indefinitely because there is nothing to stop the cycle. Some loops, especially those inadvertently introduced, are not self-terminating. Because these loops will not end by themselves, they are called infinite loops. Infinite loops can be especially vexing to a rule modeler because it isnt always apparent when a Rulesheet has entered one. A good indication, however, is that rule execution takes longer than expected to complete! A special control is provided to prevent infinite loops. This control is described in the Terminating Infinite Loops section, below. Trivial Loops Single-rule loops, or loops caused by rules that depend logically on themselves, are also known as trivial loops. We consider single-rule loops to be a special kind of loop because they consist of just a single rule that successively revisits, or triggers, itself. To enable the self-triggering mode of looping, we must select Rulesheet > Processing Modes > Advanced Inferencing with Self-Triggering from Studios menubar, as shown in
Figure 115 Selecting Advanced Inferencing with Self-Triggering Processing Mode for a Rulesheet
Page 117
Notice the the icon to the left of the Conditions header - it contains the additional tiny arrow, which indicates self-triggering is active. Heres an example of a loop created by a self-triggering rule:
Lets trace this rule to make sure we understand how it works. When Cargo.weight has a value equal to or greater than 0, then rule 1 fires and the value of Cargo.weight is incremented by 1. Data state has now changed, in other words, the value of at least one of the attibutes has changed. In this case, its the value of Cargo.weight which has changed. Because it was rule 1 execution that caused the data state change, and since self-triggering is enabled, the same rule 1 will be re-evaluated. Now, if the value of Cargo.weight satisfied the rule initially, it certainly will do so again, so the rule fires again, and self-triggers again. And so on, and so on. This is also an example of an infinite loop, because no logic exists in this rule to prevent it from continuing to loop and fire. An Exception to Self-Triggering Self-triggering logic can also be modeled in Column 0 of the Rulesheet, as shown in Figure 117:
But Figure 117 is also a good example of why it might be desirable to disable self-triggering processing: we only want the weight to increment once, not enter into an infinite loop, which it would otherwise do, unconditionally! This is a special case where we have intentionally prevented this rule from iterating, even though self-triggering is enabled. This rule will execute only once, regardless of looping processing mode.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 118
Another example of a loop caused by self-triggering rule, but one which is not infinite, is shown below. The behavior described only occurs when Rulesheet processing mode is set to Advanced Inferencing with Self-Triggers:
In Figure 118 above, the rule continues to fire until Cargo.weight reaches a value of 21, whereupon it fails to satisfy the Condition, and firing ceases. The loop terminates with Cargo.weight containing a final value of 21. Its important to note that in all three examples, an initial Cargo.weight value of 0 or higher was necessary to activate the loop. A negative (or null) value, for example, would not have satisfied the rules Condition and the loop would not have begun at all. Multi-rule Loops As the name suggests, multi-rule loops exist when 2 or more rules are mutually dependent. As with single-rule loops, the Rulesheet containing the looping rules must be configured to process them. This is accomplished as before. Choose Rulesheet > Processing Mode > Advanced Inferencing from the Studio menubar, as shown previously in Figure 113. Heres an example of a multi-rule logical loop:
Page 119
In Figure 119, rule 2 is dependent upon rule 1, and rule 1 is dependent upon rule 2. Weve also added a rule 3, which doesnt participate in the 12 loop, but will generate a nice Violation message when the 12 loop finally terminates. Note, rule 3 does not cause the 12 loop to terminate, it just announces that the loop has terminated. Lets test these rules and see how they behave. In Figure 120, we see a simple Ruletest.
Were providing a starting value of Cargo.weight just to get the loop going. According to the Condition in rule 1, this value needs to be between 1 and 10 (inclusive).
Page 120
When intentionally building looping rules, it is often helpful to post messages with embedded attribute values (as shown in the Rule Statements section of Figure 119) so we can trace the loops operation and verify it is behaving as expected. It should be clear to the reader that the Ruletest shown in Figure 121 contains the expected results.
Page 121
the default Rulesheet processing mode is Optimized Inferencing, which does not permit revisiting rules that have already been evaluated once). We must manually enable the loop processing mode of our choice to cause the loops to execute. This is the strongest, most fool-proof mechanism for preventing unexpected looping behavior simply keep loop processing disabled.
Identifying Loops
Assuming we havent intentionally incorporated looping logic in our Rulesheet, then we need a way to discover if unintentional loops occur in our rules. The Loop Detection Tool To help identify inadvertent loops, Studio provides a Check for Logical Loops tool in the Studio toolbar. The tool contains a powerful algorithm that analyzes dependencies between rules on the same Rulesheet, and reports discovered loops to the rule modeler. For the Loop Detector to notice mutual dependencies, a Rulesheet must have looping enabled using one of the choices described earlier. Clicking the Check for Logical Loops icon displays a window that describes the mutual dependencies found on the Rulesheet. To illustrate loop detection, well use a few of the same examples from before.
When applied to a Rulesheet containing just the single-rule loop shown in Figure 122, the Check for Logical Loops tool displays the following window:
Page 122
Figure 124 A Single-Rule Loop Detected by the Check for Logical Loops Tool
The Check for Logical Loops tool first lists rules where mutual dependencies exist. Then, it lists the distinct, independent loops in which those rules participate, and finally it lists where self-triggering rules exist (if any). In this simple single-rule loop example, only one rule contains a mutual dependency, and only one loop exists in the Rulesheet. Note that the Check for Logical Loops tool does not automatically fix anything, it simply points out to us that our rules have loops, and gives us an opportunity to remove or modify the offending logic. Removing Loops If the Check for Logical Loops tool detects loops, we can take one of several corrective actions: If no loops are desirable, then click Rulesheet > Processing Mode and de-select whichever of the two looping options is currently selected. Once done, the Check for Logical Loops tool will no longer detect loops and the software will no longer process them. If all loops are desirable, then take measures to ensure that none of the loops are or become infinite. Normally, this means adding conditional logic to one of the looping rules to make sure that the rule cant be satisfied indefinitely. This is similar to the bounding of Condition 1 in Figure 119 using a Values set of 0..20. Once Cargo.weight reaches 21, the rules Condition will no longer be satisfied and the loop will terminate.
Page 123
If some loops are desirable and some are not, then remove the inter-dependencies in the unwanted loops and ensure the desired loops are not infinite.
Terminating Infinite Loops By definition, infinite loops wont terminate by themselves. Therefore, Corticon provides a safety valve setting described in the Server Integration & Deployment Guide, Appendix E. com.corticon.reactor.rulebuilder.maxloop is a property that caps the number of iterations allowed before the system automatically terminates a loop. The default setting is 100, meaning that a loop is allowed to iterate up to 100 times normally. Once the number of loops exceeds the maxloop setting, then the system automatically terminates the loop and generates a Violation error message. This means that the final number of loop iterations will be 101: 100 normal iterations plus the final iteration that causes the Violation message to appear and the loop to terminate. The Violation message is shown below:
If you are comfortable writing looping rules, and want the software to be able to loop more than 100 times, be sure to reset this property to a higher value. Keep in mind that the more iterations the system performs, the longer rule execution may take. If the Rulesheets you intend to deploy require high iteration counts, be sure to inform your deployment manager so he/she can configure the target Corticon Server with a higher maxloop cap.
LOOPING EXAMPLE
Problem
For any given day of the week, determine the next working day. Take into consideration weekends and holidays.
Solution
Implemented correctly in Studio, these rules should start with a given input date, and increment as necessary until the next workday is identified (workday defined here as any day not Saturday, Sunday, or a national holiday). A simple Vocabulary that supports these rules is shown in Figure 118.
Page 124
Next, the rules are implemented in the Rulesheet shown in Figure 127.
Lets step through this Rulesheet. 1. First, notice that the Scope section wasnt used. Were using a very simple Vocabulary with short entity names and no associations, so aliases arent necessary. Furthermore, none of our rules use collection operations, so aliases representing collections arent required either. 2. The first rule executed is the Nonconditional equation (in Condition/Action column 0) setting nextWorkDay equal to currentDate plus one day. 3. Rule 1 (in column 1) checks to see if the DateTime of the nextWorkDay matches any of the holidays defined in one or more Holiday entities. If it does, then the Action row B increments nextWorkDay by one day and posts a warning message.
Page 125
4. Rule 3 checks to see if the nextWorkDay falls on a Sunday. Notice that this rule uses the .dayOfWeek operator, which is described in full detail in the Rule Language Guide. If the day of the week is Sunday (in other words, .dayOfWeek returns a value of 1), then the Action increments nextWorkDay by one day and posts a Warning message. 5. Rule 4 checks to see if the nextWorkDay falls on a Saturday. If the day of the week is Saturday (in other words, .dayOfWeek returns a value of 7), then the Action row C increments nextWorkDay by two days and posts a Warning message. By incrementing 2 days, we skip an extra iteration because we know Sunday is also a non-workday! Dont forget to check for conflicts they do exist in this Rulesheet. However, we will make the assumption that a holiday never falls on a weekend. Resolution of the conflicts is straightforward 18, so we wont address that in detail here. A modified Rulesheet displays the overrides added to resolve the conflicts in Figure 128.
Using the same rules as before, lets click the Logical Loop Checker following window appears:
18
One conflict that between rules 1 and 4 is left unresolved because we have assumed that a holiday never falls on a weekend. See Logical Analysis chapter more a complete discussion of conflict and other logical problems.
Page 126
This window first identifies exactly which rules are involved in loops. Secondly, the window outlines the specific attribute interactions that create the loops. Now that we fully understand the looping logic present in our Rulesheet, lets create a Ruletest to verify that the loops operate as intended and produce the correct business results.
Page 127
Given the fact that July 4th, 2003 falls on a Friday, we expect nextWorkDay to contain a final value of July 7th, 2003 a Monday when the loops terminate. Running the Ruletest:
Page 128
You have almost certainly noticed Corticons inherent ability to process multiple test scenarios at once. For example, a rule written using the Vocabulary term Cargo.weight will be evaluated (and potentially fired) for every instance of Cargo encountered during execution. If a Ruletest contains 4 Cargo entities, then the rule engine will test the rules conditions with each of them. If any of the Cargo entities satisfy the rules conditions, then the rule will fire. This could mean that the rule fires once, twice, or up to four times, depending on the actual data values of each Cargo. We know from our prior discussion of Scope that a rule will evaluate all data that shares the same scope as the rule itself. This iterative behavior is a natural part of the Corticon rule engine design theres nothing special we need to do to enable it or turn it on. Note, that this behavior is different from the modes of looping discussed above because the Cargo.weight rule is not re-evaluated for a given piece of data. Rule execution is still single-pass. Its just that it makes a single pass through each of the 4 Cargo entities. The advantage of this natural iteration is that we dont need to force it the rule engine will automatically process all data that shares the same scope as the rule. If the Ruletest contains 4 Cargos, the rule will be evaluated 4 times. If the Ruletest contains 4000 Cargos, the rule will be evaluated 4000 times. We dont write the rule any differently in Studio. But this advantage can also be a disadvantage. What if we want rule execution to stop part-way through its evaluation of a given set of entity data (which we call a binding). What if, after finding a Cargo that satisfies the rule among the set (binding) of Cargo entities, we want to stop evaluation mid-stream? In normal operation, this is not possible. Heres a simple example.
In the example in Figure 132, we see a simple rule that sets thing.selected = true for all thing.aSize = small. Notice in the adjacent Ruletest, that each small Thing is selected. Thing[2] and Thing[3] are both small, so they are both selected by the rule. The rule has evaluated all three Things, but finding only two that satisfy the rules condition, only fires twice. This iteration happened automatically. What if we wanted rule execution to stop after finding the first Thing that satisfies the rule? In other words, allow the rule engine to fire for Thing[2] but stop processing before firing for Thing[3]. Is that possible? You might think the following Rulesheet would accomplish this goal.
Page 129
Figure 133 Rulesheet and Ruletest, threshold condition added, CaPT disabled
The example in Figure 133 includes two changes: 1) Thing.selected is defaulted to false in the Nonconditional rule (Action row A0). And 2) a second Condition row checks for Thing.selected = false as part of rule 1. This is called a threshold condition. You might be temped to think that when Thing[2] fires the rule, its value of selected (re-set to true) would be sufficient to stop further evaluation and execution of Thing[3]. But as we see in the adjacent Ruletest, that this isnt the case. The reason is that Thing[3] is an entirely separate entity within the binding, and is entitled to its own evaluation of rule 1 regardless of what happended with Thing[2]. The addition of the threshold condition accomplished nothing. A special feature in Studio, called Use Condition as Processing Threshold (abbreviated as CaPT), allows us to interrupt processing of the binding. You activate this option by selecting the rule column involved, then from the Studio menu bar, choose Rulesheet > Rule Columns(s) > Use Condition as Processing Threshold. Once selected, CaPT causes the rule column header to display in bold type, as shown below in Figure 134, circled in orange.
Figure 134 Rulesheet and Ruletest, threshold condition added, CaPT enabled
When CaPT is activated, it breaks out of the automatic binding iteration whenever an instance in the binding fails to satisfy the threshold condition. In this case, Thing[2], having just fired rule 1, no longer satisfies the threshold condition, and causes rule execution to stop before evaluating Thing[3]. If we re-ran this Ruletest, we might see Thing[3] evaluated first, in which case rule execution would stop before evaluating Thing[2]. Within a binding, sequence of evaluation of
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 130
elements is random and may change from execution to execution. There is nothing about the binding that enforces an order or sequence among the bound elements.
TEST YOURSELF:
Answers are provided in Appendix D. 110. What is the main difference between inferencing and looping? 111. A loop that does not end by itself is known as an __________ loop. 112. A loop that depends logically on itself is known as a single-rule or __________ loop. 113. True or False. The Check for Logical Loops tool in Studio will always find mutual dependencies in a Rulesheet if they are present. 114. True or False. The Check for Logical Loops tool in Studio can fix inadvertent loops. Referring to the following illustration, answer questions 115 through 117:
115. Given these two rules, is it necessary for the Rulesheet to use the Inferencing mode shown? Why or why not? 116. Is there any potential harm in having this Rulesheet configured to Advanced Inferencing with SelfTriggering? Why or why not?
Page 131
117. If the Rulesheet as shown above were tested with a DVD having a price tier of High, quantity available of 150,000, and release date within the past 6 months, what would be the outcome of the test? 118. This icon indicates which type of inferencing is enabled for this Rulesheet?
119. This icon indicates which type of inferencing is enabled for this Rulesheet?
120. A ________________ determines the sequence of rule execution and is generated when a Rulesheet is _______________.
Page 132
WHAT IS A FILTER?
A Filter expression acts to limit or reduce the data in working memory to only that subset whose members satisfy the expression. A Filter does not permanently remove or delete any data; it simply excludes data from evaluation by other rules in the same Rulesheet. We often say that data satisfying a Filter expression survives the Filter. Data that does not survive the Filter is said to be filtered out. Data that has been filtered out is ignored by other rules in the same Rulesheet. A Filter expression, no matter what its full behavior, only affects data in its own Rulesheet Rulesheets are unaffected by Filter expressions in other Rulesheets. As an example, look at the Rulesheet sections shown in Figure 135 and Figure 136, below:
The Scope window in Figure 135 defines aliases for a root-level Policy entity, a collection of Driver entities related to that Policy, and a collection of Vehicle entities related to that Policy, named thePolicy, drivers, and cars, in that order. To start with, well write a simple Filter and observe its default behavior. In the simple scenario below, the Filter expression reduces the set of data acted upon by the Nonconditional rule (column 0), which in this case merely posts the Rule Statement as a message.
Page 133
Our result is not unexpected: for every element in the collection (every Driver) whose age attribute is greater than 16, we see a posted message in the Ruletest, as shown below:
Rule Modeling Guide Because only Jacob and Lisa are older than 16, Rule Messages are posted only for them.
Page 134
Maximum Filters
By default, each Filter you write acts as a maximum filter. This means not only will the data not satisfying the Filter be filtered out of subsequent evaluations, but in cases where this data comprises a collection where no elements survive the Filter, the parent entity will also be filtered out! Heres an example of a maximum filter in action:
Notice two important things about this Ruletest: first, none of the Driver entities in the Input are older than 16, which means none of them survives the Filter. Second, because the parent Policy entity does not contain at least one Driver which satisfies the Filter, then the parent Policy itself
Page 135
also fails to survive the Filter. If no Policy entity survives the Filter, then rule Column 0 has no data upon which to act, so no Policy is assigned a startDate equal to today. The Ruletests Output, shown in Figure 139, confirms the behavior. Why would we want a Filter to behave this way? The behavior of a maximum filter may seem too powerful to be very practical or useful. In reality, youll probably find that the maximum filter behavior is generally what you want when filtering your data. If other rules on the Rulesheet act or operate on Policy, then a maximum filter gives you a very easy way to specify and control which Policy entities are affected. Maximum filter is also the original 19 behavior of Filters (and of their Precondition/Filter counterparts in Corticon Studio 4 and earlier), so for backward compatibility purposes with older models written with these expectations, we have kept it this way as new versions of Corticon have been released over the years. We wouldnt want to change an important behavior like this and have older Rule Sets begin acting completely differently from their authors intents.
Minimum Filters
There are occasions, however, when the maximum behavior of a Filter is unwanted because its too strong. In these cases, we want to apply a Filter to the elements of a collection but still keep the parent entity even if none of its children survive the Filter. When would we want to do this? When we want to act on the parent independently in subsequent rules When we want to act on data in other collections associated with the same parent.
The first case is neatly illustrated by our previous example. What if we really wanted the Nonconditional rule column 0 to act on Policy regardless of the results of the filter on its Driver children? A maximum filter prevents this in those cases where none of the children survive the Filter, as shown in Figure 139. A minimum Filter ensures a parent always survives, even if none of its children do. To turn a Filter expression into a minimum Filter, right-click on the Filter row and select Minimum Filter from the popup window, as shown (cropped) in Figure 140:
Figure 140 Selecting Minimum Filter Option from the Right-Click Popup Menu
19
Rule Modeling Guide The yellow funnel icon in the Filter window receives a small green circle symbol The yellow funnel icons in the Scope window receive small green circle symbols
Page 136
The Filter expression included under the parent entitys Scope node is shown in light gray text to indicate that the entity is no longer subject to the Filter. In other words, the entity cant be filtered out by a minimum Filter.
Page 137
From Figure 142 its clear that the minimum filter did not prevent the parent Policy entity from surviving and being acted upon by the Nonconditional rule column 0 even though none of its Driver children survived.
WHAT IS A PRECONDITION?
If youre comfortable with the minimum and maximum behaviors of a Filter expression, then its precondition behavior is even easier to understand. While reading this section, keep in mind that Filters always act as either minimum or maximum filters, but they can also act as preconditions if you enable that behavior as described in this section. If you think of filtering as a mandatory behavior but a precondition as an extra, optional behavior, then youll be in good shape later. Also, it may be helpful to think of the precondition behavior, if enabled, taking effect after the filtering step is complete. Precondition behavior of a Filter ensures that execution of a Rulesheet stops unless at least one piece of data survives the Filter. If execution of a Rulesheet stops because no data survived the Filter, then execution moves on to the next Rulesheet (in the case where the Rulesheet is part of a Ruleflow). If no more Rulesheets exist in the Ruleflow, then execution of the entire Ruleflow is complete. In effect, a Filter with precondition behavior enabled acts as a gatekeeper for the entire Rulesheet - if no data survived the Filter, then the Rulesheets gate stays closed and no additional rules on that Rulesheet will be evaluated or executed no matter what. If however, data survived the Filter, then the gate opens and the surviving data can be used in the evaluation and execution of other rules on the same Rulesheet. The precondition behavior of a Filter is significant because it allows us to control Rulesheet execution regardless of the scope used in the rules. Take for example the Rulesheet shown in Figure 143. The Filter in row 1 is acting in its standard default mode of maximum filter. This means that Driver entities in the collection named drivers and the collections parent entity Policy are both affected by this Filter. Only those elements of drivers older than 16 will survive, and at least one must survive for the parent Policy also to survive.
But how does this affect the Claim in Nonconditional row A (of rule column 0)? Claim, as a root-level entity, is safely outside of the scope of our Filter, and therefore unaffected by it. Nothing the Filter
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 138
does (or doesnt do) has any effect on what happens in Action row A the two logical expressions are completely independent and unrelated. As a result, Claim.validClaim will always be false, even when none of the elements in drivers are older than 16. A quick Ruletest verifies this prediction:
But what if the business intent of our rule is to update Claim based on the evaluation of Policy and its collection of Drivers? What if the business intent requires that the Policy and Claim really be related in some way? How do we model this? Before true precondition behavior was introduced to Studio 20, our only practical option was to mandate an actual physical association between Policy and Claim, then incorporate that association into the scope of our Filter and rules. For example:
20
Page 139
Notice that Claim is no longer a root-level entity we have associated it with Policy and given the associated Claim an alias aClaim. Its the alias, not the root-level entity, thats used in Nonconditional row A. So, when no elements of drivers are older than 16, the maximum filter ensures the parent Policy entity does not survive. And since the Policy does not survive the filter, its associated Claim does not survive, either. Heres an example of this:
The net effect is that validClaim can only be false when one or more drivers is older than 16, which is what we want. But obtaining this result required us to monkey around with our data 21 to
21
And potentially our Vocabulary, data model, and database schema, too!
Page 140
associate Claim with Policy. Sometimes we as rule modelers have this freedom and flexibility. Often, we do not. If we dont, then we need an alternative method for controlling the execution of subsequent rules without relying on unnatural or artificial data and/or data model manipulations. Heres where the precondition behavior is useful. Using the same example as in Figure 143, right-click on Filter row 1 and select Precondition.
Figure 147 Selecting Precondition Behavior from the Filter Right-Click Popup Menu
Note that the two options Precondition and Minimum Filter are mutually exclusive: turning one on turns the other off. A Filter cannot be both a Precondition AND a minimum Filter because at least one piece of data ALWAYS survives a minimum filter, so a Precondition would never stop execution. Selecting Precondition causes the following: The yellow funnel icon in the Filter window receives a small red circle symbol The yellow funnel icons in the Scope window receive small red circle symbols
Page 141
As described before, the precondition behavior of the Filter will cause Rulesheet execution to stop whenever no data survives the Filter. So in the original case where Policy and Claim were unassociated, a Filter in precondition mode, as shown in Figure 149:
accomplishes our business intent without artificially changing our Vocabulary or underlying data model. A final proof is provided in Figure 150.
Page 142
Page 143
Figure 152 Rulesheet with one Condition row moved to Filters row
Page 144
Even though expressions in the Filters section of the Rulesheet are evaluated before Conditions, the results are the same. This holds true for all rule expressions that do not involve collection operations (and therefore do not need to use aliases we have used aliases in this example purely for convenience and brevity of expression): conditional statements, whether they are located in the Filters or Conditions sections, are ANDed together. Order doesnt matter. In other words, to use the logic from the preceding example:
If person.age > 40 AND person.skydiver = true, then person.riskRating = high
Because it doesnt matter which conditional statement is executed first, we could have written the same logic as:
If person.skydiver = true AND person.age > 40, then person.riskRating = high
This independence of order is similar to the commutative property of multiplication: 4 x 5 = 20 and 5 x 4 = 20. Aliases work perfectly well in a declarative language (like Studios) because regardless of the order of processing, the outcome is always the same.
Location Matters
Unfortunately, order independence does not apply to conditional expressions that include collection operations. In the following Rulesheets, notice that one of the conditional expressions uses the collection operator size, and therefore must use an alias to represent the collection Person.
Page 145
The Rulesheets appear identical with the exception of the location of the two conditional statements. But do they produce identical results? Lets test the Rulesheets to see, testing Figure 154 first:
What happened here? Because Filters are always applied first, our Rulesheet initially screened or filtered out the elements of collection person whose skydiver value was false. Think of the Filter as allowing only skydivers to pass through to the rest of the Rulesheet. The Conditional rule then checks to see if the number of elements in collection person is more than 3. If it is, then ALL person elements in the collection that pass through the filter (in other words, all skydivers) receive a riskRating value of high. Because our first Ruletest included only 3 skydivers, the collection fails the Conditional rule, and no value is assigned to riskRating for any of the elements, skydiver or not. Lets modify the Ruletest and rerun the rules:
Page 146
Its clear from this run that our rules fired correctly, and assigned a riskRating of high to all skydivers for a collection containing more than 3 skydivers. Now lets test the Rulesheet in Figure 155, where the rule containing the collection operation is in the Filters section.
What happened this time? Because Filters apply first, the size operator counted the number of elements in our person collection, regardless of who skydives and who doesnt. Here, the Filter allows any collection and the whole collection of more than 3 persons to pass through to the Conditions section of the Rulesheet. Then, the Conditional rule checks to see if any of the elements in collection person skydive. Each person who skydives receives a riskRating value of high. Even though our Ruletest included only 3 skydivers, the collection contains 4 persons and therefore passes the Preconditional filter. Any skydiver in the collection then has its riskRating assigned a value of high.
Page 147
Its important to point out that the Rulesheets in Figure 154 and Figure 155 really implement two different business rules. When we built our Rulesheets, we neglected to write the plain-language business rule statements (violating our methodology!). The rule statements for these two Rulesheets would look like this:
The difference here is subtle but important. In the first rule statement, we are testing for skydivers within groups that contain more than 3 skydivers. In the second, we are testing for skydivers within groups of more than 3 people.
Once again, our Rulesheets differ only in the location of a Conditional expression. In Figure 159, the gender test is modeled in the second Conditional row, whereas in Figure 160, its implemented in the second Filter row. Does this difference have an impact on rule execution? Lets build a Ruletest and use it to test the Rulesheet in Figure 159 first.
Page 148
As we see in Figure 161, the combination of a Condition that uses a collection operator (the size test) with another Condition that doesnt (the gender test) produces an interesting result. What appears to have happened is that, for a collection of more than 3 skydivers, all females in that group have been assigned a riskRating of high. Step-by-step, here is what the Server did: 1. The Filter screened the collection of Persons (represented by the alias person) for
skydivers.
2. If there are more than 3 surviving elements in person (i.e., skydivers), then all females in the filtered collection are assigned a riskRating value of high. It may be helpful to think of the Server checking to make sure there are more than 3 surviving elements, then cycling through those whose gender is female, and assigning riskRating one element at a time. Expressed as a plain-language rule statement, our Rulesheet implements the following rule statement:
Its important to note that Conditions do not have the same filtering effect on collections that Filter expressions do, and the order of Conditions in a rule has no effect whatsoever on rule execution. Now that we understand the results in Figure 161, lets see what our second Rulesheet produces.
Page 149
This time, no riskRating assignments were made to any element of collection person. Why? Because multiple Filters are logically ANDed together, forming a compound filter. In order to survive the compound filter, elements of collection person must be both skydivers AND female. Elements that survive this compound filter pass through to the size test in the Condition/Action rule, where they are counted. If there are more than 3 remaining, then all surviving elements are assigned a riskRating value of high. Rephrased, our Rulesheet implements the following rule statement:
Just to confirm we understand how the Server is executing this Rulesheet, lets modify our Ruletest and rerun:
Page 150
Figure 163 now includes 4 female skydivers, so, if we understand our rules correctly, we expect all 4 to pass through the compound filter and then satisfy the size test in the Conditions. This should result in all 4 surviving elements receiving a riskRating of high. Figure 163 confirms our understanding is correct.
Page 151
and would have passed no collection at all (a null collection) had it been subjected to a maximum filter? Studio resolves this potential point of confusion by making the minimum filter option unavailable for those filters that contain collection operations. This has the practical effect of ensuring that the parent of a collection that fails a Filter containing a collection operation will never sneak through and appear to the rule writer as an empty collection.
TEST YOURSELF:
Answers are provided in Appendix D. 121. True or False. All expressions modeled in the Filters section of the Rulesheet behave as filters. 122. True or False. All expressions modeled in the Filters section of the Rulesheet behave as preconditions. 123. True or False. Some rules may be unaffected by Filters expressions on the same Rulesheet. 124. When 2 conditional expressions are expressed as 2 Filter rows, they are logically ______ together. ored anded replaced duplicated
125. True or False. A Filter row is a stand-alone rule that can be assigned its own Rule Statement 126. A null collection is a collection that: a. has a parent but no children b. has children but no parent c. has no parent and no children d. has a parent and children 127. An empty collection is a collection that: a. has a parent but no children b. has children but no parent c. has no parent and no children d. has a parent and children 128. A Filter expression is equivalent to a Conditional expression as long as it includes ______ collection operators in the expression. some all no at least one
129. True or False. To join two Filters with an or operator, you must use the word or in between expressions.
Rule Modeling Guide 130. By default, all Filter expressions are ______________ filters minimum coffee maximum extreme
Page 152
minimum filter
maximum filter
precondition noncondition
minimum filter
maximum filter
precondition noncondition
minimum filter
maximum filter
precondition noncondition
134. What happens when a Filter expression, acting as a precondition, is not satisfied? a. The expression is ignored and Rulesheet execution continues b. The Rulesheet is re-executed from the beginning c. The last Rulesheet is executed d. The next Rulesheet is executed e. All Rulesheet execution stops f. Execution of that Rulesheet stops 135. Which Filters behaviors may be active at the same time? a. Maximum filter and precondition b. Minimum filter and precondition c. Minimum and maximum filter d. Precondition may only act alone
Page 153
For the sample data shown below, determine which data survives the Filter for each question. Enter the entity number (the number in square brackets) for each survivor in the appropriate column. Assume the collection Movie has alias movies, Movie.dVD has alias dvds, and Movie.oscar has alias oscars. Maximum filters are shown in regular type and minimum filters are shown in bold type. None behave as Preconditions.
Precondition/Filter Expressions example: movies.studio = RKO 136. dvds.priceTier = High 137. oscars -> size > 4 138. oscars.win = T 139. oscars.nomination 140. oscars.win or oscars.category = Best Actor 141. oscars.win and oscars.category = Best Actor 142. dvds.quantityAvailable > 100 143. oscars -> exists(win = T) 144. movies.yearReleased.yearsBetween (today) > 50 145. dvds -> notEmpty 146. movies -> isEmpty 147. dvds.releaseDate > 1/1/2000 148. movies.genre <> Drama 149. oscars -> forAll(win = T) 150. oscars -> size > 2 Movie 1 DVD 1 Oscar 1,2,3,4,5
Page 154
During development, patterns may emerge in the way business rules define relationships between Vocabulary terms. For example, in our sample FlightPlan application, a recurring pattern might be that all aircraft have limits placed on their maximum takeoff weights. We might notice this pattern by examining specific business rules captured during the business analysis phase:
These rules are almost identical; only a few key parts parameters are different. Although aircraft type (747 or DC-10) and max cargo weight (200,000 or 150,000 lbs) are different in each rule, the basic form of the rule is the same. In fact, we can generalize the rule as follows:
Where the parameters X and Y can be organized in table form as shown below:
Aircraft type X 747 DC-10 Maximum cargo weight Y 200,000 150,000
It is important to recognize these patterns because they can drastically simplify rule writing and maintenance in Studio. As shown in Figure 164, we could build these two rules as a pair of Rulesheets, each with a Filter expression that filters data by aircrafttype.
Page 155
But there is a simpler and more efficient way of writing these two rules that leverages the concept of parameterization. Figure 165 illustrates how this is accomplished:
Notice how both rules are modeled on the same Rulesheet. This makes it easier to organize rules that share a common pattern and maintain them over time. If the air cargo company decides to add new aircraft types to its fleet in the future, the new aircraft types can simply be added as additional columns. Also notice the business rule statements in the Rule Statements section. By entering 1:2 in the Ref column and inserting attribute names into the rule statement, the same statement can be reused for both rule columns. The syntax for inserting Vocabulary terms into a rule statement requires the use of {..} curly brackets enclosing the term. See the Rule Language Guide for more details on embedding dynamic values in Rule Statements. In addition to collecting parameterized rules on the same Rulesheet, other things can be done to improve rule serviceability. In the Trade Allocation sample application that accompanies the Business Rules Management installation, two parameterized rules are accessible directly from the applications user interface the user can update these parameters without entering the Studio because they are stored externally. When the application runs, Studio accesses the parameter table to determine which rules should fire.
PARAMETERIZED RULE WHERE A SPECIFIC BUSINESS RULE IS A PARAMETER WITHIN A GENERIC BUSINESS
RULE
The previous section illustrated the simplest examples of parameterized rules. Other subtler examples occur frequently. For example, lets return to the Trade Allocation sample application included in the Studio installation. A recurring pattern in Trade Allocation might be that specific accounts prohibit or restrict the holding of specific securities for specific reasons. We might notice this pattern by examining specific business rules captured during the business analysis phase:
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 156
The first specific rule might be motivated by another, general rule that states:
The general rule explains why Airbus places this specific restriction on its account holdings Boeing is a competitor. The second rule is very similar in that it also defines an account restriction for a security attribute (the issuers industry classification), even though the rule has a different motivation. (A clients investments must not conflict with its ethical guidelines?) There may be many other business rules that share a common structure, meaning similar entity context and scope. This pattern allows us to define a generic business rule:
Absent a method for accommodating many similar rules as a single, generalized case, we need to enter each specific rule separately into a Rulesheet. This makes the task of capturing, optimizing, testing, and managing these rules more difficult and time-consuming than necessary. In the example of Trade Allocation, an Account Restriction (as a Vocabulary term) might be associated with Account (as the holder or owner of the restriction), as well as other entities shown in the following figure. For illustration purposes, the Vocabulary is shown as a UML class diagram.
Page 157
Entity/Attribute
Security.type An account must not hold a security of a restricted type Issuer.name Industry.name
An account must not hold a security issued by a restricted company An account must not hold a security issued by a company in a restricted industry
Note that Transaction is the scope 22 for this Rulesheet because all included rules apply only to Securities related to a specific Account and contained in the same Transaction. Also, note that the rule statements have been written as generic rules, with parameters appended to identify the specific examples involved in rule execution. This provides the user with a more complete explanation of which rule fired and why it fired. The following Ruletest tests the 2nd and 3rd rule statements. A single transaction contains one account, Airbus, which has two account restrictions: no competitor securities and no tobacco industry securities. Two securities are included in the transaction, one for Boeing (a competitor) and one for RJR (a company in the tobacco industry). Running the Ruletest in Figure 168, we see:
22
See chapter/module Rule Scope and Context for an in-depth explanation of this key concept
Page 158
Page 159
1 2 3
list of Accounts
4 5 6
Add Restriction
Delete Restriction
no Junk Bonds (lower than Bbb) no Small Cap equities no RJR-Nabisco no Tobacco securities
Figure 169 Sample GUI Window for Populating a Rules Parameter Table
Step 1 The user selects an Account for which the Account Restriction will be created. Referring back to our example, the user would select Airbus from the list box. Step 2 The user enters a specific business rule that provides the motivation for the Account Restriction. The prior example used no competitor securities and no tobacco securities. Step 3 The user selects the type of restriction being created. Our example used issuer.name and
industry.name.
Step 4 Once all components of the Account Restriction are entered and selected, clicking Add Restriction creates the restriction by populating the AccountRestriction table in an external database.
AccountRestriction table Account Security.type Issuer.name Industry.name Business Rule
Airbus Airbus
-----
Boeing ---
--Tobacco
Step 5 After adding a restriction, it appears in the lower scrolling text box. Selecting the Business Rule in the scrolling text box and clicking Delete Restriction will remove it from the box and from the table. Step 6 The checkbox indicates an active or inactive Business Rule. This allows the user to deactivate a rule without deleting it. In practice, another attribute could be added to the AccountRestriction
Page 160
entity called active. A Precondition might filter out inactive rules to prevent them from firing during runtime.
WARNING!
Whenever you decide to maintain rule parameters outside of Studio, you run the risk of introducing ambiguities or conflicts into your Rulesheet. The Conflict Checker may not help you discover these problems since some of the rule data isnt shown in Studio. So always try to design your parameter maintenance forms and interfaces to prevent ambiguities from being introduced.
TEST YOURSELF:
Answers are provided in Appendix D. 151. When several rules use the same set of Conditions and Actions, but different values for each, we say that these rules share a common __________________. 152. Another name for the different values in these expressions is _______________ . 153. True or False. When several rules share a pattern, the best way to model them is as a series of Boolean Conditions. 154. Whats a potential danger of maintaining rule parameters outside of a Studio Rulesheet? 155. Write a generalized rule that identifies the pattern in the following rule statements: a. Platinum customers buy $100,000 or more of product each year b. Gold customers buy between $75,000 and less than $100,000 of product each year c. Silver customers buy more than $50,000 and less than $75,000 of product each year d. Bronze customers buy between $25,000 and $50,000 of product each year 156. In the rules listed above, what are the parameters? 157. Describe the ways in which these parameters can be maintained. What are the advantages and disadvantages of each option?
Page 161
Scenario Testing
Scenario testing is the process of comparing actual decision operation to expected operation, using data scenarios or test cases. The Studio Ruletest provides the capability to build test cases using real data, which may then be fed to a set of rules for evaluation. The actual output produced by the rules may then be compared to the output we expect those rules to produce. If the actual output matches the expected output, then we may have some degree of confidence that the decision is performing properly. Why only some confidence and not complete confidence will be addressed over the course of this chapter.
Rule Modeling Guide To test these rules, we create a new scenario in a Ruletest, as shown in Figure 171.
Page 162
In this scenario, we have created a single example of Person, a non-smoker aged 45. Based on the rules we just created, we expect that the Condition in Rule 1 will be satisfied (People aged 55 or younger) and that the persons riskRating will be assigned the value of low. To confirm our expectations, we run the Ruletest:
As we see in Figure 172, our expectations are confirmed: Rule 1 fires and riskRating is assigned the value of low. Furthermore, the .post command displays the appropriate rule statement. Based on this single scenario, can we say conclusively that these rules will operate properly for other possible scenarios; i.e., for all instances of Person? How do we answer this critical question?
Page 163
decisions are rarely composed of just a single rule. More commonly, a decision is composed of dozens or hundreds of rules, and the ways in which the rules interact can be very complex. Despite this complexity, there are several traditional methods for analyzing sets of rules to discover logical problems.
Flowcharts
A flowchart that captures these two rules might look like the following:
Upon closer examination, the flowchart reveals two problems with our rules: what Action(s) should be taken if either test fails, in other words, if Person.age>55 or if Person.smoker=false? The rules built in Figure 170 do not handle these two cases. But there is also a third, subtler problem here: what happens if both Conditions are satisfied, specifically when Person.age<=55 and Person.smoker=true? When Person.age<=55, we want Person.riskRating to be given the
Page 164
value of low. But when Person.smoker=true, we want Person.riskRating to be given the value of high. We have discovered a dependency between our rules they are not truly separate and independent evaluations because they both assign a value to the same attribute. So the flowchart we began with turns out to be an incorrect graphical representation of our rules, because the decision flow doesnt truly follow two parallel and independent paths. Lets try a different flowchart:
Page 165
In the flowchart in Figure 174, we have acknowledged an interdependence between the two rules, and have arranged them accordingly. However, a few questions still exist. For example, why did we choose to place the smoker rule before the age rule? By doing so we are giving the smoker rule an implicit priority over the age rule because any smoker will immediately be given a riskRating value of High regardless of what their age is. Is this what the business intends, or are we as modelers making unjustified assumptions? We call this a problem of logical conflict 23, because its simply not clear from our two rules, as they have been written, what the correct outcome should be. Does one rule take priority over the other? Should one rule take priority over the other? This is, of course, a business question, but the rule writer must be aware of the dependency problem and resulting conflict in order to ask the question in the first place. Also, notice that there is still no outcome for a non-smoker older than 55. We call this a problem of logical completeness and it must be taken into consideration, no matter which flowchart we use. The point we are making is that discovery of logical problems in sets of rules using the flowcharting method is very difficult and tedious, especially as the number and complexity of rules in a decision (and the resulting flowcharts) grows.
Test Databases
The use of a test database is another common method for testing rules (or any kind of business logic, for that matter). The idea is to build a large number of test cases, with carefully chosen data, and determine what the correct system response should be for each case. Then, the test cases are processed by the logical system and output is generated. Finally, the expected output is compared to the actual output, and any differences are investigated as possible logical bugs. Lets construct a very small test database with only a few test cases, determine our expected outcomes, then run the tests and compare the results. We want to ensure that our rules execute properly for all cases that might be encountered in a real-life production system. To do this, we must create a set of cases that includes all such possibilities. In our simple example of two rules, this is a relatively straightforward task: condition Age <= 55 Age > 55
Figure 175 All Combinations of Conditions in Table Form
In Figure 175, we have assembled a table using the Values sets from each of the Conditions in our rules. By arranging one set of values in rows, and the other set in columns, we create the Cross
23
Conflict is also known as Ambiguity. In older versions of Corticon Studio, the term ambiguity is used more frequently.
Page 166
Product (also known as the direct product or cross product) of the two Values sets, which means that every member of one set is paired with every member of the other set. Since each Values set has only two members, the Cross Product yields 4 distinct possible combinations of members (2 multiplied by 2). These combinations are represented by the intersection of each row and column in the table in Figure 175. Now lets fill in the table using the expected outcomes from our rules. Rule 1, the age rule, is represented by row 1 in the table above. Recall that rule 1 deals exclusively with the age of the applicant and is not impacted by the applicants smoker value. To put it another way, the rule produces the same outcome regardless of whether the applicants smoker value is true or false. Therefore, the action taken when rule 1 fires (riskRating is assigned the value of low) should be entered into both cells of row 1 in the table, as shown in Figure 176.
Likewise, rule 2, the smoker rule, is represented by column 1 in Figure 175. The action taken if rule 2 fires (riskRating is assigned the value of high) should be entered into both cells of column 1 as shown in Figure 177.
The table format illustrates the fact that a complete set of test data should contain four distinct cases (each cell corresponds to a case). Rearranging, our test cases and expected results can be summarized as follows: Test case 1 2 3 age
<= 55 <= 55 > 55
smoker
true false true
Expected outcome
low, high low high
Page 167
> 55
false
The table format also highlights two problems we encountered earlier with flowcharts. In Figure 177, row 1 and column 1 intersect in the upper left cell (this cell corresponds to test case #1 in Figure 178). As a result, each rule tries to assert its own action one rule assigns a low value, and the other rule assigns a high value. Which rule is correct? Logically speaking, they both are. But if the rule analyst had a business preference, it was certainly lost in the implementation. As before, we simply cant tell by the way the two rules are expressed. Logical conflict reveals itself once more. Also notice the lower right cell (corresponding to test case #4) it is empty. The combination of age>55 AND non-smoker (smoker=false) produces no outcome because neither rule deals with this case the logical incompleteness in our business rules reveals itself once more. Before we deal with the logical problems discovered here, lets build a Ruletest in Studio that includes all four test cases in Figure 178:
Lets look at the test case results in Figure 179. Are they consistent with our expectations? With a minor exception in case #1, the answer is yes. In case #1, riskRating has been assigned the value of high. But also notice the rule statements posted: case #1 has produced two messages which indicate
Page 168
that both the age rule and the smoker rule fired as expected. But since riskRating can hold only one value, the system non-deterministically (at least from our perspective) assigned it the value of high. So if using test cases works, what is wrong with using it as part of our Analysis methodology? Lets look at the assumptions and simplifications made in the previous example: 1. We are working with just two rules with two Conditions. Imagine a rule pattern comprising three Conditions our simple 2-dimensional table expands into three dimensions. This may still not be too difficult to work with as some people are comfortable visualizing in three dimensions. But what about four or more? Its true that large, multi-dimensional tables can be flattened and represented in a 2-D table, but these become very large and awkward very quickly. 2. Each of our rules contains only a single Conditional parameter limited to only two values. Each also assigns, as its Action, a single parameter which is also limited to just two values. When the number of rules and/or values becomes very large, as is typical with real-world business decisions, the size of the Cross Product rapidly becomes unmanageable. For example, a set of only six Conditions, each choosing from only only ten values produces a Cross Product of 106, or one million combinations. Manually analyzing a million combinations for conflict and incompleteness is tedious and time-consuming, and still prone to human error. In many cases, the potential set of cases is so large, that few project teams take the time to rigorously define all possibilities for testing. Instead, they often pull test cases from an actual database populated with real data. If this occurs, conflict and incompleteness may never be discovered during testing because its unlikely that every possible combination will be covered by the test data.
Expanding Rules
Returning to our original rules (reproduced from Figure 170):
Page 169
As illustrated by the table in Figure 176, rule 1 (the age rule) is really a combination of two sub-rules; we specified an age value for the first Condition but did not specify a smoker value for the second Condition. Because the smoker Condition has two possible values (true and false), the two subrules can be stated as follows:
Studio makes it easy to view sub-rules for any or all columns in a Rulesheet. By clicking the Expand Rules button on the toolbar, or simply double-clicking the column header, Studio will display subrules for any selected column. If no columns are selected, then all sub-rules for all columns will be shown. Sub-rules are labeled using Decimal numbers: rule 1 below has two sub-rules labeled 1.1 and 1.2. Sub-rules 1.1 and 1.2 are equivalent to the upper left and upper right cells in Figure 176.
Page 170
As we pointed out before, the outcome is the same for each sub-rule. Because of this, the sub-rules can be summarized as the general rules shown in column 1 of Figure 180. We also say that the two sub-rules collapse into the rules shown in column 1. The dash symbol in the smoker value of column 1 indicates that the actual value of smoker doesnt matter to the execution of the rule it will assign riskRating the value of low no matter what the smoker value is (as long as age <= 55, satisfying the first Condition). Looking at it a different way, only those rules with dashes in their columns have sub-rules, one for each value in the complete value set determined for that Condition row.
Page 171
The mechanics of stepping through and resolving each conflict has been covered in detail in the Basic Tutorial for Corticon Studio Modeling Rules. Here, our intent is to correlate the results of the automatic conflict check with the problems we identified first with the flowchart method, then later with test cases. Sub-rules 1.1 and 2.1, the sub-rules highlighted in pink and yellow in Figure 182, correspond to the intersection of column 1 and row 1 of Figure 177 or test case #1 in Figure 178. But note Studio does not instruct the rule writer how to resolve the conflict it simply alerts the rule writer to its presence. The rule writer, ideally someone who knows the business, must decide how to resolve the problem. The rule writer has two basic choices: 1. Change the Action(s) for one or both rules. We could change the Action in sub-rule 1.1 to match 2.1 or vice versa. Or we could introduce a new Action, say riskRating = medium, as the Action for both 1.1 and 2.1. If either method is used, the result will be that the Conditions and Actions of sub-rule 1.1 and 2.1 are identical. This removes the conflict, but introduces redundancy, which, while not a logical problem, can reduce processing performance in deployment. Removing redundancies in Rulesheets is discussed in the Optimization section of this chapter. 2. Use an Override. Think of an override as an exception. To override one rule with another means to instruct the Corticon Server to fire only one rule even when the Conditions of both rules are satisfied. Another way to think about overrides is to refer back to the discussion surrounding the flowchart in Figure 174. At the time, we were unclear which decision should execute first no priority had been declared in our rules. But it made a big difference how we constructed our flowchart and what results it generated. To use an override here, we simply select the number of the sub-rule to be overridden from the drop-down box at the bottom of the column of the overriding sub-rule, as shown circled in Figure 183. This is expressed simply as sub-rule 2.1 overrides 1.1. It is incorrect to think of overrides as defining execution
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 172
sequence. An override does not mean fire rule 2.1 then fire rule 1.1. It means fire rule 2.1 and do not fire rule 1.1.
An override is essentially another business rule, which should to be expressed somewhere in the Rule Statements section of the Rulesheet. To express this override in plain English, the rule writer might choose to modify the rule statement for the overridden rule:
This modification successfully expresses the effect of the override. If ever in doubt as to whether you have successfully resolved a conflict, simply click the Check for Conflicts button again. The affected sub-rules should not highlight as you step through any remaining ambiguities. If all ambiguities have been resolved, youll see the following window:
Page 173
Clicking OK to dismiss the message window, we see that the Completeness Check has produced a new column (3), shaded in green:
This new rule, the combination of age>55 AND smoker=false corresponds to the intersection of column 2 and row 2 in Figure 177 and test case #4 in Figure 178. The Completeness Checker has discovered our missing rule! To do this, the Completeness Checker employs an algorithm which calculates all mathematical combinations of the Conditions values (the Cross Product), and compares them to the combinations defined by the rule writer as other columns (other rules in the Rulesheet). If the comparison determines that some combinations are missing from the Rulesheet, these combinations are automatically added to the Rulesheet. As with the Conflict Check, the Action
Page 174
definitions of the new rules are left to the rule writer. The rule writer should also remember to enter new plain-language Rule Statements for the new columns so its clear what logic is being modeled. The corresponding rule statement might look like this:
Page 175
Notice that columns 3-4 have been automatically added to the Rulesheet. But also notice that column 3 contains an unusual Condition: gender <> female. Because the other two Conditions in column 3
Page 176
have dash values, we know it contains component or sub-rules. By double-clicking on column 3s header, its sub-rules are revealed:
Because our Rulesheet is intended to identify high-risk pregnancies, it would not seem necessary to evaluate non-female (i.e., male) patients at all. And if male patients are evaluated, then we can say with some certainty that the scenarios described by sub-rules 3.1 and 3.3 those scenarios containing pregnant males are truly unnecessary. While these combinations may be members of the Cross Product, they are clearly not combinations that can occur in real life. If other rules in an application prevent combinations like this from occurring, then sub-rules 3.1 and 3.3 may also be unnecessary here. On the other hand, if no other rules catch this faulty combination earlier, then we may want to use this opportunity to raise an error message or take some other action that prompts a reexamination of the input data.
Renumbering Rules
Continuing with the previous pregnancy example, lets assume that we agree that sub-rules 3.1 and 3.3 are impossible, and so may be safely ignored. However, we decide to keep sub-rules 3.2 and 3.4 and assign Actions to them. For this example, well just post violation messages to them. However, when we try to enter Rule Statements for sub-rules 3.2 and 3.4, we discover that Rule Statements can only be entered for general rules (whole-numbered columns), not sub-rules. To convert column 3, with its four sub-rules, into four whole-numbered general rules, select Rulesheet>Rule Column(s)>Renumber Rules from the Studio menubar.
Page 177
Now that the columns have been renumbered, Rule Statements may be assigned to columns 4 and 6, and columns 3 and 5 may be deleted or disabled (if desired). When impossible or undesirable rules are created by the Completeness Checker, we recommend disabling the rule columns rather than deleting them. When disabled, the columns remain visible to all modelers, eliminating any surprise (and shock) when future modelers apply the Completeness Check and discover missing rules that you had already found and deleted. And if you disable the columns, be sure to include a Rule Statement that explains why. See Figure 191 for an example of a fully complete and well-documented Rulesheet
Page 178
Matrix to Calculate Shipping Charges per Pound From/To zone 1 zone 2 zone 3 zone 4 zone 5 zone 1 $0.25 $0.35 $0.45 $0.55 $0.65 zone 2 $0.35 $0.25 $0.35 $0.45 $0.55 zone 3 $0.45 $0.35 $0.25 $0.35 $0.45 zone 4 $0.55 $0.45 $0.35 $0.25 $0.35 zone 5 $0.65 $0.55 $0.45 $0.35 $0.25
In Figure 193 we have built a simple Vocabulary with which to implement these rules. Because each cell in the table represents a single rule, our Rulesheet will contain 25 columns (the Cross Product equals 5x5 or 25).
Page 179
Rather than manually create all 25 combinations (and risk making a mistake), you can use the Expansion Tool to help you do it. This is a three-step process. Step 1 consists of entering the full range of values found in the table in the Conditions cells, as shown in Figure 194.
Now, use the Expansion Tool to expand column 1 into 25 non-overlapping columns. We now see the 25 sub-rules of column 1 (only the first ten sub-rules are shown in Figure 195 due to page width limitations in this document):
Page 180
Each sub-rule represents a single cell in the original table. Now, select the appropriate value of shipCharge in the Actions section of each sub-rule as shown in Figure 196.
In step 3, shown in Figure 197, we renumber the sub-rules to arrive at the final Rulesheet with 25 general rules, each of which may now be assigned a Rule Statement.
Memory Management
As you might suspect, the Completeness Checker and Expansion algorithms are memory-intensive, especially as Rulesheets become very large. If Studio runs low on memory, refer to the Studio Installation Guide, Changing Studio Memory Allocation section, for details on increasing Studios memory allotment.
Rule Modeling Guide introduced to accomplish specific purposes. Both scenarios are discussed in the chapter Rule Dependency: Chaining and Looping.
Page 181
OPTIMIZING RULESHEETS
The Compress Tool
Studio helps improve performance by removing redundancies within Rulesheets. There are two types of redundancies the Compress Tool detects and removes: 1. Rule or sub-rule duplication. The Compress Tool will search a Rulesheet for duplicate columns (including sub-rules that may not be visible unless the rule columns are expanded), and delete extra copies. Picking up where we left off in Figure 186, lets add another rule (column #4), as shown in Figure 198.
While these 4 rules use only 2 Conditions and take just 2 Actions (an assignment to riskRating and a posted message), they already contain a redundancy problem. Using the Expand Tool this redundancy is visible in Figure 199.
Page 182
Looking at the compressed Rulesheet in Figure 200, we see that column #4 has disappeared entirely. More accurately, the Compress Tool determined that column 4 was a duplicate of one of the sub-rules in column 1 (1.2) and simply removed it. Looking at the Rule Statement section, we see that the rule statement for rule 4 has been renumbered to match the surviving rule.
Page 183
Compression does not, however, alter the text of the rule statement; that task is left to the rule writer. Its important to note that the compression does not alter the Rulesheets logic; it simply affects the way the rules appear in the Rulesheet the number of columns, Values sets in the columns, etc. Compression also streamlines rule execution by ensuring that no rules are processed more than necessary. 2. Combining Values sets to simplify and shorten Rulesheets. Recall our shipping charge example. By using the Compress Tool, Rulesheet columns are combined wherever possible by creating Values sets in Condition cells. For example, rule 6 in Figure 201 (highlighted below) is the combination of rule 6 and 8 from Figure 197.
Value sets in Condition cells are equivalent to the logical operator OR. Rule 6 therefore reads: 6. A manifest with a Zone 2 sending address AND a Zone 1 OR Zone 3 receiving address costs $0.35 per pound to ship. In deployment, The Server will execute this new rule 6 faster than the previous rule 6 and 8 together.
Page 184
Page 185
To remind you of the underlying Cross Product used by the Completeness Checker, well Expand the Rulesheet momentarily and examine the sub-rules present:
A total of 26 new columns (counting both rules and sub-rules) have been created exactly what we expect 24 and what the Completeness Check message window states. Now, Compress the Rulesheet and fill in the Actions for the new columns as shown in Figure 205:
Because the added rules are non-overlapping, we can be sure they wont introduce any ambiguities into the Rulesheet. To prove this, select the Conflict Checker .
Three Conditions each with 3 members in their Values sets yields a Cross Product of 27 combinations (3*3*3 or 33). Subtracting the combination already present in column 1, we expect 26 new columns to be added.
24
Page 186
Figure 206 Proof that no New Conflicts have been Introduced by the Completeness Check
This pattern tells us that the only case where the aircraft type is a 747 is when max cargo volume is greater than 300 AND max cargo weight is greater than 200,000 AND tail number is N123UA. This rule is expressed in column 1. In all other cases, specifically where max cargo volume is 300 or less OR max cargo weight is 200,000 or less OR tail number is something other than N123UA will the aircraft type be a DC-10 (or any of the values are null). These rules are expressed in columns 2, 3 and 4, respectively. The characteristic diagonal line of Condition values in columns 2-4, surrounded by dashes indicates a classic OR relationship between the 3 Conditions in these columns. The Compression algorithm was designed to produce this characteristic pattern whenever the underlying rule logic is present. It helps the rule writer to better see how the rules relate to each other.
You may be surprised to see a total of 54 sub-rules (columns) displayed (in Figure 207) instead of the 26 we had prior to compression. Look closely at the 54 columns and you will see several instances of sub-rule redundancy of the 18 sub-rules within original columns 2, 3 and 4, almost half are redundant (for example, sub-rules 2.1, 3.1 and 4.1, shown in Figure 207, are identical). What happened?
Page 187
TEST YOURSELF:
Answers are provided in Appendix D. 158. What does it mean for two rules to be ambiguous? 159. What does it mean for a Rulesheet to be complete? 160. Are all ambiguous rules wrong, and must all ambiguities be resolved before deployment? Why or why not? 161. Are all incomplete Rulesheets wrong, and must all incompletenesses be resolved before deployment? Why or why not? 162. Match the Studio tool name with its toolbar icon
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 188
Conflict Checker Compression Tool Expansion Tool Collapse Tool Conflict Filter Completeness Checker 163. Explain the different ways in which an Ambiguity/Conflict between two rules can be resolved. 164. True or False. Defining an override enforces a specific execution sequence of the two ambiguous rules 165. True or False. A Conditions row with an incomplete values set will always result in an incomplete Rulesheet. 166. If a Rulesheet is incomplete due to an incomplete values set, will the Completeness Checker detect the problem? Why or why not? 167. Can a rule column define more than one override? 168. If rule 1 overrides rule 2, and rule 2 overrides rule 3, does rule 1 automatically override rule 3? 169. Are rules created by the Completeness Checker always legitimate? 170. In a rule column, what does a dash (-) character mean? 171. True or False. The Expansion Tool permanently changes the rule models in a Rulesheet. If false, how can it be reversed? 172. True or False. The Compression Tool permanently changes the rule models in a Rulesheet. If false, how can it be reversed? 173. If a rule has 3 condition rows, and each condition row has a Values set with 4 elements, what is the size of the Cross Product? 174. In above question, is it necessary to assign actions for every set of conditions (i.e., for every column)?
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 189
175. If it is not desired to assign actions for every column, what can be done to/with these columns? 176. Which Studio tool helps to improve Rulesheet performance? Expansion Tool Compression Tool Completeness Checker Collapse Tool Squeeze Tool
177. How is the compression performed by the Completeness Checker different from that performed by the Compression Tool? 178. Whats wrong with using databases of test data to discover Rulesheet incompleteness? 179. If you expand a rule column and change the Actions for one of the sub-rules, what will Studio force you to do before saving the changes? 180. What does it mean for one rule to subsume another?
Page 190
When we use different Version numbers to describe identically named Ruleflows, the Server keeps them straight in memory, and responds correctly to requests for the different Versions. In other words, an application or process can use (or call) different versions of the same Ruleflow depending on certain criteria. The details of how this works at the Server level are technical in nature and are described in the Server Integration & Deployment Guide. A plain-text description of this version can be added in the Comments tab. Version numbers may be raised anytime but never lowered.
Page 191
TEST YOURSELF:
Answers are provided in Appendix D. 181. True or False. If a Ruleflow has an Effective date, it must also have an Expiration date. 182. True or False. If a Ruleflow has an Expiration date, it must also have an Effective date. 183. True or False. Ruleflow Version numbers are mandatory 184. Which Studio menu contains the Ruleflow Properties settings? 185. True or False. A Ruleflow Minor or Major Version number may be raised or lowered. 186. True or False. Ruleflow Effective and Expiration dates are mandatory.
Page 192
Notice that weve selected French in the second line of the Supported Locales pane, circled below in orange. This choice causes a second column to appear to the right in the Vocabulary pane (shown below in an orange rectangle).
Page 193
In the French column, we must manually add French translations for each Vocabulary term, including association role names. These translated terms must be unique from the English or other base version shown in the left-hand column. With a localized Vocabulary, now switch your operating system to French locale. Different OSs have different methods for switching locales - consult your OS help or documentation for assistance.
Page 194
If you do not see the Natural Language choice listed, you may need to Reset Perspective first. This typically only happens if you are upgrading from an earlier version of Studio. Once selected, you should see a new Window appear in Studio:
Page 195
If you have other Locales enabled (see Localization chapter for more details), then the Natural Language window will include columns for other languages besides English. This allows you to define Natural Language text for those locales, too. A populated Natural Language window is shown below. Notice that weve tried to be as clear and descriptive as possible, including the words If in Conditions and Then in Actions. Weve also used to indicate that the expression continues in the column cells to the right. Your use of natural language may vary, but we recommend adopting a consistent, clear style.
Figure 216 Populating the Natural Language Window populated with natural language text
Once natural language expressions are defined, you can view these entries in place of the standard Condition and Action expressions in the Rulesheet. 1. 2. Close the Natural Language window by clicking the tabs X On the Studio menubar, click the icon to display the Natural Language expressions entered previously. Note that while Natural Language is displayed, the text of the Condition and Action rows cannot be edited. To revert to original, editable expressions, click the icon
3.
.
Figure 217 Populating the Natural Language Window populated with natural language text
Page 196
5.
Page 197
Notice in Figure 218 that tutorial_example version 1 is not yet live (the Live column checkbox is unchecked). This means we can make changes to it.
Page 198
Changing Rule Statements for those rule columns that have them, including Text and Serverity changes. Re-applying the Conflict Checker following any changes to ensure new no new conflicts have been introduced by your changes
Server Console does not allow the following types of changes to a Rulesheet: Adding/removing/changing any Scope used by any rules Adding/removing/changing any Filters used by the Rulesheet Adding/removing/changing Condition or Action expressions Adding/removing rule columns to the decision table Adding/removing Rule Statements Adding/removing/changing and looping or advanced Inferencing features in a Rulesheet Enabling or disabling any Rulesheet rows or columns
The Rulesheet change page also includes a Business View/Technical View toggle button that shows/hides Rulesheet Scope and Filters, if used. Once you have updated the Rulesheet with any changes, click the Save button at the bottom of the page. A message will display the updated Decision Service timestamp and advise that a slight delay may occur before the Decision Service is ready to be promoted to live status. This delay is due to the time required to compile the Decision Service on the fly by Corticon Server. For more information about Decision Service compilation, please see the Server Integration & Deployment Guide.
Page 199
be sure to use forward slashes when writing the path to your new Reports directory, such as
C:/Program Files/Corticon/Studio/myReports
Once you have created your own XSLT stylesheet (or modified the sample provided), copy the entire <corticon_install_dir>\Samples\Reports directory to <corticon_install_dir>\Studio \configuration\com.corticon.brms. Close and re-open Studio, and it will discover the new XSLT stylesheets and use them to generate reports.
Page 200
Page 201
A null pointer exception (NPE) almost always indicates a problem with the rule engine, whether it is being employed by the Studio or by Corticon Server. If you encounter this error, please contact Technical Support, and set aside copies of the Vocabulary, Rulesheet, and Ruletest so we can use them for further troubleshooting. The Reactor Exception
This error is also indicative of a possible rule engine problem, but it may also indicate improper or unnecessarily complex language usage in your rule expressions. The Rule Languages flexibility may permit workarounds to the limitation(s) that produced this message; Corticon Technical Support should be contacted for further assistance. As with the NPE errors, please save copies of the Vocabulary, Rulesheet, and Ruletest for use by Corticon Support staff. The Fatal Exception On very rare occasions, you may experience a full crash of the Studio application. In these cases, youll see a window like the following:
Page 202
This type of problem can only be resolved by Corticon. But before contacting Corticon Technical Support, please click on the button, which will display a window with more information about the cause of the error, as shown below:
Click the Copy button (as shown) and paste the text into a text file. Please send us this text file along with the standard set of Studio files (Vocabulary, Rulesheet, Ruletest) when you report this problem.
Rule Modeling Guide Your Ruletest produced none of the errors listed above, or You or Corticon Technical Support identified workarounds that overcame these errors
Page 203
Does the Rulesheet produce the expected test results? In other words, does the actual output match the expected output? If so, and you were using the same scenario that caused the original problem, then the problem is not with the rules or with Studio, but instead with the data integration or Server deployment. Proceed to Troubleshooting Server Problems If not, the problem is with the rules themselves. Continue in this section.
Page 204
Disable rows, rule columns, and/or Rulesheets until the strange or unexpected behavior stops.
At the Breakpoint
At the point at which abnormal behavior begins, what results is the breakpoint rule producing? No results at all the breakpoint rule should fire (given the data in the Ruletest) but does not. Proceed to the No Results section. Incorrect results the breakpoint rule does fire, but without the expected result. Proceed to the Incorrect Results section.
Page 205
Failure of a rule to produce any results at all indicates the rule is telling the rule engine to do something it cant do 25. Frequently, this means the engine tries to perform an operation on a term that doesnt exist or isnt defined at time of rule execution. For example, trying to: Increment or decrement an attribute (using the += or -= operators, respectively) whose value doesnt exist (in other words, has a null value). Post a message to an entity that doesnt exist, either because it was not part of the Ruletest to begin with, or because it was deleted or re-associated by prior rules. Post a message with an embedded term from the Vocabulary whose value doesnt exist in the Ruletest, or was deleted by prior rules. Create (using the .new operator) a collection child element where no parent exists, either because it was not part of the Ruletest to begin with, or because it was deleted or re-associated by prior rules. Trying to forward-chain 26 within the same rule. For example, if Action row B in a given rule derives a value that is required in Action row C, then the rule may not fire. Both Actions must be executable independently in order for the rule to fire. If forward-chaining is required in the decision logic, then the chaining steps should be expressed as separate rules.
25 26
This assumes, of course, that the rule should fire under normal circumstances. Forward-chaining is the process of using the results of one expression as the input to another.
Page 206
Once the breakpoint rule has been isolated, it is often helpful to copy the relevant logic into another Rulesheet for more focused testing. Refer to the Rule Language Guide to ensure you have expressed your rules correctly. Be sure to review the usage restrictions for the operator(s) in question. If, after isolating and verifying the suspicious expression syntax, you are unable to fix the problem, please call Corticon Technical Support. As always, be prepared to send us a) the product version used, and b) the set of Studio files (.ecore, .ers, .erf, and .ert) that will allow us to reproduce the problem.
Open CcConfig.jar with a standard decompression utility (like WinZip or 7-Zip) and look for a text file named CcCommon.properties. Look for the loglevel property and change its value to INFO Restart Corticon Server and rerun the test.
Go to the directory containing log files. In the default Windows Tomcat installation, this is
<corticon_install_dir>\Server\Tomcat\CcServer\Log and locate todays log file. Its filename is in yyyymmdd.log format.
Either delete or rename todays log file. A new log file is created every day, and each Corticon Server transaction adds entries to the days log. Because daily log files may become quite large, it is useful to start with a fresh log that records only the problematic transaction. The next time Corticon Server processes a transaction, a new log file will be created and entries made in it.
What is Corticon Servers response? No response In most cases, the failure of Corticon Server to produce a log file means that the invocation/request is not even reaching it! The most common causes of a non-responsive (invocation produces no log file entry) Corticon Server include: Incorrect Corticon Server deployment. Review procedures in the Server Integration & Deployment Guide to ensure correct deployment. Incorrect Corticon Server invocation
Page 207
1. Incorrect URL. If using a web services deployment, ensure the SOAP message is addressed correctly, and that no firewalls or port configurations prevent the SOAP message from reaching Corticon Server. 2. Incorrect API. Review the Server Integration & Deployment Guide for complete details on Java APIs available for Corticon Server invocation. A complete JavaDoc and sample code set is also provided in the <corticon_install_dir>\JavaDoc directory. Even though Corticon Server may not respond to an incorrect invocation, the host server or container (app server, web server, etc) may respond either at a command line or log level. Check to see if the host server has responded to your invocation.
Response containing errors The most common causes of erroneous Corticon Server responses include: Incorrect messaging 1. Message payload does not conform to service contract. Compare your SOAP message to the service contract produced by the Deployment Console to ensure compliance. Many 3rdparty tools are available that automatically validate an XML document (in this case, the SOAP message) to its schema (in this case, the WSDL service contract). Notice that if Corticon Server cannot even parse the inbound SOAP message, no entry will be made in Corticon Servers log. Instead, the error message will be displayed directly in the web server console, as shown below:
Figure 225 Server Console Message Highlighting Incorrect SOAP Request Structure
2. Incorrect or missing Decision Service Name. Ensure the SOAP messages Decision Service Name attribute matches the name of the Decision Service as it was deployed by either a deployment descriptor file or an API method call. See figure below.
Page 208
Figure 226 Log Excerpt Highlighting Missing Decision Service Name in SOAP Request
Corticon Server licensing problem 1. License not installed. Your CcLicense.jar license file must be located in the same directory as the CcServer.jar file. In the default installation, CcServer.jar appears in both
<corticon_install_dir>\Studio\configuration\org.eclipse.osgi\bund les\6\1\.cp\lib and <corticon_install_dir>\Server\Tomcat\webapps\axis\WEB-INF\lib, so
ensure your valid license file appears in both locations as well. 2. If you are using one of the .war or .ear packages provided in <corticon_install_dir>\Samples, then be sure that those packages also include valid copies of CcLicense.jar. 3. License expired. See your Corticon liaison for an updated license file.
Page 209
4. License capacity exceeded. License capacity is measured in several ways: Number of unique Decision Services that may run concurrently in Corticon Server. Make sure your license can support the total number of unique .erf files referenced by deployed .cdd files. Number of copies of Decision Services the Server may create to handle transaction volume (known as Reactors). Make sure your license can support the max pool size specified in the deployed .cdd files. See figure below. Number of rules allowed for all Decision Services deployed. Make sure your license can support the total number of rules contained in all the deployed .erf files. IP address (or multiple) allowed. Make sure your license URL address matches the address of your Corticon Server. Number of transactions per time period allowed. Make sure your license can support the total number of transactions per time being requested of Corticon Server.
Page 210
Deployment Descriptor (.cdd) file problems 1. Missing .erf file. The .erf file has been moved and is no longer located in the directory referenced by the .cdd file.
2. Missing .cdd file. The .cdd file is missing from the \cdd directory, or the taskname contained in the SOAP request message does not match any of the tasknames in any of the .cdd files deployed to Corticon Server.
Page 211
3. Missing \cdd directory. The proper location of this directory (when installed using default parameters) is
<corticon_install_dir>\Server\Tomcat\CcServer\cdd
Object translation errors due to incorrect Vocabulary external name mappings 1. External names mapped incorrectly 2. External data types specified incorrectly 3. ALL entities must be mapped, even those with all transient attributes
TEST YOURSELF
Answers are provided in Appendix D. 187. Troubleshooting is based on the principle that Rulesheets behave the same way when tested in Studio as when executed on ___________.
Page 212
188. The first step in troubleshooting a suspected rule problem is to reproduce the behavior in a Studio _________ (test) 189. If the Rulesheet executes correctly in Studio, then where does the problem most likely occur? 190. Which of the following problems requires you to contact Corticon Support for help? Fatal Error Null Pointer Exception Reactor Error Expired License
191. The specific rule where execution behavior begins acting abnormally is called the _____________. 192. True or False. When a rule fires, some of its Actions may execute and some may not. 193. What Studio tools help you to identify the Rulesheets breakpoint? 194. A dark gray-colored Rulesheet box within a Ruleflow indicates that the Rulesheet has been __________. 195. A disabled rule: a. executes in a Studio Test but not on the Server b. executes on the Studio but not in a Studio Test c. executes in both Studio Tests and on the Server d. executes neither in a Studio Test nor on the Server 196. Where is the Server loglevel setting located? 197. To produce a more detailed Server log file, what loglevel setting should be enabled? 198. True or False. The Server license file needs to be located everywhere the Corticon Server is installed. 199. If you are reporting a possible Studio bug to Corticon Support, what minimum information is needed to troubleshoot? 200. Which of the following cannot be disabled? a. a Condition row
Rule Modeling Guide b. an Action row c. a Filter row d. a leaf of the Scope tree e. a Noncondition row (i.e., an Action row in Column 0) f. a rule column g. a Rulesheet h. a Ruleflow
Page 213
Page 214
In this scenario, each Condition has a set of 2 possible values: person is 45 or older: person is a smoker: persons risk rating:
{true, false} {true, false}
high
Note that we have only filled in a single value of risk rating, because the business rule above only covers a single scenario: where age >= 45 and smoker = true. A Completeness Check quickly identifies the remaining 3 scenarios:
Page 215
Completing the truth table and the Rulesheet requires the definition of 2 additional business rules:
and updating the truth table, we recognize the classic AND Boolean function.
age >= 45 smoker risk rating
Once the basic truth table framework has been established in the Rulesheet by the Completeness Checker in other words, all logical combinations of Conditions have been explicitly entered as separate columns in the Rulesheet we can alter the outcomes to implement other standard Boolean constructions. For example, the NAND construction has the following truth table:
Page 216
NAND
age >= 45 smoker risk rating
Also known as Not And, this construction is shown in the following Rulesheet:
Page 217
OR
age >= 45 smoker risk rating
Page 218
XOR
Using Exclusive Or logic, riskRating is high whenever the age or smoker test, but not both, is satisfied. This construction is shown in the following Rulesheet:
age >= 45
smoker
risk rating
Page 219
NOR
Also known as Not Or, this construction is shown in the following Rulesheet:
age >= 45 smoker risk rating
Page 220
XNOR
Also known as Exclusive NOR, this construction is shown in the following Rulesheet:
age >= 45 smoker risk rating
Page 221
Notice that the extended transient attribute packDate is colored orange in the Vocabulary tree. XML response messages created by Server will not contain the packDate attribute.Appendix C: Answers to Test Yourself Questions
Page 222
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
Page 223
3.
4. 5.
6.
7. 8. 9.
10. Attributes
Rule Modeling Guide 11. Boolean, DateTime, Decimal, Integer, String 12. blue and yellow 13. orange and yellow
Page 224
14. An Extended Transient Vocabulary term is used when the term is needed to hold a temporary value that is not required to be stored in external data. 15. Associations are bidirectional by default 16. cardinality 17. 18. 19. Target.source.attribute 20. target 21.
22.
Page 225
23. identify terms, separate terms, assemble and relate terms, diagram vocabulary remove answer from question 24. a 25. operators 26. Rule Language Guide 27. False. Custom Data Types must be based on the 7 base data types. They extend the 7 base data types. 28. b. May match other Custom Data Type Names 29. True 30. value < 10 31. True 32. No 33. Airbus 34. Attribute values are pre-populated in pulldowns based on the enumerated values. 35. Allow you to re-use entities by bundling or creating a sub-set within the vocabulary. (technically equivalent to packages in Java or namespaces in XML.)
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 226
38. All entities have native attributes, but Bicyle = 100% native, the others have 1 native attribute each and 3 inherited. Entities with inherited attributes = MountainBike, RoadBike,
TandemBike
Page 227
49. The Award entity could be split into two separate entities, or an attribute could be added to Award to identify the type of award. 50. Using roles helps to clarify rule context. 51. unique 52. True 53. all examples shown are Boolean expressions 54. can use Movie if it is the root term, or DVD.movie if DVD is the root term The root term can either be Movie or DVD no conditions in the rule prevent either one from being the root term 55. can use Movie.dVD if Movie is the root term, or DVD if it is the root term The root term can either be Movie or DVD no conditions in the rule prevent either one from being the root term 56. False. Both Movie and DVD terms in this example are root terms with no relationship to each other. 57. Once for the Movie satisfying the rule conditions and its associated DVD 58. Twice: once for each DVD (i.e. the cross product of the DVDs and the Movie satisfying the rule conditions) 59. a. High b. Low c. Low for each DVD d. Twice: once for each DVD e. Four: each of the 2 rules fired 2 times f. cross product g. no, each rule should only fire once for the DVD associated with the Movie h. change the Movie and DVD terms to share the same scope, starting either with Movie as the root term (Movie and Movie.dVD) or DVD as the root term (DVD and DVD.movie)
Page 228
60. False. Aliases are only required to be used in certain circumstances, but they can be used at any time and provide a good way of simplifying rule expressions. 61. Scope is another way of defining a specific context or perspective in the Vocabulary 62. be updated 63. False. Each alias must be unique and cannot have the same spelling as any term in the Vocabulary.
Rule Modeling Guide c. the special word other cant be used as a range endpoint. d. the range contains overlaps between 5 and 10, but this is acceptable in v5. e. the range contains an overlap at 10, but this is acceptable in v5. f. this is an incomplete set and should be {red, green, blue, other} g. the range contains overlaps between 3 and 15, but this is acceptable in v5.
Page 229
74. False. The term other may not be used in Action row Values sets since Actions can only assign specific values.
75. The Rulesheet would be modeled as shown above. 76. True 77. False. Nonconditional rules are governed by Preconditions on the same Rulesheet only if they share the same scope as the Preconditions.
Page 230
COLLECTIONS
jump to questions 78. Children of a Parent entity are also known as elements of a collection. 79. False. A collection can be comprised of root-level entities. 80. True 81. True 82. Refer to the Rule Language Guide for a full list and description of all collection operators. 83. Rule Language Guide 84. Order total is equal to the sum of the line item prices on the order. 85. items 86. one-to-many (1->*) 87. It is not an acceptable replacement since the use of any collection operator requires that the collection be represented by an alias. 88. set the navigability of the association between Order and LineItem to Order->lineItem. In other words, make the association one-directional from Order to LineItem. 89. Optional, Convenient 90. A collection alias is not required in this case because no collection operator is being applied to the collection. 91. forAll 92. exists 93. a. aroles ->size > 3 where aroles is an alias for Actor.roles b. mdvd ->isEmpty where mdvd is an alias for Movie.dVD
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 231
c. mdextras ->exists(deletedScenes=T) where mdextras is an alias for Movie.dVD.extras d. mgglobes ->exists(win=T) where mgglobes is an alias for Movie.goldenGlobe e. mroles ->size > 15 where mroles is an alias for Movie.roles f. mdvd.quantityAvailable ->sum >= 100 where mdvd is an alias for Movie.dVD g. mdvd.quantityAvailable ->sum < 2 where mdvd is an alias for Movie.dVD h. mdsuppliers ->size > 1 where mdsuppliers is an alias for Movie.dVD.supplier 94. Actor, Distributor, DVDExtras 95. Actor, Movie 96. The ->forAll operator tests whether all elements of a collection satisfy a condition. The ->exists operator tests whether at least one element of a collection satisfies a condition. 97. The ->notEmpty operator tests whether a collection is not empty, meaning there is at least one element in the collection. The ->isEmpty operator tests whether a collection is empty, meaning there are no elements in the collection. 98. To ensure that the system knows precisely which collection (or copy) you are referring to in your rules, its necessary to use a unique alias to refer to each collection.
Rule Modeling Guide a. Integer b. String c. Boolean d. Decimal e. Boolean f. Boolean g. Boolean 103. a. valid b. invalid c. valid d. valid e. valid f. invalid g. valid 104. The part of Studio that checks for syntactical problems is called the Parser.
Page 232
105. False. Although the Parser in Studio is very effective at finding syntactical errors, it is not perfect and cant anticipate all possible combinations of the rule language. 106. This Filter tests if the difference between the current year and the year a movie was released is more than 10 years. 107. This Condition tests if the total quantity of DVDs available divided by the number of DVD versions of a movie is less than or equal to 50,000 or greater than 50,000. This same calculation could be performed by using the ->avg operator by itself. 108. If the average quantity available of a DVD is greater than 50,000 for a movie that is more than 10 years old, then flag the movie with a warning. 109. a. False b. False
Page 233
Page 234
Rule Modeling Guide 139. Movie 1; DVD 1; Oscars 1, 2, 3, 4, 5 140. Movie 1; DVD 1; Oscars 1, 2 141. none 142. none 143. Movie 1; DVD 1; Oscars 1, 2, 3, 4, 5 144. Movie 1; DVD 1; Oscars 1, 2, 3, 4, 5 145. Movie 1; DVD 1; Oscars 1, 2, 3, 4, 5 146. none 147. Movie 1; DVD 1; Oscars 1, 2, 3, 4, 5 148. none 149. Movie 1; DVD 1 150. Movie 1; DVD 1; Oscars 1, 2, 3, 4, 5
Page 235
Page 236
156. Type of customer: {Platinum, Gold, Silver, Bronze} and spend amount: {25000..50000, (50000..75000], (75000..10000], >100000}. Depending on how the rules are modeled, one of these values sets will be part of a Condition and should be completed with the special word other. 157. These parameters may be maintained in the values sets of an individual Rulesheet, which is easy to perform, but makes reuse more difficult. They may be maintained as Custom Data Types (Enumerated) in the Vocabulary, which makes reuse easier.
Page 237
167. Yes. One rule can override multiple other rules by holding the Ctrl key to multi-select overrides from the drop-down. 168. No, overrides are not transitive and must be specified directly between all applicable rules. 169. No, rules created by the Completeness Checker may be comprised of combinations of Conditions that cannot or should not occur in real data. In those cases, rules for such combinations may not make sense at all. 170. A dash specifies that the Condition should be ignored for this rule. 171. False. The Expansion Tool merely expands a Rulesheet so that all sub-rules are visible. The results can be reversed by using the Collapse Tool. 172. True. It may be reversible using Undo, or by manually removing redundant sub-rules after expansion. 173. 64 (4 x 4 x 4) 174. It is not necessary to assign actions for a rule column if that combination of conditions cannot or should not exist in real data. We recommend disabling columns added by the Completeness Check that you determine need no Actions. 175. They may be disabled, deleted, or just left as-is with no Actions (but this last option is not recommended since it will still cause activity which can impact performance). 176. Compression Tool 177. The compression performed by the Completeness Checker is designed to reduce a large set of missing rules into the smallest set of non-overlapping columns, while the compression performed by the Compression Tool is designed to reduce the number of rules into the smallest set of general rules (i.e. create columns with the most dashes). 178. Even very large databases may still not contain all possible combinations of data necessary to verify Rulesheet completeness. In short, they may be incomplete themselves. 179. Renumber the rules and potentially ask you to consolidate Rule Statements if duplicate row numbers result from the renumbering.
Page 238
180. Subsumation occurs when the Compression Tool detects that a more general rule expression includes the logic of a more specific rule expression. In this case, the more specific rule can be removed.
TROUBLESHOOTING RULESHEETS
jump to questions 187. Troubleshooting is based on the principle that Rulesheets behave the same way when tested in Studio as when executed on Server 188. The first step in troubleshooting a suspected rule problem is to reproduce the behavior in a Studio Test. 189. In the integration with Corticon Server. 190. All of them! 191. The specific rule where execution behavior begins acting abnormally is called the breakpoint. 192. True. In v5, partial rule firing is allowed. 193. Disabling Rulesheets; Filters, Nonconditions, Conditions, Action rows; or rule columns 194. A dark gray-colored Rulesheet tab indicates that Rulesheet has been disabled.
Rule Modeling Guide 195. d 196. loglevel is located in CcCommon.properties inside CcConfig.jar. 197. loglevel should be set to INFO 198. True.
Page 239
199. Vocabulary (.ecore), Rulesheet (.ers), and a Ruletest (.ert) and the Ruleflow (.erf) if any. We also need to know the Studio version youre using. 200. d and h
CORTICON
Business Rules Modeling Studio 5.2 Rule Language Guide
Page i
TABLE OF CONTENTS
Table of Contents ........................................................................................................................................................i Preface ........................................................................................................................................................................1 Intended Audience .................................................................................................................................................1 Corticon Business Rules Management Technical Publications ..............................................................................1 Documentation Conventions .................................................................................................................................1 Reading the PDF File ..............................................................................................................................................1 Introduction ................................................................................................................................................................2 Overview of the Corticon Rule Language...............................................................................................................2 Rule Structure ....................................................................................................................................................2 Basic Data Types ................................................................................................................................................2 Truth Values .......................................................................................................................................................3 Collection Operators ..........................................................................................................................................3 Language Operators...........................................................................................................................................3 Generic Business Vocabulary......................................................................................................................................4 Rule Operators ...........................................................................................................................................................5 Organization ...........................................................................................................................................................5 Icons .......................................................................................................................................................................5 Tool Tips .................................................................................................................................................................6 Usage Restrictions ..................................................................................................................................................7 Rule Operator Summaries by Category ......................................................................................................................8 General Terms ........................................................................................................................................................8 Literals................................................................................................................................................................8 Functions............................................................................................................................................................8 Attribute Operators ...............................................................................................................................................9 Boolean ..............................................................................................................................................................9 DateTime............................................................................................................................................................9 Date................................................................................................................................................................. 13 Time ................................................................................................................................................................ 16 Decimal ........................................................................................................................................................... 19 Integer ............................................................................................................................................................. 22 String ............................................................................................................................................................... 25 Entity/Collection Operators ................................................................................................................................ 27 Entity ............................................................................................................................................................... 27 Collection ........................................................................................................................................................ 28 Sequence......................................................................................................................................................... 30 Rule Operators Sorted Alphabetically ..................................................................................................................... 32 Absolute Value......................................................................................................................................................... 33 Add Numbers ........................................................................................................................................................... 34
1/13/2012
Page ii
Add Strings............................................................................................................................................................... 36 Add Days .................................................................................................................................................................. 37 Add Hours ................................................................................................................................................................ 38 Add Minutes ............................................................................................................................................................ 39 Add Months ............................................................................................................................................................. 40 Add Seconds ............................................................................................................................................................ 41 Add Years ................................................................................................................................................................. 42 Associate Element(s) ............................................................................................................................................... 43 At ............................................................................................................................................................................. 45 Average .................................................................................................................................................................... 47 CellValue .................................................................................................................................................................. 48 Concatenate ............................................................................................................................................................ 52 Contains ................................................................................................................................................................... 54 Day ........................................................................................................................................................................... 56 Days Between .......................................................................................................................................................... 58 Day of Week ............................................................................................................................................................ 60 Day of Year .............................................................................................................................................................. 62 Decrement ............................................................................................................................................................... 63 Disassociate Element(s) ........................................................................................................................................... 65 Divide ....................................................................................................................................................................... 66 Div ............................................................................................................................................................................ 68 Ends With ................................................................................................................................................................ 69 Equals used as an Assignment .............................................................................................................................. 70 Equals used as a Comparison ............................................................................................................................... 72 Equals Ignoring Case ................................................................................................................................................ 74 Equals Strings only ................................................................................................................................................ 75 Exists ........................................................................................................................................................................ 77 Exponent.................................................................................................................................................................. 79 False ......................................................................................................................................................................... 81 First .......................................................................................................................................................................... 83 Floor......................................................................................................................................................................... 85 For All....................................................................................................................................................................... 86
1/13/2012
Page iii
Greater Than............................................................................................................................................................ 88 Greater Than Or Equal To ........................................................................................................................................ 90 Hour ......................................................................................................................................................................... 92 Hours Between ........................................................................................................................................................ 94 Increment ................................................................................................................................................................ 96 Index Of ................................................................................................................................................................... 98 Is Empty ................................................................................................................................................................. 100 Iterate .................................................................................................................................................................... 102 Last ........................................................................................................................................................................ 104 Less Than ............................................................................................................................................................... 106 Less Than Or Equal To............................................................................................................................................ 108 Logarithm (Base 10)............................................................................................................................................... 110 Logarithm (Base x) ................................................................................................................................................. 112 Lowercase .............................................................................................................................................................. 114 Maximum Value .................................................................................................................................................... 116 Maximum Value (Collection) ................................................................................................................................. 118 Minimum Value ..................................................................................................................................................... 119 Minimum Value (Collection).................................................................................................................................. 121 Minute ................................................................................................................................................................... 122 Minutes Between .................................................................................................................................................. 123 Mod ....................................................................................................................................................................... 125 Month .................................................................................................................................................................... 126 Months Between ................................................................................................................................................... 128 Multiply ................................................................................................................................................................. 130 Natural Logarithm ................................................................................................................................................. 132 New........................................................................................................................................................................ 134 New Unique ........................................................................................................................................................... 136 Not ......................................................................................................................................................................... 138 Not Empty .............................................................................................................................................................. 140 Not Equal To .......................................................................................................................................................... 141 Now ....................................................................................................................................................................... 143 Null ........................................................................................................................................................................ 145
1/13/2012
Page iv
Other...................................................................................................................................................................... 147 Or ........................................................................................................................................................................... 149 Remove Element ................................................................................................................................................... 151 Replace Element(s) ................................................................................................................................................ 154 Round .................................................................................................................................................................... 156 Second ................................................................................................................................................................... 158 Seconds Between .................................................................................................................................................. 159 Size of String .......................................................................................................................................................... 161 Size Of Collection ................................................................................................................................................... 162 Sorted By ............................................................................................................................................................... 164 Sorted By Descending ............................................................................................................................................ 167 Starts With ............................................................................................................................................................. 170 Substring ................................................................................................................................................................ 172 Subtract ................................................................................................................................................................. 174 Sum ........................................................................................................................................................................ 176 Today ..................................................................................................................................................................... 178 To Date Casting a DateTime to a Date................................................................................................................ 180 To DateTime Casting a String to a DateTime ...................................................................................................... 181 To DateTime Casting a Date to a DateTime........................................................................................................ 182 To DateTime Casting a Time to a DateTime ....................................................................................................... 183 To DateTime Timezone Offset ............................................................................................................................ 184 To Decimal ............................................................................................................................................................. 185 To Integer .............................................................................................................................................................. 187 To String................................................................................................................................................................. 189 To Time Casting a DateTime to a Time ............................................................................................................... 190 Trend ..................................................................................................................................................................... 191 True........................................................................................................................................................................ 193 Uppercase .............................................................................................................................................................. 195 Week of Month ..................................................................................................................................................... 196 Week of Year ......................................................................................................................................................... 197 Year ........................................................................................................................................................................ 198 Years Between ....................................................................................................................................................... 200
1/13/2012
Page v
Special Syntax ........................................................................................................................................................ 201 Value Ranges ..................................................................................................................................................... 201 Numeric Value Ranges in Conditions ............................................................................................................ 201 Numeric Value Ranges in Filter Rows ........................................................................................................... 201 String Value Ranges in Condition Cells ......................................................................................................... 202 String Value Ranges in Filter Rows................................................................................................................ 202 DateTime, Date, and Time Value Ranges in Condition Cells......................................................................... 202 DateTime, Date, and Time Value Ranges in Filter Rows ............................................................................... 203 Inclusive & Exclusive Ranges ......................................................................................................................... 203 Overlapping Value Ranges ............................................................................................................................ 204 Using Value Sets in Condition Cells ................................................................................................................... 206 Embedding Attributes in Posted Rule Statements............................................................................................ 208 No expressions in Rule Statements .............................................................................................................. 209 Including Apostrophes in Strings ...................................................................................................................... 209 Advanced Collection Syntax .............................................................................................................................. 210 Step 1 ............................................................................................................................................................ 210 Step 2 ............................................................................................................................................................ 210 Step 3 ............................................................................................................................................................ 210 Step 4 ............................................................................................................................................................ 210 Statement Blocks .............................................................................................................................................. 211 Important Notes about Statement Blocks .................................................................................................... 212 Appendix A: Character Precedence: Unicode & Java Collator ............................................................................. 214 Appendix B: Arithmetic Operator Precedence ..................................................................................................... 218 Appendix C: DateTime Data Type ......................................................................................................................... 219 Formats or Masks.............................................................................................................................................. 219 Presentation and Persistence ........................................................................................................................... 219 Appendix D: Corticon Studio and Server 5.2 Product Documentation ............................................................... 220
1/13/2012
Page 1
PREFACE
INTENDED AUDIENCE
Rule Language Guide provides detailed information necessary to assist you in using the Corticon Rule Language to build rules in Studio. This guide is intended for use by technical business analysts and application developers. This document assumes that you are familiar with the Studio and its usage. For assistance in using Studio, refer to Studios Online Help or Studio Quick Reference Guide.
DOCUMENTATION CONVENTIONS
Studio documentation uses the following conventions: Document names are shown in bold face italic type: Rule Modeling Guide Screen, Window, and button names are shown in bold face type: Custom Setup screen Important information such as Notes, Tips and Warnings are shown in this color scheme: The Complete setup option is automatically selected. Hyperlinks are underlined and shown in blue: the cursor changes to a hand: Introduction File names and user-defined information are shown in this font and color: Installing.pdf
1/13/2012
Page 2
INTRODUCTION
OVERVIEW OF THE CORTICON RULE LANGUAGE
Graphical modeling languages and tools (UML, ER, ORM, for example) are not sufficiently precise for specifications. Additional constraints on the objects in the model must also be defined. While natural languages are easily used by individuals without a programming background, they are often ambiguous. On the other hand, formal programming languages are precise, but not easily used by business analysts and other non-programmers. The Corticon Rule Language has been developed to resolve this dilemma. Based on the Object Constraint Language (OCL, an extension of the Universal Modeling Language specification 1.1), the Corticon Rule Language (CRL) is designed to enable non-programmers to express rules clearly and precisely without the use of procedural programming languages. More information on OCL may be found at www.uml.org.
Rule Structure
In traditional programming languages (or logic systems), most rules are expressed via IF/THEN structures. The IF clause contains a conditional expression and the THEN clause contains actions the rule should perform if all conditions have been met. This IF/THEN structure is expressed as Conditions and Actions in the Rulesheet user interface of Studio. For more information on building and organizing rules in Studio, see the Basic Tutorial for Corticon Studio Modeling Rules.
1/13/2012
Page 3
In this guide, the data types Integer and Decimal are often referred to by the generic term <Number>. Wherever <Number> is used, either Integer or Decimal data types may be used. Syntax such as <DateTime> indicates that data must conform to the data type shown in angle brackets (<..>). For this example, you might enter 9/13/2001 2:00:00 PM EST. Do not type the angle brackets themselves. See Appendix C for further details on formatting DateTime, Date, and Time information.
Truth Values
This guide uses the notation <Expression> to refer to some combination of terms from the Vocabulary that resolves or evaluates to a single truth value. A truth value is the Boolean value (true or false) assigned to an expression upon evaluation by the rule engine. For example, the expression Patient.name=John has a truth value of true whenever the patients name is John. If it is not John, then the truth value of this expression is false.
Collection Operators
Many of the operators provided in the CRL deal exclusively with collections of entities. When using collection operators, the expression must use aliases to represent the collection(s) operated on by the collection operator(s). A complete discussion of aliases is included in the Rule Modeling Guide. Reminders are included throughout this manual wherever collection operators are referenced.
Language Operators
CRL operators can be grouped into various classifications as shown in the following tables. Each operator is subsequently described in detail in the Language Reference section of this document. This section includes a detailed description of the operator, its syntax, usage restrictions, and a real example in a Studio Rulesheet.
1/13/2012
Page 4
1/13/2012
Page 5
RULE OPERATORS
ORGANIZATION
Rule Operators are classified based on the data type(s) of the terms to which the operator may be applied (known as the operand), as shown in Figure 2:
ICONS
Rule Operators are assigned icons which provide the user with information about their usage. The following table describes these icons: Icon Where Found
General, Literals category General, Functions category Operators, Boolean category Operators, all categories
Purpose
indicates special values or constants indicates system values that are automatically retrieved upon rule execution. this special unary operator icon is used only with not indicates the operator uses a period . to attach to its operand. Most operators with this icon typically fell into the previous function category. indicates the operator is used between two operands. Most operators with this icon typically fell into the previous comparison category.
Examples null, true, other now, today not day, round, contains equals, multiply
1/13/2012
Page 6
sum, size
see Appendix
TOOL TIPS
In Studio, moving the mouse over a Vocabulary operator and pausing, or hovering for a moment, will cause a dynamic tool tip text box to display. This tool tip contains information about operator syntax, return data type, and description, all of which are supplied in more detail in this Guide. For questions not answered by the tool tip, refer to the detailed operator descriptions in this Guide. Figure 3 shows a typical tool tip for the date operator .monthsBetween:
1/13/2012
Page 7
USAGE RESTRICTIONS
Figure 4 and Figure 5 show the general usage restrictions for the various types of Vocabulary terms depending on where they are used in a Rulesheet. This table indicates, for example, that entities (terms from the Business Vocabulary) may be used in any section of the Rulesheet. Rule Operators, on the other hand, are restricted to only 3 sections. Note: some operators have specific restrictions that vary from this general table please see each operators usage restrictions for details of these exceptions. Rulesheet Section
Name Scope Filter Rows Condition Rows Condition Cells Actions Rows Action Cells Rule Statements
Rulesheet Section #
Literals Functions Operators Data Values Terms
7
Figure 5 - Sections of Rulesheet: Numbers Correlate with Table Above
1/13/2012
Page 8
GENERAL TERMS
Literal Terms may be used in any section of the Rulesheet, except Scope and Rule Statements. Exceptions to this general statement exist see individual literals for detailed usage restrictions.
Literals
Name Null null none The null value corresponds to one of three different scenarios: True true or T False false or F Other other CellValue cellValue any cellValue is a variable whose value is determined by the rule Column that executes any When included in a conditions Values set, other represents any value not explicitly included in the set, including null. Boolean Represents the Boolean value false Boolean Represents Boolean value true the absence of an attribute in a Ruletest scenario the absence of data for an attribute in a Ruletest scenario an object that has a value of null Syntax Returned Data Type Description
Functions
Name Now Syntax Returned Data Type Description
1/13/2012
Page 9
Returns the current system date and time when the rule is executed.
ATTRIBUTE OPERATORS
The operators summarized in the tables below may be applied to attributes only. They are listed by attribute datatype.
Boolean
Name Syntax Returned Data Type Description
Equals (used as a comparison) <Expression1> = <Expression2> Equals (used as an assignment) <Boolean1> = <Expression1> Not Equal To <Expression1> <> <Expression2> Boolean Returns a value of true if <Expression1> does not have the same truth value as <Expression2> Boolean Assigns the truth value of <Expression1> to <Boolean1> Boolean Returns a value of true if <Expression1> has the same value as <Expression2>.
Or <Expression1> or <Expression2> or Boolean Returns a value of true if either <Expression1> or <Expression2> evaluates to true.
Not not <Expression> Boolean Returns the negation of the truth value of <Expression>
DateTime
Note: A DateTime data type must contain both date information and time information. Applying a DateTime operator to a DateTime attribute should always produce a result. Be sure to use the data type that suits your needs.
1/13/2012
Page 10
Equals (used as a comparison) <DateTime1> = <DateTime2> Boolean Returns a value of true if <DateTime1> is the same as <DateTime2>, including both the Date and the Time portions
Equals (used as an assignment) <DateTime1> = <DateTime2> Not Equal To <DateTime1> <> <DateTime2> Less than <DateTime1> < <DateTime2> Greater than <DateTime1> > <DateTime2> Less than or Equal to <DateTime1> <= <DateTime2> Greater than or Equal to <DateTime1> >= <DateTime2> Year <DateTime>.year Month <DateTime>.month Day <DateTime>.day Hour Integer Returns the day portion of <DateTime> as an Integer between 1 and 31 Integer Returns the month in <DateTime> as an Integer between 1 and 12 Integer Returns the century/year portion of <DateTime> as a four digit Integer Boolean Returns a value of true if <DateTime1> is greater than or equal to <DateTime2> Boolean Returns a value of true if <DateTime1> is less than or equal to <DateTime2> Boolean Returns a value of true if <DateTime1> is greater than or equal to <DateTime2> Boolean Returns a value of true if <Date1> is less than <Date2> Boolean Returns a value of true if <DateTime1> does not equal <DateTime2> DateTime Assigns the value of <DateTime2> to <DateTime1>
1/13/2012
Page 11
Returns the hour portion of <DateTime>. The returned value is based on a 24-hour clock.
Minute <DateTime>.min Integer Returns the minute portion of <DateTime> as an Integer between 0 and 59
Second <DateTime>.sec Integer Returns the seconds portion of <DateTime> as an Integer between 0 and 59
Add years <DateTime>.addYears(<Integer>) Add months <DateTime>.addMonths(<Integer>) Add days <DateTime>.addDays(<Integer>) Add hours <DateTime>.addHours(<Integer>) Date Adds the number of hours in <Integer> to the number of hours in the Time portion of <DateTime> Date Adds the number of days in <Integer> to the number of days in <DateTime> Date Adds the number of months in <Integer> to the number of months in <DateTime> Date Adds the number of years in <Integer> to the number of years in <DateTime>
Add minutes <DateTime>.addMinutes(<Integer>) Date Adds the number of minutes in <Integer> to the number of minutes in the Time portion of <DateTime>
Add seconds <DateTime>.addSeconds<Integer>) Date Adds the number of seconds in <Integer> to the number of seconds in the Time portion of <DateTime>
Years between
1/13/2012
Page 12
Returns the Integer number of years between <DateTime1> and <Date2>. This function returns a positive number if <DateTime2> is later than <DateTime1>.
Months between <DateTime1>.monthsBetween(<DateTim e2>) Integer Returns the Integer number of months between <DateTime1> and <DateTime2>. If the month and year portions of <DateTime1> and <DateTime2> are the same, the result is zero. This function returns a positive number if <DateTime2> is later than <DateTime1>.
Days between <DateTime1>.daysBetween(<DateTime2> ) Integer Returns the Integer number of days between <DateTime1> and <DateTime2>. If the two dates differ by less than a full 24-hour period, the value is zero. This function returns a positive number if <DateTime2> is later than <DateTime1>.
Hours between <DateTime1>.hoursBetween(<DateTime2 >) Integer Returns the Integer number of hours between <DateTime1> and <DateTime2>. If the two dates differ by less than a full hour, the value is zero. This function returns a positive number if <DateTime2> is later than <DateTime1>.
Minutes between <DateTime1>.minsBetween(<DateTime2 >) Integer Returns the Integer number of minutes between <DateTime1> and <DateTime2>. This function returns a positive number if <DateTime2> is later than <DateTime1>.
Seconds between <DateTime1>.secsBetween(<DateTime2> ) Integer Returns the Integer number of seconds between <DateTime1> and <DateTime2>. This function returns a positive number if <DateTime2> is later than <DateTime1>.
Day of Week
1/13/2012
Page 13
Returns an Integer corresponding to day of the week, with Sunday equal to 1, in <DateTime>.
Week of Year <DateTime>.weekOfYear Integer Returns an Integer from 1 to 52, equal to the week number within the year in <DateTime>
Day of Year <DateTime>.dayOfYear Integer Returns an Integer from 1 to 366, equal to the day number within the year in <DateTime>
Week of Month <DateTime>.weekOfMonth Integer Returns an Integer from 1 to 6, equal to the week number within the month in <DateTime> or <Date>. A week begins on Sunday and ends on Saturday.
To Date <DateTime>.toDate To Time <DateTime>.toTime To String <DateTime>.toString String Converts DateTime to a String with date and time information Time Returns the time portion only of DateTime Date Returns the date portion only of DateTime
Date
Name Equals (used as a comparison) <Date1> = <Date2> Boolean Returns a value of true if < Date1> is the same as <Date2>, including both the Date and the Time portions Syntax Returned Data Type Description
1/13/2012
Page 14
Equals (used as an assignment) < Date1> = <Date2> Not Equal To < Date1> <> <Date2> Less than < Date1> < <Date2> Greater than < Date1> > <Date2> Less than or Equal to < Date1> <= <Date2> Greater than or Equal to < Date1> >= <Date2> Year <Date>.year Month <Date>.month Day <Date>.day Add years <Date>.addYears(<Integer>) Add months Date Adds the number of years in <Integer> to the number of years in <Date> Integer Returns the day portion of <Date> as an Integer between 1 and 31 Integer Returns the month in <Date> as an Integer between 1 and 12 Integer Returns the century/year portion of <Date> as a four digit Integer Boolean Returns a value of true if < Date1> is greater than or equal to <Date2> Boolean Returns a value of true if < Date1> is less than or equal to <Date2> Boolean Returns a value of true if < Date1> is greater than or equal to <Date2> Boolean Returns a value of true if <Date1> is less than <Date2> Boolean Returns a value of true if < Date1> does not equal <Date2> DateTime Assigns the value of <Date2> to < Date1>
1/13/2012
Page 15
Add days <Date>.addDays(<Integer>) Years between <Date1>.yearsBetween(<Date2>) Integer Returns the Integer number of years between <Date1> and <Date2>. This function returns a positive number if <Date2> is later than <Date1>. Date Adds the number of days in <Integer> to the number of days in <Date>
Months between <Date1>.monthsBetween(<Date2>) Integer Returns the Integer number of months between <Date1> and <Date2>. If the month and year portions of <Date1> and <Date2> are the same, the result is zero. This function returns a positive number if <Date2> is later than <Date1>.
Days between <Date1>.daysBetween(<Date2>) Integer Returns the Integer number of days between <Date1> and <Date2>. If the two dates differ by less than a full 24hour period, the value is zero. This function returns a positive number if <Date2> is later than <Date1>.
Day of Week <Date>.dayOfWeek Integer Returns an Integer corresponding to day of the week, with Sunday equal to 1, in <Date>.
Week of Year <Date>.weekOfYear Integer Returns an Integer from 1 to 52, equal to the week number within the year in <Date>
Day of Year
1/13/2012
Page 16
Returns an Integer from 1 to 366, equal to the day number within the year in <Date>
Week of Month <Date>.weekOfMonth Integer Returns an Integer from 1 to 6, equal to the week number within the month in <DateTime> or <Date>. A week begins on Sunday and ends on Saturday.
To String <Date>.toString To DateTime <Date>.toDateTime DateTime Returns a DateTime where the date portion is equal to the value of <Date> and the time portion is equal to 00:00:00 in the systems local timezone String Converts DateTime to a String with date and time information
To DateTime with Timezone Offset <Date>.toDateTime(<string>) DateTime Returns a DateTime where the date portion is equal to the value of <Date> and the time portion is equal to 00:00:00 in the timezone specified by the value of <string>
Time
Name Equals (used as a comparison) <Time1> = <Time2> Boolean Returns a value of true if <Time1> is the same as <Time2>, including both the Date and the Time portions Syntax Returned Data Type Description
Equals (used as an assignment) <Time1> = <Time2> DateTime Assigns the value of <Time2> to <Time1>
1/13/2012
Page 17
Returns the hour portion of <Time>. The returned value is based on a 24hour clock.
Minute <Time>.min Second <Time>.sec Integer Returns the seconds portion of <Time> as an Integer between 0 and 59 Adds the number of days in <Integer> to the number of days in <Time> Integer Returns the minute portion of <Time> as an Integer between 0 and 59
Date
Date
Adds the number of hours in <Integer> to the number of hours in the Time portion of <Time>
Add minutes
1/13/2012
Page 18
Adds the number of minutes in <Integer> to the number of minutes in the Time portion of <Time>
Add seconds <Time>.addSeconds<Integer>) Date Adds the number of seconds in <Integer> to the number of seconds in the Time portion of <Time>
Hours between <Time1>.hoursBetween(<Time2>) Integer Returns the Integer number of hours between <Time1> and <Time2>. If the two dates differ by less than a full hour, the value is zero. This function returns a positive number if <Time2> is later than <Time1>.
Minutes between <Time1>.minsBetween(<Time2>) Integer Returns the Integer number of minutes between <Time1> and <Time2>. This function returns a positive number if <Time2> is later than <Time1>.
Seconds between <Time1>.secsBetween(<Time2>) Integer Returns the Integer number of seconds between <Time1> and <Time2>. This function returns a positive number if <Time2> is later than <Time1>.
To String <Time>.toString To DateTime <Time>.toDateTime DateTime Returns a DateTime where the time portion is equal to the value of <Time> and the date portion is equal to the epoch. String Converts <Time> to a String with date and time information
1/13/2012
Page 19
Decimal
In this section, wherever the syntax includes <Number>, either Integer or Decimal data types may be used.
Name Syntax Returned Data Type Description
Equals (used as a comparison) <Number1> = <Number2> Equals (used as an assignment) <Number1> = <Number2> Not Equal To <Number1> <> <Number2> Less than <Number1> < <Number2> Greater than <Number1> > <Number2> Less than or Equal to <Number1> <= <Number2> Greater than or Equal to <Number1> >= <Number2> Add <Number1> + <Number2> Number Returns the sum of <Number1> and <Number2>. The resulting data type is the more expansive of either <Number1> or <Number2>. For example, if an Integer value is added to a Decimal value, the resulting value will be a Decimal. See Appendix B. Boolean Returns a value of true if <Number1> is greater than or equal to <Number2>. Boolean Returns a value of true if <Number1> is less than or equal to <Number2>. Boolean Returns a value of true if <Number1> is greater than <Number2>. Boolean Returns a value of true if <Number1> is less than <Number2>. Boolean Returns a value of true if <Number1> is not equal to <Number2>. Number Assigns the value of <Number2> to the value of <Number1>. Boolean Returns a value of true if <Number1> is the same as <Number2>.
Subtract
1/13/2012
Page 20
Subtracts <Number2> from <Number1>. The resulting data type is the more expansive of either <Number1> or <Number2>. See Appendix B.
Multiply <Number1> * <Number2> Number Returns the product of <Number1> and <Number2>. The resulting data type is the more expansive of either <Number1> or <Number2>. See Appendix B.
Divide <Number1> / <Number2> Number Divides <Number1> by <Number2>. The resulting data type is the more expansive of either <Number1> or <Number2>. See Appendix B.
Exponent <Number1> ** <Number2> Decimal Raises <Number1> to the power of <Number2>. The resulting data type is the more expansive of either <Number1> or <Number2>. See Appendix B.
Increment <Number1> += <Number2> Number Increments <Number1> by <Number2>. The data type of <Number1> must accommodate the addition of <Number2>. See Appendix B.
Decrement <Number1> -= <Number2> Number Decrements <Number1> by the value of <Number2>. The data type of <Number1> must accommodate the addition of <Number2>. See Appendix B.
Absolute Value <Decimal>.absVal Decimal Returns the absolute value of <Number>. If the <Number> is positive, <Number> itself is returned; if <Number> is negative, the negation of <Number> is returned.
Floor
1/13/2012
Page 21
Returns the largest (closest to positive infinity) Integer that is not greater than <Number>.
Round <Decimal>.round Round(n) <Decimal>.round(<Integer>) To Integer <Decimal>.toInteger Integer Converts an attribute of type Decimal to type Integer. Decimals will have the decimal point and fraction (those digits to the right of the decimal point) truncated. Decimal Rounds <Decimal> to the number of decimal places specified by <Integer>. Decimal Rounds <Decimal> to the nearest Integer.
To String <Decimal>.toString Maximum Value <Decimal>.max(<Number>) Minimum Value <Decimal>.min(<Number>) Logarithm (base 10) <Decimal>.log Logarithm (base x) <Decimal1>.log(<Decimal2>) Decimal Returns the logarithm (base <Decimal2>) of <Decimal1>. <Decimal1> may not be zero. Decimal Returns the logarithm (base 10) of <Decimal>. <Decimal> may not be zero. Number Returns the lesser of <Decimal> and <Number>. Number Returns the greater of <Decimal> and <Number>. String Converts an attribute of type Decimal to type string
Natural Logarithm <Decimal>.ln Decimal Returns the natural logarithm (base e) of <Decimal>. <Decimal> may not be zero.
1/13/2012
Page 22
Integer
In this section, wherever the syntax includes <Number>, either Integer or Decimal data types may be used.
Name Syntax Returned Data Type Description
Equals (used as a comparison) <Number1> = <Number2> Equals (used as an assignment) <Number1> = <Number2> Number Assigns the value of <Number2> to the value of <Number1>. The data type of <Number1> must be expansive enough to accommodate <Number2>. Boolean Returns a value of true if <Number1> is the same as <Number2>.
Not Equal To <Number1> <> <Number2> Less than <Number1> < <Number2> Greater than <Number1> > <Number2> Less than or equal to <Number1> <= <Number2> Greater than or equal to <Number1> >= <Number2> Add <Number1> + <Number2> Number Returns the sum of <Number1> and <Number2>. The resulting data type is the more expansive of either <Number1> or <Number2>. For example, if an Integer value is added to a Decimal value, the resulting value will be a Decimal. See Appendix B. Boolean Returns a value of true if <Number1> is greater than or equal to <Number2>. Boolean Returns a value of true if <Number1> is less than or equal to <Number2>. Boolean Returns a value of true if <Number1> is greater than <Number2>. Boolean Returns a value of true if <Number1> is less than <Number2>. Boolean Returns a value of true if <Number1> is not equal to <Number2>.
1/13/2012
Page 23
Subtracts <Number2> from <Number1>. The resulting data type is the more expansive of either <Number1> or <Number2>. See Appendix B.
Multiply <Number1> * <Number2> Number Returns the product of <Number1> and <Number2>. The resulting data type is the more expansive of either <Number1> or <Number2>. See Appendix B.
Divide <Number1> / <Number2> Number Divides <Number1> by <Number2>. The resulting data type is the more expansive of either <Number1> or <Number2>. See Appendix B.
Exponent <Number1> ** <Number2> Number Raises <Number1> to the power of <Number2>. The resulting data type is the more expansive of either <Number1> or <Number2>. See Appendix B.
Increment <Number1> += <Number2> Number Increments <Number1> by <Number2>. The data type of <Number1> must accommodate the addition of <Number2>. See Appendix B.
Decrement <Number1> -= <Number2> Number Decrements <Number1> by the value of <Number2>. The data type of <Number1> must accommodate the addition of <Number2>. See Appendix B.
Absolute Value <Integer>.absVal Number Returns the absolute value of <Integer>. If the < Integer > is positive, < Integer > itself is returned; if < Integer > is negative, the negation of < Integer > is returned.
1/13/2012
Page 24
Returns the whole number of times that <Integer2> fits within <Integer1> - any remainder is discarded.
Mod <Integer1>.mod(<Integer2>) Integer Returns the whole number remainder that results from dividing <Integer1> by <Integer2>. If the remainder is a fraction, then zero is returned.
Logarithm (base 10) <Integer>.log Logarithm (base x) <Integer>.log(<Decimal>) Natural Logarithm <Integer>.ln Decimal Returns the natural logarithm (base e) of <Number>. <Integer> may not be zero. Decimal Returns the logarithm (base <Decimal>) of <Integer>. <Integer> may not be zero. Decimal Returns the logarithm (base 10) of <Integer>. <Integer> may not be zero.
1/13/2012
Page 25
String
Name Syntax Returned Data Type Description
Equals (used as a comparison) <String1> = <String2> Boolean Returns a value of true if <String1> exactly matches <String2>. Both case and length are examined to determine equality. See Appendix A for character precedence.
Equals (used as an assignment) <String1> = <String2> Not Equal to <String1> <> <String2> Less than <String1> < <String2> Boolean Returns a value of true if <String1> is less than <String2>. See Appendix A for character precedence. Boolean Returns a value of true if <String1> is not equal to <String2>. String Assigns the value of <String2> to the value of <String1>.
Greater than <String1> > <String2> Boolean Returns a value of true if <String1> is greater than <String2>. See Appendix A for character precedence.
Less than or equal to <String1> <= <String2> Boolean Returns a value of true if <String1> is less than or equal to <String2>. See Appendix A for character precedence.
Greater than or equal to <String1> >= <String2> Boolean Returns a value of true if <String1> is greater than or equal to <String2>. See Appendix A for character precedence.
Adding Strings <String1> + <String2> Size String Concatenates <String1> to <String2>. Alternative syntax.
1/13/2012
Page 26
Converts the value in <String> to data type DateTime ONLY if all characters in <String> correspond to a valid DateTime mask (format)
To Decimal <String>.toDecimal Decimal Converts an attribute of type String to data type Decimal ONLY if all characters in <String> are numeric and contain not more than one decimal point. If any nonnumeric characters are present (other than a single decimal point or leading minus sign), no value is returned.
To Integer <String>.toInteger Integer Converts an attribute of type String to type Integer ONLY if all characters in <String> are numeric. If any non-numeric characters are present, no value is returned.
Substring <String>.substring(<Integer1>,<Integer2> ) Equals Ignoring Case String Returns that portion of <String> between character positions <Integer1> and Integer2>.
1/13/2012
Page 27
Returns a value of true if the <String1> begins with the characters specified in <String2>.
Ends with <String1>.endsWith(<String2>) Boolean Evaluates the contents of <String1> and returns a value of true if the String ends with the characters specified in <String2>.
Contains <String1>.contains(<String2>) Boolean Evaluates the contents of <String1> and returns a value of true if it contains the exact characters defined by <String2>
Equals <String1>.equals(<String2>) Index Of <String1>.indexOf(<String2) Integer Returns the beginning character position number of <String2> within <String1>, if <String1> contains <String2>. If it does not, the function returns a value of zero. Boolean Returns a value of true if <String1> is the same as <String2>.
ENTITY/COLLECTION OPERATORS
The operators summarized in the tables below may be applied to entities or collections only.
Entity
Name New <Entity>.new[<Expression1>,] Entity Creates a new instance of <Entity>. Expressions (optional) in square brackets [..] must be written in the form: attribute = value. Syntax Returned Data Type Description
1/13/2012
Page 28
Creates a new instance of <Entity> only if the instance created is unique as defined by optional <Expression1>,
Remove <Entity>.remove Entity Deletes the entity from memory and from the resultant XML document.
Collection
Name Replace element(s) <Collection1> = <Collection2> <Collection1> = <Entity> modifies a collection replaces all elements in <Collection1> with elements of <Collection2> or with <Entity>, provided the new associations are allowed by the Business Vocabulary. Syntax Returned Data Type Description
Associate element(s) <Collection1> += <Collection2> <Collection1> += <Entity> modifies a collection Associates all elements of <Collection2> or <Entity> with <Collection1>. Every <Collection> must be expressed as a unique alias.
Disassociate element(s) <Collection1> -= <Collection2> modifies a collection Disassociates all elements of <Collection2> from <Collection1>. Does not delete the disassociated elements. Every <Collection> must be expressed as a unique alias.
Is empty <Collection> ->isEmpty Not empty <Collection> ->notEmpty Exists Boolean Returns a value of true if <Collection> contains at least one element. Boolean Returns a value of true if <Collection> contains no elements
1/13/2012
Page 29
Returns a value of true if <Expression> holds true for at least one element of <Collection>
For all <Collection> ->forAll(<Expression>) Boolean Returns a value of true if every <Expression> holds true for every element of <Collection>
Sorted by <Collection> ->sortedBy(<Attribute>) converts a collection into a sequence Sequences the elements of <Collection> in ascending order, using the value of <Attribute> as the index. <Collection> must be expressed as a unique alias.
Sorted by Descending <Collection>->sortedByDesc (<Attribute>) converts a collection into a sequence Sequences the elements of <Collection> in descending order, using the value of <Attribute> as the index. <Collection> must be expressed as a unique alias.
Iterate <Collection> ->iterate(<Expression>) Executes <Expression> for every element in <Collection>. <Collection> must be expressed as a unique alias.
Size of collection <Collection> ->size Integer Returns the number of elements in <Collection>. <Collection> must be expressed as a unique alias.
Sum <Collection.attribute> ->sum Number Sums the values of the specified <attribute> for all elements in <Collection>. <attribute> must be a numeric data type.
Average
1/13/2012
Page 30
Averages all of the specified attributes in <Collection>. <Collection> must be expressed as a unique alias. <attribute> must be a numeric data type
Minimum <Collection.attribute> ->min Number Returns the lowest value of <attribute> for all elements in <Collection>. <attribute> must be a numeric data type
Maximum <Collection.attribute> ->max Number Returns the highest value of <attribute> for all elements in <Collection>. <attribute> must be a numeric data type
Sequence
Sequence operators act on collections that have already been ordered by a sorting operator (see sortedBy and sortedByDesc). In other words, sequence operators operate on collections that have been turned into sequences. The notation <Sequence> used below, is shorthand for a completed sorting operation. For example: <Collection> -> sortedBy(<Attribute>) produces a <Sequence>, in this case the elements of <Collection> arranged in ascending order using <Attribute> as the index. This <Sequence> can then be used with one of the sequence operators described below. The design of the Object Constraint Language (upon which the CRL is based), allows for the chaining of operators, so a collection operator and a sequence operator can be used in the same expression to produce a sequence and identify a particular element of that sequence in the same step. For example: <Entity.attribute1> = <Collection> sortedBy(<Attribute3>) first.<Attribute2> performs the following: 1. sorts <Collection> in ascending order according to <Attribute3>, turning it into a <Sequence> 2. locates the first element of <Sequence> 3. reads the value of <Attribute2> of the first element 4. assigns the value of <Attribute2> of the first element to <Entity.attribute1>
Name Syntax Returned Data Type Description
1/13/2012
Page 31
First <Sequence> ->first Entity Returns the first element of <Sequence>. <Sequence> must be expressed as a unique alias.
Last <Sequence> ->last Entity Returns the last element of <Sequence>. <Sequence> must be expressed as a unique alias.
Trend <Attribute> -> <Sequence>.trend String Returns a 4-character string, INCR, DECR, CNST, or NONE depending on the trend of <Attribute> within <Sequence>.
1/13/2012
Page 32
1/13/2012
Page 33
ABSOLUTE VALUE
SYNTAX
<Number>.absVal
DESCRIPTION
Returns the absolute value of <Number>. If the <Number> is positive, <Number> itself is returned; if <Number> is negative, the negation of <Number> is returned.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .absVal to produce the absolute value of decimal2 and assign it to
decimal1
SAMPLE RULETEST
A sample Ruletest provides decimal2 values for three different scenarios of Entity1. Input and Output panels are shown below.
1/13/2012
Page 34
ADD NUMBERS
SYNTAX
<Number1> + <Number2>
DESCRIPTION
Adds <Number1> to <Number2>. The resulting data type is the more expansive of those of <Number1> and <Number2>. For example, if you are adding an Integer value and a Decimal value, the resulting value will be a Decimal. See Appendix B.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 applies. No special exceptions.
1/13/2012
Page 35
SAMPLE RULETEST
A sample Ruletest provides an integer1 value of 300 which is added to the value of decimal2 and assigned to the value of decimal1 for three instances of Entity1. Input and Output panels are shown below.
1/13/2012
Page 36
ADD STRINGS
SYNTAX
<String1> + <String2>
DESCRIPTION
Adds <String1> to <String2>. This has the same effect as using the .concat operator. However, the + syntax permits concatenation of more than two String values without nesting, as shown in the example below.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses the add strings operation to add the String AAA to string2 to ZZZ and assign the result to string1
SAMPLE RULETEST
1/13/2012
Page 37
ADD DAYS
SYNTAX
<DateTime>.addDays(<Integer>) <Date>.addDays(<Integer>)
DESCRIPTION
Adds the number of days in <Integer> to the number of days in <DateTime> or <Date>.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .addDays to add 45 days to the value of dateTime2 and assign the result to dateTime1.
SAMPLE RULETEST
A sample Ruletest provides values of dateTime2 for three instances of Entity1. Input and Output panels are shown below. Notice the month portion of dateTime1 also changes accordingly.
1/13/2012
Page 38
ADD HOURS
SYNTAX
<DateTime>.addHours(<Integer>) <Time>.addHours(<Integer>)
DESCRIPTION
Adds the number of hours in <Integer> to the number of hours in the Time portion of <DateTime> or <Time>.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .addHours to add 30 hours to the value of dateTime2 and assign the result to dateTime1.
SAMPLE RULETEST
A sample Ruletest provides values of dateTime2 for three instances of Entity1. Input and Output panels are shown below.
1/13/2012
Page 39
ADD MINUTES
SYNTAX
<DateTime>.addMinutes(<Integer>) <Time>.addMinutes(<Integer>)
DESCRIPTION
Adds the number of minutes in <Integer> to the number of minutes in the Time portion of <DateTime> or <Time>.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .addMinutes to add 90 minutes to the value of dateTime2 and assign the result to dateTime1.
SAMPLE RULETEST
A sample Ruletest provides values of dateTime2 for three instances of Entity1. Input and Output panels are shown below.
1/13/2012
Page 40
ADD MONTHS
SYNTAX
<DateTime>.addMonths(<Integer>) <Date>.addMonths(<Integer>)
DESCRIPTION
Adds the number of months in <Integer> to the number of months in <DateTime> or <Date>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .addMonths in a Nonconditional rule to add 10 months to the value of dateTime2 and assign the result to dateTime1.
SAMPLE RULETEST
A sample Ruletest provides values of dateTime2 for three instances of Entity1. Input and Output panels are shown below. Notice the year portion of dateTime1 also changes accordingly.
1/13/2012
Page 41
ADD SECONDS
SYNTAX
<DateTime>.addSeconds(<Integer>) <Time>.addSeconds(<Integer>)
DESCRIPTION
Adds the number of seconds in <Integer> to the number of seconds in the Time portion of <DateTime> or <Time>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .addSeconds in a Nonconditional rule to add 90 seconds to the value of timeOnly2 and assign the result to timeOnly1.
SAMPLE RULETEST
A sample Ruletest provides values of timeOnly2 for three instances of Entity1. Input and Output panels are shown below. Notice how the time wraps around to the beginning of the day, even though Time data type does not include date information.
1/13/2012
Page 42
ADD YEARS
SYNTAX
<DateTime>.addYears(<Integer>) <Date>.addYears(<Integer>)
DESCRIPTION
Adds the number of years in <Integer> to the number of years in the Date portion of <DateTime> or <Date>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .addYears in a Nonconditional rule to add 10 years to the value of dateOnly2 and assign the result to dateOnly1.
SAMPLE RULETEST
A sample Ruletest provides values of dateOnly2 for three instances of Entity1. Input and Output panels are shown below.
1/13/2012
Page 43
ASSOCIATE ELEMENT(S)
SYNTAX
<Collection1> += <Collection2> <Collection1> += <Entity>
DESCRIPTION
Associates all elements of <Collection2> or a single element named <Entity> with <Collection1>, provided such an association is allowed by the Business Vocabulary. Every <Collection> must be expressed as a unique alias. If the cardinality of the association between the parent entity of <Collection> and the <Entity> being added is one-to-one (a straight line icon beside the association in the Rule Vocabulary), then this associate element syntax is not used. Instead, replace element syntax is used, since the collection can contain only one element, and any element present will be replaced by the new element.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: associate element may only be used in Action Rows (section 5 in Figure 5).
RULESHEET EXAMPLE
The following Rulesheet uses associate element to associate an element of collection2 to collection1 when boolean1 value of any element in collection2 is true. Note that the Action is not associating all elements in collection2 with collection1, only those elements within collection2 that satisfy the condition.
1/13/2012
Page 44
SAMPLE RULETEST
A sample Ruletest provides two examples of Entity2 with boolean1 values, and a single Entity1. Input and Output panels are described below:
1/13/2012
Page 45
AT
SYNTAX
<Sequence> ->at(<Integer>).<Attribute1>
DESCRIPTION
Returns the value of <Attribute1> for the element at position <Integer> in <Sequence>. Another operator, such as sortedBy, must be used to transform a <Collection> into a <Sequence> before at may be used. <Sequence> must be expressed as a unique alias. See Advanced Collection Syntax for more examples of usage. <Attribute1> may be of any data type.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses at(2) to identify the second element of the sequence created by applying sortedBy to collection1. Once identified, the value of the string1 attribute belonging to this second element is evaluated. If the value of string1 is Joe, then boolean1 attribute of Entity1 is assigned the value of true.
1/13/2012
Page 46
SAMPLE RULETEST
A sample Ruletest provides a collection of three elements, each with a decimal1 value. Input and Output panels are shown below.
1/13/2012
Page 47
AVERAGE
SYNTAX
<Collection.attribute> ->avg
DESCRIPTION
Averages the values of all of the specified attributes in <Collection>. <Collection> must be expressed as a unique alias. <attribute> must be a numeric data type.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses avg to average the integer1 values of all elements in collection2, then assigns the resulting value to decimal1 in Entity1. Note the use of the alias collection2 to represent the collection of Entity2 elements associated with Entity1.
SAMPLE RULETEST
A sample Ruletest provides integer1 values for three elements in collection2. The following illustration shows Input and Output panels:
1/13/2012
Page 48
CELLVALUE
SYNTAX
Various, see Examples below
DESCRIPTION
When used in an expression, cellValue is essentially a variable whose value is determined by the rule Column that executes. Using cellValue in a Condition or Action expression eliminates the need for multiple, separate Rows to express the same logic.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: cellValue may only be used in Condition and Action Rows (sections 3 and 5 in Figure 5).
RULESHEET EXAMPLE 1
This sample Rulesheet uses cellValue to increment integer1 by the amount in the Action Cell of the rule Column that fires. An equivalent Rulesheet which does not use cellValue is also shown for comparison purposes.
1/13/2012
Page 49
SAMPLE RULETEST 1
A sample Ruletest provides two examples of boolean1. The following table shows Input and Output panels.
RULESHEET EXAMPLE 2
The following Rulesheet uses cellValue to evaluate whether collection1 includes at least one member with a string1 value of the entry in the Conditions Cell of the rule Column.
1/13/2012
Page 50
SAMPLE RULETEST 2
A sample Ruletest provides three examples of collection1 each member has a string1 value. Input and Output panels are shown below.
1/13/2012
Page 51
RULESHEET EXAMPLE 3
The following Rulesheet uses cellValue to create a new member of collection1 with string1 value equal to the Action Cell in the rule Column that fires.
SAMPLE RULETEST 3
A sample Ruletest provides string1 values for three examples. The following illustration shows Ruletest Input and Output panels. Notice that each collection1 already has one element prior to executing the test. This simply ensures the results will be displayed in hierarchical style.
1/13/2012
Page 52
CONCATENATE
SYNTAX
<String1>.concat(<String2>)
DESCRIPTION
Concatenates <String1> to <String2>, placing <String2> at the end of <String1>
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .concat to create string1 by combining string1 and string2 from Entity1.entity2.
1/13/2012
Page 53
SAMPLE RULETEST
A sample Ruletest provides three examples of string1 and string2. Input and Output panels are shown below.
1/13/2012
Page 54
CONTAINS
SYNTAX
<String1>.contains(<String2>)
DESCRIPTION
Evaluates <String1> and returns a value of true if it contains or includes the exact (case-sensitive) characters specified in <String2>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE 1
The following Rulesheet uses .contains to evaluate whether string1 includes the characters silver and assigns a value to boolean1 for each outcome.
1/13/2012
Page 55
SAMPLE RULETEST 1
A sample Ruletest provides string1 values for three examples. Input and Output panels are shown below. Note case sensitivity in these examples. Posted messages are not shown.
1/13/2012
Page 56
DAY
SYNTAX
<DateTime>.day <Date>.day <DateTime>.day
DESCRIPTION
Returns the day portion of <DateTime> or <Date> as an Integer between 1 and 31.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .day to assign a value to string1 and post a message.
1/13/2012
Page 57
SAMPLE RULETEST
A sample Ruletest provides dateTime1 values for three examples. Input and Output panels are shown below. Posted messages are not shown.
1/13/2012
Page 58
DAYS BETWEEN
SYNTAX
<DateTime1>.daysBetween(<DateTime2>) <Date1>.daysBetween(<Date2>)
DESCRIPTION
Returns the Integer number of days between DateTimes or Dates. This function calculates the number of milliseconds between the date values and divides that number by 86,400,000 (the number of milliseconds in a day). Any fraction is truncated, leaving an Integer result. If the two dates differ by less than a full 24-hour period, the value returned is zero. A positive Integer value is returned when <DateTime2> occurs after <DateTime1>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .daysBetween to determine the number of days that have elapsed between dateTime1 and dateTime2, compare it to the values in the Condition cells, and assign a value to string1.
1/13/2012
Page 59
SAMPLE RULETEST
A sample Ruletest provides dateTime1 and dateTime2 for two examples. Input and Output panels are shown below.
1/13/2012
Page 60
DAY OF WEEK
SYNTAX
<DateTime>.dayOfWeek <Date>.dayOfWeek
DESCRIPTION
Returns an Integer between 1 and 7, corresponding to the table below:
returned Integer 1 2 3 4 day of the week Sunday Monday Tuesday Wednesday returned Integer 5 6 7 day of the week Thursday Friday Saturday
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .dayOfWeek to assign a value to boolean1.
1/13/2012
Page 61
SAMPLE RULETEST
1/13/2012
Page 62
DAY OF YEAR
SYNTAX
<DateTime>.dayOfYear <Date>.dayOfYear
DESCRIPTION
Returns an Integer from 1 to 366, equal to the day number within the year.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .dayOfYear to assign a value to string1.
SAMPLE RULETEST
1/13/2012
Page 63
DECREMENT
SYNTAX
<Number1> -= <Number2>
DESCRIPTION
Decrements <Number1> by the value of <Number2>. The data type of <Number1> must accommodate the subtraction of <Number2>. In other words, an Integer may not be decremented by a Decimal without using another operator (such as .toInteger or .floor) to first convert the Decimal to an Integer.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: decrement may only be used in Action Rows (section 5 in Figure 5).
RULESHEET EXAMPLE
This sample Rulesheet uses decrement to reduce integer1 by the value of integer2 when boolean1 is false.
1/13/2012
Page 64
SAMPLE RULETEST
A sample Ruletest provides three examples of integer1, integer2, and boolean1. Input and Output panels are shown below.
1/13/2012
Page 65
DISASSOCIATE ELEMENT(S)
SYNTAX
<Collection1> -= <Collection2>
DESCRIPTION
Disassociates all elements of <Collection2> from <Collection1>. Elements are not deleted, but once disassociated from <Collection1>, they are moved to the root level of the data. <Collection1> must be expressed as a unique alias. Contrast this behavior with remove, which deletes elements entirely.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: disassociate element may only be used in Action Rows (section 5 in Figure 5).
RULESHEET EXAMPLE
This sample Rulesheet removes those elements from collection1 whose boolean1 value is true.
SAMPLE RULETEST
A sample Ruletest provides a collection with three elements. The illustration shows Input and Output panels:
1/13/2012
Page 66
DIVIDE
SYNTAX
<Number1> / <Number2>
DESCRIPTION
Divides <Number1> by <Number2>. The resulting data type is the more expansive of those of <Number1> and <Number2>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses divide to divide decimal1 by integer1 and assign the resulting value to
decimal2
1/13/2012
Page 67
SAMPLE RULETEST
A sample Ruletest provides decimal1 and integer1 values for three examples. Input and Output panels are shown below.
1/13/2012
Page 68
DIV
SYNTAX
<Integer1>.div(<Integer2>)
DESCRIPTION
Returns an Integer equal to the whole number of times that <Integer2> divides into <Integer1>. Any remainder is discarded.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .div to calculate the whole number of times 3 divides into integer2, and assigns the resulting value to integer1.
SAMPLE RULETEST
A sample Ruletest provides integer2 values for three examples. Input and Output panels are shown below.
1/13/2012
Page 69
ENDS WITH
SYNTAX
<String1>.endsWith(<String2>)
DESCRIPTION
Evaluates <String1> and returns a value of true if it ends with the characters specified in <String2>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .endsWith to evaluate whether string1 ends with the characters ville and assigns a different value to string2 for each outcome.
SAMPLE RULETEST
A sample Ruletest provides string1 values for three examples. Input and Output panels are shown below.
1/13/2012
Page 70
DESCRIPTION
Boolean DateTime* Number Assigns the truth value of <Expression1> to <Boolean1>. Assigns the value of <DateTime2> to <DateTime1>. Assigns the value of <Number2> to <Number1>. Automatic casting1 will occur when assigning an Integer data type to a Decimal data type. To assign a Decimal value to an Integer value, use the .toInteger operator. Assigns the value of <String2> to <String1>.
String
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: equals used as an assignment may only be used in Action Rows (section 5 in Figure 5).
RULESHEET EXAMPLE
The following Rulesheet uses equals twice: in an Action row to assign a value to decimal1, and in an Action row to assign a value to string1 based on the value of boolean1.
1/13/2012
Page 71
SAMPLE RULETEST
A sample Ruletest provides two examples of boolean1. Input and Output panels are shown below:
1/13/2012
Page 72
DESCRIPTION
Boolean DateTime* Number String Returns a value of true if <Expression1> is the same as <Expression2>. Returns a value of true if <DateTime1> is the same as <DateTime2>, including both the Date and the Time portions Returns a value of true if <Number1> is the same as <Number2>. Different numeric data types may be compared in the same expression. Returns a value of true if <String1> is the same as <String2>. Both case and length are examined to determine equality. Studio uses the ISO character precedence in comparing String values. See Appendix A.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses equals to Ruletest whether decimal1 equals decimal2, and assign a value to string1 based on the result of the comparison.
1/13/2012
Page 73
SAMPLE RULETEST
A sample Ruletest provides two examples. Input and Output panels are shown below:
1/13/2012
Page 74
DESCRIPTION
Returns a value of true if <String1> is the same as <String2>, irrespective of case.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .equalsIgnoreCase to compare the values of string1 and string2, and assign a value to boolean1 based on the results of the comparison.
SAMPLE RULETEST
A sample Ruletest provides the plane type for three sets of string1 and string2. Input and Output panels are shown below. Notice how these results differ from those shown in the .equals example.
1/13/2012
Page 75
DESCRIPTION
Returns a value of true if <String1> is exactly the same as <String2>, including character case. This is alternative syntax to equals (used as a comparison).
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .equals to compare the contents of string1 and string2, and assign a value to boolean1 as a result.
1/13/2012
Page 76
SAMPLE RULETEST
A sample Ruletest provides three sets of string1 and string2. Input and Output panels are shown below. Notice how these results differ from those shown in the .equalsIgnoreCase example.
1/13/2012
Page 77
EXISTS
SYNTAX
<Collection> ->exists(<Expression1>,<Expression2>,) <Collection> ->exists(<Expression1> or <Expression2> or )
DESCRIPTION
Returns a value of true if <Expression> holds true for at least one element of <Collection>. <Collection> must be expressed as a unique alias. Multiple <Expressions> are optional, but at least one is required. Both AND (indicated by commas between <Expressions>) and OR syntax (indicated by or between <Expressions>) are supported within the parentheses (..). However, take care to ensure invariant expressions are not inadvertently created. For example:
<Collection> -> exists(integer1=5, integer1=8)
will always evaluate to false because no integer1 value can be both 5 AND 8 simultaneously.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses exists to check for the existence of an element in collection1 whose string1 value equals New, and assigns a value to decimal1 based on the results of the test. Note the use of unique alias collection1 to represent the collection of Entity2 associated with Entity1.
1/13/2012
Page 78
SAMPLE RULETEST
A sample Ruletest provides 2 separate collections of Entity2 elements and Entity1.decimal1 values. Input and Output panels are shown below.
1/13/2012
Page 79
EXPONENT
SYNTAX
<Number1> ** <Number2>
DESCRIPTION
Raises <Number1> by the power of <Number2>. The resulting data type is the more expansive of those of <Number1> and <Number2>. To find a root, <Number2> should be expressed as a fraction. For example, the square root is expressed as 0.5
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses exponent to raise integer1 and integer2 by the power of 2 and 0.5, respectively, and assign the resulting value to decimal1 and decimal2, respectively.
1/13/2012
Page 80
SAMPLE RULETEST
A sample Ruletest provides decimal1 and integer1 values for three examples.
1/13/2012
Page 81
FALSE
SYNTAX
false or F
DESCRIPTION
Represents the Boolean value false. Recall from discussion of truth values that an <expression> is evaluated for its truth value, so the expression Entity1.boolean1=false evaluates to true only when boolean1=false. But since boolean1 is Boolean and has a truth value all by itself without any additional syntax, we could simply state not Entity1.boolean1, with the same effect. Many examples in the documentation use explicit syntax like boolean1=true or boolean2=false for clarity and consistency, even though boolean1 or not boolean2 are equivalent, respectively, to the explicit syntax.
USAGE RESTRICTIONS
The Literals row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses false in a Filter row to test whether boolean1 is false, and perform the Nonconditional computation if it is. As discussed above, the alternative expression not Entity1.boolean1 is logically equivalent.
1/13/2012
Page 82
SAMPLE RULETEST
A sample Ruletest provides three examples. Assume decimal2=10.0 and integer1=5 for all examples. Input and Output panels are shown below:
1/13/2012
Page 83
FIRST
SYNTAX
<Sequence> ->first.<attribute1>
DESCRIPTION
Returns the value of <attribute1> of the first element in <Sequence>. Another operator, such as sortedBy, must be used to transform a <Collection> into a <Sequence> before first may be used. <Sequence> must be expressed as a unique alias. See Advanced Collection Syntax for more examples of usage. <attribute1> may be of any data type.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses first to identify the first element of the sequence created by applying sortedBy to collection1. Once identified, the value of the string1 attribute belonging to this first element is evaluated. If the value of string1 is Joe, then boolean1 attribute of Entity1 is assigned the value of true.
1/13/2012
Page 84
SAMPLE RULETEST
A sample Ruletest provides a collection of three elements, each with a decimal1 value. Input and Output panels are shown below.
1/13/2012
Page 85
FLOOR
SYNTAX
<Decimal>.floor
DESCRIPTION
Returns the Integer closest to zero from <Decimal>. .floor may also be thought of as a truncation of <Decimal>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The Rulesheet uses .floor to assign Integer values to integer1 that are closer to zero than the input decimal1 values.
SAMPLE RULETEST
A sample Ruletest provides three decimal1 values. Input and Output panels are shown below: Notice how these results differ from those shown in the Round example.
1/13/2012
Page 86
FOR ALL
SYNTAX
<Collection> ->forAll(<Expression1>, <Expression2>,) <Collection> ->forAll(<Expression1> or <Expression2> or )
DESCRIPTION
Returns a value of true if every <Expression> holds true for every element of <Collection>. <Collection> must be expressed as a unique alias. Multiple <Expressions> are optional, but at least one is required. Both AND (indicated by commas between <Expressions>) and OR syntax (indicated by or between <Expressions>) is supported within the parentheses (..). However, take care to ensure invariant expressions are not inadvertently created. For example:
<Collection> -> forAll(integer1=5, integer1=8)
will always evaluate to false because no single integer1 value can be both 5 AND 8 simultaneously, let alone all of them.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses forAll to check for the existence of an element in collection1 whose string1 value equals New, and assigns a value to decimal1 based on the results of the test. Note the use of unique alias collection1 to represent the collection of Entity2 associated with Entity1.
1/13/2012
Page 87
SAMPLE RULETEST
A sample Ruletest provides 2 separate collections of Entity2 elements and Entity1.decimal1 values. The following illustration shows Input and Output panels
1/13/2012
Page 88
GREATER THAN
SYNTAX
DateTime* Number String <DateTime1> > <DateTime2> <Number1> > <Number2> <String1> > <String2>
DESCRIPTION
DateTime* Returns a value of true if <DateTime1> is greater than or equal to <DateTime2>. This is equivalent to <DateTime1> occurring after <DateTime2> Returns a value of true if <Number1> is greater than <Number2>. Different numeric data types may be compared in the same expression. Returns a value of true if <String1> is greater than <String2>. Studio uses Appendix A to determine character precedence.
Number String
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies, with the following exception: greater than may also be used in Conditional Value Sets & Cells (section 5 of Figure 5).
RULESHEET EXAMPLE
The following Rulesheet uses greater than to test whether string1 is greater than string2, and assign todays date to dateTime1 if it is. See today for an explanation of this literal term.
1/13/2012
Page 89
SAMPLE RULETEST
A sample Ruletest provides three examples. Input and Output panels are shown below:
1/13/2012
Page 90
DESCRIPTION
DateTime* Returns a value of true if <DateTime1> is greater than or equal to <DateTime2>. This is equivalent to <DateTime1> occurring on or after <DateTime2> Returns a value of true if <Number1> is greater than or equal to <Number2>. Different numeric data types may be compared in the same expression. Returns a value of true if <String1> is greater than or equal to <String2>. Studio uses Appendix A to determine character precedence.
Number String
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies, with the following exception: greater than or equal to may also be used in Conditional Value Sets & Cells (section 5 of Figure 5).
RULESHEET EXAMPLE
The following Rulesheet uses greater than or equal to to test whether string1 is greater than or equal to string2, and assign todays date to dateTime1 if it is. See today for an explanation of this literal term.
1/13/2012
Page 91
SAMPLE RULETEST
A sample Ruletest provides two examples. Input and Output panels are shown below:
1/13/2012
Page 92
HOUR
SYNTAX
<DateTime>.hour <Time>.hour
DESCRIPTION
Returns the hour portion of <DateTime> or <Time>. The returned value is based on a 24-hour clock. For example, 10:00 PM (22:00 hours) is returned as 22.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .hour to evaluate dateTime1 and assign the hour value to integer1.
1/13/2012
Page 93
SAMPLE RULETEST
A sample Ruletest provides three examples of dateTime1. Input and Output panels are shown below. Notice that the hour returned is dependent upon the timezone of the machine executing the rule. The hour returned is independent of the machine running the Ruletest and only depends on the locale/timezone of the data itself.
1/13/2012
Page 94
HOURS BETWEEN
SYNTAX
<DateTime1>.hoursBetween(<DateTime2>)
DESCRIPTION
Returns the Integer number of hours between any two DateTimes or Times. The function calculates the number of milliseconds between the two values and divides that number by 3,600,000 (the number of milliseconds in an hour). The decimal portion is then truncated. If the two dates differ by less than a full hour, the value is zero. This function returns a positive number if <DateTime2> is later than <DateTime1>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .hoursBetween to determine the number of hours that have elapsed between dateTime1 and dateTime2, compare it to the Values set, and assign a value to string1.
1/13/2012
Page 95
SAMPLE RULETEST
A sample Ruletest provides dateTime1 and dateTime2 for two examples. Input and Output panels are shown below.
1/13/2012
Page 96
INCREMENT
SYNTAX
<Number1> += <Number2>
DESCRIPTION
Increments <Number1> by the value of <Number2>. The data type of <Number1> must accommodate the addition of <Number2>. In other words, an Integer may not be incremented by a Decimal without using another operator (such .toInteger or .floor) to first convert the Decimal to an Integer.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: increment may only be used in Action Rows (section 5 in Figure 5).
RULESHEET EXAMPLE
This sample Rulesheet uses increment to increment integer1 by the value of integer2 when boolean1 is true.
1/13/2012
Page 97
SAMPLE RULETEST
A sample Ruletest provides three examples of integer1, integer2, and boolean1. Input and Output panels are shown below.
1/13/2012
Page 98
INDEX OF
SYNTAX
<String1>.indexOf(<String2>)
DESCRIPTION
Determines if <String2> is contained within <String1> and returns an Integer value equal to the beginning character position of the first occurrence of <String2> within <String1>. If <String1> does not contain <String2>, then a value of 0 (zero) is returned. This operator is similar to .contains but returns different results. A 0 result from .indexOf is equivalent to a false value returned by the .contains operator. If <String1> contains more than one occurrence of <String2>, .indexOf returns the first character position of the first occurrence. For example: If <String1> holds the String value Mississippi and <String2> holds the String value ss, then the .indexOf operator returns 3. The second occurrence of ss beginning at position 6 is not identified.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .indexOf to evaluate whether string1 includes the characters silver and assigns a value to integer1 corresponding to the beginning character position of the first occurrence.
1/13/2012
Page 99
SAMPLE RULETEST
A sample Ruletest provides string1 values for three examples. Input and Output panels are shown below. Notice sensitivity to case in example 1.
1/13/2012
Page 100
IS EMPTY
SYNTAX
<Collection> ->isEmpty
DESCRIPTION
Returns a value of true if <Collection> contains no elements (i.e., has no children). isEmpty does not check for an empty or null value of an attribute, but instead checks for existence of elements within the collection. As such, a unique alias must be used to represent the <Collection> being tested.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses isEmpty to determine if collection1 has any elements. Note the use of unique alias collection1 to represent the collection of Entity2 associated with Entity1.
1/13/2012
Page 101
SAMPLE RULETEST
A sample Ruletest provides two example collection1. The following illustration shows Input and Output panels
1/13/2012
Page 102
ITERATE
SYNTAX
<Collection> ->iterate(<Expression>)
DESCRIPTION
Executes <Expression> for every element in <Collection>. <Collection> must be expressed as a unique alias.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: iterate may only be used in Action Rows (section 5 in Figure 5).
RULESHEET EXAMPLE
This sample Rulesheet uses iterate to assign the value of test to string1 in every element in collection1 if the collection1 contains at least one element whose integer1 value is 5. See exists for more information on this operator.
SAMPLE RULETEST
A sample Ruletest provides three elements in collection1. Input and Output panels are shown below.
1/13/2012
Page 103
1/13/2012
Page 104
LAST
SYNTAX
<Sequence> ->last.<Attribute1>
DESCRIPTION
Returns the value of <Attribute1> of the last element in <Sequence>. Another operator, such as sortedBy, must be used to transform a <Collection> into a <Sequence> before last may be used. <Sequence> must be expressed as a unique alias. <Attribute1> may be of any data type. See Advanced Collection Syntax for more examples of usage.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses last to identify the last element of the sequence created by applying sortedBy to collection1. Once identified, the value of the string1 attribute belonging to this last element is evaluated. If the value of string1 is Joe, then boolean1 attribute of Entity1 is assigned the value of true.
1/13/2012
Page 105
SAMPLE RULETEST
A sample Ruletest provides a collection of three elements, each with a decimal1 value. Input and Output panels are shown below.
1/13/2012
Page 106
LESS THAN
SYNTAX
DateTime* Number String <DateTime1> < <DateTime2> <Number1> < <Number2> <String1> < <String2>
DESCRIPTION
DateTime* Number String Returns a value of true if <DateTime1> is less than <DateTime2>. This is equivalent to <DateTime1> occurring before <DateTime2> Returns a value of true if <Number1> is less than <Number2>. Different numeric data types may be compared in the same expression. Returns a value of true if <String1> is less than <String2>. Studio uses Appendix A to determine character precedence.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies, with the following exception: less than may also be used in Conditional Value Sets & Cells (section 5 of Figure 5).
RULESHEET EXAMPLE
The following Rulesheet uses less than to test whether string1 is less than string2, and assign todays date to dateTime1 if it is. See today for an explanation of this literal term.
1/13/2012
Page 107
SAMPLE RULETEST
A sample Ruletest provides two examples. Input and Output panels are shown below:
1/13/2012
Page 108
DESCRIPTION
DateTime* Number String Returns a value of true if <DateTime1> is less than or equal to <DateTime2>. This is equivalent to <DateTime1> occurring on or before <DateTime2> Returns a value of true if <Number1> is less than or equal to <Number2>. Different numeric data types may be compared in the same expression. Returns a value of true if <String1> is less than or equal to <String2>. Studio uses Appendix A to determine character precedence.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies, with the following exception: less than or equal to may also be used in Conditional Value Sets & Cells (section 5 of Figure 5).
RULESHEET EXAMPLE
The following Rulesheet uses less than or equal to to test whether string1 is less than or equal to string2, and assign todays date to dateTime1 if it is. See today for an explanation of this literal term.
1/13/2012
Page 109
SAMPLE RULETEST
A sample Ruletest provides two examples. Input and Output panels are shown below:
1/13/2012
Page 110
DESCRIPTION
Returns a Decimal value equal to the logarithm (base 10) of <Number>. If <Number> is equal to 0 (zero) an error is returned when the rule is executed.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .log to calculate the logarithm (base 10) of integer1 and assign it to decimal1.
SAMPLE RULETEST 1
A sample Ruletest provides results for three examples of integer1. Input and Output panels are shown below:
1/13/2012
Page 111
SAMPLE RULETEST 2
Another sample Ruletest for three examples of integer1 where one example is equal to zero (0). The resulting error is illustrated below. Notice that the error encountered in the 2nd example causes all Rulesheet execution to halt, leaving the 3rd example unprocessed.
1/13/2012
Page 112
LOGARITHM (BASE X)
SYNTAX
<Number>.log(<Decimal>)
DESCRIPTION
Returns a Decimal value equal to the logarithm (base <Decimal>) of <Number>. If <Number> is equal to 0 (zero) an error is returned when the rule is executed.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .log to calculate the logarithm (base 7.0) of integer1 and assign it to decimal1.
SAMPLE RULETEST 1
A sample Ruletest provides results for three examples of integer1. Input and Output panels are shown below:
1/13/2012
Page 113
SAMPLE RULETEST 2
Another sample Ruletest for three examples of integer1 where one example is equal to zero (0). The resulting error is illustrated below.
1/13/2012
Page 114
LOWERCASE
SYNTAX
<String>.toLower
DESCRIPTION
Converts all characters in <String> to lowercase characters.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toLower to convert string1 to lowercase, compare its value with string2, and assign a value to boolean1 based on the results of the comparison.
1/13/2012
Page 115
SAMPLE RULETEST
A sample Ruletest provides three examples of string1 and string2. Input and Output panels are shown below:
1/13/2012
Page 116
MAXIMUM VALUE
SYNTAX
<Number1>.max(<Number2>)
DESCRIPTION
Returns either <Number1> or <Number2>, whichever is greater.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .max to compare the values of decimal1 and decimal2, and integer1 and integer2, and posts a message based on their size relative to 5.0 and 8, respectively.
1/13/2012
Page 117
SAMPLE RULETEST
A sample Ruletest provides four examples, two using decimal1 and decimal2, and two using integer1 and integer2 as input data.
1/13/2012
Page 118
DESCRIPTION
Returns the highest value of <attribute> for all elements in <Collection>. <attribute> must be a numeric data type. <Collection> must be expressed as a unique alias.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses max to identify the highest value of decimal1 in all elements of collection1, then assign it to Entity1.decimal1.
SAMPLE RULETEST
A sample collection contains five elements, each with a value of decimal1.
1/13/2012
Page 119
MINIMUM VALUE
SYNTAX
<Number1>.min(<Number2>)
DESCRIPTION
Returns either <Number1> or <Number2>, whichever is smaller.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .min to compare the values of decimal1 and decimal2, and integer1 and integer2, and posts a message based on their size relative to 5.0 and 8, respectively
1/13/2012
Page 120
SAMPLE RULETEST
A sample Ruletest provides four examples, two using decimal inputs, and two using integers.
1/13/2012
Page 121
DESCRIPTION
Returns the lowest value of <attribute> for all elements in <Collection>. <attribute> must be a numeric data type. <Collection> must be expressed as a unique alias.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses min to identify the lowest value of decimal1 in all elements of collection1, then assign it to Entity1.decimal1.
SAMPLE RULETEST
A sample collection contains five elements, each with a value of decimal1.
1/13/2012
Page 122
MINUTE
SYNTAX
<DateTime>.min <Time>.min
DESCRIPTION
Returns the minute portion of <DateTime> or <Time> as an Integer between 0 and 59. This operator cannot be used with Date attributes because no time information is present.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .min to evaluate dateTime1 and assign the minute value to integer1.
SAMPLE RULETEST
A sample Ruletest provides three examples of dateTime1. Input and Output panels are shown below:
1/13/2012
Page 123
MINUTES BETWEEN
SYNTAX
<DateTime1>.minsBetween(<DateTime2>) <Time1>.minsBetween(<Time2>)
DESCRIPTION
Returns the Integer number of minutes between DateTimes or between Times. The function calculates the number of milliseconds between the two dates and divides that number by 60,000 (the number of milliseconds in a minute). The decimal portion is then truncated. If the two dates differ by less than a full minute, the returned value is zero. This function returns a positive number if <DateTime2> is later than <DateTime1>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .minsBetween to determine the number of minutes that have elapsed between dateTime1 and dateTime2, compare it to the Values set, and assign a value to string1.
1/13/2012
Page 124
SAMPLE RULETEST
A sample Ruletest provides dateTime1 and dateTime2 for two examples. Input and Output panels are shown below. Notice the different masks (formats) used for the DateTime data.
1/13/2012
Page 125
MOD
SYNTAX
<Integer1>.mod(<Integer2>)
DESCRIPTION
Returns the whole number remainder that results from dividing <Integer1> by <Integer2>. If the remainder is a fraction, then 0 (zero) is returned.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .mod to calculate the whole number remainder resulting from the division of integer2 by 3. The result is assigned to integer1.
SAMPLE RULETEST
A sample Ruletest provides three examples of integer2. Input and Output panels are shown below.
1/13/2012
Page 126
MONTH
SYNTAX
<DateTime>.month <Date>.month
DESCRIPTION
Returns the month in <DateTime> or <Date> as an Integer between 1 and 12.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .month to evaluate dateTime1 and dateOnly1 and assign the month value to integer1 and integer2, respectively.
SAMPLE RULETEST
A sample Ruletest provides three examples of dateTime1 or dateOnly1. Input and Output panels are shown below. The month returned is independent of the machine running the Ruletest and only depends on the locale/timezone of the data itself.
1/13/2012
Page 127
1/13/2012
Page 128
MONTHS BETWEEN
SYNTAX
<DateTime1>.monthsBetween(<DateTime2>) <Date1>.monthsBetween(<Date2>)
DESCRIPTION
Returns the Integer number of months between DateTimes or between Dates. The month and year portions of the date data are subtracted to calculate the number of elapsed months. The day portions are ignored. If the month and year portions are the same, the result is zero. This function returns a positive number if <DateTime2> is later than <DateTime1>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .monthsBetween to determine the number of months that have elapsed between dateTime1 and dateTime2, compare it to the values in the Condition Cells, and assign a value to string1.
1/13/2012
Page 129
SAMPLE RULETEST
A sample Ruletest provides dateTime1 and dateTime2 for two examples. Input and Output panels are shown below. Notice the variations in date masks (formats).
1/13/2012
Page 130
MULTIPLY
SYNTAX
<Number1> * <Number2>
DESCRIPTION
Multiplies <Number1> by <Number2>. The resulting data type is the more expansive of those of <Number1> and <Number2>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses multiply to multiply integer1 and integer2 and compare the result to
100
SAMPLE RULETEST
A sample Ruletest provides three examples of integer1 and integer2. Input and Output panels are shown below.
1/13/2012
Page 131
1/13/2012
Page 132
NATURAL LOGARITHM
SYNTAX
<Number>.ln
DESCRIPTION
Returns a Decimal value equal to the natural logarithm (base e) of <Number>. If <Number> is equal to 0 (zero), an error is returned when the rule is executed. This error will halt execution for all data present.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .ln to calculate the natural logarithm of decimal2 and assign it to decimal1.
SAMPLE RULETEST 1
A sample Ruletest provides results for three examples of decimal2. Input and Output panels are shown below:
1/13/2012
Page 133
SAMPLE RULETEST 2
Another sample Ruletest for three examples of decimal2 where one example is equal to zero (0). The resulting error is illustrated below:
1/13/2012
Page 134
NEW
SYNTAX
<Entity>.new[<Expression1>,<Expression2>]
DESCRIPTION
creates a new <Entity> with attribute values defined by optional <Expression>. Expressions (when present) should be written as assignments in the form: attribute = value. The attribute used in <Expression> (when present) must be an attribute of <Entity>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 does not apply. Special exceptions: new may only be used in Action Rows (section 5 in Figure 5). AND logic, expressed as commas between <Expressions>, is supported within the square brackets [..]. OR logic is not supported within the square brackets [..].
RULESHEET EXAMPLE
The following Rulesheet uses .new to create a new Entity2 element in collection1 when Entity1 has a string1 value equal to PO 123-ABC. An alias is not required by the .new operator, because it is possible to create a new entity at the root level, without inserting it into a collection. The collection alias used here is required by the += (Associate Element to collection) operator.
1/13/2012
Page 135
SAMPLE RULETEST
A sample Ruletest provides 2 collections of Entity1. Input and Output panels are illustrated below:
1/13/2012
Page 136
NEW UNIQUE
SYNTAX
<Entity>.newUnique[<Expression1>,<Expression2>]
DESCRIPTION
newUnique is an unusual operator in that it contains both action and condition logic. When an Action containing this operator is executed, a new <Entity> will be created only if no other entity exists with the characteristics defined by <Expression1> and <Expression2>, etc. <Expression1> and <Expression2> are optional. If no expression is present within the square brackets [..], the newUnique operator will create a new entity only if none currently exists in memory.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 does not apply. Special exceptions: newUnique may only be used in Action Rows (section 5 in Figure 5). AND logic, expressed as commas between <Expressions>, is supported within the square brackets [..]. OR logic is not supported within the square brackets [..].
RULESHEET EXAMPLE
The following Rulesheet uses .newUnique to create a new Entity2 element with string1=abc, and add it to collection1 only if no existing Entity2 already has string1=abc. A collection alias is not required by the .newUnique operator because it is possible to create a new entity at the root level, without inserting it into a collection. The collection alias used here is required by the += (Associate Element to collection) operator.
1/13/2012
Page 137
SAMPLE RULETESTS
Each of three sample tests provides different combinations of Entity1 and Entity2. Input and Output panels are illustrated below:
1/13/2012
Page 138
NOT
SYNTAX
not <Expression>
DESCRIPTION
Returns the negation of the truth value of <Expression>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies, with the following special exception: not may also be used in Conditional Cells.
RULESHEET EXAMPLE
The following Rulesheet uses not to negate the value of A in the Condition Cell of rule 2. Not may only be used in this manner if there is at least one other value (including other or null) present in the Condition Cells values drop-down list (i.e., there must be at least one alternative to the value negated by not).
1/13/2012
Page 139
SAMPLE RULETEST
A sample Ruletest provides three examples of string1. Input and Output panels are shown below:
1/13/2012
Page 140
NOT EMPTY
SYNTAX
<Collection> ->notEmpty
DESCRIPTION
Returns a value of true if <Collection> contains at least one element. notEmpty does not check for attribute values, but instead checks for the existence of elements within a collection. As such, it requires the use of a unique alias to represent the collection being tested.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses the notEmpty function to determine if collection1 has elements. Note the use of unique alias collection1 to represent the collection of Entity2 associated with Entity1.
SAMPLE RULETEST
A sample Ruletest provides two collections. The following illustration shows Input and Output panels
1/13/2012
Page 141
NOT EQUAL TO
SYNTAX
Boolean DateTime* Number String <Expression1> <> <Expression2> <DateTime1> <> <DateTime2> <Number1> <> <Number2> <String1> <> <String2>
DESCRIPTION
Boolean DateTime* Number String Returns a value of true if <Expression1> does not have the same truth value as <Expression2>. Returns a value of true if <DateTime1> does not equal <DateTime2>. This is equivalent to <DateTime1> not occurring on <DateTime2> Returns a value of true if <Number1> is not equal to <Number2>. Different numeric data types may be compared in the same expression. Returns a value of true if <String1> is not equal to <String2>. Studio uses Appendix A to determine character precedence.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses not equal to to test whether decimal1 equals decimal2, and assign a value to string1 based on the result of the comparison.
1/13/2012
Page 142
SAMPLE RULETEST
A sample Ruletest provides two examples. Input and Output panels are shown below:
1/13/2012
Page 143
NOW
SYNTAX
now
DESCRIPTION
Returns the current system date and time when the rule is executed. This DateTime value is assigned the first time now is used in a Decision Service (Rule Set), then remains constant until the Decision Service finishes execution, regardless of how many additional times it is used. This means that every rule in a Rule Set containing now will use the same DateTime value.
USAGE RESTRICTIONS
The Literals row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses now to determine how many hours have elapsed between now and dateTime1 (see .hoursBetween for more details on this operator), and assign a value to string1 based on the result.
SAMPLE RULETEST
A sample Ruletest provides two examples of dateTime1. Assume now is equal to Thursday, March 16, 2006 8:50:00 AM EST. Input and Output panels are shown below. Notice the variation in DateTime masks (formats).
1/13/2012
Page 144
1/13/2012
Page 145
NULL
SYNTAX
null
DESCRIPTION
The null value corresponds to one of three different scenarios: 1. the absence of an attribute in a Ruletest Input pane or request message 2. the absence of data for an attribute in a Ruletest (the value zero counts as data) 3. a business object (supplied by an external application) that has an instance variable of null A null value is different from an empty String (for String data types) or zero for numeric data types. An empty String is represented in Studio Ruletest as []. Any attribute value, including any empty strings, may be reset to null in a Ruletest by right-clicking the attribute and choosing select value to null. Mandatory attributes (property set in the Vocabulary) may not have a null value.
USAGE RESTRICTIONS
The Literals row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses null to test for the existence of a real value in decimal1, and assign a value to boolean1 as a result.
1/13/2012
Page 146
SAMPLE TEST
A sample Ruletest provides four examples of decimal1. Input and Output panels are illustrated below. Posted messages are not shown.
1/13/2012
Page 147
OTHER
SYNTAX
other
DESCRIPTION
When included in a conditions Values set (the drop-down list of values available in a Conditions Cell), other represents any value not explicitly included in the set, including null. If null is explicitly included in the Values set, then other does not include null.
USAGE RESTRICTIONS
The Literals row of the table in Figure 4 does not apply. Special exception: other may only be used in Condition Cells (section 4 of the Figure 5) because it is a non-specific value used in comparisons.
RULESHEET EXAMPLE
The following Rulesheet uses other to test the value of decimal1. If decimal1 has any value other than null, boolean1 is assigned the value of false.
1/13/2012
Page 148
SAMPLE TEST
A sample Ruletest provides three examples of decimal1. Ruletest Input and Output panels are shown below:
1/13/2012
Page 149
OR
SYNTAX
<Expression1> or <Expression2> or . OR may also be used with forAll and exists expressions
DESCRIPTION
Returns a value of true if either <Expression1> or <Expression2> evaluates to true. When used between two or more expressions in the Preconditions section, creates a compound filter for the Rulesheet that follows. See Rule Modeling Guide for details on using Preconditions as filters. OR is not available in the Conditions section because the logical OR construction is implemented using multiple Columns in the decision table, or by value sets in Conditions Cells.
USAGE RESTRICTIONS
The Literals row of the table in Figure 5 does not apply. Special exception: or may only be used in the Filters section of the Rulesheet to join 2 or more expressions, as shown above, or within forAll and exists expressions as described in those sections.
RULESHEET EXAMPLE
The following Rulesheet uses or to test the value of integer1, boolean1, and string1 to set the value of boolean2
1/13/2012
Page 150
SAMPLE TEST
A sample Ruletest provides three examples. Ruletest Input and Output panels are shown below:
1/13/2012
Page 151
REMOVE ELEMENT
SYNTAX
<Entity>.remove <Collection>.remove
DESCRIPTION
Removes <Entity> or removes elements from <Collection> and deletes it/them. If removing from a collection, then using a unique alias to represent the collection is optional since .remove is not a collection operator. If any elements in <Collection> have one-to-many associations with other entities, then those entities will also be deleted. When using .remove to delete elements of a collection, associated entities will not be removed. To remove a chain of associated entities, use .remove on each level of the association hierarchy, beginning with the last or lowest level and working up. For example of this behavior, see example 2, below.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: .remove may only be used in Action Rows (section 5 in Figure 5).
RULESHEET EXAMPLE
This Rulesheet uses the operator to remove elements from collection1 whose decimal1 value is greater than 5. Note the optional use of unique alias collection1 to represent the collection of Entity2 elements associated with Entity1.
1/13/2012
Page 152
SAMPLE TEST
A sample Ruletest provides a collection with two elements. The illustration showsRuletest Input and Output panels
RULESHEET EXAMPLE 2
This Rulesheet uses the operator to remove elements from Entity1.entity2 whose decimal1 value is greater than 5. Note no unique alias has been used to represent the collection of Entity2 elements associated with Entity1.
1/13/2012
Page 153
SAMPLE RULETEST 2
A sample Ruletest provides an Entity1 with two entity2, each of which has an entity3 child of its own. The illustration shows Ruletest Input and Output panels. Note that when an entity2 is removed, its associated entity3 is moved to the root level.
1/13/2012
Page 154
REPLACE ELEMENT(S)
SYNTAX
<Collection1> = <Collection2> <Collection> = <Entity>
DESCRIPTION
Replaces all elements in <Collection1> with the elements in <Collection2>, provided the association between the two is permitted by the Business Vocabulary. In the second syntax, <Entity> is associated with <Collection>, replacing the <Entity> already associated, when the association between the two is one-to-one in the Business Vocabulary. All collections must be expressed as unique aliases.
USAGE RESTRICTIONS
The Operators row of table in Figure 4 does not apply. Special exceptions: replace element may only be used in Action Rows (section 5 in Figure 5).
RULESHEET EXAMPLE
This sample Rulesheet uses the replace element operator to add Entity3 to collection1 if its boolean1 value is true. Note the use of unique alias collection1 to represent the collection of Entity3 elements associated with Entity2. Recall from the generic Business Vocabulary shown in Figure 1, the association between Entity2 and Entity3 has a cardinality of one-to-one. This means that if multiple Entity3 are present, only one will be added to collection1.
1/13/2012
Page 155
SAMPLE TEST
Four sample tests provide scenarios of two elements which share a one-to-one association. Input and Output panels are illustrated below:
1/13/2012
Page 156
ROUND
SYNTAX
<Decimal>.round(<Integer>)
DESCRIPTION
Rounds <Decimal> to the number of decimal places specified by <Integer>. Standard rounding conventions apply, meaning numbers ending with significant digits of 5 or more round up and numbers ending with significant digits less than 5 round down. <Integer> is optional if no parameter is specified, then <Decimal> rounds to the nearest whole number of type Decimal.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .round to round the value of decimal2 to the 2nd decimal place, and assigns it to decimal1.
1/13/2012
Page 157
SAMPLE TEST
A sample Ruletest provides results for five examples of decimal2.
1/13/2012
Page 158
SECOND
SYNTAX
<DateTime>.sec <Time>.sec
DESCRIPTION
Returns the seconds portion of <DateTime> or <Time>. The returned value is an Integer between 0 and 59.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses the .sec function to evaluate dateTime1, return the seconds value, and assign it to integer1.
SAMPLE TEST
A sample Ruletest provides results for two examples of dateTime1.
1/13/2012
Page 159
SECONDS BETWEEN
SYNTAX
<DateTime1>.secsBetween(<DateTime2>) <Time1>.secsBetween(<Time>)
DESCRIPTION
Returns the Integer number of seconds between DateTimes or between Times. The number of milliseconds in <DateTime1> is subtracted from that in <DateTime2>, and the result divided by 1000 (the number of milliseconds in a second). The result is truncated. This function returns a positive number if <DateTime2> is later than <DateTime1>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .secsBetween to determine the number of seconds that have elapsed between dateTime1 and dateTime2, compare it to the Values set, and assign a value to string1.
1/13/2012
Page 160
SAMPLE TEST
A sample Ruletest provides dateTime1 and dateTime2 for two examples. Input and Output panels are shown below.
1/13/2012
Page 161
SIZE OF STRING
SYNTAX
<String>.size
DESCRIPTION
Returns the Integer number of characters in <String>. All characters, numbers, symbols, and punctuation marks are counted, including spaces before, within, and after words.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses the .size function to determine the length of string1 and assign it to
integer1
SAMPLE TEST
A sample Ruletest provides three examples. Input and Output panels are shown below:
1/13/2012
Page 162
SIZE OF COLLECTION
SYNTAX
<Collection> ->size
DESCRIPTION
Returns the Integer number of elements in <Collection>. <Collection> must be expressed as a unique alias.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses size to count the number of elements in collection1, and assign a value to boolean2. Note the use of unique alias collection1 to represent the collection of Entity2 associated with Entity1.
1/13/2012
Page 163
SAMPLE TEST
A sample Ruletest provides three examples of collection1. Input and Output panels are shown below.
1/13/2012
Page 164
SORTED BY
SYNTAX
<Collection> ->sortedBy(<Attribute2>) -> sequence operator.<Attribute1>
DESCRIPTION
Sequences the elements of <Collection> in ascending order, using the value of <Attribute2> as the index, and returns the <Attribute1> value of the element in the sequence position determined by the sequence operator. A sequence must be created before any sequence operator (first, last, or at) is used to identify a particular element. <Attribute1> and <Attribute2> must be attributes of <Collection>. <Attribute2> may be any data type except Boolean. Strings are sorted according to character precedence see Appendix A. <Collection> must be expressed as a unique alias. See Advanced Collection Syntax and special statement block syntax for more examples of usage.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
1/13/2012
Page 165
SAMPLE RULETEST 1
A sample Ruletest provides a collection of three elements, each with a decimal1 and string1 value. Input and Output panels are shown below.
1/13/2012
Page 166
SAMPLE RULETEST 2
A sample Ruletest provides a collection of three elements, each with a decimal1 and string1 value. Input and Output panels are shown below.
1/13/2012
Page 167
SORTED BY DESCENDING
SYNTAX
<Collection> ->sortedByDesc(<Attribute2>) -> sequence operator.<Attribute1>
DESCRIPTION
Sequences the elements of <Collection> in descending order, using the value of <Attribute2> as the index, and returns the <Attribute1> value of the element in the sequence position determined by the sequence operator. A sequence must be created before any sequence operator (first, last, or at) is used to identify a particular element. <Attribute1> and <Attribute2> must be attributes of <Collection>. <Attribute2> may be any data type except Boolean. Strings are sorted according to their ISO character precedence see Appendix A. <Collection> must be expressed as a unique alias. See Advanced Collection Syntax and special statement block syntax for more examples of usage.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
1/13/2012
Page 168
SAMPLE RULETEST 1
A sample Ruletest provides a collection of three elements, each with a decimal1 value. Input and Output panels are shown below.
1/13/2012
Page 169
SAMPLE RULETEST 2
A sample Ruletest provides a collection of three elements, each with a decimal1 value. Input and Output panels are shown below.
1/13/2012
Page 170
STARTS WITH
SYNTAX
<String1>.startsWith(<String2>)
DESCRIPTION
Returns a value of true if <String1> begins with the characters specified in <String2>. Comparisons are case-sensitive.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .startsWith to evaluate whether string1 begins with the value of string2 and assigns a different value to boolean1 for each outcome.
1/13/2012
Page 171
SAMPLE TEST
A sample Ruletest provides string1 and string2 values for four examples. Input and Output panels are shown below.
1/13/2012
Page 172
SUBSTRING
SYNTAX
<String>.substring( <Integer1>, <Integer2>)
DESCRIPTION
Returns the portion of <String> beginning with the character in position <Integer1> and ending with the character in position <Integer2>. The number of characters in <String> must be at least equal to <Integer2>, otherwise an error will be produced. Both <Integer1> and <Integer2> must be positive integers, and <Integer2> must be greater than <Integer1>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses .substring to return those characters of string1 between positions 4 and 7 (inclusive), and assign the resulting value to string2.
1/13/2012
Page 173
SAMPLE RULETEST 1
A sample Ruletest provides string1 values for four examples. Input and Output panels are shown below.
SAMPLE RULETEST 2
Another sample Ruletest shows string1 values with two examples having insufficient character strings. The resulting error message is illustrated below:
1/13/2012
Page 174
SUBTRACT
SYNTAX
<Number1> - <Number2>
DESCRIPTION
Subtracts the value of <Number2> from that of <Number1>. The resulting data type is the more expansive of those of <Number1> and <Number2>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This sample Rulesheet uses subtract to reduce the value of decimal1 by decimal2, compare the resulting value to zero, and assign a value to boolean1
1/13/2012
Page 175
SAMPLE TEST
A Ruletest provides three examples of decimal1 and decimal2. Input and Output panels are shown below.
1/13/2012
Page 176
SUM
SYNTAX
<Collection.attribute> ->sum
DESCRIPTION
Sums the values of the specified <attribute> for all elements in <Collection>. <attribute> must be a numeric data type. <Collection> must be expressed as a unique alias.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This Rulesheet uses the sum function to add all decimal1 attributes within collection1. Note the use of unique alias collection1 to represent the collection of Entity2 associated with
Entity1
1/13/2012
Page 177
SAMPLE TEST
A sample Ruletest provides 3 elements in collection1. Input and Output panels are shown below.
1/13/2012
Page 178
TODAY
SYNTAX
today
DESCRIPTION
Returns the current system date when the rule is executed. This Date Only value is assigned the first time today is used in a Decision Service (Rule Set), then remains constant until the Decision Service finishes execution, regardless of how many additional times it is used. This means that every rule in a Rule Set using today will use the same Date Only value. No time portion is assigned
USAGE RESTRICTIONS
The Literals row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses today to determine how many days have elapsed between today and dateTime1, and assign a value to string1 based on the result.
1/13/2012
Page 179
SAMPLE TEST
A sample Ruletest provides three examples of dateOnly1. Assume today is equal to Friday, November 23, 2007. Input and Output panels are shown below:
1/13/2012
Page 180
DESCRIPTION
Converts the value in <DateTime> to a Date datatype, containing only the date portion of the DateTime. If <DateTime> contains no date information, then the system epoch is used.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toDate to convert dateTime1 and DateTime2 to Date datatypes and assign the values to dateTime1 and dateTime2.
SAMPLE TEST
1/13/2012
Page 181
DESCRIPTION
Converts the value in <String> to data type DateTime ONLY if all characters in <String> correspond to a valid Date, Time, or DateTime mask (format). For complete details on DateTime masks, see Rule Modeling Guide
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toDateTime to convert string1 to type DateTime and assign the value to dateTime1.
SAMPLE TEST
1/13/2012
Page 182
DESCRIPTION
Converts the value in <Date> to data type DateTime. The date portion is the same as the <Date> value and the time portion is set to 12:00:00 AM in the current timezone.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toDateTime to convert dateOnly1 to type DateTime and assign the value to dateTime1.
SAMPLE TEST
1/13/2012
Page 183
DESCRIPTION
Converts the value in <Time> to data type DateTime ONLY if all characters in <Time> correspond to a valid DateTime mask (format). The time portion is the same as the <Time> value and the date portion is the epoch (see .toTime operator)
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toDateTime to convert timeOnly1 to type DateTime and assign the value to dateTime1.
SAMPLE TEST
1/13/2012
Page 184
DESCRIPTION
Converts the value in <Date> to data type DateTime ONLY if all characters in <Date> correspond to a valid DateTime mask (format). The date portion is the same as the <Date> value and the time portion is set to 00:00:00 in the timezone specified by <String>, which is the timeZoneOffset. The timeZoneOffset must take the form of a valid timezone offset such as -08:00, +03:30, 01:45
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toDateTime to convert dateOnly1 to type DateTime and assign the value to dateTime1, with a timezone offset of -5.
SAMPLE TEST
1/13/2012
Page 185
TO DECIMAL
SYNTAX
<Integer>.toDecimal <String>.toDecimal
DESCRIPTION
Converts the value in <Integer> or all characters in <String> to data type Decimal. Converts a String to Decimal ONLY if all characters in <String> are numeric and contain not more than one decimal point. If any non-numeric characters are present in <String> (other than the single decimal point or a leading minus sign), no value is returned by the function. Note: Integer values may be assigned directly to Decimal data types without using the .toDecimal operator because a Decimal data type is more expansive than an Integer.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toDecimal to convert integer1 and string1 to type Decimal and assign them to decimal1 and decimal2, respectively.
1/13/2012
Page 186
SAMPLE TEST
1/13/2012
Page 187
TO INTEGER
SYNTAX
<Decimal>.toInteger <String>.toInteger
DESCRIPTION
Converts the value in <Decimal> or all characters in <String> to data type Integer. All decimals have fractional portions truncated during the conversion. Strings are converted ONLY if all characters in <String> are numeric, without a decimal point. If any non-numeric characters (with the sole exception of a single leading minus sign for negative numbers) are present in <String>, no value is returned by the function. Do not use on String values of null or empty String () as this will generate an error message.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toInteger to convert decimal1 and string1 to type Integer and assign them to integer1 and integer2, respectively.
1/13/2012
Page 188
SAMPLE TEST
1/13/2012
Page 189
TO STRING
SYNTAX
<Number>.toString <DateTime*>.toString *includes DateTime, Date, and Time data types
DESCRIPTION
Converts a value to a data type of String.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toString to convert 3 data types to strings. Rule N.3 also uses the alternative String concatenation syntax. See Add Strings for details.
SAMPLE TEST
1/13/2012
Page 190
DESCRIPTION
Converts the value in <DateTime> to a Time data type, containing only the time portion of the full DateTime. If <DateTime> contains no time information, then the time portion is set to 12:00:00 AM in the current timezone. Note: Should this value be saved in a database field supporting a full DateTime, the date portion is saved as the epoch specified in com.corticon.crml.OclDate.epochForTimeValues. See Server Integration & Deployment Guide for a complete description of this and other properties inside CcCommon.properties.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toTime to convert dateTime1 to Time and assign the value to TimeOnly1.
SAMPLE TEST
1/13/2012
Page 191
TREND
SYNTAX
<Collection.attribute> -> <Sequence>.trend
DESCRIPTION
Returns one of the following 4-character strings depending on the trend of <Collection.attribute> once sequenced by the same or different attribute in <Collection>. <Sequence> is an ordered set of <Collection> in the form {x1, x2, x3 xn}, where
INCR the value of <attribute> of element xn+1 is greater than or equal to the value of
<attribute> of element xn for every element. At least one <attribute> value of element x must be greater than that of xn-1
DECR the value of <attribute> of element xn+1 is less than or equal to the value of <attribute>
of element xn for every element. At least one <attribute> value of element x must be less than that of xn-1
CNST the value of <attribute> of element xn+1 is equal to the value of <attribute> for
An alternative way to understand this operator is to view the index attribute used to sequence the collection as the independent variable (traditionally plotted along the x axis in a standard x-y graph) in a set of data pairs. The attribute evaluated by the .trend operator, <Collection.attribute>, is the dependent variable, plotted along the y axis. When so plotted, the 4-character words returned by .trend correspond to curves with positive, negative, zero (constant), or arbitrary slopes2.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
This Rulesheet uses the .trend function to analyze integer1 attributes within collection1 sorted by decimal1. The resulting trend value is assigned to string1.
Technically, the slope of an INCR curve need not be positive everywhere, but must have a first derivative (instantaneous slope) that is positive at some point along the curve and never be negative. The slope of a CNST curve must be zero everywhere.
1/13/2012
Page 192
SAMPLE TEST
Two sample tests provide two collections of elements, each with a decimal1 and integer1 values. Input and Output panels are shown below.
1/13/2012
Page 193
TRUE
SYNTAX
true or T
DESCRIPTION
Represents Boolean value true. Recall from the discussion of truth values that an <expression> is evaluated for its truth value, so the expression Entity1.boolean1=true will evaluate to true only if boolean1=true. But since boolean1 is Boolean and has a truth value all by itself without any additional syntax, we dont actually need the =true piece of the expression. Many examples in the documentation use explicit syntax like boolean1=true or boolean2=false for clarity and consistency, even though boolean1 or not boolean2 are equivalent logical expressions.
USAGE RESTRICTIONS
The Literals row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses true in a Precondition to Ruletest whether boolean1 is true, and perform the Nonconditional computation if it is. As discussed above, the alternative expression Entity1.boolean1 is logically equivalent.
1/13/2012
Page 194
SAMPLE TEST
A sample Ruletest provides three examples. Assume decimal2=10.0 and integer1=5 for all examples. Input and Output panels are shown below:
1/13/2012
Page 195
UPPERCASE
SYNTAX
<String>.toUpper
DESCRIPTION
Converts all characters in <String> to uppercase.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .toUpper to convert string2 to uppercase and assign it to string1.
SAMPLE TEST
A sample Ruletest provides three examples. Input and Output panels are shown below:
1/13/2012
Page 196
WEEK OF MONTH
SYNTAX
<DateTime>.weekOfMonth <Date>.weekOfMonth
DESCRIPTION
Returns an Integer from 1 to 6, equal to the week number within the month in <DateTime> or <Date>. A week begins on Sunday and ends on Saturday.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .weekOfMonth to assign a value to integer1.
SAMPLE TEST
1/13/2012
Page 197
WEEK OF YEAR
SYNTAX
<DateTime>.weekOfYear <Date>.weekOfYear
DESCRIPTION
Returns an Integer from 1 to 52, equal to the week number within the year in <DateTime> or <Date>. A week begins on Sunday and ends on Saturday. When a year ends between Sunday and the next Friday, or in other words when a new year begins between Monday and the next Saturday, the final day(s) of December will be included in week 1 of the new year. For example, 12/29/2002 fell on a Sunday, so 12/29-31 are included in week 1 of 2003.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .weekOfYear to assign a value to integer1.
SAMPLE TEST
1/13/2012
Page 198
YEAR
SYNTAX
<DateTime>.year <Date>.year
DESCRIPTION
Returns the century/year portion of <DateTime> or <Date>. The returned value is a four digit Integer.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .year to evaluate dateTime1 and dateOnly1 and assign the year values to integer1 and integer2, respectively.
SAMPLE TEST
A sample Ruletest provides three examples of dateTime1 and dateOnly1. Input and Output panels are shown below:
1/13/2012
Page 199
1/13/2012
Page 200
YEARS BETWEEN
SYNTAX
<DateTime1>.yearsBetween(<DateTime2>) <Date1>.yearsBetween(<Date2>)
DESCRIPTION
Returns the Integer number of years between DateTimes or between Dates. The number of months in <DateTime2> is subtracted from the number of months in <DateTime1>, and the result is divided by 12 and truncated. This function returns a positive number if <DateTime2> is later than <DateTime1>.
USAGE RESTRICTIONS
The Operators row of the table in Figure 4 applies. No special exceptions.
RULESHEET EXAMPLE
The following Rulesheet uses .yearsBetween to determine the number of months that have elapsed between dateTime1 and dateTime2, compare it to the Values set, and assign a value to string1.
SAMPLE TEST
A sample Ruletest provides dateTime1 and dateTime2 for two examples. Input and Output panels are shown below.
1/13/2012
Page 201
SPECIAL SYNTAX
The following sections describe special rule language syntax not found in the Operator Vocabulary.
VALUE RANGES
When using values in Condition Cells for Integers, Decimals, Strings, or DateTime data types, the values do not need to be discreet they may be in the form of a range 3. A value range is typically expressed in the following format: x..y, where x and y are the starting and ending values for the range inclusive of the endpoints if there is no other notation to indicate otherwise. This is illustrated in Figure 6 below.
In this example, we are assigning an integer2 value to Entity1 depending on its integer1 value. The value range 101..200 represents all values (integers in this case) between 101 and 200, including 101 and 200. This is an inclusive range because both the starting and ending values are included in the range.
1/13/2012
Page 202
1/13/2012
Page 203
1/13/2012
Page 204
Listed below are all of the possible combinations of parenthesis and bracket notation for value ranges and their meanings:
(x..y) (x..y] [x..y) [x..y]
- is the range between x & y, excluding both x & y - is the range between x & y, excluding x and including y - is the range between x & y, including x and excluding y - is the range between x & y, including both x & y
As illustrated in Figure 6 and Figure 12, if a value range has no enclosing parentheses or brackets, it is assumed to be closed. It is therefore not necessary to use the [..] notation for a closed range in Studio; in fact, if you try to create a closed value range by entering [..], the square brackets will be automatically removed. However, should either end of a value range have a parenthesis or a bracket, then the other end must also have a parenthesis or a bracket. For example, x..y) is not allowed, and is properly expressed as [x..y). When using range notation, always ensure x is less than y, i.e., an ascending range. A range where x is greater than y (a descending range) may result in errors during rule execution.
Page 205
Figure 15 - Ruletest showing multiple rules firing for given test data
1/13/2012
Page 206
Sometimes, however, its useful to combine more than one value in the same Cell. This is accomplished by holding CTRL while clicking to select multiple values from the Condition Cell dropdown box. When multiple values are selected in this manner, pressing ENTER will automatically enclose the resulting set in curly brackets {..} in the Cell as shown in the sequence of Figure 17 and Figure 18. Additional values may also be typed into Cells. Be sure the comma separators and curly brackets remain correct during hand-editing.
The rule implemented in Column 1 of Figure 18 is logically equivalent to the Rulesheet shown in Figure 19. Both are implementations of the following rule statement:
1/13/2012
Page 207
1. If a flightplans cargo weight is less than 200 OR greater than 400, then the flightplans aircraft type must be a DC-10
If you write rules that are logically ORed in separate Columns, performing a Compression will reduce the Rulesheet to the fewest number of Columns possible by creating value sets in Cells wherever possible. Fewer Columns results in faster Rulesheet execution, even when those Columns contain value sets. Compressing the Rulesheet in Figure 19 will result in the Rulesheet in Figure 18. Condition Cell value sets can also be negated using the not operator. To negate a value, simply type not in front of the leading curly bracket { as shown in Figure 20. This is an implementation of the following rule statement:
1. If a flightplans cargo weight is NOT less than 200 OR NOT greater than 400, then the flightplans aircraft type must be a DC-10
Value sets can also be created in the Overrides Cells at the foot of each Column. This allows one rule to override multiple rules in the same Rulesheet.
1/13/2012
Page 208
1/13/2012
Page 209
Figure 22 - Rule Messages Window Showing Bracketed Embedded Attributes (Orange Box)
When an attribute uses an Enumerated Custom Data Type, the dynamic value embedded in the posted Rule Message will be the Value, not the Label. See the Rule Modeling Guide, Building the Vocabulary chapter for more information about Custom Data Types.
The text will turn red, because Studio thinks that the string1 value is Jane and the remaining text s dog Spot is invalid. To properly express a String value that includes single quotes or apostrophes, you must use the special character backslash (\) that tells Studio to ignore the apostrophe(s) as follows:
entity1.string1=Jane\s dog Spot
1/13/2012
Page 210
When preceded by the backslash, the second apostrophe will be ignored and assumed to be just another character within the String. This notation works in all sections of the Rulesheet, including Values sets. It also works in the Possible Values section of the Vocabulary Editor.
Step 1
Collection1
This expression returns the collection {e1, e2, e3, e4, e5,en} where ex is an element (an entity) in Collection1. We already know that alias Collection1 represents the entire collection.
Step 2
Collection1 -> sortedBy(attribute1)
This expression returns the collection {e1, e2, e3, e4, e5,en} arranged in ascending order based on the values of attribute1 (which we call the index).
Step 3
Collection1 -> sortedBy(attribute1) -> last
returns {en} where en is the last element in Collection1 when sorted by attribute1 This expression returns a specific entity (element) from Collection1. It does not return a specific value, but once we have identified a specific entity, we can easily reference the value of any attribute it contains, as in the following:
Step 4
Collection1 -> sortedBy(attribute1) -> last.attribute2
which returns {en.attribute2} This expression not only returns a specific value, but just as importantly, it also returns the entity the value belongs to. This entity context is important because it allows us to do things to the entity itself, like assign a value to one of its attributes. For example:
1/13/2012
Page 211
The above expression will assign the value of xyz to attribute2 of the entity whose attribute1 is highest in Collection1. Contrast this with the following:
Collection1.attribute1 -> sortedBy(attribute1) -> last
which returns a single integer value, like 14. Notice that all we have now is a number, a value. We have lost the entity context, so we cant do anything to the entity that owns the attribute with value of 14. In many cases, this is just fine. Take for example:
Collection1.attribute1 -> sortedBy(attribute1) -> last > 10
In this expression, its not important that we know which element has the highest value of attribute1, all we want to know is if the highest value (whomever it belongs to) is greater than 10. Understanding the subtleties of collection syntax and the concept of entity context is important because it helps us to use the returned entities or values correctly. For example: Return the lower of the following two values: 12 The age of the oldest child in the family
What is really being compared here? Do we care which child is oldest? Do we need to know his or her name? No. We simply need to compare the age of that child (whichever one is oldest) with the value of 12. So this is the expression that models this logic:
family.age -> sortedByDesc(age) -> first.min(12)
.min, as we know, is an operator that acts upon numeric data types (Integer or Decimal). And since we also know that family.age -> sortedByDesc(age) -> first returns a number, then its legal and valid to use .min at the end of this expression. What about this scenario: Name the youngest child Junior.
family -> sortedByDesc(age) -> last.name=Junior
Now we want to return a specific entity that of the youngest child and assign to its name a value of Junior. We need to keep the entity context in order to make this assignment, and the expression above accomplishes this.
STATEMENT BLOCKS
Sequence operators can easily extract an attribute value from the first, last or other specific element in a sorted collection (see first, last, or at(n) for examples). This is especially useful when the attributes value is involved in a comparison in a Conditional or Preconditional rule. Sometimes, however, it is desirable to identify a particular element in a sequence and flag or tag it for use in subsequent rules. This can be accomplished using special syntax called Statement Blocks.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. 1/13/2012
Page 212
Statement Blocks, permitted only in the Action rows of the Rulesheet, use special variables, prefixed by a ? character, to hold or pin an element so that further action may be taken on it, including tagging it by assigning a value to one of its attributes. These special holder variables may be declared on the fly, meaning they do not need to be defined anywhere prior to use. Heres an example. In a sales management system, the performance of sales reps is analyzed every quarter, and the highest grossing sales rep is awarded Salesperson of the Quarter. This special status is then used to automatically increase the reps commission percentage on sales made in the following quarter. Well use the same generic Vocabulary as in all previous examples, but make these assumptions:
Vocabulary Term Entity2 Entity1.entity2 Entity2.string1 Entity2.decimal1 Entity2.string2 Entity2.decimal2 Meaning a salesperson collection of salespeople a salespersons name a salespersons quarterly sales a salespersons award a salespersons commission percentage
Page 213
(e2), sorted in ascending order according to quarterly sales (decimal1). Once identified by the sequencing operator last, this salesperson is momentarily held by the ?tag variable, which we declared on-the-fly. 2. the second part of the statement the part following the semicolon assigns a value to an attribute of the element held by the ?tag. In our example, we are assigning a value of Salesperson of the Quarter to the string2 attribute of the salesperson held by ?tag. In effect, we have tagged the highest grossing salesperson with this award. 3. the two parts above must be included on the same Action Row, separated by a semicolon. If the two parts are separated in different sections or in different Rows of the same section, the element represented by the ? variable is lost, in other words, ?tag loses its grip on the element identified by the sequencing operator. Now that we have tagged our winner, we can use the tagged element (awardee) to take additional actions. In the Conditional rule, we increase the commission percentage of the winner by 5% using the increment operator. The next figure shows a Ruletest Input and Output pane. As expected, our highest grossing salesperson has been awarded Salesperson of the Year honors, and has had her commission raised by an additional 5%.
Figure 24 Output Panel with Winner and Adjusted Commission in Bold Black Text
1/13/2012
Page 214
precedence than & (26 < 44). These characters are decisive because they are the first different characters encountered as the two strings are compared beginning with characters in position 1.
B > aardvark
precedence than <space> (57 > 1). The first seven characters of each String are identical, so the final character comparison is decisive.
character name typed space _ , ; : ! ? / dash or minus sign underline or underscore comma semicolon colon exclamation point question mark slash precedence 1 2 3 4 5 6 7 8 9 Unicode 5.0 code 0020 002D 005F 002C 003B 003A 0021 003F 002F
1/13/2012
Page 215
1/13/2012
Page 216
1/13/2012
Page 217
1/13/2012
Page 218
Order 1 2 3
Operator () Unary * /
Operator Name Parenthesis Negation Multiplication Division Addition Subtraction Less Than Less Than Or Equal To Greater Than Greater Than Or Equal To Equal Not Equal Exponentiation
Example (5.5 / 10) -10 5.5 * 10 5.5 / 10 5.5 + 10 10.0 5.5 5.5 < 10 5.5 <= 5.5 10 > 5.5 10 >= 10 5.5=5.5 5.5 <> 10 10 ** 2
+ -
= <>
**
1/13/2012
Page 219
1/13/2012
Page 220
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
1/13/2012
CORTICON
Business Rules Server 5.2 Tutorial Deploying Web Services with Java
TABLE OF CONTENTS
Table of Contents ......................................................................................................................................... iii Introduction .................................................................................................................................................. 1 Purpose & Intended Audience.................................................................................................................. 1 Corticon Business Rules Management Product Documentation ............................................................. 1 Documentation Conventions .................................................................................................................... 1 Technical Support ..................................................................................................................................... 2 Conceptual Overview .................................................................................................................................... 3 What is a Web Service? ............................................................................................................................ 3 What is a Decision Service? ...................................................................................................................... 3 What is The Corticon Business Rules Server? ........................................................................................... 3 What is a Web Services Consumer? ......................................................................................................... 3 Getting Started.............................................................................................................................................. 4 Deploying the Corticon Business Rules Server as a Web Services Server ................................................ 4 Deploying a Ruleflow to the Corticon Business Rules Server ................................................................... 4 Consuming a Decision Service .................................................................................................................. 4 Starting the Corticon Business Rules Server ................................................................................................. 5 Starting Tomcat and Verifying Operation................................................................................................. 5 Installing Corticon Server.......................................................................................................................... 5 Deploying a Ruleflow to the Corticon Server................................................................................................ 7 Creating a Ruleflow................................................................................................................................... 7 Creating and Installing a Deployment Descriptor File .............................................................................. 7 Launching the Deployment Console .................................................................................................... 8 Using the Deployment Console to Create a Deployment Descriptor file ............................................ 8 Installing the Deployment Descriptor File.......................................................................................... 11 Hot Re-Deploying Deployment Descriptor Files and Ruleflows ......................................................... 11 Consuming a Decision Service..................................................................................................................... 13 Integrating and Testing a Decision Service ............................................................................................. 13 Path 1 Using Corticon Studio as a SOAP Client to Consume a Decision Service.................................. 14 Creating a New Test in Studio ............................................................................................................ 14 Executing the Remote Test ................................................................................................................ 16 Path 2 Using Bundled Sample Code to Consume a Decision Service .................................................. 17 Creating a Request Message for a Decision Service........................................................................... 17 Sending a Request Message to the Server ......................................................................................... 19 Path 3 Using a SOAP Client to Consume a Decision Service ................................................................ 22 Web Services Service Contracts ......................................................................................................... 22 Web Services Messaging Styles.......................................................................................................... 22 Creating a Service Contract Using the Deployment Console ............................................................. 23 Creating a Request Message for a Decision Service........................................................................... 24 Sending a Request Message to the Server ......................................................................................... 25 Limits of the Default Evaluation License ................................................................................................ 25
Page iv
Troubleshooting ..................................................................................................................................... 26 Appendix A: Corticon Business Rules Management Product Documentation .......................................... 27
Page 1
INTRODUCTION
PURPOSE & INTENDED AUDIENCE
The Tutorial for Corticon Server - Deploying Web Services provides step-by-step instructions for: Deploying Corticon Business Rules Server as a Web Services server on the bundled Apache Tomcat web server. Loading the Server with a sample Ruleflow or one of your own design. Testing the Ruleflow with live data using bundled SOAP client code.
This manual is intended primarily for use by IT professionals involved with the deployment to the Server of Ruleflows developed in Studio. This manual assumes you have already installed Corticon Business Rules Server software on a PC according to the instructions found in Appendix F of the Server Integration & Deployment Guide.
DOCUMENTATION CONVENTIONS
Corticon documentation uses the following conventions: Document names are shown in bold face italic type: Studio Installation Guide. Screen, button and window names are shown in bold face type: Custom Setup screen. Important information such as Notes, Tips and Warnings are shown in this color scheme: Tools Notes and Tips Warnings
Hyperlinks are underlined and shown in blue: the cursor changes to a hand: Custom Setup. File names, code, and user-defined information are shown as: Installing.pdf.
Page 2
Menu options are indicated using bold text and arrows: File>Save denotes the selection of the Save option from the File menu.
TECHNICAL SUPPORT
For Corticon product support, contact +1 650.212.2424 ext. 200 or email support@corticon.com
Page 3
CONCEPTUAL OVERVIEW
This tutorial assumes you have a basic familiarity with the concepts of Web Services and Corticon Business Rules Management. This section helps answer some of the foundational questions from new users of the Corticon Business Rules Server.
Page 4
GETTING STARTED
This Tutorial steps through the procedure necessary for running the Corticon Business Rules Server as a Web Services server, deploying Ruleflows to the Server, exposing the Ruleflows as Decision Services and testing them with document-style SOAP requests. There are other installation, deployment and integration options available beyond the SOAP/Web Services method described here, including Javacentric options using Java objects and APIs. More detailed information on all available methods is contained in the Server Integration & Deployment Guide. This Tutorial consists of three main sections:
Page 5
When you start this bundled Tomcat for the first time, it will unpack axis.war, and create a new axis directory inside \webapps. This new folder contains the complete Corticon Server web application. If you intend to install Corticon Server onto another web server besides the bundled Tomcat, refer to the Server Integration & Deployment Guide for more details on using the axis.war package supplied. To verify that Corticon Server is installed correctly on Tomcat, perform the following steps: 1. Be sure Tomcat is already running, as above. 2. Launch your Internet Bowser and go to http://localhost:8082/axis. 3. Click View the list of deployed Web services. 4. You should see the screen shown in Figure 1.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 6
Page 7
All three methods are described more thoroughly in the Server Integration & Deployment Guide.
CREATING A RULEFLOW
For purposes of this Tutorial, we will assume you have already created a Ruleflow suitable for deployment. If you have completed the Basic Tutorial for Corticon Studio Modeling Rules, then you have indeed created a sample Ruleflow that is ready for deployment to the Server. In the Basic Tutorial for Corticon Studio Modeling Rules we built and tested a new Ruleflow from scratch. We will use that Ruleflow here, but the same steps we outline must be followed regardless of the Ruleflow we use. If you no longer have your original Ruleflow, then use tutorial_example.erf located in
<corticon_install_dir>\Samples\Rule Projects\Tutorial\Tutorial-Done as a
substitute. The rules inside are essentially the same as those built in the first part of the Basic Tutorial for Corticon Studio Modeling Rules.
Page 8
Deployment Descriptors are easily created using the Deployment Console, which is installed by both the Studio installer (Integration & Deployment mode only) and the Server installer.
Page 9
3 1
Deployment Descriptor files are created within the top half of the Deployment Console (labeled as Decision Service Deployment Properties) using the settings and options listed in the following paragraphs. For the moment, well ignore the lower half of the Deployment Console window that portion (labeled as Service Contract Specification) will be addressed later in this Tutorial. Follow these steps to create a Deployment Descriptor file. 1. If you launched Deployment Console from within Studio, then any open Ruleflows will have already been added to the table, and you can skip this step. If the Ruleflow section is empty, use the Add Ruleflow button to add one. 2. Verify the Ruleflow you added is displayed in this section. All Ruleflows listed will be included in the Deployment Descriptor file, but their deployment characteristics are specified on an individual basis using the next 4 steps. 3. Give the Ruleflow a Decision Service Name. This is a shorthand identifier or handle for the Decision Service. It is used when invoking the Decision Service, either via an API call or a SOAP Request message. A default Decision Service name will be entered automatically based on the Ruleflow name. tutorial_example.erf, for example, will
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 10
be given the default name tutorial_example. You can change this, but be sure to remember what you entered because you will use this name later to invoke the Decision Service.
4. In this Tutorial we will skip over the Version, Version Label, Effective Date, and Expiration Date settings. Descriptions of these settings can be found in the Server Integration & Deployment Guide and the Rule Modeling Guide. Scroll to the right until you see the Maximum and Minimum Pool Size settings. These tell the Server how to handle higher transaction volumes. The concept of a pool is described in more detail in the Server Integration & Deployment Guide. For now, simply accept the default settings, as shown in Figure 3.
7
Figure 4 - Deployment Console's Decision Services Deployment Properties Window, Part 3
5. Continue scrolling to the right until you see the Dynamic Reload setting shown in Figure 4. The default entry is No, which we will keep for this Tutorial example. See the Server Integration & Deployment Guide for more details on this option. 6. XML Messaging Style. The default entry is Auto Detect, which we will keep for this example. See the Server Integration & Deployment Guide for more details on this option.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 11
7. Use the Save Deployment File button to create the new Deployment Descriptor file. After youve named and saved it, the .cdd name will appear in the title bar. For the moment, save this file anywhere and remember where it is. We will move it to the correct location in the next section. The Deployment Descriptor files XML structure is fully described in the Server Integration & Deployment Guide.
Page 12
deployment process. But in development or testing environments, it can be convenient to allow dynamic updates so that Ruleflow changes can be deployed more quickly. Having selected No for the Dynamic Reload setting earlier, our tutorial_example Decision Service will not update automatically when the .erf file is changed. To enable this automatic refresh, choose Yes for the Dynamic Reload setting.
Page 13
Page 14
this path, we recommend completing the Studio Installation Guide and the Basic Tutorial for Corticon Studio Modeling Rules before continuing here. Path 3 Use a commercially available SOAP client to integrate with and test a Decision Service. In other words, this SOAP client will read a web-services-standard service contract (discussed below), generate a request message from it, send it to the Corticon Server and display the response message. Corticon Business Rules Management does not include such an application, so the reader must obtain one in order to complete this path.
Page 15
Now, drag a Cargo entity from the Vocabulary to the Input pane. Enter sample data as shown in Figure 6.
Page 16
.
Figure 6 - Sample Data in an Studio Remote Ruletest
The Output pane of the Testsheet shown in Figure 7 displays the response message returned by the Corticon Server. This confirms that our Decision Service has processed the data contained in the request and sent back a response containing new data (the container attribute and the message).
Page 17
6. Enter data into the Input Testsheet just like you did when testing the Ruleflow in the Basic Tutorial for Corticon Studio Modeling Rules. Your Input Testsheet will now appear similar to Figure 9:
Page 18
7. Use Studios menubar option Ruletest>Testsheet>Data>Input>Export Request XML to export this Input pane as an XML document. We will use this exported XML document as the body or payload of our request message. Give the export file a name and remember where you save it. We will assign a filename of sample.xml for purposes of this Tutorial. 8. Open sample.xml in any text editor. It should appear very similar to Figure 10.
9. Modify sample.xml by deleting the <?XML version=1.0 encoding=UTF-8?> tag from the very top (this will be added automatically by the bundled sample code we will use to send this as a request message to the Decision Service). This tag is shown above in Figure 10, enclosed in an orange box. 10. Change the decisionServiceName attribute value in the CorticonRequest element from InsertDecisionServiceName to the service name of the Decision Service as it was defined in your deployed .cdd file. In our example, this name is tutorial_example. This piece is shown above in Figure 10 and below in Figure 11 (before and after the changes) enclosed in a blue box. Your sample.xml file should now look like this:
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 19
11. Save your changes to the XML file and exit your text editor.
Page 20
2. Replace OrderProcessingPayload.xml (shown in orange box in Figure 12) with the name of your test XML file. In this Tutorial, our test XML file is named sample.xml. 3. Save the changes to TestDS.cmd. 4. Move your XML test file (sample.xml) to the
<corticon_install_dir>\Server\Tomcat\CcServer\cddinit directory.
6. Type TestDS (the name of the command script) in the DOS command window and press Enter. 7. You should see the following response from your Decision Service:
Page 21
The response message shown in Figure 13 is exactly what the Servers output looks like when it is returned to the consuming application. There are several things to note in this response. The container attribute has been assigned a value of oversize. The input data volume and weight have been returned in the response message unchanged. If your rules do not change input data, it will be returned exactly as sent. The Studio Ruletest assigned unique id values to our terms during the XML export. However, if the Server receives a request message without id values, it will assign them automatically to ensure resulting terms remain associated properly. The Messages section of the response has been populated with a posted message. Notice that the contents of the severity and text tags match those used in the rules. The entityReference tag in the Messages section uses an href to link or point to the associated elements id value. In this case, we see that the posted message links to (or is associated with) Cargo with id equal to Cargo_id_1. In this case, there is only one Cargo it could link to, but a production request message may contain hundreds or thousands of Cargo entities. In those cases, maintaining href association between entities and their message(s) is critical.
Page 22
The SOAP wrapper or envelope tags were added by the bundled sample code to ensure the request message was sent in accordance with web service standards.
Other details of the Server response message are described in the Server Integration & Deployment Guide.
Page 23
8 9 10 11 12 13 14
Figure 14 - Deployment Consoles Service Contract Specification Window
Launch the Deployment Console as before and follow the instructions below to generate a service contract. All Deployment Console options below are also described in more detail in the Server Integration & Deployment Guide. 8. Decision Service Level / Vocabulary Level. These radio buttons determine whether one service contract is generated per listed Ruleflow, or if a single master service contract is generated from the entire Vocabulary. A Decision Service-level service contract is usable only for a specific Decision Service, whereas a Vocabulary-level service contract can be used for all Decision Services that were built using that Vocabulary. Choose the option that is most compatible with your SOAP tool. 9. Vocabulary File. If generating a Vocabulary-level service contract, enter the Vocabulary file name (.ecore) here. If generating a Decision Service-level contract, this field is readonly and shows the Vocabulary associated with the currently highlighted Ruleflow row above.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
Page 24
10. Select Work Document Entity. If generating a Vocabulary-level service contract, enter the entity name from the list that is the root of the service contract. For more details on the concept of work document entity (WDE), refer also to the Rule Modeling Guide. If generating a Decision Service-level contract, the field shows the WDE associated with the currently highlighted Ruleflow. If no WDE has yet been specified, or if you wish to change it, select one from the list. If you are using the tutorial_example.erf Ruleflow, the appropriate WDE is Cargo. 11. Type. This is the service contract type: WSDL, XML Schema, or Java classes. Note, no output is produced when Java classes is selected because there is no standard method for describing service contracts in the Java world. 12. XML Messaging Style. Enabled only for Vocabulary-level service contracts. Describes the message style, flat or hierarchical, in which the WSDL will be structured. 13. SOAP Server URL. URL for the SOAP node that is bound to the Server. Enabled for WSDL service contracts only. The default URL http://localhost:8082/axis/services/Corticon makes a Decision Service available to the default Server installation performed earlier. Note: this URL can be changed and additional URLs can be added to the drop-down list. See Appendix C of the Server Integration & Deployment Guide for details. 14. Generate Service Contracts. Use this button to generate either the WSDL or XML Schema service contracts into the output directory. If you select Decision Service-level contracts, one service contract per Ruleflow listed at top will be created. If you select Vocabularylevel, only one contract is created per Vocabulary file.
Page 25
Enter all required data into the request message. The tutorial_example.erf example requires the following data: Vocabulary Term
Cargo.weight Cargo.volume
Possible Values A number less than or equal to 200,000 Any real number
The Server log will capture errors and exceptions caused by expired or under-strength licenses. These log messages are detailed in the Troubleshooting section of the Rule Modeling Guide. If you are already a Corticon customer, you should have access to an unlimited license that will lift these restrictions. If you are an evaluator, and discover that these limitations are preventing or inhibiting your evaluation, please contact Corticon or your reseller for a license with expanded capabilities.
Page 26
TROUBLESHOOTING
The Rule Modeling Guide contains an extensive chapter on Troubleshooting, including tips for troubleshooting rules in Studio, as well as problems encountered during Decision Service consumption. Please refer to the Rule Modeling Guide for more details. Many users will find other installations of Tomcat already present on their machines. Very often, the default port settings for these installations conflict with the default port setting of Corticons Tomcat installation, which is 8082. To change Tomcats default port to something other than 8082, refer to the Field Note Changing Apaches Default Port, available on www.RulesWorld.com.
Page 27
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
CORTICON
Business Rules Server 5.2 Integration & Deployment Guide
Page ii
TABLE OF CONTENTS
Preface ........................................................................................................................................................................8 Intended Audience .................................................................................................................................................8 Corticon Business Rules Management Product Documentation ...........................................................................8 Documentation Conventions .................................................................................................................................8 Reading the PDF File ..............................................................................................................................................9 Overview.................................................................................................................................................................. 10 Choose The Deployment Architecture ................................................................................................................ 10 Installation Option 1: Web Services................................................................................................................ 11 Installation Option 2: Java Services with XML Message Payloads .................................................................. 12 Installation Option 3: Java Services with Java Object Payloads...................................................................... 12 Installation Option 4: In-process Java Classes with Java Object or XML Payloads ......................................... 12 Installing the Business Rules Server ........................................................................................................................ 14 Basic Server Classes............................................................................................................................................. 14 Installing Corticon Server .................................................................................................................................... 14 as a J2EE SOAP Servlet ................................................................................................................................. 15 as a J2EE Enterprise Java Bean (EJB) ............................................................................................................ 15 as Java Classes In-process or in a Custom Java Container ........................................................................... 16 The Corticon Home Directory ............................................................................................................................. 17 A Configuration Setting using CORTICON_HOME........................................................................................... 18 The Corticon Server Sandbox .............................................................................................................................. 18 Testing the Installed Corticon Server .................................................................................................................. 18 as a J2EE SOAP Servlet ................................................................................................................................. 19 as a J2EE Enterprise Java Bean (EJB) ............................................................................................................ 23 as In-Process Java Classes ............................................................................................................................ 24 Preparing Studio Files for Deployment ................................................................................................................... 27 Mapping the Vocabulary ..................................................................................................................................... 27 XML Mapping .................................................................................................................................................. 27 Java Object Mapping ...................................................................................................................................... 31 Java Generics .................................................................................................................................................. 38 Java Enumerations .......................................................................................................................................... 38 Verifying Java Object Mapping ....................................................................................................................... 41 Listeners .......................................................................................................................................................... 41 Deploying Corticon Ruleflows ................................................................................................................................. 42 Ruleflow Deployment.......................................................................................................................................... 42 using Deployment Descriptor files ............................................................................................................... 42 Telling the Server Where to find Deployment Descriptor Files ...................................................................... 49 using the Server Web Console ..................................................................................................................... 52 using APIs ..................................................................................................................................................... 52 Testing the Deployed Corticon Decision Service................................................................................................. 53
Page iii
Deploying and Testing Decision Services via Deployment Descriptor Files (.cdd) ......................................... 53 Deploying and Testing Decision Services via APIs .......................................................................................... 54 Deploying Uncompiled vs. Pre-compiled Decision Services ............................................................................... 57 ERF files ........................................................................................................................................................... 57 EDS Files .......................................................................................................................................................... 57 Integrating Corticon Decision Services .................................................................................................................... 59 Components of a Call to Corticon Server ............................................................................................................ 59 the Decision Service Name ............................................................................................................................. 59 the Data .......................................................................................................................................................... 59 Service Contracts: Describing the Call................................................................................................................. 60 The XML WorkDocument................................................................................................................................ 60 Java Business Objects ..................................................................................................................................... 60 Creating XML Service Contracts with Corticon Deployment Console ............................................................ 60 Types of XML Service Contracts .......................................................................................................................... 65 XML Schema (XSD) .......................................................................................................................................... 65 Web Services Description Language (WSDL) .................................................................................................. 65 Annotated Examples of XSD and WSDLs Available in the Deployment Console ............................................ 66 Passing Null Values in XML Messages ................................................................................................................. 66 Support for Windows Communication Framework (WCF) ................................................................................. 67 Definitions Section (WSDL only) ..................................................................................................................... 67 Decision Service Information Section (WSDL & XSD) ..................................................................................... 67 PortType Section (WSDL only) ........................................................................................................................ 69 Binding Section (WSDL only)........................................................................................................................... 69 .NET Compatible XML Messaging ................................................................................................................... 70 Invoking Corticon Server ......................................................................................................................................... 71 Methods of Calling Corticon Server .................................................................................................................... 71 SOAP Call......................................................................................................................................................... 71 Java Call........................................................................................................................................................... 71 Request/Response Mode .................................................................................................................................... 72 Administrative APIs ............................................................................................................................................. 73 Monitoring Corticon Server ..................................................................................................................................... 75 Launching and Logging In to Server Console ...................................................................................................... 75 Console Main Menu Page ................................................................................................................................... 76 Decision Services Page ........................................................................................................................................ 78 Service Name .................................................................................................................................................. 78 Version ............................................................................................................................................................ 82 Live .................................................................................................................................................................. 82 Deployed from CDD ........................................................................................................................................ 82 Dynamic Reload .............................................................................................................................................. 83 Executions ....................................................................................................................................................... 83 Avg Time (ms) ................................................................................................................................................. 85 Clear Stats ....................................................................................................................................................... 85 Deploy Decision Service Page ............................................................................................................................. 85 Server State..................................................................................................................................................... 86
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page iv
Configure Rule Server ......................................................................................................................................... 87 Logging Tab ..................................................................................................................................................... 87 Deployment Directory Tab.............................................................................................................................. 87 Decision Service Options Tab.......................................................................................................................... 88 License Tab...................................................................................................................................................... 88 Monitor Rules Server Page.................................................................................................................................. 88 Rules Server Stats Tab..................................................................................................................................... 89 Rules Server Settings Tab................................................................................................................................ 89 Environment Settings Tab............................................................................................................................... 89 Memory Utilization Tab .................................................................................................................................. 89 Rules Server Log .............................................................................................................................................. 89 WSDLs.................................................................................................................................................................. 89 Configuring Corticon Server .................................................................................................................................... 90 Most Common Property Changes ....................................................................................................................... 91 Log Location .................................................................................................................................................... 91 Log Level ......................................................................................................................................................... 91 Automatic Decision Service Reload ................................................................................................................ 91 Inside Corticon Server ............................................................................................................................................. 93 The Basic Path ..................................................................................................................................................... 93 Ruleflow Compilation the .eds File .................................................................................................................. 93 Multi-threading and Concurrency Reactors and Server Pools ......................................................................... 93 State .................................................................................................................................................................... 94 Reactor State .................................................................................................................................................. 94 Corticon Server State ...................................................................................................................................... 95 Dynamic Discovery of New or Changed Decision Services ................................................................................. 96 Replicas and Load Balancing ............................................................................................................................... 97 Exception Handling ............................................................................................................................................. 97 Decision Service Versioning and Effective Dating ................................................................................................... 98 Deploying Decision Services with Identical Decision Service Names.................................................................. 98 Sample Ruleflows ................................................................................................................................................ 99 Invoking a Decision Service by Major Version Number .................................................................................... 102 Specifying a Major Version in a SOAP Request Message ............................................................................. 102 Specifying Version in a Java API Call ............................................................................................................. 105 Default Behavior ........................................................................................................................................... 105 Invoking a Decision Service by Date.................................................................................................................. 105 Specifying Decision Service Effective Timestamp in a SOAP Request Message ........................................... 106 Specifying Effective Timestamp in a Java API Call ........................................................................................ 109 Default Behavior ........................................................................................................................................... 109 Specifying Both Major Version and Effective Timestamp ............................................................................ 110 Summary of Major Version and Effective Timestamp Behavior ....................................................................... 111 Performance and Tuning Guide............................................................................................................................. 112 Rulesheet Performance and Tuning .................................................................................................................. 112 Server Performance and Tuning ....................................................................................................................... 112
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page v
Optimizing Pool Settings for Performance ................................................................................................... 112 Single Machine Configuration....................................................................................................................... 113 Cluster Configuration .................................................................................................................................... 114 Logging .......................................................................................................................................................... 115 Batching the Data in a Single Transaction .................................................................................................... 115 Capacity Planning.......................................................................................................................................... 116 Internationalization ............................................................................................................................................... 118 Appendix A: Service Contract and Message Samples........................................................................................... 119 Annotated Examples of XSD and WSDLs Available in the Deployment Console .............................................. 119 1 Vocabulary-Level XML Schema, FLAT XML Messaging Style ....................................................................... 119 Header .......................................................................................................................................................... 119 CorticonRequestType and CorticonResponseType ...................................................................................... 119 WorkDocumentsType ................................................................................................................................... 121 MessagesType............................................................................................................................................... 121 VocabularyEntityNameType ......................................................................................................................... 122 VocabularyAttributeNameTypes .................................................................................................................. 123 2 Vocabulary-Level XML Schema, HIER XML Messaging Style ....................................................................... 124 Header .......................................................................................................................................................... 124 CorticonRequestType and CorticonResponseType ...................................................................................... 124 WorkDocumentsType ................................................................................................................................... 124 MessagesType............................................................................................................................................... 124 VocabularyEntityNameType ......................................................................................................................... 124 VocabularyAttributeNameTypes .................................................................................................................. 124 3 Decision-Service-Level XML Schema, FLAT XML Messaging Style............................................................... 125 Header .......................................................................................................................................................... 125 CorticonRequestType and CorticonResponseType ...................................................................................... 125 WorkDocumentsType ................................................................................................................................... 125 MessagesType............................................................................................................................................... 125 VocabularyEntityNameType and VocabularyAttributeNameTypes ............................................................. 125 4 Decision-Service-Level XML Schema, HIER XML Messaging Style ............................................................... 126 Header .......................................................................................................................................................... 126 CorticonRequestType and CorticonResponseType ...................................................................................... 126 WorkDocumentsType ................................................................................................................................... 126 MessagesType............................................................................................................................................... 126 VocabularyEntityNameType and VocabularyAttributeNameTypes ............................................................. 126 5 Vocabulary-Level WSDL, FLAT XML Messaging Style .................................................................................. 127 SOAP Envelope.............................................................................................................................................. 127 Types ............................................................................................................................................................. 127 Messages ...................................................................................................................................................... 127 PortType........................................................................................................................................................ 127 Binding .......................................................................................................................................................... 127 Service........................................................................................................................................................... 128 6 Vocabulary-Level WSDL, HIER XML Messaging Style .................................................................................. 129 SOAP Envelope.............................................................................................................................................. 129 Types ............................................................................................................................................................. 129
Page vi
Messages ...................................................................................................................................................... 129 PortType........................................................................................................................................................ 129 Binding .......................................................................................................................................................... 129 Service........................................................................................................................................................... 129 7 Decision-Service-Level WSDL, FLAT XML Messaging Style .......................................................................... 130 SOAP Envelope.............................................................................................................................................. 130 Types ............................................................................................................................................................. 130 Messages ...................................................................................................................................................... 130 PortType........................................................................................................................................................ 130 Binding .......................................................................................................................................................... 130 Service........................................................................................................................................................... 130 8 Decision-Service-Level WSDL, HIER XML Messaging Style .......................................................................... 131 SOAP Envelope.............................................................................................................................................. 131 Types ............................................................................................................................................................. 131 Messages ...................................................................................................................................................... 131 PortType........................................................................................................................................................ 131 Binding .......................................................................................................................................................... 131 Service........................................................................................................................................................... 131 Extended Service Contracts .............................................................................................................................. 132 Examples ........................................................................................................................................................... 134 Vocabulary-Level WSDL, FLAT XML Messaging Style.................................................................................... 135 Decision-Service-Level XSD, HIER XML Messaging Style............................................................................... 139 Sample CorticonRequest Content ................................................................................................................ 141 Sample CorticonResponse Content .............................................................................................................. 142 Appendix B: API Summary .................................................................................................................................... 144 Appendix C: Corticon Business Rules Management Properties & Settings .......................................................... 145 Controlling Corticon Studio ............................................................................................................................... 145 Controlling Corticon Server ............................................................................................................................... 145 Common Properties (CcCommon.properties) .................................................................................................. 146 Properties used by Both Studio and Server ................................................................................................. 146 Corticon Deployment Console Properties (CcDeployment.properties)............................................................ 155 Properties Used by Deployment Console ..................................................................................................... 155 Corticon Studio Properties (CcStudio.properties)............................................................................................. 157 Properties Used by Studio Only .................................................................................................................... 157 Corticon Server Properties (CcServer.properties)............................................................................................. 160 Properties Used Solely by Business Rules Server ......................................................................................... 160 Appendix D: Sample Code Summary .................................................................................................................... 168 Appendix E: Corticon Studio and Server 5.2 Product Documentation ................................................................. 170 Appendix F: Using the Corticon Business Rules Server Installer ......................................................................... 171 Corticon Server Setup Wizard ........................................................................................................................... 171 System Requirements ....................................................................................................................................... 171 New Installation or Upgrade? ....................................................................................................................... 172 License Agreement ....................................................................................................................................... 173
Page vii
Choosing Installation Directory .................................................................................................................... 173 Changing Installation Directory .................................................................................................................... 174 Install Set ...................................................................................................................................................... 175 Pre-Installation Summary ............................................................................................................................. 175 Install Status.................................................................................................................................................. 176 Completing the Setup Wizard ....................................................................................................................... 176 Desktop Shortcut .......................................................................................................................................... 177 Program Maintenance ...................................................................................................................................... 177 Remove Program .......................................................................................................................................... 177
Page 8
PREFACE
INTENDED AUDIENCE
The Server Integration & Deployment Guide provides you with the necessary steps to install and integrate Corticon Server into a Web Service or Java container. This guide is intended for use by technical architects and application developers. This document assumes that you are familiar with various third-party software products and operating environments. Please refer to Appendix E for references to further documentation.
DOCUMENTATION CONVENTIONS
Corticon Business Rules Management technical documentation uses the following conventions: Document names are shown in bold face italic type: Server Integration & Deployment Guide. Screen, menu and button names are shown in bold face type: Custom Setup screen. The following icons precede important information such as Tools, Notes, Tips and Warnings. Associated text is shown in the font and color scheme illustrated: Tools Notes and Tips Warnings
Hyperlinks are underlined and shown in blue: the cursor changes to a hand: Custom Setup. In some cases, hyperlinks connect to external, 3rd-party resources that were verified current at time of publication. Corticon does not warrant operation of these links beyond date of publication. File names, paths, methods, class names and data are shown in red monotype: Installing.pdf.
Page 9
Page 10
OVERVIEW
The Corticon Business Rules Server installation and deployment process involves the sequence of activities illustrated in the following diagram. Use this diagram as a map to this manual each box below corresponds to a following chapter. Choose Deployment Architecture Install the Business Rules Server Deploy Decision Services Integrate Decision Services Invoke Decision Services
Corticon Server is deployed with a Currently using Web Services. Servlet interface, causing individual Need to expose Decision Services Ruleflows to act as Web Services. to the Internet or other distributed Invocations to Corticon Server are architecture. made using standard SOAP Using Microsoft .NET or other requests, and data is transferred legacy systems which do not within the SOAP request as an XML support Java method calls payload. (invocations). Corticon Server is deployed with an Prefer to use XML for best Enterprise Java Bean (EJB) interface flexibility in data payload. and integrated with architectures Prefer JMS or RMI method calls for that can make Java method calls high performance and/or tighter
January 13, 2012
Server Integration & Deployment Guide 5.2 and transfer XML payloads. 3 - Java Services with Java Object Payloads coupling to client applications.
Page 11
Corticon Server is deployed with an Prefer Java objects for data Enterprise Java Bean (EJB) interface payload. and integrated with architectures Prefer JMS or RMI method calls for that can make Java method calls high performance. and transfer Java object payloads. Willing to accept decreased portability Corticon Server is deployed into a Require lightest-weight, smallestclient-managed JVM as Java classes footprint install. Prefer direct, in-process method calls for lowest messaging overhead and fastest performance
Table 1 Corticon Server Installation Options
Call Server With SOAP: RPC or Document-style Server API via JMS Server API via RMI in-process Java methods from the Server API
Send Data As XML String (RPC-style) XML Document (Document-style) XML String or JDOM collection or map of Java Business Objects XML String or JDOM collection or map of Java Business Objects
Java Classes
Page 12
When deploying Corticon Decision Services into a Web Services server, the Deployment Console (or Deployment Console API) is used to generate WSDL files for each Decision Service (see Deploying Corticon Ruleflows). These WSDL files can then be used to integrate the Decision Services into Consuming applications as standard Web Services (see Integrating Decision Services). Corticon users can also build their own infrastructure that publishes the WSDL files to UDDI directories for dynamic discovery and binding.
This approach avoids the overhead of SOAP messaging, but requires that consuming applications speak Java, in other words, be able to invoke the Corticon Server API via JMS or RMI. The payload of the call is the same XML representation as in the Web Services deployment method, minus the SOAP wrapper. Using XML offers good decoupling of consuming application from Decision Service and greater degrees of flexibility.
This option offers the best performance, as payloads dont need transformation from objects to/from XML. That being said, it is also the least portable because it requires Java objects and a tight relationship between those objects and the Corticon Vocabulary to exist. In addition, it suffers in flexibility because changes to the Vocabulary require changes to the Java object model (note: External name mapping and extended attributes, as discussed below and in the Corticon product documentation, offer some help in coping with these constraints).
Installation Option 4: In-process Java Classes with Java Object or XML Payloads
The installation option with lightest weight and smallest footprint is the In-process Java option. With this option, no interface or wrapper class is used to forward calls from the client application to Corticon Server (CcServer.jar). Instead, the client must use the Corticon Server Java API to initialize the Corticon Server classes, load any Decision Services, and execute them. In addition, the client application must start and manage the JVM in which the Corticon Server classes are loaded.
Page 13
JVM and thread management are normally functions of the Servlet or EJB container in a web or application server if you choose to take responsibility for these activities in your client code then you dont need a container, at least as far as Corticon Server is concerned. Installing Corticon Server without a web or application server reduces the overall application footprint and permits more compact installations, but by eliminating the helpful functions of the container, it places more of the deployment burden on you.
Page 14
logic.
CcConfig.jar this contains a set of text .property files that list and set all the
and JDOM. Corticon warrants Corticon Server operation ONLY with the specific set of classes inside this jar.
CcI18nBundles.jar this contains the English and other language templates used by Corticon Server. ant-launcher.jar supports Corticon Servers deployment-time Decision
language operators as Extended Operators. (See the Rule Language Guide for details.)
Page 15
executed in Studio Ruletests as they do when executed by Corticon Server, no matter how Corticon Server is installed.
Page 16
WebLogic, Oracle AS, or IBM WebSphere. Commercial application servers offer the greatest degree of manageability, security and reliability, but open-source J2EE application servers such as JBOSS are also available. One advantage of the wrapper or helper class approach to installation is that variations in the application server environment may be addressed in the wrapper class itself, rather than in the set of Corticon Server classes. The base set of Corticon Server jars remains the same irrespective of deployment environment only the wrapper class changes. The industry-standard method of deploying an EJB into a J2EE application servers EJB container is via an enterprise archive, or .ear, file. This file contains everything required to deploy a fully functional Session EJB (stateless), including all classes, configuration files and interfaces. Corticon includes a complete sample .ear file along with all source code with the standard default Corticon Server installation. Your application server documentation will include instructions for installing an .ear file. This .ear file, named CcServer.ear, is located in the Samples\Server\Containers\EAR directory, which is in the Corticon installation directory. Note: the .ear file provided is intended to be a sample wrapper for instructional purposes. Source code is also included in \src so you can adapt the wrapper to your specific environment and platform. The sample .ear file is not certified for use on any specific application server and is not warranteed by Corticon. This .ear file contains the default evaluation license, named CcLicense.jar. If you are a Corticon customer, you will be provided with a permanent version of this file. You must insert it into the .ear (replacing the original) in order to remove the evaluation license limitations. The sample .ear file also contains axis.war, enabling you to deploy both a Servlet and a EJB version of Corticon Server simultaneously. This allows you to expose both SOAP and Java interfaces to the same Decision Service, making your Decision Services even easier to use throughout your enterprise infrastructure.
Page 17
Transaction management, including invocation of Corticon Server using the standard Java API set.
Corticon Server can also be installed into a custom container within any application. Corticon Server has a small footprint and thus can be installed into client applications including browser-based applications, laptops and mobile devices. For step-by-step instructions on using the Installer to gain access to Corticon Servers core jar files, see Appendix F of this guide. Installation in-process or in a custom container involves these basic steps: Place the following Corticon Server jar files in a location accessible by the surrounding Java container:
CcServer.jar CcConfig.jar CcServerLicense.jar CcThirdPartyJars.jar CcI18nBundles.jar ant_launcher.jar CcExtensions.jar [optional only necessary if you have added custom rule language
operators to the Operator Vocabulary as Extended Operators. (See Rule Language Guide for details.) Configure the Java classpath to include the jar files listed above. Change the logPath property inside CcCommon.properties to an explicit path to a directory for the Corticon Server Log file. Write code that:
Initializes Corticon Server Sets environment variables such as CORTICON_HOME (see below) Deploys the Decision Services into Corticon Server Requests a decision by marshaling the data payload and then invoking the relevant Corticon Decision Service Processes the response from the Decision Service. Sample code is provided that demonstrates an in-process deployment of Corticon Server. This code, named testServer.bat, is located in the Server directory of your Corticon installation directory.
Page 18
Therefore, when Corticon Server starts up from this batch file, the logPath location will be:
Server\Tomcat\CcServer\Log (assuming Windows) in your Corticon installation directory. This
directory will be created the first time Server starts up, if its not already present. Youll find many cases where file paths and locations are controlled by CORTICON_HOME variable - be sure to set this value in your Corticon Server startup script or include it in your Corticon Server wrapper classes.
When using the sample startServer.bat file, this location is Server\Tomcat\CcServer\CcServerSandbox (assuming Windows path notation) in your Corticon installation directory. This directory will be created the first time Server starts up, if its not already present. If the location specified by com.corticon.ccserver.sandboxDir cannot be found or is not available, the location defaults to the JVMs home directory.
Page 19
Page 20
Figure 1 testServerAxisTomcat.bat
When executed, the testServerAxisTomcat.bat opens a DOS window and displays the API menu, as shown below:
Page 21
The menu displayed in the DOS window is too large to fit on a single printed page, so it has been divided into two screenshots here. In the upper portion of the DOS window, shown in Figure 2, above, the classpath definition process is visible. Once all classes are loaded, the Corticon Server starts up in the JRE, which is needed by our simple SOAP client class.
Page 22
In the lower portion of the DOS window, shown in Figure 3 above, we see the available API methods listed by number. Most of these methods apply to Corticon Server with loaded Ruleflows. Since we have not deployed any Ruleflows yet, we will need to use an administrative method to test if Corticon Server is correctly installed as a SOAP Servlet inside our web server. A good administrative method to call is option #23, Get CcServer current info. This choice corresponds directly to the Java API method getCcServerInfo(), described in complete detail in the JavaDocs provided in the standard Corticon Server installation. Selecting option #23, Get CcServer current info, causes the CcServerAxisTest class to make a call to the Corticon Server SOAP Servlet. It asks for a list of configuration parameters and returns them to the DOS window. The results of the call are shown in Figure 4, below:
Page 23
The response verifies that our Server is running correctly as a SOAP Servlet and is listening for, and responding to, calls. At this stage in the deployment, this is all we want to verify.
Page 24
directory, and is designed to perform the basic in-process initialization, and then present a menu of API methods you can invoke from within a DOS window. Viewing testServer.bat with a text editor, you can see how it sets classpaths, starts the JVM and then invokes the CcServerApiTest class. The source code (.java) for this class is provided in the Server\src directory of your Corticon installation directory. It is a good reference to use when you want to see exactly how the Corticon Server API set is used in your own code. In addition to the 6 base Corticon Server jars listed above, the batch file also loads some hard-coded Java business objects for use with the Java Object Messaging options (menu option 28-33 in Figure 7). These hard-coded classes are included in CcServer.jar so as to ensure their inclusion on the JVMs classpath whenever CcServer.jar is loaded. The hard-coded Java objects are intended for use when invoking the OrderProcessing.erf Decision Service included in the default Corticon Server installation.
Figure 5 testServer.bat
When executed, the testServer.bat opens a DOS window and displays the API menu, as shown below:
Page 25
The menu displayed in the DOS window is too large to fit on a single printed page, so it has been divided into two screenshots here. In the upper portion of the DOS window, shown in Figure 6, above, the class loading process is visible. Once all classes are loaded, Corticon Server starts up in the JVM.
Page 26
In the lower portion of the DOS window shown in Figure 7 above, we see the available API methods, listed by number. Most of these methods apply to a Corticon Server with loaded Rulesheets. Since we have not deployed any Rulesheets yet, we will need to use an administrative method to test if Corticon Server is loaded in-process correctly. A good administrative method to call is option #23, Get CcServer Info. This choice corresponds directly to the Java API method getCcServerInfo() described in complete detail in the JavaDoc. Selecting option #23, Get CcServer Info, causes the CcServerApiTest class to make a call to the Corticon Server running in-process. It asks for a list of configuration parameters and returns them to the DOS window. The results of the call are shown in Figure 8, below:
testServer.bat didnt load any Decision Services, so Corticon Server is basically replying with an
empty status message. But the important thing is that we have verified that Corticon Server is running correctly in-process and is listening for, and responding to, calls. At this stage in the deployment, this is all we want to verify.
Page 27
XML Mapping
If you have chosen to use Option 1 or 2 in Table 1 in other words, the data payload of your call will be in the form of an XML document then your Vocabulary may need to be configured to match the naming convention of the elements in your XML payload. Entity Mapping Vocabulary entities correspond to XML complex elements (complexTypes). If the complexType matches exactly (spelling, case, special characters, everything), then no mapping is necessary. However, if the complexType name differs in any way from the Vocabulary entity name, then the complexType name must be entered into the XML Class Name property, as shown below.
Page 28
In the example shown in Figure 10, the Vocabulary entity name (Aircraft) does not exactly match the name of the external XML Class (Plane), so the mapping entry is required. If the two names were identical, then no mapping entry would be necessary. If XML Namespaces vary within the document, then use the XML Namespace field to enter the full namespace of the XML Element Name. If no XML Namespace value is entered, then it is assumed that all XML Elements use the same namespace. Attribute Mapping Vocabulary attributes correspond to XML simple elements. If the element name matches exactly (spelling, case, special characters, everything), then no mapping is necessary. However, if the element name differs in any way from the Vocabulary attribute name, then the element name must be entered into the XML Property Name property, as shown in Figure 11, below.
If XML Namespaces vary within the document, then use the XML Namespace field to enter the full namespace of the XML Element Name. If no XML Namespace value is entered, then it is assumed that all XML Elements use the same namespace.
Page 29
Vocabulary associations correspond to references between XML complex elements. If the element name matches exactly (spelling, case, special characters, everything), then no mapping is necessary. However, if the element name differs in any way from the Vocabulary association name, then the element name must be entered into the XML Property Name property, as shown below.
XML Namespace Mapping Changes in BRMS Version 5.2 In BRMS versions prior to 5.2, Corticon Server assumed that incoming XML requests were loosely compliant with the XSD/WSDL generated for a particular Decision Service (by the Deployment Console, for example). The Corticon XSD/WSDLs generated all had a targetNamespace of urn:Corticon. The problem with this approach is that most SOA systems, particularly those that care about XML validation, require the targetNamespace to be unique, ideally globally unique. Two properties in CcDeployment.properties (com.corticon.xml.addDefaultNamespace and com.corticon.schemagenerator.addDefaultNamespace) allow you to turn off targetNamespace usage in the XSD/WSDL altogether. But prior to version 5.2, you could not selectively assign specific namespaces to specific elements (either Entities or Attributes) within the Vocabulary. In version 5.2, the XML Schema targetNamespace is controlled by a new CcDeployment.properties property named ensureUniqueTargetNamespace so that you can specify the desired behavior of Corticons XSD/WSDL generation subsystem. By default, the SOAP envelope targetNamespace will be set to a concatenation of the following strings: the WSDL's service soap address location + forward slash character (/) + the decision service name.
You can also switch back to old (prior to version 5.2) behavior for backward compatibility purposes by setting ensureUniqueTargetNamespace=false. The following screenshots juxtapose old XSD/WSDLs with new XSD/WSDLs:
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 30
Figure 13 Old XSD with Generic Namespace (version 5.1 and earlier)
Figure 14 New XSD with Unique Namespace (version 5.2 and later)
Figure 15 Old WSDL with Generic Namespace (version 5.1 and earlier)
Figure 16 New WSDL with Unique Namespace (version 5.2 and later)
Namespace mapping changes in version 5.2 also affect some APIs. Please see the JavaDoc for full details.
Page 31
3. Use the Browse button to select the location of your Java Business Objects. They should be compiled class files or Java archives (.jar files).
Page 32
4. Select the package containing the Java business objects as shown above
5. If the import succeeds, you will see the message shown in Figure 20.
Page 33
Now that the import is complete, well examine our Vocabulary to see what happened. Entity Lets take a look at our sample class, which we intend to map to the Aircraft entity.
We can see in line 6 of Figure 21 that this class isnt actually named Aircraft its named MyAircraft. The automatic mapper attempts to locate a class by the same name as each entity. In the case of Aircraft, it looks for a class named Aircraft. Not finding one, it leaves the field empty, as shown in Figure 22.
Page 34
Because no Aircraft class exists in the package, we need to manually map this entity, using the Java Package and Java Class Name drop-downs, as shown in Figure 23, below. The metadata import process populates the drop-downs for us. Be sure to select the package name from the Java Package drop-down so the mapper knows where to look.
Attribute When attempting to map attributes, the mapper looks for class properties which are exposed using public get and set methods by the same name. For example, if mapping attribute flightNumber, the mapper looks for public getFlightNumber and setFlightNumber methods in the mapped class.
Page 35
In the case of attribute tailNumber, the mapper finds get and set methods that conform to this naming convention, so the method names are inserted into the fields in gray type, as shown in Figure 25, below.
In those cases where the mapper cannot locate the corresponding methods, you will need to select them manually. Notice in the MyAircraft class shown in Figure 21, no get and set methods exist for istrAircraftType since it is a public instance variable. Therefore, we need to select it from the Java Object Field Name drop-down, as shown in Figure 26, below.
Page 36
When a class property contains get and set methods, but their names do not conform to the naming convention assumed by the auto-mapper, we must select the method names from the Java Object Get Method and Set Method drop-downs, as shown in Figure 27 below.
If you worked with Java Object Messaging and mapping in earlier versions of Corticon Business Rules Management, then you may recall that external data types also required manual mapping. In Version 5.2, a propertys data type is detected by the auto-mapper, so theres no need to manually enter it. This is shown by the flightNumber attribute in Figure 28, below. Note from Figure 21 that this property uses a primitive data type int, and it is automatically mapped anyway.
Page 37
Association The mapper looks for get and set methods for associations the same way that it does for attributes. In the case of the Aircraft.flightPlan association, shown in Figure 29, below, these methods dont conform to the naming convention expected by the mapper. So once again, we must manually select the appropriate method names from the Java Object Get Method and Set Method drop-downs, as shown in Figure 30, below.
Page 38
Java Generics
Support for type-casted collections is included in Corticon Business Rules Management Version 5.2. If your Java Business Objects include type-casted collections (introduced in Java 5), then Corticon will ensure these constraints are interpreted correctly in association processing.
Java Enumerations
Enumerations are custom Java objects you define and use inside of your Business Objects. They are used to define a preset value set for a particular type. For simplicity, lets assume that a Java Enumeration has a Name and multiple Labels (or Types). Here is a common example of a Java Enumeration:
public enum Day { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY; }
The Day enumeration has 5 different Labels {Day.MONDAY, Day.TUESDAY, Day.WEDNESDAY, Day.THURSDAY, and Day.FRIDAY}. All of these labels are all considered of type Day. So if a method signature accepts a Day type, it will accept all 5 of these defined labels. For example:
public class Person { private Day iPayDay = null; public Day getPayDay() {return iPayDay;} public void setPayDay(Day aValue) {iPayDay = aValue;} }
Page 39
Because Day.MONDAY is of type Day, the setting of the value is complete. Prior to Version 5.2, business rules could only set basic Data Types into Business Objects. Basic data types included String, Long, long, Integer, int, Boolean, boolean, etc. But in 5.2, business rule execution can also set your business objects Enumeration values. Corticon performs this by matching Labels in your business objects enumerations with the Custom Data Type (CDT) labels defined in your Vocabulary. From our example: Java Enumeration Label Names for enum Day:
MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY
Now, the Vocabulary must have these same Labels defined in the CDT that is assigned to the attribute.
Figure 31 Vocabulary CDT Labels must match Business Object Enumeration Labels (Types)
Page 40
Figure 32 Vocabulary Mapper found correct Metadata based on matching enumeration labels
The key to metadata matching is the Labels as long as your BO enumeration labels match the Vocabularys CDT Labels, it should work fine. So what happens if the Labels do NOT match? Extra validation has been added to the Vocabulary to help identify this problem. The example below shows a Label mismatch:
Notice the Vocabulary attribute is flagged with the small orange warning icon (shown in the upper left of the figure above). The associated warning message states:
Java Object Get Method getPayDay return type is an Enumeration and has a mismatch in values between the Enumeration Labels [MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY] and Custom Datatype Labels [MONDAYS, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY].
Page 41
Once all mappings have been made (either automatically or manually), these warning icons will disappear.
Listeners
During runtime, when an attributes value is updated by rules, the update is communicated back to the business object by way of Listener classes. Listener classes are compiled at deployment time when Corticon Server detects a Ruleflow using Java Object Messaging. Once compiled, these Listener classes are also added to the .eds file, which is the compiled, executable version of the .erf. This process ensures that Corticon Server knows how to properly update the objects it receives during an invocation. Because the update process uses compiled Listener classes instead of Java Reflection, the update process occurs very quickly in runtime. Even though Java Object metadata was imported into Studio for purposes of mapping the Vocabulary, and those mappings were included in the Rulesheet and Ruleflow assets, the Listener classes, like the rest of the .erf, is not compiled until deployment time. As a result, the same Java business object classes must also always be available to Corticon Server during runtime. Corticon Server assumes it will find these classes on your application servers classpath. If it cannot find them, Listener class compilation will fail, and your deployed Ruleflow will be unable to process transactions using Java business objects as payload data. If a Ruleflow (.erf) is deployed to Corticon Server without compiled Listeners, then it will accept only invocations with XML payloads, and reject invocations with Java object payloads. When invoked with Java object payloads, Corticon Server will return an exception, as shown in Figure 35, below.
CcServer.execute(String, Collection, Integer, Date) Decision Service DecisionServiceName is not enabled to run Object Execution. Vocabulary and Ruleset need to be regenerated with proper Java Object mappings in place
Page 42
Rulesheets may be tested in Studio using Ruletests, however they must be packaged as Ruleflows in order to be deployed to Corticon Server. Rulesheets cannot be deployed directly to Corticon Server. Once a Ruleflow has been built and tested in Studio, it must be prepared for deployment. Deploying a Ruleflow requires at least one and, often two, steps:
RULEFLOW DEPLOYMENT
Once a Ruleflow has been deployed to the Corticon Server, we stop calling it a Ruleflow and start calling it a Decision Service. The process of deploying a Ruleflow is really an act of instructing a running Corticon Server instance to load a Ruleflow and prepare to execute it in response to a call from an external client application. There are 2 ways to inform the Corticon Server which Ruleflows it should load and how to configure certain execution parameters for each. These methods are discussed in the following paragraphs.
Deployment Descriptor files are easily created and managed using the Corticon Deployment Console utility. The Deployment Console is included by default in all Corticon Server installations. Purpose of the Deployment Console Utility The Deployment Console has two functions:
Page 43
Create Deployment Descriptor files. These files, carrying the file suffix .cdd, are XML documents which instruct Corticon Server which Ruleflows to load, and how to configure certain parameters and settings for each Ruleflow. Creating and using Deployment Descriptor files will make up the main topics within this chapter. Create XML service contract documents. These documents are used for Ruleflow integration and will be discussed in the Integration chapter of this manual.
Launching the Deployment Console Utility Deployment Console is started in one of two ways: From the Windows Start menu, Programs>Corticon>Deployment Console. Using the batch file DepConsole.exe in the Server directory of your Corticon installation directory.
The Deployment Console is divided into two sections (one section for each of its two functions), shown in Figure 36 with orange labels. Because the Deployment Console is a wide window, it will be shown as two halves - a left half shown in Figure 36 and a right half shown in Figure 37. Depending on your screen resolution, you may need to scroll between the left and right portions of the Deployment Console window using the horizontal scroll bar provided. The blue numbered circles shown in the figures are further described below:
Page 44
Deployment Descriptor
2 7
5 8
6 9
Service Contract
This section is described in the Integrating Decision Services chapter of this manual
Figure 36 Left Portion of Deployment Console, with Deployment Descriptor File Options Numbered
The numbered steps below correspond to the Deployment Console diagram above. 1. File menubar. File is used to create new Deployment Descriptor files (File>Save), open an 1 existing .cdd (File>Open), or save a .cdd under a different name (File>Save As). The .cdd name appears in the title bar. 2. Decision Service Name. A unique identifier or label for the Decision Service. It is used when 2 invoking the Decision Service, either via an API call or a SOAP request message. See Invoking Corticon Server for usage details. 3 3. Ruleflow. All Ruleflows listed in this section are included in the open Deployment Descriptor file. The name of the open Deployment Descriptor file is shown in the Deployment Consoles title bar. Deployment properties are specified on a per-Ruleflow basis. Each row represents one Ruleflow. Use the button to navigate to a Ruleflow file and select it for inclusion in this Deployment Descriptor file. Note that Ruleflow absolute pathnames are shown in this section, but relative pathnames are included in the actual .cdd file.
Page 45
The term deploy, as we use it here, means to inform the Corticon Server that you intend to load the Ruleflow and make it available as a Decision Service. It does not require actual physical movement of the .erf file from a design-time location to a runtime location, although you may do that if you choose just be sure the files path is up-to-date in the Deployment Descriptor file. But movement isnt required you can save your .erf file to any location in a file system, and also deploy it from the same place as long as the running Corticon Server can access the path. 4 Version: the version number assigned to the Ruleflow in the Ruleflow>Properties window of Corticon Studio. Note that this entry is editable only in Studio and not in the Deployment Console. An explanation of how Corticon Server processes this information is found in the Decision Service Versioning and Effective Dating chapter, below. Also see the Quick Reference Guide for a brief description of the Ruleflow Properties window and the Rule Modeling Guide for details on using the Ruleflow versioning feature. It is displayed in the Deployment Console simply as a convenience to the Ruleflow deployer. 5 Version Label: the version label assigned to the Ruleflow in the Ruleflow>Properties window of Corticon Studio. Note that this entry is editable only in Studio and not in the Deployment Console. See the Quick Reference Guide for a brief description of the Ruleflow Properties window and the purpose of the Ruleflow versioning feature. 6 Effective Date: the effective date assigned to the Ruleflow in the Ruleflow>Properties window of Corticon Studio. Note that this entry is editable only in Studio and not in the Deployment Console. An explanation of how Corticon Server processes this information is found in the Decision Service Versioning and Effective Dating chapter, below. Also see the Quick Reference Guide for a brief description of the Ruleflow Properties window and the purpose of the Ruleflow effective dating feature. 7 2. Add/Remove Ruleflow. The Add button creates a new empty row in section 3. The Remove button removes the highlighted row from section 3. There is no limit to the number of Ruleflows that may be included in a single Deployment Descriptor file. 3. Pre-compile Decision Services: By default, Corticon Server compiles Ruleflows upon 8 deployment, on-the-fly. In other words, a Ruleflow is not compiled until it is deployed to Corticon Server. You can choose to pre-compile Ruleflows in advance of deployment. If you choose to pre-compile, then youll be prompted for a deposit location for the .eds file (which contains the compiled executable code). The .cdd file will contain reference to the .eds instead of the usual .erf file. 4. Save Deployment File: saves the .cdd file. Equivalent to File>Save option from the File 9 menubar. 5. 10 Expiration Date: the expiration date assigned to the Ruleflow in the Ruleflow>Properties window of Corticon Studio. Note that this entry is editable only in Studio and not in the Deployment Console. An explanation of how Corticon Server processes this information is found in the Decision Service Versioning and Effective Dating chapter, below. Also see the Quick Reference Guide for a brief description of the Ruleflow Properties window and the purpose of the Ruleflow expiration dating feature.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 46
Minimum: The minimum number of instances or copies created for a Decision Service when it is loaded by Corticon Server. Instances of a Decision Service are known as Reactors. These Reactors are placed in a pool, where they wait patiently until assigned by Corticon Server to an incoming request, or expire due to inactivity. The larger the pool size, the greater the concurrency (but greater the memory usage). Default entry is 1, which means that even under no load no incoming requests Corticon Server will always maintain one Reactor in the pool for this Decision Service. Maximum: The maximum number of Reactors Corticon Server can put into the pool for this Decision Service. Therefore, the number of Reactors that can execute concurrently is determined by the max pool size. If additional requests for the Decision Service arrive when all Reactors are busy, the new requests queue until Corticon Server can allocate a Reactor to the new transaction (usually right after a Reactor is finished with its current transaction). The more Reactors in the pool, the greater the concurrency (and the greater the memory usage). See Performance and Tuning chapter for more guidance on Pool configuration. Default entry is 5.
10
11
12
13
This section is described in the Integrating Decision Services chapter of this manual
Figure 37 Right Portion of Deployment Console, with Deployment Descriptor File Options Numbered
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 47
7. 12 Dynamic Reload. If Yes, then Corticon Server will periodically look to see if a Deployment Descriptor file, or any of the Decision Service entries in that file, has changed since the .cdd was last loaded. If so, it will be automatically reloaded. The time interval between checks is defined by property com.corticon.ccserver.serviceIntervals in CcServer.properties. Even if No, Corticon Server will still use the most recent Ruleflow when it adds new Reactors into the pool. 8. 13 XML Messaging Style. Determines whether request messages for this Decision Service should contain a flat (Flat) or hierarchical (Hier) payload structure. The Decision Service Contract Structures section of the Integration chapter provides samples of each. If set to Auto Detect, then Corticon Server will accept either style and respond in the same way. A Deployment Descriptor File Template Deployment Descriptor files are expressed in XML. The Deployment Descriptor file shown below contains royal blue parameter names that correspond to fields in the Deployment Console. Each line containing a parameter also has a dark blue index number that references the like-numbered section in one of the two Deployment Console diagrams shown above. For example, <min-size> and <max-size>, shown below labeled with blue index number 8 correspond to the Minimum and Maximum Pool Size settings labeled with blue index number 8 in Figure 36.
<?xml version="1.0" encoding="UTF-8"?> <cdd soap_server_binding_url="URL or SOAP node relaying requests to Corticon Server"> <decisionservice> 3 <ruleset-uri>path to first Ruleflow.erf file</ruleset-uri> <auto-reload-if-modified>Dynamic Reload setting</auto-reload-if-modified> 12 <msg-struct-type>XML Messaging Style</msg-struct-type> 13 <pool> 2 <name>first decision service name</name> <min-size>minimum pool size</min-size> 11 <max-size>maximum pool size</max-size> </pool> </decisionservice> <decisionservice> 3 <ruleset-uri>path to second Ruleflow .erf file</ruleset-uri> <auto-reload-if-modified>Dynamic Reload setting</auto-reload-if-modified> 12 <msg-struct-type>XML Messaging Style</msg-struct-type> 13 <pool> 2 <name>second decision service name</name> <min-size>minimum pool size</min-size> 11 <max-size>maximum pool size</max-size> </pool> </decisionservice> </cdd>
Page 48
Note in the template Deployment Descriptor file above, two separate Decision Services are included. There is no limit to the number of Decision Services you can include in a single Deployment Descriptor file. Each Decision Service has its own <decisionservice> element. An Actual Deployment Descriptor File Using the same settings as shown in Figure 37, above, a Deployment Descriptor file was generated:
<?xml version="1.0" encoding="UTF-8"?> <cdd soap_server_binding_url="http://localhost:8082/axis/services/Corticon"> <decisionservice> <ruleset-uri>tutorial_example.erf</ruleset-uri> B <auto-reload-if-modified>true</auto-reload-if-modified> <msg-struct-type />A <pool> <name>tutorial_example</name> <min-size>1</min-size> <max-size>5</max-size> </pool> </decisionservice> <decisionservice> <ruleset-uri>ruleflow2.eds</ruleset-uri> <auto-reload-if-modified>true</auto-reload-if-modified> <msg-struct-type /> <pool> <name>ruleflow2</name> Multiple Decision <min-size>1</min-size> Services allowable <max-size>5</max-size> </pool> </decisionservice> </cdd>
In the actual Deployment Descriptor file shown above, note the following: A <msg-struct-type /> is empty in both Ruleflow sections. This indicates a selection of Auto detect in section 13 of the Deployment Console. If Flat message style is selected in section 13, the Deployment Descriptor file will contain a FLAT entry here. Selecting Hier in section 13 will insert HIER here. The path names to the Ruleflow.erf files (or .eds files if pre-compiled) are B expressed relative to the location of the Deployment Descriptor file (indicated by the ../../ syntax). If the saved location of the Deployment Descriptor file has path in common with the location of the .erf file, then the .erf path included here will be expressed in relative terms. If the two locations have no path in common (they are saved to separate machines, for example), then the .erfs path will be expressed in absolute terms. These paths may always be manually edited if changes are desired. UNC paths can also be used to direct Server to look at remote directories. Use caution in moving .cdd files once deposited because the relative
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 49
path pointer to the .erf or .eds may be disrupted. If you save a .cdd file to a particular location, then move it later, you may need to edit the relative path pointer to the .erf or .eds. If you are using the bundled Apache Tomcat server to test and deploy your Ruleflow, the Deployment Descriptor file must be copied to the Server \Tomcat\CcServer\cdd directory of your Corticon installation directory because Corticon Server is pre-configured (default settings) to read all .cdd files in this directory upon startup.
Page 50
Were already familiar with loadFromCddDir() it causes Corticon Server to look in the directory defined by the argument string and load any and all .cdd files it finds inside. This is a very convenient way to load Decision Services onto Corticon Server because one call to loadFromCddDir() is all you need to load multiple Decision Services on Corticon Server. But it is less obvious where the argument for the method is coming from. Looking lower in CcSoapServerInit.java, we see some utility methods that define the argument.
findCorticonDirectory() tries to obtain the value of autoloaddir from CcProperties. CcProperties holds all property values from CcConfig.jar for that Corticon Server instance. So in effect, the method is looking into the active CcConfig.jar file and trying to retrieve the value of com.corticon.soap.autoloaddir. But autoloaddir isnt defined in any of the .properties files inside CcConfig.jar.
Server Integration & Deployment Guide 5.2 So, failing to find a value for autoloaddir, findCorticonDirectory() next assembles a pathname by combining the values of lstrUserDir and cstrServerCddPath.
Page 51
cstrServerCddPath is a constant defined as CcServer/cdd inside this class. lstrUserDir, on the other hand, comes from cstrUserDirPropName, which is a constant defined earlier in the class as user.dir. User.dir is a variable set during JVM startup. In the case of the bundled Tomcat installation, user.dir is defined in the startServer.bat file.
When Tomcat starts, user.dir is given the value of <corticon_install_dir>\Server\Tomcat by default, and then when Corticon Server starts, it retrieves this value of user.dir in order to assemble a pathname string to use as an argument in loadFromCddDir(). When all these variables
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Server Integration & Deployment Guide 5.2 are assembled, the final argument to the method is:
<corticon_install_dir>\Server\Tomcat\CcServer\Cdd.
Page 52
Using the autoloaddir Property Although the autoloaddir property isnt set by default, its easy to add and use in your deployments. If you decide youd rather specify your cdd path in a class rather than hard-code in your application server launch scripts, simply add the com.corticon.soap.autoloaddir property to any .properties file inside CcConfig.jar. A pathname will then be available when the findCorticonDirectory() method looks for it when CcSoapServerInit.class runs during Corticon Server initialization.
Be sure to write your absolute pathname using forward slashes, as shown above. Remember, even if you chose to use the autoloaddir property, you will still need code in your interface class (wrapper) to read the property and insert it into the loadFromCddDir() method, as shown in Figure 39. And youll also need code that then invokes the loadFromCddDir() method as shown in Figure 38. Using Servers web console The Monitoring chapter explains how to set Servers autoloaddir property remotely from the web console.
using APIs
While Deployment Descriptor files are a convenient way to specify the Ruleflows to be deployed and their configuration settings, there is another way to communicate the very same information to a running Corticon Server the Java API set. In the section above describing testing an in-process installation, Figure 7 shows an option 9 named Add a Decision Service (6 parameters). Selecting this option, then entering the arguments as prompted invokes the addDecisionService() method. The arguments used by this method include: 1. Decision Service Name
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Server Integration & Deployment Guide 5.2 2. Decision Service path 3. Dynamic Reload setting (a.k.a auto-reload) 4. Minimum Pool Size 5. Maximum Pool Size 6. Message Structure Type
Page 53
As you can see, these are the very same parameters contained in the Deployment Descriptor file! Another similar option available in Figure 7 is: Add a Decision Service (3 parameters)
This method provides for backwards compatibility with previous versions of Corticon Server which had fewer features. The 3 parameter version uses only the first 3 entries (respectively) in the list above.
Deploying and Testing Decision Services via Deployment Descriptor Files (.cdd)
Start the bundled instance of Apache Tomcat and allow about 10 seconds for the web services, including the Corticon Server Servlet, to start up. Now, run the Axis test batch file testServerAxisTomcat.bat referred to earlier. Selecting option 22, shown in Figure 3, invokes the getDecisionServiceNames() method (this method requires no arguments).
Page 54
When Corticon Server started up, the Decision Service listed in Figure 43 was deployed automatically using Deployment Descriptor files included and pre-installed in <corticon_install_dir>\Server\Tomcat\CcServer\cdd. If you create your own Deployment Descriptor file and put it in this directory, the Ruleflows it contains and describes will also be deployed automatically whenever Corticon Server Servlet starts up inside Tomcat. It is important to note that Decision Services deployed using Deployment Descriptor files may only be removed from deployment or have deployment properties changed via their Deployment Descriptor file. In other words, a Decision Service deployed from Deployment Descriptor file cannot have its deployment properties changed by direct invocation of the API set; for example, if we try to use the Axis test batch file to Remove a Decision Service (option 19 and 20 from Figure 3). This is an important rule and worth reiterating: The deployment settings of Decision Services deployed via Deployment Descriptor files can only be changed by modifying their Deployment Descriptor file. The Java API methods have no effect on these Decision Services. The deployment settings of Decision Services deployed via Java API methods can only be changed via Java API methods. Deployment Descriptor files have no effect on these Decision Services.
In Figure 44, above, we see that the attempt to remove OrderProcessing, the Decision Service deployed by OrderProcessing.cdd (located in <corticon_install_dir>\Server\Tomcat\CcServer\cdd) has failed. To remove this Decision Service from deployment, or to modify any of its deployment settings, we must return to the Deployment Descriptor file, make the changes, and then allow the Corticon Server to update via its Dynamic Reload feature.
Server Integration & Deployment Guide 5.2 3. Verify that the Decision Service is loaded. 4. Remove the Decision Service from Deployment. 5. Verify that the Decision Service has been removed from deployment. Verifying no Decision Services are loaded As shown in Figure 7, option 21 requests the names of deployed Decision Services:
Page 55
The response in Figure 45 shows that no Decision Services are currently deployed to Corticon Server running in-process. Now, lets load the Decision Service named tutorial_example.erf located in
<corticon_install_dir>\Samples\Rule Projects\Tutorial\Tutorial-Done using the 6
Page 56
Notice that the 6 parameters we entered are the same 6 entries in the list of deployment properties described in the Deployment Descriptor file section, Figure 36 and Figure 37. The very first parameter, Decision Service Name, has been given the value of airCargo. You may notice a pause before the Transaction completed message is displayed. This is due to the deployment-time compilation performed by Corticon Server 5.2. Larger Ruleflows (more Rulesheets or rules) will require more time to compile. Now, to verify that this Decision Service is deployed, well re-invoke the
getDecisionServiceNames() method using option 21.
Figure 47 shows that the Decision Service named airCargo is deployed to Corticon Server. Now, to remove airCargo from deployment, well use option 18.
And then to verify that airCargo has been removed from Corticon Server, we invoke getDecisionServiceNames() once again using option 21:
Figure 49 shows that airCargo has successfully been removed from deployment.
Page 57
ERF files
The .erf file is really just a pointer file that informs Corticon Server where, specifically, to look for the component parts of the Decision Service, including the .ecore and all included .ers files. This has the following important consequences: All of the component files (.ecore and .ers) must be accessible to Corticon Server, so that it is able to read them during compilation. This may mean you need to keep tighter access controls on the various component files involved, which may be less convenient in production environments.
.erf compilation occurs on-the-fly, which may take a few seconds when first
deployed If an .ers file is shared among multiple .erf files, then a change to the .ers will cause .erfs to update also if their auto-reload property is set to true and Corticon Servers dynamic monitoring update service is running.
Because of these considerations, uncompiled Decision Service deployments are often used in nonproduction environments, where component files (.ecore and .ers) are more likely to change frequently or require looser controls.
EDS Files
The .eds file is a self-contained, complete deployment asset that includes compiled versions of all component files, including .ecore and .ers file. This has the following important consequences: Only the .eds file needs to be accessible to Corticon Server. Original component files (.ecore and .ers) can be archived offline and accessed only when changes need to be made to them.
.eds files are already compiled, so Corticon Server can load them quickly upon deployment, without the lag time required by .erf on-the-fly compilation.
if a rule changes inside a component .ers file, then the .eds must be recompiled and redeployed. The Corticon Servers dynamic monitoring update service will detect changes only to the .eds dateTimeStamp, not to the dateTimeStamp changes of any internal component files.
Because of these considerations, pre-compiled Decision Service deployments are often used in production environments, where component files (.ecore and .ers) are less likely to change frequently or require tighter controls.
Page 58
If your .erf contains Service Call-Outs, be sure to add the SCO classes to deployConsole.bat so that they are included in the classpath when the .eds is compiled. More information about SCOs can be found in the Extensions User Guide.
Page 59
The name and location of Corticon Server we want to call will be discussed in the Invocation chapter, since this information is concerned more with protocol than with content. The focus of this chapter will be on the other two items, Decision Service Name and data payload.
the Data
While the data itself may vary for a given Decision Service from transaction to transaction and call to call, the structure of that data how it is arranged and organized must not vary. The data contained in each call must be structured in a way Corticon Server expects and can understand. Likewise, when
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 60
Corticon Server executes a Decision Service and responds to the client with new data, that data too must be structured in a consistent manner. If not, then the client or calling application will not understand it.
Page 61
This section is described in the Deploying Rule Sets chapter of this manual
Service Contract 16 17 18 19 20 21 22 23
Service contracts provide a published XML interface to Decision Services. They inform consumers of the necessary input data and structure required by the Decision Service and of the data structure the consumer can expect as output. 9. Decision Service Level / Vocabulary Level. These radio buttons determine whether one service 16 contract is generated for each Ruleflow listed in the Deployment Descriptor section of the Deployment Console (the upper portion), or for the Vocabulary listed in section 17. Often, the same payload structure flows through many decision steps in a business process. While any given Decision Service might use only a fraction of the payloads content (and therefore have a more efficient invocation), it is sometimes convenient to create a single master service contract from the Decision Services Vocabulary. This simplifies the task of integrating the Decision Services into the business process because a request message conforming to the master service contract can be used to invoke any and all Decision Services
Page 62
that were built with that Vocabulary. This master service contract, one which encompasses the entire Vocabulary, is called Vocabulary Level. The downside to the Vocabulary-level service contract is its size. Any request message generated from a Vocabulary-level service contract will contain the XML structure for every term in the Vocabulary, even if a given Decision Service only requires a small fraction of that structure. Use of a Vocabulary-level service contract therefore introduces extra overhead because request messages generated from it may be unnecessarily large. In an application or process where performance is a higher priority than integration flexibility, using a Decision Service Level service contract is more appropriate. A Decision Service-level service contract contains the bare minimum structure necessary to consume that specific Decision Service no more, no less. A request message generated from this service contract will be the most compact possible, resulting in less network overhead and better overall system performance. But it may not be reusable for other Decision Services. 17 Vocabulary File. If generating a Vocabulary-level service contract, enter the Vocabulary file name (.ecore) here. If generating a Decision Service-level contract, this field is read-only and shows the Vocabulary associated with the currently highlighted Ruleflow row above. See Corticon Decision Service Contracts for details. 10. Select Work Document Entity. Before any service contract can be generated, a Work 18 Document Entity (WDE) must be chosen. The WDE serves as the root context for the XML document, whether flat or hierarchical in format. To assign a WDE in Studio, use menubar option Ruleflow>Properties and select from the drop-down in the Properties window. A Decision Service invocation should contain a data payload, and the WDE is simply a way of defining the minimum payload necessary. The entity selected as WDE becomes a mandatory element in the invocation. If generating a Vocabulary-level service contract, select a WDE from the list. If generating a Decision Service-level contract, select the Ruleflow row in the Deployment Descriptor file section to highlight it, then select a WDE from the list. Do this for each Ruleflow. If a WDE has already been selected for a Ruleflow, it should appear in this field. If it has already been specified, you can change it here and the Ruleflow file will also be updated. 19 Type. This is the service contract type: WSDL or XML Schema. A WSDL can also be created from within Studio using the Ruletest > Testsheet > Data > Export WSDL menu option. See the Ruletest chapter of the Studio Quick Reference Guide for more details. 20 11. XML Messaging Style. When using XML to describe the payload, there are two structural styles the payload may take, flat and hierarchical. Flat payloads have every entity instance at the top (root) level with all associations represented by reference. Hierarchical payloads represent associations with child entity instances embedded or indented within the parent entity structure.
Server Integration & Deployment Guide 5.2 Both styles are illustrated below. Assume a Decision Service uses an Account and its associated SecurityPositions. In the Flat style, the payload is structured as:
Page 63
Server Integration & Deployment Guide 5.2 In the hierarchical style, the payload is structured as:
Page 64
Child entity instances are embedded (or indented) under parents via their association role names
The Hierarchical style need not be solely hierarchical; some associations may be expressed as flat, others as hierarchical. In other words, hierarchical can really be a mixture of both flat and hierarchical. A mixture of hierarchical and flat elements is sometimes called a hybrid style. Note that in the flat style, all entity names start with an upper case letter. Associations are represented by href tags and role names which appear with lowercase first letters. By contrast, in the hierarchical style, an embedded entity is identified by the role name representing that nested relationship (again, starting with a lowercase letter). Role names are defined in the Vocabulary. This option is enabled only for Vocabulary-level service contracts, because the message style for Decision Service-level service contracts is specified in the Deployment Descriptor file section (the upper portion) of the Deployment Console. 12. Output directory. The directory location where the Deployment Console saves new service 21 contracts. 13. SOAP Server URL. URL for the SOAP node that is bound to the Corticon Server. Enabled for 22 WSDL service contracts only. The default URL is http://localhost:8082/axis/services/Corticon that makes a Decision Service
Page 65
available to the default Corticon Server Tomcat installation. This default may be changed in CcDeployment.properties see CcDeployment.Properties. 14. 23 Generate Service Contracts. Generates the WSDL or XML Schema service contracts into the output directory. If you select Decision Service-level contracts, one service contract per Ruleflow listed in the Deployment Descriptor section (the upper portion) of the Deployment Console will be created. If you select Vocabulary-level service contracts, only one contract is created for the Vocabulary file specified in section 16.
1 2
From W3C. For more information on XML Schemas, see http://www.w3schools.com/schema/schema_intro.asp For more information on WSDL, see http://www.w3schools.com/wsdl/default.asp January 13, 2012
Page 66
Corticon Decision Service WSDLs are always Document-style! If you intend to use a commercially available software toolset to import WSDL documents and generate request messages, be sure the toolset contains support for Document-style WSDLs.
Section 1 2 3 4 5 6 7 8
Level Vocabulary Vocabulary Decision Service Decision Service Vocabulary Vocabulary Decision Service Decision Service Flat
An association
An entity
Page 67
Page 68
<xsd:element name="DecisionServiceName" type="xsd:string" minOccurs="1"/> <xsd:element name="DecisionServiceTargetVersion" type="xsd:nonNegativeInteger" nillable="true"/> <xsd:element name="DecisionServiceEffectiveTimestamp" type="xsd:dateTime" nillable="true"/> <xsd:element name="WorkDocuments" type="tns:WorkDocumentsType" /> <xsd:element name="Messages" type="tns:MessagesType" /> </xsd:sequence> </xsd:complexType>
Vocabulary-level
<xsd:complexType name="CorticonRequestType"> <xsd:sequence> <xsd:element name="WorkDocuments" type="tns:WorkDocumentsType" /> </xsd:sequence> <xsd:attribute name="decisionServiceName" use="required" type="xsd:string" /> <xsd:attribute name="decisionServiceTargetVersion" use="optional" type="xsd:nonNegativeInteger" /> <xsd:attribute name="decisionServiceEffectiveTimestamp" use="optional" type="xsd:dateTime" /> </xsd:complexType> <xsd:complexType name="CorticonResponseType"> <xsd:sequence> <xsd:element name="WorkDocuments" type="tns:WorkDocumentsType" /> <xsd:element name="Messages" type="tns:MessagesType" /> </xsd:sequence> <xsd:attribute name="decisionServiceName" use="required" type="xsd:string" /> <xsd:attribute name="decisionServiceTargetVersion" use="optional" <xsd:complexType name="CorticonRequestType"> <xsd:sequence> <xsd:element name="DecisionServiceName" type="xsd:string" minOccurs="1"/> <xsd:element name="DecisionServiceTargetVersion" type="xsd:nonNegativeInteger" nillable="true"/> <xsd:element name="DecisionServiceEffectiveTimestamp" type="xsd:dateTime" nillable="true"/> <xsd:element name="WorkDocuments" type="tns:WorkDocumentsType" /> </xsd:sequence> </xsd:complexType> <xsd:complexType name="CorticonResponseType"> <xsd:sequence> <xsd:element name="DecisionServiceName" type="xsd:string" minOccurs="1"/> <xsd:element name="DecisionServiceTargetVersion" type="xsd:nonNegativeInteger" nillable="true"/> <xsd:element name="DecisionServiceEffectiveTimestamp" type="xsd:dateTime" nillable="true"/> <xsd:element name="WorkDocuments" type="tns:WorkDocumentsType" /> <xsd:element name="Messages"
January 13, 2012
Page 69
Page 70
Page 71
SOAP Call
The structure and contents of this message are described in the Integration chapter. Once the SOAP request message has been prepared, a SOAP client must transmit the message to the Corticon Server (deployed as a Web Service) via HTTP. If your SOAP tools have the ability to assemble a compliant request message from a WSDL you generated with the Deployment Console, then it is very likely they can also act as a SOAP client and transmit the message to a Corticon Server deployed to the bundled Apache Tomcat web server. The Tutorial for Corticon Server Deploying Web Services describes one way to test this method of invocation 1. Use a 3rd-party tool or application (like Altova XMLSpy, for example) as a SOAP client. When developing and testing SOAP messaging, its very helpful to use some type of message interception tool 3 that allows you to grab a copy of the request message as it leaves the client and the response message as it leaves Corticon Server. This lets you inspect the messages and ensure no unintended changes have occurred, especially on the client-side.
Java Call
The specific method used to invoke a Decision Service is the execute() method. The method offers a choice of arguments: An XML string, which contains the Decision Service Name as well as the payload data. The payload data must be structured according to the XSD generated by the Deployment Console. Defining this data payload structure to include as an argument to the execute method is the most common use of the XSD service contract. A JDOM XML document, which contains the Decision Service Name as well as the payload data (array).
Such as tcpTunnelUI or TCPTrace
January 13, 2012
Server Integration & Deployment Guide 5.2 The Decision Service Name plus a collection of Java business objects which represent the WorkDocuments. The Decision Service Name plus a map of Java business objects which represent the WorkDocuments.
Page 72
Optional arguments representing Decision Service Version and Effective Timestamp may also be included these are described in the Versioning and Effective Dating chapter of this manual. All variations of the execute() method are described fully in the JavaDoc. These arguments are passed by reference. Vocabulary Term Entity Attribute Association Corresponding Java Construct Java class (JavaBean compliant) Java property within a class Class reference to another class
For example, in the Tutorial for Corticon Studio Basic Rule Modeling, the three Vocabulary entities: FlightPlan, Cargo, Aircraft would be represented by the consumer as three Java classes. Each class would have properties corresponding to the Vocabulary entity attributes (e.g. volume, weight). The association between Cargo and FlightPlan would be handled by Java class properties containing object references; the same would be true for the association between Aircraft and FlightPlan. Note that even if there is only a one-way reference between two classes participating in an association (from FlightPlan to Cargo, for example), if the association is defined as bidirectional in the Vocabulary, rules may be written to traverse the association in either direction. Bidirectionality is asserted by Corticon Server even if the Java association is unidirectional (as most are, due to inherent synchronization challenges with bidirectional associations in Java objects). Use the same testServer.bat (located in <corticon_install_dir>\Server) to see how the execute() method is used with Java objects. In addition to the 6 base Corticon Server jars, the batch file also loads some hard-coded Java business objects for use with the Java Object Messaging options (menu option 28-33 in Figure 7). These hard-coded classes are included in CcServer.jar so as to ensure their inclusion on the JVMs classpath whenever CcServer.jar is loaded. The hard-coded Java objects are intended for use when invoking the OrderProcessing.erf Decision Service included in the default Corticon Server installation.
REQUEST/RESPONSE MODE
Regardless of which invocation method you choose to call Corticon Server, keep in mind that it, by default, acts in a requestresponse mode. This means that one request sent from the client to Corticon Server will result in one response sent by Corticon Server back to the client. Multiple calls may be made by different clients simultaneously, and Corticon Server will assign these requests to
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 73
different Reactors in the pool as appropriate. As each Reactor completes its transaction, the response will be sent back to the client. Also, the form of the response will be the same as the request: if the request is a web services call (SOAP message), then the response will be as well. If a Java application uses the execute() method to transmit a map of objects, then Corticon Server will also return the results in a map.
ADMINISTRATIVE APIS
In addition to the execute() method (and its variations), a set of administrative APIs allows client control over most Corticon Server functions. These methods are described in more detail in the JavaDoc, CcServerAdminInterface class, including: 1. Adds (deploying) a specific Decision Service onto Corticon Server (addDecisionService) without using a .cdd file. Available in either 3- or 6-parameter versions. 2. Removes all Decision Services which were loaded (deployed) via the addDecisionService method (clearAllNonCddDecisionServices). Does not affect Decision Services deployed via a .cdd file. 3. Queries Corticon Server for admin information such as version number, deployed Decision Service settings, etc. (getCcServerInfo). 4. Queries Corticon Server for a list of loaded (deployed) Decision Service Names (getDecisionServiceNames) 5. Initializes Corticon Server, causing it to start up and restore state from ServerState.xml (initialize) 4 6. Queries Corticon Server to see if a Decision Service Name (or specific version or effective date) is deployed (isDecisionServiceDeployed) 5 7. Instructs Corticon Server to load all Decision Services in a specific .cdd file (loadFromCdd) 8. Instructs Corticon Server to load all Decision Services from all .cdd files located in a specific directory (loadFromCddDir) 9. Changes the auto-reload setting for a Decision Service (or specific version) (modifyDecisionServiceAutoReload). Does not affect Decision Services deployed via a .cdd file. 10. Changes the message structure type setting (FLAT or HIER) for a Decision Service (or specific version) (modifyDecisionServiceMessageStructType). Does not affect Decision Services deployed via a .cdd file. 11. Changes the min and/or max pool settings for a Decision Service (or specific version) (modifyDecisionServicePoolSizes). Does not affect Decision Services deployed via a .cdd file.
4 5
New addition to the API set in eServer 5.1 New addition to the API set in eServer 5.1
January 13, 2012
Page 74
12. Changes the path of a deployed Decision Service (Ruleflow) (modifyDecisionServiceRuleflowPath). Does not affect Decision Services deployed via a .cdd file. 6 13. Instructs Corticon Server to dump and reload (refresh) a specific Decision Service (or version) (reloadDecisionService). 14. Removes (undeploying) a Decision Service (or specific version) (removeDecisionService). Does not affect Decision Services deployed via a .cdd file. 15. Sets Corticon Server Log level (setLogLevel). This is the same Log level that can also be set statically using CcCommon.properties inside CcConfig.jar. All properties files are described in Appendix C. 16. Sets Corticon Server Log path (setLogPath). This is the same Log path that can also be set statically using CcCommon.properties inside CcConfig.jar. All properties files are described in Appendix C. 17. Starts Corticon Servers Dynamic Update monitoring service (startDynamicUpdateMonitoringService). This is the same update service that can also be set statically using CcServer.properties inside CcConfig.jar. All properties files are described in Appendix C. 18. Stops Corticon Servers Dynamic Update monitoring service (stopDynamicUpdateMonitoringService). This is the same update service that can also be set statically using CcServer.properties inside CcConfig.jar. All properties files are described in Appendix C. A Decision Service deployed using a .cdd file may only have its deployment setting changed by modifying the .cdd file. A Decision Service deployed using APIs may only have its deployment settings modified by APIs. All APIs are available as both Java methods (described fully in the JavaDoc) and as operations in a SOAP request message. Corticon provides a WSDL containing full descriptions of each of these methods so they may be called through a SOAP client. When deployed as a Servlet, Corticon Server automatically publishes an Administration Console on port 8082, which among other things, exposes as set of WSDLs. See the next chapter for more details.
Page 75
Out of the box, the Console includes 2 user accounts: User Name
admin <empty>
Password
admin <empty>
Page 76
To add, modify, or delete user accounts, open serverconsole-user.xml in a text editor and update accordingly. This file is located in the \axis\WEB-INF directory of your web server. In the bundled Tomcat Windows installation, this location is <corticon_install_dir>\Apache\webapps\axis\WEB-INF. The XML description corresponding to the default accounts is shown in Figure 64.
Figure 64 serverconsole-user.xml
If you login using the <empty> account, or if you choose the Limited Access login option, your use of the Server Console will be limited to read-only mode. In this mode, you will not be able to deploy Decision Services or configure or monitor the Server. If you try to view the Deploy Decision Service, Configure Rules Server, or Monitor Rules Server pages (see below), you will receive a message similar to User does not have rights to deploy a new Decision Service or User does not have rights to view Server settings.
Page 77
The lower right corner of the Main Menu page also contains icons corresponding to several of the menu options: Icon Description Turn on Server Console display refresh. If enabled, Console will update its display every 4-5 seconds. While making changes to Console page settings, you may want to turn off refresh, otherwise your entries may be wiped out (before you have a chance to save them) when the Console refreshes. Turn off Server Console display refresh. While making changes to Console page settings, you may want to turn off refresh, otherwise your entries may be wiped out (before you have a chance to save them) when the Console refreshes. Go to the Decision Service page. Go to the Deploy Decision Service page. Go to the Configure Rules Server page. Go to the Monitor Rules Server page.
Server Integration & Deployment Guide 5.2 Go to the Main Menu page.
Page 78
The table displayed on the Decision Services page contains the following information and controls:
Service Name
This is the name assigned to a deployed Decision Service, whether deployed by a .cdd file, or by data manually entered on the Deploy Decision Service page. When assigned via a .cdd file, the name is entered as the Decision Service Name in the Deployment Console. In Server Console, the Service Names are hyperlinks, which, when clicked, display additional information about the deployment properties of the Decision Service. Clicking the Service Name hyperlink displays 4 tabs:
Page 79
If the Decision Service was deployed by a .cdd file, then the contents of the .cdd are displayed on this page. If the Decision Service was deployed by the Deploy Decision Service page, then the information entered on that page (which is persisted in serverstate.xml) is displayed. The information displayed on the Overview page, shown in Figure 67, is collected from 3 sources: from the .cdd file or from the information entered in the Deploy Decision Service page (depending on how the Decision Service was deployed). In both cases, the information reflects the state of the Decision Service at the time of deployment. the Ruleflow file (.erf) itself, either from file DateTime stamps or from properties set in the Rule Set>Properties menu of Corticon Studio. real-time/dynamic retrieved from Corticon Server Console. For example Pool Settings|Available/Total Instances in Pool reflects the current Reactor pool status for that Decision Service. The number of Reactors available and total, will change as Corticon Server grows/shrinks each Decision Services pool to handle demand. For more information about Reactor pools, see Pool Size and Optimizing Pool Size.
Page 80
Another feature of the Overview tab allows Server Console users with RW access to perform limited management and updates to the deployed Ruleflows and constituent Rulesheets. Since this is fundamentally a rule modeling activity, it is addressed in the Rule Modeling Guide. Service Configuration Tab Available only to users with RW access. If the selected Decision Service was deployed by a .cdd file, then deployment properties cannot be changed on this tab they must be changed in the .cdd file itself. See the Deploying Corticon Ruleflows chapter for more information about .cdd files and the Deployment Console.
Server Integration & Deployment Guide 5.2 If the Decision Service was deployed by the Deploy Decision Service page, then the deployment properties can be changed on the Service Configuration tab using the Update button. Also, use Update to re-deploy changes to a Decision Service.
Page 81
Monitored Attribute and Analysis Buckets: Server Console allows you to monitor specific attributes in a deployed Decision Service. By choosing attributes to monitor, you can view the statistical breakdown of attribute values over the course of many Decision Service executions. For example, the Ruleflow created in the Basic Rule Modeling Guide assigns values such as pallet and container to attribute Cargo.packaging. To monitor this attribute, enter the fully qualified attribute name (including the entity) in the Monitored Attribute box (shown in the blue box in Figure 68 below) and enter the exact value or values in the Analysis Buckets box (separated by a comma) as shown in the orange box in Figure 68 below.
After entering your attribute and values, click Add to add them to the monitored list. The results of attribute monitoring can be viewed in the Distribution Chart tab, described below.
Page 82
Rulesheet reports can be generated directly from this tab. See the Rule Modeling Guide for more information about Corticon Studios reporting framework. Detailed reports display all elements of the Rulesheet, including Scope, Filters, and other sections. Rule Statements reports display only those Rule Statements entered for rules. If a rule has no Rule Statement, then that rule will not appear in this report style. Business Friendly reports display the Natural Language equivalents (if present) of the rules. Test Execution Tab If you have a compliant Corticon Request XML message file, then you can use this tab to send it to Corticon Server and view its Response. Navigate to the XML message file using the Browse button, then click Execute Test to invoke Corticon Server. To be compliant, your XML Request message must follow the same rules as described in Path 2 in the Server Deployment Tutorial.
Version
This indicates the Version number of the Decision Service deployed. A Decision Services version number is set in the Rule Set>Properties menu option of Studio for each Ruleflow (.erf file). See Decision Service Versioning and Effective Dating in this manual, and the Rule Modeling Guide for more information.
Live
This column indicates the deployment status of the Decision Service. If deployed and ready to receive invocations, the Live checkbox will be checked. If a new version of a Decision Service has been created using the Overview tab, then it will not become live until promoted. This process is described in more detail in the Rule Modeling Guide.
Page 83
Dynamic Reload
Indicates if Corticon Servers maintenance thread will watch for changes to the Decision Service and refresh the pool if updates are detected. For Decision Services deployed via .cdd, this option is set in the Dynamic Reload field of the Deployment Console. If deployed via the Deploy Decision Service page of Server Console, Dynamic Reload is automatically Yes.
Executions
The number of times the Decision Service has executed since statistics were last cleared. This number is a hyperlink which, when clicked, display two additional tabs. Performance Tab The Decision Service Performance Monitoring Service and Decision Service Time Interval Performance Analysis Service must be On for this feature to work. To turn these services On, go to the Configure Decision Service page, Decision Service Options tab. The top graph displays average execution time for all executions performed within Server Consoles recording interval. The lower graph displays the number of executions performed within Server Consoles recording interval. Server Consoles recording interval is 10 seconds by default, but can be changed in CcServer.properties.
Page 84
Distribution Chart Tab The Decision Service Results Distribution Analysis Service must be On for this feature to work. To turn On, go to the Configure Decision Service page, Decision Service Options tab. This tab displays a pie chart of the distribution of values of attributes monitored in the Service Configuration tab.
Page 85
Clear Stats
Clicking Clear resets Execution, Average Time, Performance and Distribution Chart data. This option is available only to users with RW access.
Page 86
Server State
In many prior versions of Corticon Server (4.2 and earlier), Decision Services deployed via APIs remained deployed only for the duration of Corticon Servers session. If Corticon Server (or its host container) was stopped and restarted, Decision Services deployed previously by APIs would NOT redeploy automatically until those APIs were called again. Decision Services deployed via .cdd files, however, would redeploy automatically. In Corticon Server 5.2, the deployment state of all Decision Services, regardless of how deployed, is persisted in a new file named ServerState.xml, located in \axis\CcServerSandbox\DoNotDelete. The Deploy Decision Service page captures the same deployment information as a .cdd, and stores it in the ServerState.xml file. These fields are described in the Deploying Corticon Ruleflows chapter above. One exception: to update a Decision Service, we assume youll change the Ruleflows compiled.eds file and then redeploy using the Service Configuration tabs Update button. Therefore, a Dynamic Reload setting isnt necessary. When Corticon Server restarts, it reads the ServerState.xml file and redeploys any Decision Services included in it.
To use this page, you must pre-compile your .erf file into an .eds file, and use the in the Rule Set (path) field above. You cannot directly deploy uncompiled .erf files via Server Console. Enter the required deployment information in the provided boxes, and click Deploy.
Page 87
Once deployed, Corticon Server creates a local copy of the .eds file in its local CcServerSandbox directory structure. The location path can be seen in the ServerState.xml file in Figure 72 below. It does this so that it always has access to the executable code (stored inside the .eds file) when it attempts to reload/redeploy the Decision Service. If you want to change the Ruleflow, we recommend using the Update button on the Service Configuration tab of the Decision Service page. We dont recommend editing the local copy of the .erf file because the two files will not be identical. Using the Update method ensures the original and local copies are always the same.
All other entries in the Deploy Decision Service page are visible above in the <NonCDDs> section of the document.
Logging Tab
The Logging tab displays the current settings of LogPath and LogLevel properties. These properties are stored in CcCommon.properties, but can be overridden with values entered on this tab. The new values are written to ServerState.xml and take effect each time Corticon Server is started.
Page 88
License Tab
The values shown are decrypted from the CcLicense.jar currently in use by the running instance of Corticon Server. Licensed To and Deactivate Date are two important fields.
Page 89
WSDLS
This page provides access to WSDL files for all Corticon Server APIs. In some prior versions of Corticon Server (4.2 and earlier), this page was accessible via the Axis home page (http://<yourServer>:<yourPort>/axis). In version 4.3 and later (including 5.2), this URL is now used as the home address for Server Console. You also can access this page directly (external of the Console) by using this address: http://<yourServer>:<yourPort>/axis/servlet/AxisServlet
Page 90
CcServer.properties
The most commonly changed properties are summarized in this chapter. For a complete description of all properties, see Appendix C.
Page 91
Log Location
logpath=%CORTICON_HOME%/Log
Set in CcCommon.properties. This path determines where Corticon Server log file is deposited. By default, %CORTICON_HOME% is set to <corticon_install_dir>\Server\Tomcat\CcServer.
Log Level
loglevel=VIOLATION
Set in CcCommon.properties. This property controls the amount of information included in Corticon Servers log file. Options:
DEBUG To be used only at the direction of Progress technical support. Never deploy Corticon Server in production with loglevel set to DEBUG. Log files created
in this mode may become very large and slow down Corticon Servers performance by orders of magnitude.
INFO All messages except debugging messages are logged. Never deploy Corticon Server in production with loglevel set to INFO. Log files created in this mode may
become very large and slow down Corticon Servers performance by orders of magnitude.
RULETRACE Logs rule firings and performance data. Do not deploy Corticon Server in production with loglevel set to RULETRACE. While log files are not nearly as large as those generated in DEBUG or INFO modes, they still require time
Page 92
Changes to any .cdd loaded to Corticon Server by a loadFromCdd or loadFromCddDir API call, including new or removed Decision Services and changes to settings of deployed Decision Services. Changes to any .cdd file (including new .cdds within the Deployment Descriptor directory) by a loadFromCddDir API call, including new or removed Decision Services and changes to settings of deployed Decision Services. Changes in any of the Decision Services loaded to Corticon Server. This is done via a compilation timestamp check.
This maintenance thread is enabled by default in CcServer.properties, but it can be disabled using
com.corticon.ccserver.dynamicupdatemonitor.autoactivate=false
The maintenance thread can be shutdown and restarted dynamically using the Administrative APIs:
CcServerAdminInterface.stopDynamicaUpdateMonitoringService() CcServerAdminInterface.startDynamicUpdateMonitoringService()
Page 93
required. If you want to pre-compile Ruleflows into .eds files prior to deployment on Server, the Pre-Compile option in the Deployment Console enables this. See the Deployment chapter for more details.
Exception: A maintenance thread is created at Corticon Serverstartup time. This thread does not interact with clients of the Corticon Server. Its sole job is to scan for changes in the Ruleflow (or their included Rulesheet files) for dynamic reload purposes.
January 13, 2012
Page 94
SOAP Servlet or Java Servlet in a web server, EJB in a J2EE application server). In the case where an inprocess Java call is made from a client application, the thread of execution is the same one in which the client runs. All requests, regardless of source, resolve to an execute() API method call to Corticon Server. The execute() method associates the incoming request to the compiled code of the requested Decision Service (the .eds file). For example, if a Decision Service named processLoan.erf is configured with a maximum pool size of 10, then the Corticon Server can create up to 10 Reactors of this Decision Service to handle up to 10 simultaneous requests for that service. If, after processing these 10 requests, subsequent concurrent demand is less than 10, the Corticon Server will reduce the pool size accordingly to release working memory. The period of time elapsed before these inactive Reactors are released is set by property com.corticon.ccserver.inactivity in CcServer.properties. Note that the Corticon Server does not actually force the JVMs garbage collection to clean up it simply notifies the JVM that garbage collection may be performed and the JVM triggers it according to its own processes. Released Reactors are swept up by garbage collection when the JVM performs it. On the other hand, if 15 simultaneous requests for processLoan.erf are received, then Corticon Server will spawn Reactors to handle the demand until its maximum pool size limit for that Decision Service is reached. After the limit is reached, additional requests will be queued until a Reactor finishes a request and becomes available for assignment to a queued request. Requests will stay in queue until a) a Reactor becomes available, or b) the Corticon Servers queue timeout is reached, whichever comes first. The Corticon Servers queue timeout is set by property com.corticon.ccserver.timeout in CcServer.properties. Pool sizing is set at the Decision Service level in the Deployment Descriptor file (.cdd). See the Deployment Console section for details on setting the pool size in a .cdd file. Pool size parameters are also contained in addDecisionService() API method described here.
STATE
Reactor State
A Reactor is an executable instance of a deployed Ruleflow/Decision Service. Corticon Server acts as the broker to one or more Reactors for each deployed Ruleflow. During Ruleflow execution, the Reactor is a stateless component, so all data state must be maintained in the message payloads flowing to and from the Reactor. If a deployed Ruleflow is composed of multiple Rulesheets, state is preserved across those Rulesheets as the Rulesheets successively execute within the Ruleflow. However, no interaction with the client application occurs between or within Rulesheets. After the last Rulesheet within the Ruleflow is executed, the results are returned back to the client as a CorticonResponse message. Upon sending the CorticonResponse message, the Reactor is released and returned to the Server pool, awaiting assignment of a new, incoming CorticonRequest thread of execution.
Page 95
As an integrator, you must keep in mind that there are only two ways for you to retain state upon completion of a Ruleflow or Decision Service execution. 1. Receive and parse the data from within the CorticonResponse message. In the case of integration Option 1 or 2, the data is contained in the XML document payload or string/JDOM argument. In the case of Option 3, the data consists of Java business objects in a collection or map. 2. Persist the results of a Decision Service execution to an external database. Once a Decision Service execution has completed, the Reactor itself does not remember anything about the data it just processed. After the CorticonResponse message is sent, the Reactor is returned to the pool in preparation for the next transaction (the next CorticonRequest).
This is a new feature in Corticon Server5.1 and operates differently than in other Corticon BRMS versions.
January 13, 2012
Server Integration & Deployment Guide 5.2 to allow/prevent Corticon Server reading ServerState.xml, use the com.corticon.server.serverstate.load property, also located in CcServer.properties.
Page 96
You can customize Corticon Servers state and restart behavior by combining these two property settings:
serverstate. persistchanges true serverstate. load true
Server Restart Behavior Server maintains ServerState.xml during operation, and automatically reads it upon restart to restore to the old state. Server maintains ServerState.xml during operation, but does NOT automatically read it upon restart. New Server state upon restart is unaffected by ServerState.xml. This allows a system administrator to manually control state restoration from the ServerState.xml, if desired. Server attempts to read ServerState.xml upon restart, but finds nothing there. No old state restored. no ServerState.xml document exists, and Server does not attempt to read it upon restart. No old state restored.
true
false
false false
true false
Page 97
EXCEPTION HANDLING
Should an exception occur, the Server throws Java exceptions. These are documented in the JavaDoc.
Page 98
To phrase this requirement differently, Decision Services deployed with the same Major Version and Minor Version number and same Effective/Expiration Dates must have different Decision Service Names. The Deployment Console shown in Figure 93, below, displays the parameters of a Deployment Descriptor file with three Decision Services listed.
Page 99
Notice: All three Decision Service Names are the same: skydiver4. All three Ruleflow filenames are the same: skydiver4.erf. Each Ruleflow deploys a different Rulesheet. Each Rulesheet has a different file name, as shown on the following pages. The file locations (paths) are different for each Ruleflow. This is an operating system requirement since no two files in the same directory location may share a filename. All three Decision Services have different (Major) Version numbers. All three Decision Services have different combinations of Effective and Expiration dates.
It is also possible to place all Ruleflow files (.erf) in the same directory location as long as their filenames are different. Despite having different Ruleflow filenames, they may still share the same Decision Service Name as long as their Version or Effective/Expiration Dates are different.
SAMPLE RULEFLOWS
The Ruleflows well use in this section are based on Rulesheet variations on the same simple theme. Notice that the only difference between the three Rulesheets is the threshold for the age-dependent rules (columns 2 and 3 in each Rulesheet). The age threshold is 35, 45, and 55 for Version 1, 2 and 3, respectively. Although simple, this difference will be sufficient to illustrate how the Corticon Server distinguishes Versions in runtime. Figure 94, below, displays the sample Vocabulary we will be using in support of our Version examples.
Page 100
Page 101
Well use the default Tomcat web server included with Corticon Server installation. We recommend you complete the Tutorial for Corticon Server Deploying Web Services and the prior sections of this manual before proceeding. Once Corticon Server is started and reads the Deployment Descriptor file, the Decision Services are deployed. In order to confirm the deployment, well use the testServerAxisTomcat.bat file (as we did in Testing Decision Services). Selecting Option 22 - Get Decision Service Names, we see:
Page 102
Notice that the Decision Service skydiver4 shows up only once in the list, even though there are actually three different versions of this Decision Service deployed and loaded on Corticon Server. This is normal Corticon Server summarizes all deployed versions of the Decision Service as a single entry on the list, even though each entry on the list may have multiple versions. Dont think of these different versions as three different Decision Services think of them as three versions of the same Decision Service.
In order to invoke a specific Major Version of a Decision Service, the Major Version number must be included as a value of the decisionServiceTargetVersion attribute in the message sample above. As the use attribute indicates, specifying a Major Version number is optional. If multiple Major Versions of the same Decision Service Name are deployed simultaneously and an incoming request fails to specify a particular Major Version number, then Corticon Server will execute the Decision Service with highest Version number.
Page 103
If multiple instances of the same Decision Service Name and Major Version number are deployed and an incoming request fails to specify a particular Major Version number, then Corticon Server will execute the Decision Service with highest Minor Version number. Lets try a few invocations using variations of the following message:
Notice from the posted message that the age threshold is 35, which corresponds to that in Major Version 1 of the Decision Service (refer back to Figure 95). This should be no surprise we specifically
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 104
requested Major Version 1 in our request message. Corticon Server has obeyed our request. The Major Version number of the executed Decision Service has been returned in the response message in the version attribute of the <Messages> complexType. This location, along with the age threshold, is shown circled in Figure 100. Now, lets modify our request message to specify Version 2, and resend.
Page 105
Once again, Corticon Server has obeyed our request and executed Version 2 of the Decision Service. The location in the response message of the Decision Service Version executed is shown circled in Figure 102, above. The age threshold of 45, which is another clue that Version 2 has been executed, is also circled in Figure 102.
where:
astrDecisionServiceName is the Decision Service Name String value. acolWorkObjs is the collection of Java Business Objects the date payload. aiDecisionServiceTargetVersion is the Integer Version number.
More information on this variant of the execute() method may be found in the JavaDoc.
Default Behavior
How does Corticon Server respond when no decisionServiceTargetVersion is specified in a request message? In this case, Corticon Server will select the highest Major Version number available for the requested Decision Service and execute it.
Page 106
From study of the example above, we see that our three deployed Decision Services have Effective and Expiration dates that overlap in several date ranges: Version 1 and Version 2 overlap from July 1, 2005 through December 31, 2005. And Version 3 overlaps with both 1 and 2 in July 2005. To understand how Corticon Server resolves these overlaps, well invoke Corticon Server with a few scenarios.
Updating CorticonRequest with decisionServiceEffectiveTimestamp according to the XSD, our new XML payload appears as shown in Figure 104. Our first Effective Timestamp value, 6/1/2004, is circled in orange.
Page 107
Sending this request message using TestDS.cmd as before, the response from Corticon Server is:
Notice that Corticon Server executed this request message using Decision Service Major Version 1, which has the Effective/Expiration Date pair of 1/1/200412/31/2005. This Major Version is the only Decision Service effective for the date specified in the request messages Effective Timestamp. As before, the Major Version number executed appears in the version attribute of the <Messages> complexType, as shown circled in Figure 105. To illustrate what happens when an Effective Timestamp falls in range of more than one Major Version of deployed Decision Services, lets modify our request message as shown in Figure 106. Our new value of decisionServiceEffectiveTimestamp is 7/10/2005.
Page 108
Send this request to Corticon Server and examine the response, below, in Figure 111.
We can see that this time Corticon Server executed the request with Major Version 3. It did so because whenever a requests decisionServiceEffectiveTimestamp value falls within range of more than one deployed Decision Service, Corticon Server chooses the Decision Service with the highest Major Version number. In this case, all three Decision Services were effective on 7/10/2005, so Corticon Server chose Major Version 3 the highest qualifying Version to execute the request.
Page 109
where:
astrDecisionServiceName is the Decision Service Name String value. acolWorkObjs is the collection of Java Business Objects the date payload. adDecisionServiceEffectiveTimestamp is the DateTime Effective
Timestamp. More information on this variant of the execute() method may be found in the JavaDoc.
Default Behavior
How does Corticon Server respond when no decisionServiceEffectiveTimestamp is specified in a request message? In this case, Corticon Server will assume that the value of decisionServiceEffectiveTimestamp is equal to the DateTime of invocation the DateTime right now. Corticon Server then selects the Decision Service which is effective now. If more than one are effective then Corticon Server selects the Decision Service with the highest Major Version number (as we saw in the overlap example).
Page 110
Page 111
Figure 110 Server Error Due to Specifying Both Major Version and Timestamp
No variation of the execute() method exists which contains arguments for both decisionServiceTargetVersion and decisionServiceEffectiveTimestamp, so this call cannot be made using the Java APIs.
Page 112
Page 113
activity on the server box and the physical resources (number and speed of CPUs, amount of physical memory) available to the server box. A maximum pool size of one (1) implies no concurrency for that Decision Service. See Multi-threading and Concurrency or the Deployment Consoles pool size section for more details The recommendations that follow are not requirements. High-performing Corticon Server deployments may be achieved with varying configurations dictated by the realities of your IT infrastructure. Our testing and field experience suggests, however, that the closer your configuration comes to these standards, the better Corticon Server performance will be. Configuring the runtime environment revolves around a few key quantities: The number of CPUs in the server box on which the Corticon Server is running. The number of wrappers deployed. The wrapper is the intermediary layer between the web/app server and Corticon Server, receiving all calls to Corticon Server and then forwarding the calls to the Server via the Corticon API set. The wrapper is the interface between deployment-specific details of an installation, and the fixed API set exposed by Corticon Server. A sample Servlet wrapper, axis.war, is provided as part of the default Corticon Server installation. The minimum and maximum pool size settings for each deployed Decision Service. These pool sizes are set in the Deployment Descriptor file (.cdd) created in the Deployment Console.
Server Integration & Deployment Guide 5.2 Ruleflow #3 (Decision Service #3): min pool size = 9, max pool size = 9.
Page 114
In this case, 9 deployed wrappers are optimum to ensure that unused or idle Reactors in the pool are minimized. This setting, however, may conflict with the wrapper number suggested by CPU core number. If we were starting with a fixed CPU core number, say 8, then we would want to reduce the pool size for Decision Service #3 to: Ruleflow #3 (Decision Service #3): min pool size = 8, max pool size = 8.
And deploy only 8 wrappers instead of 9. Had we retained the original 9/9 pool setting, the ninth Reactor in the pool would have gone unused and simply would have consumed additional memory with no benefit. On the other hand, increasing wrappers to 9 might cause a total of 9 threads of execution to be allocated to 9 reactors (any mix of Reactors for the 3 Ruleflow). Since only 8 threads can process simultaneously (only 8 physical CPU cores), then performance-robbing thread switching will occur. Minimum and Maximum Pool Sizes Current testing suggests that setting minimum and maximum pool sizes equal to each other results in best performance. Although keeping a larger number of Reactors ready in the pool requires more memory, it also eliminates the time necessary to spawn new Reactors into the pool when transaction demand suddenly increases because the pool is already loaded with the maximum number of Reactors allowed. It is also important to note that higher minimum pool settings require more time to initialize during web/app server startup because more Reactors must be put into the pool. Hyper-threading Hyper-threading is an Intel-proprietary technology used to improve parallelization of computations (doing multiple tasks at once) performed on PC microprocessors. For each processor core that is physically present, the operating system addresses two virtual processors, and shares the workload between them when possible. Field experience suggests that Hyper-threading does not allow doubling of wrappers or Reactors for a given physical CPU core number. Doubling wrappers or Reactors with the expectation that Hyperthreading will double capacity will result in core under-utilization and poor performance. We recommend setting wrapper and Reactor parameters based on the assumption of one thread per CPU core.
Cluster Configuration
The recommendations above also hold true in clustered environments, with the following clarifications: CPUs & Pools Because wrappers are typically located on the Main Cluster Instance and Reactors are located on the cluster machines, the direct relationship between CPUs and wrappers isnt so straightforward in clustered environments. The key relationship becomes number of CPUs on the cluster machine and
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 115
the maximum pool size of any given Decision Service deployed to the same machine. If the number of CPUs in cluster machine A is 4, then the maximum pool size for any Decision Service deployed to cluster machine A should not exceed 4. Wrappers & Pools Wrapper count on the Main Cluster Instance should be greater than or equal to the sum of the maximum pool sizes for any given Decision Service across all clustered machines. For example: Cluster machine A has Decision Service #1 deployed with min/max pool settings of 4/4. Cluster machine B has Decision Service #1 deployed with min/max pool settings of 6/6. Cluster machine C has Decision Service #1 deployed with min/max pool settings of 2/2.
Based on this example, the Main Cluster Instance should have at least 12 instances of the wrapper deployed to make most efficient use of the 12 available Reactors in Decision Service #1s clustered pool. Minimum and Maximum Pool Sizes As with the Single Machine configuration, minimum and maximum pool size settings should also equal each other on each cluster machine
Logging
Corticon Server log settings can have a major impact on performance. The log is set to VIOLATION mode by default, which only logs Corticon Server violations and exceptions. Configuring logging is described in Configuring Server Logging. In production deployments, Corticon Server logging should always be set to VIOLATION mode, as all other modes may increase transaction times by a factor of 10. INFO and RULETRACE modes are intended for testing environments and DEBUG mode should be enabled only on instruction from Progress technical support personnel.
Page 116
marketing workflow. Decision Services would be called at each decision-making activity for each customer. Better performance can be achieved if the marketing business process reads a batch of customer records (say, in blocks of 100) and then passes the batch into each Decision Service. The Decision Service responds with an update to the payload (100 new offers). Why might this be faster? Two reasons. First of all, the setup and takedown time of a service invocation is reduced by a factor of 100. Secondly, and more importantly, Corticon Server is optimized to handle large payloads, providing dramatic relative performance benefits versus traditional, RETEbased rule engines. Batching can most easily be done when the application processes large numbers of work documents at once. However, batching is also possible in high volume on-line scenarios such as busy e-commerce sites or call centers. In this situation, a technique known as boxcaring can be used. Incoming work is placed into a buffer (the boxcar) and when the boxcar fills up, it is sent on to the Decision Service. The Decision Service returns the boxcar with the Decision Service results enclosed. To make boxcaring work effectively in on-line situations where work arrives randomly, timers are needed to send unfilled boxcars to Corticon Server so that user response time does not suffer while waiting for the boxcar to fill. A distinct downside of batching is that it prevents Corticon Server from distributing multiple transactions across multiple Reactors in the requested Decision Services pool. If a batch request contains 10 individual payloads, then this request can only be assigned to a single Reactor, and the requesting client must wait for all 10 to complete processing before a response is sent. However, if these same 10 payloads are sent as 10 individual requests, then Corticon Server can distribute them to the available Reactors in the pool, resulting in concurrent execution and better performance.
Capacity Planning
In a given JVM, the Corticon Server and its Decision Services occupy the following amounts of physical memory:
State of Corticon Server Basic Corticon Server overhead with no Decision Services (excludes memory footprint of the JVM which varies by JDK version and platform) Load a single Decision Service from the Deployment Descriptor or addDecisionService() method API. Working memory to handle a single CorticonRequest RAM required 25 MB
~ 5 MB 10 ~ 1 MB 11
10 11
5 MB is for the Trade Allocation sample application with seven (7) Rulesheets, twenty-four (24) rules, five (5) associated entities 1 MB is for the Trade Allocation sample application with seven (7) Rulesheets, twenty-four (24) rules, five (5) associated entities (this is for steady-state usage) January 13, 2012
Page 117
You may reduce the amount of memory required in a large system by dynamically loading and unloading specific Decision Services. This is especially relevant in resource-constrained handheld or laptop scenarios where only a single business transaction occurs at a time. After the first Decision Service is invoked, it is unloaded by the application and the second Decision Service is loaded (and so on). While this will be slower than having all Decision Services always loaded, it can address tight, memory-constrained environments. A compromise alternative would only dynamically load/unload infrequently used Decision Services. The Java clock Finally, whenever performance of Java applications needs to be measured in milliseconds, it should be remembered that Java is dependent upon the operating systems internal clock. And not all operating systems track time to equal degrees of granularity. The following excerpt from the Java JavaDoc explains:
public static long currentTimeMillis()
Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds. See the description of the class Date for a discussion of slight discrepancies that may arise between "computer time" and coordinated universal time (UTC). Returns: The difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
Page 118
INTERNATIONALIZATION
Corticon Server can accept and generate data values in character sets other than English. This section describes the general capabilities of Corticon Server for use outside the English character set. Any attribute of type String can contain any character supported by the UTF-8 encoding standard. This means that characters in European and Asian languages are supported. All encoding of string values passed to Corticon Server is assumed to be UTF-8. Any CorticonResponse outputs, including Messages, will also follow UTF-8 character encoding. Vocabulary names (entities, attributes, associations) are restricted to A-Z, a-z, 0-9, and underscore. File names and their paths are restricted to A-Z, a-z, 0-9, and underscore. All tags in the XML payload must use English characters. All Java class and Java property names in any Java payload must follow Java English conventions.
In Studio, it is possible to use ISO 8859-1 encoding in lieu of UTF-8 (although this will mean that Asian languages are not supported) by setting this property in CcStudio.properties:
com.corticon.encoding.standard=ISO-8859-1
See the Studio Installation Guide for more details on enabling localization in Studio.
Page 119
Header
<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:<namespace>" targetNamespace="urn:<namespace>" elementFormDefault="qualified">
The CorticonResponse element contains the output produced by the Decision Service:
<xsd:element name="CorticonResponse" type="tns:CorticonResponseType" /> <xsd:complexType name="CorticonRequestType"> <xsd:sequence>
Page 120
This attribute contains the Decision Service Name. Because a Vocabulary-level service contract can be used for several different Decision Services (provided they all use the same Vocabulary), a Decision Service Name will not be automatically populated here during service contract generation. Your request document must contain a valid Decision Service Name in this attribute, however, so the Server knows which Decision Service to execute
<xsd:attribute name="decisionServiceName" use="required" type="xsd:string" />
This attribute contains the Decision Service target version number. While every Decision Service created in Corticon Studio 5.2 will be assigned a version number (if not manually assigned), it is not necessary to include that version number in the invocation unless you want to invoke a specific version of the named Decision Service.
<xsd:attribute name="decisionServiceTargetVersion" use="optional" type="xsd:nonNegativeInteger" />
This attribute contains the invocation timestamp. Decision Services may be deployed with effective and expiration dates, which allow the Corticon Server to manage multiple versions of the same Decision Service Name and execute the effective version based on the invocation timestamp. It is not necessary to include the invocation unless you want to invoke a specific effective version of the named Decision Service by date (usually past or future).
<xsd:attribute name="decisionServiceEffectiveTimestamp" use="optional" type="xsd:dateTime" /> </xsd:complexType> <xsd:complexType name="CorticonResponseType"> <xsd:sequence>
Each CorticonResponseType element produced by the Server will contain one WorkDocuments element:
<xsd:element name="WorkDocuments" type="tns:WorkDocumentsType" />
Each CorticonResponseType element produced by the Server will contain one Messages element, but if the Decision Service generates no messages, this element will be empty:
<xsd:element name="Messages" type="tns:MessagesType" /> </xsd:sequence>
Same as attribute in CorticonRequest. This means that every CorticonResponse will contain the Decision Service Name executed during the transaction.
<xsd:attribute name="decisionServiceName" use="required" type="xsd:string" />
Page 121
WorkDocumentsType
Entities within WorkDocumentsType may be listed in any order.
<xsd:complexType name="WorkDocumentsType">
If you plan to use a software tool to read and use a Corticon-generated service contract, be sure it supports this <xsd:choice> tag
<xsd:choice maxOccurs="unbounded">
In a Vocabulary-level XSD, a WorkDocumentsType element contains all of the entities from the Vocabulary file specified in the Deployment Console. One will be a mandatory WDE and all the others will be optional (non-WDE) entities The WDE entity is mandatory in message instances that use this service contract. It has the form:
<xsd:element name="VocabularyEntityName" type="tns:VocabularyEntityNameType" maxOccurs="unbounded" />
Non-WDE entities are optional in message instances that use this service contract (minOccurs=0 indicates optional) and have the form:
<xsd:element name="VocabularyEntityName" type=" tns:VocabularyEntityNameType" minOccurs="0" maxOccurs="unbounded" /> </xsd:choice>
This element reflects the FLAT XML Messaging Style selected in the Deployment Console:
<xsd:attribute name="messageType" fixed="FLAT" use="optional" /> </xsd:complexType>
MessagesType
<xsd:complexType name="MessagesType">
If you plan to use a software tool to read and use a Corticon-generated service contract, be sure it supports this <xsd:sequence> tag (see important note below)
<xsd:sequence>
This version number corresponds to the responding Decision Services version number, which is set in Studio.
<xsd:attribute name="version" type="xsd:string" /> </xsd:complexType>
A Message element consists of several items see the Rule Language Guide for more information on the post operator, which generates the components of a Messages element.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 122
The text element corresponds to the text of the posted Rule Statements
<xsd:element name="text" type="xsd:string" /> <xsd:element name="entityReference"> <xsd:complexType>
The href association corresponds to the entity references of the posted Rule Statements
<xsd:attribute name="href" type="xsd:anyURI" /> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType>
The XML tag <xsd:sequence> is used to define the attributes of a given element. In an XML Schema, <sequence> requires the elements that follow to appear in exactly the order defined by the schema within the corresponding XML document. If CcServer.properties com.corticon.ccserver.ensureComplianceWithServiceContract
is:
true, the Server will return the elements in the same order as specified by the service
contract, even for elements created during rule execution and not present in the incoming message. false, the Server may return elements in any order. Consuming applications should be designed accordingly. This setting results in slightly better Server performance.
VocabularyEntityNameType
<xsd:complexType name="VocabularyEntityNameType"> <xsd:sequence>
A VocabularyEntityNameType contains zero or more VocabularyAttributeNames, but any VocabularyAttributeName may appear at most once per VocabularyEntityNameType
<xsd:element name="VocabularyAttributeName" type="xsd:VocabularyAttributeNameType" nillable="false" minOccurs="0" />
Associations between VocabularyEntityNames are represented as follows. This particular association is optional and has one-to-one or many-to-one cardinality:
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 123
Every VocabularyEntityNameType will contain a unique id number if an id is not included in the CorticonRequest element, the Server will automatically assign one and return it in the CorticonResponse
<xsd:attribute name="id" type="xsd:ID" use="optional" />
The ExtURIType is used by all associations in messages having FLAT XML Message Style
<xsd:complexType name="ExtURIType"> <xsd:attribute name="href" type="xsd:anyURI" /> </xsd:complexType> </xsd:schema>
VocabularyAttributeNameTypes
Every attribute in a Corticon Vocabulary has one of five datatypes Boolean, String, Date, Integer, or Decimal. Thus when entities are passed in a CorticonRequest or CorticonResponse, their attributes must be one of these five types. In addition, the ExtURIType type is used to implement associations between entity instances. The href attribute in an entity points to another entity with which it is associated.
Page 124
Header
This section of the XSD is identical to the FLAT version, described above.
WorkDocumentsType
One line in this section differs from the FLAT version (described above): This attribute value indicates the HIER XML Messaging Style selected in the Deployment Console:
<xsd:attribute name="messageType" fixed="HIER" use="optional" />
MessagesType
This section of the XSD is identical to the FLAT version, described above.
VocabularyEntityNameType
Because this service contract uses HIER structure, associated entities in the Vocabulary make direct reference to each other, as shown here. The type of an associated Vocabulary entity uses that entitys type, rather than the ExtURIType found in the FLAT version
<xsd:sequence> <xsd:element name="VocabularyEntityName" type="tns:VocabularyEntityNameType" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence>
href is present in this element only in the HIER version. This attribute is present because HIER messages typically use an indented or embedded XML structure. However, the HIER option also permits a hybrid or combination FLAT-HIER structure, so the optional href attribute is included purely for handling any FLAT elements that appear in a hybrid message
<xsd:attribute name="href" type="xsd:anyURI" use="optional" />
VocabularyAttributeNameTypes
This section of the XSD is the same as the FLAT version, described above.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 125
Header
This section of the XSD is identical to the Vocabulary-level FLAT version, described above.
Notice that the name of the Decision Service you entered in section 2 of Figure 36 is automatically inserted in fixed="DecisionServiceName". The use of the fixed element is optional in some cases, fixed may give XML parsers difficulty. See Extended Service Contracts: Fixed Attribute for details on removing the fixed element from your service contracts.
WorkDocumentsType
This section of the XSD is identical to the Vocabulary-level FLAT version, described here.
MessagesType
This section of the XSD is identical to the Vocabulary-level FLAT version, described here.
Page 126
Header
This section of the XSD is identical to the Vocabulary-level FLAT version, described above.
WorkDocumentsType
This section of the XSD is identical to the Vocabulary-level HIER version, described above.
MessagesType
This section of the XSD is identical to the Vocabulary-level FLAT version, described above.
Page 127
Types
<types> <xsd:schema xmlns:tns="urn:Corticon" targetNamespace="urn:<namespace>" elementFormDefault="qualified">
This <type> section contains the entire Vocabulary-level XSD, FLAT-style service contract, minus the XSD Header section or details on <namespace> definition, see XML Namespace Mapping
</types>
Messages
The SOAP service supports two messages, each with a single argument. See portType
<message name="CorticonRequestIn"> <part name="parameters" element="cc:CorticonRequest" /> </message> <message name="CorticonResponseOut"> <part name="parameters" element="cc:CorticonResponse" /> </message>
PortType
<portType name="VocabularyNameDecisionServiceSoap">
Binding
Use HTTP transport for SOAP operation defined in <portType>
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 128
Service
<service name="VocabularyNameDecisionService">
Any text you enter in a Rulesheets comments window (accessed via Rulesheet>Properties>Comments tab on the Studio menubar) will be inserted here:
<documentation>optional Rulesheet comments</documentation> <port name="VocabularyNameDecisionServiceSoap" binding="tns:VocabularyNameDecisionServiceSoap">
Corticon Server Servlet URI contained in section 22 of the Deployment Console will be inserted here:
<soap:address location="http://localhost:8082/axis/services/Corticon" /> </port> </service> </definitions>
Page 129
Types
<types> <xsd:schema xmlns:tns="urn:<namespace>" targetNamespace="urn:<namespace>" elementFormDefault="qualified">
This <type> section contains the entire Vocabulary-level XSD, HIER-style service contract, minus the XSD Header section or details on <namespace> definition, see XML Namespace Mapping
</types>
Messages
This section of the WSDL is identical to the Vocabulary-level FLAT version, described above.
PortType
This section of the WSDL is identical to the Vocabulary-level FLAT version, described above.
Binding
This section of the WSDL is identical to the Vocabulary-level FLAT version, described above.
Service
This section of the WSDL is identical to the Vocabulary-level FLAT version, described above.
Page 130
Types
<types> <xsd:schema xmlns:tns="urn:<namespace>" targetNamespace="urn:<namespace>" elementFormDefault="qualified">
This <type> section contains the entire Decision Service-level XSD, FLAT-style service contract, minus the XSD Header section or details on <namespace> definition, see XML Namespace Mapping
</types>
Messages
This section of the WSDL is identical to the Vocabulary-level FLAT version, described above.
PortType
This section of the WSDL is identical to the Vocabulary-level FLAT version, described above, with the exception of the following line:
<portType name="DecisionServiceNameSoap">
Binding
This section of the WSDL is identical to the Vocabulary-level FLAT version, described above, with the exception of the following line:
<binding name="DecisionServiceNameSoap" type="tns: DecisionServiceNameSoap">
Service
This section of the WSDL is identical to the Vocabulary-level FLAT version, described above, with the exception of the following lines:
<service name="DecisionServiceName"> <port name="DecisionServiceNameSoap" binding="tns: DecisionServiceNameSoap">
Page 131
Types
<types> <xsd:schema xmlns:tns="urn:<namespace>" targetNamespace="urn:namespace>" elementFormDefault="qualified">
This <type> section contains the entire Decision Service-level XSD, HIER-style service contract, minus the XSD Header section or details on <namespace> definition, see XML Namespace Mapping
</types>
Messages
This section of the WSDL is identical to the Decision Service-level FLAT version, described above.
PortType
This section of the WSDL is identical to the Decision Service-level FLAT version, described above.
Binding
This section of the WSDL is identical to the Decision Service-level FLAT version, described above.
Service
This section of the WSDL is identical to the Decision Service-level FLAT version, described above.
Page 132
Any attribute (the Vocabulary attribute) whose value was changed by the Corticon Server during rule execution will have the newOrModified attribute set to true. Also, In FLAT messages, the newOrModified attribute of an entity is true if: Any contained attribute is modified. Any association to that entity is added or removed.
In HIER messages, the newOrModified attribute of an entity is true if the entity, or any of its associated entities: Any contained attribute is modified. Any association to that entity is added or removed.
This attribute (XML attribute, not Vocabulary attribute) is enabled and disabled by the enableNewOrModified property in CcCommon.properties (see Appendix C for details). In order to make use of the newOrModified attribute, your consuming application must be able to correctly parse the response message. Because this attribute adds additional complexity to the service contract and its resultant request and response messages, be sure your SOAP integration toolset is capable of handling the increased complexity before enabling it. Extended Datatypes If the newOrModified attribute is enabled, then the base XML datatypes must be extended to accommodate it. The following complexTypes are included in service contracts that make use of the newOrModified attribute. ExtBooleanType
<xsd:complexType name="ExtBooleanType"> <xsd:simpleContent> <xsd:extension base="xsd:boolean"> <xsd:attribute name="newOrModified" type="xsd:boolean" use="optional" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType>
Page 133
ExtDateTimeType
<xsd:complexType name="ExtDateTimeType"> <xsd:simpleContent> <xsd:extension base="xsd:dateTime"> <xsd:attribute name="newOrModified" type="xsd:boolean" use="optional" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType>
If CcServer.properties com.corticon.ccserver.ensureComplianceWithServiceContract is
False: the Server will return an attribute of type Date in the same form as it was
received.
True: the Server will return an attribute of type Date using the date mask yyyyMM-dd'T'HH\:mm\:ss z
ExtIntegerType
<xsd:complexType name="ExtIntegerType"> <xsd:simpleContent> <xsd:extension base="xsd:integer"> <xsd:attribute name="newOrModified" type="xsd:boolean" use="optional" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType>
ExtDecimalType
<xsd:complexType name="ExtDecimalType"> <xsd:simpleContent> <xsd:extension base="xsd:decimal"> <xsd:attribute name="newOrModified" type="xsd:boolean" use="optional" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType>
Page 134
As with the newOrModified attribute, some XML or SOAP toolsets have difficulty parsing service contracts and messages which include the fixed attribute, seen in the CorticonRequest and CorticonResponse complexType sections of all service contracts. As of this manuals release date, it is known that versions of Microsofts .NET SOAP toolkit have difficulty with fixed. To improve compatibility, CcDeployment.properties includes a property named com.corticon.deployment.includeFixedTaskValueInServiceContract, which if set to false, removes the fixed attribute from all service contracts generated by the Deployment Console.
EXAMPLES
This section illustrates with an example how the service contract is generated and what the input and output payload looks like. The example used is from the Tutorial for Corticon Studio Basic Rule Modeling. A FlightPlan is associated with a Cargo. A FlightPlan is also associated with an Aircraft. The Vocabulary is shown below.
Page 135
In this section, both WSDL and XML Schema service contracts are shown. Some annotations are provided. The WSDL example uses FLAT XML messaging style; the XML Schema example uses HIER messaging style.
Page 136
<types> <xsd:schema xmlns:tns= "urn:decision:CargoDecisionService" targetNamespace= "urn:decision:CargoDecisionService" elementFormDefault="qualified"> <xsd:element name="CorticonRequest" type="tns:CorticonRequestType" /> <xsd:element name="CorticonResponse" type="tns:CorticonResponseType" /> <xsd:complexType name="CorticonRequestType"> <xsd:sequence> <xsd:element name="WorkDocuments" type="tns:WorkDocumentsType" /> </xsd:sequence> <xsd:attribute name="decisionServiceName" use="required" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="CorticonResponseType"> <xsd:sequence> <xsd:element name="WorkDocuments" type="tns:WorkDocumentsType" /> <xsd:element name="Messages" type="tns:MessagesType" /> </xsd:sequence>
Even though this is a Vocabulary-level WSDL, the Decision Service Name is still required:
<xsd:attribute name="decisionServiceName" use="required" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="WorkDocumentsType"> <xsd:choice maxOccurs="unbounded">
This is a Vocabulary-level service contract, so all entities in the Vocabulary are included here:
<xsd:element name="Aircraft" type="tns:AircraftType" minOccurs="0" maxOccurs="unbounded" /> <xsd:element name="Cargo" type="tns:CargoType" minOccurs="0" maxOccurs="unbounded" />
Page 137
</xsd:sequence> <xsd:attribute name="version" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="MessageType"> <xsd:sequence> <xsd:element name="severity"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Info" /> <xsd:enumeration value="Warning" /> <xsd:enumeration value="Violation" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="text" type="xsd:string" /> <xsd:element name="entityReference"> <xsd:complexType> <xsd:attribute name="href" type="xsd:anyURI" /> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType name="AircraftType"> <xsd:sequence> <xsd:element name="aircraftType" type="xsd:string" nillable="false" minOccurs="0" /> <xsd:element name="maxCargoVolume" type="xsd:decimal" nillable="false" minOccurs="0" /> <xsd:element name="maxCargoWeight" type="xsd:decimal" nillable="false" minOccurs="0" /> <xsd:element name="tailNumber" type="xsd:string" nillable="false" minOccurs="0" /> <xsd:element name="flightPlan" type="tns:ExtURIType" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="id" type="xsd:ID" use="optional" /> </xsd:complexType> <xsd:complexType name="CargoType"> <xsd:sequence> <xsd:element name="manifestNumber" type="xsd:string" nillable="false" minOccurs="0" /> <xsd:element name="volume" type="xsd:decimal" nillable="false" minOccurs="0" /> <xsd:element name="weight" type="xsd:decimal" nillable="false" minOccurs="0" /> <xsd:element name="flightPlan" type="tns:ExtURIType" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="id" type="xsd:ID" use="optional" /> </xsd:complexType> <xsd:complexType name="FlightPlanType"> <xsd:sequence>
Page 138
Page 139
Page 140
<xsd:attribute name="messageType" fixed="HIER" use="optional" /> </xsd:complexType> <xsd:complexType name="MessagesType"> <xsd:sequence> <xsd:element name="Message" type="tns:MessageType" minOccurs="0" maxOccurs="unbounded" /> </xsd:sequence> <xsd:attribute name="version" type="xsd:string" /> </xsd:complexType> <xsd:complexType name="MessageType"> <xsd:sequence> <xsd:element name="severity"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:enumeration value="Info" /> <xsd:enumeration value="Warning" /> <xsd:enumeration value="Violation" /> </xsd:restriction> </xsd:simpleType> </xsd:element> <xsd:element name="text" type="xsd:string" /> <xsd:element name="entityReference"> <xsd:complexType> <xsd:attribute name="href" type="xsd:anyURI" /> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType name="CargoType"> <xsd:sequence> <xsd:element name="container" type="xsd:string" nillable="false" minOccurs="0" /> <xsd:element name="needsRefrigeration" type="xsd:boolean" nillable="true" minOccurs="0" /> <xsd:element name="volume" type="xsd:long" nillable="false" minOccurs="0" /> <xsd:element name="weight" type="xsd:long" nillable="false" minOccurs="0" /> </xsd:sequence> <xsd:attribute name="id" type="xsd:ID" use="optional" /> <xsd:attribute name="href" type="xsd:anyURI" use="optional" /> </xsd:complexType> </xsd:schema> </types> <message name="CorticonRequestIn"> <part name="parameters" element="cc:CorticonRequest" /> </message> <message name="CorticonResponseOut"> <part name="parameters" element="cc:CorticonResponse" /> </message> <portType name="tutorial_exampleSoap">
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 141
<operation name="processRequest"> <input message="tns:CorticonRequestIn" /> <output message="tns:CorticonResponseOut" /> </operation> </portType> <binding name="tutorial_exampleSoap" type="tns:tutorial_exampleSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <operation name="processRequest"> <soap:operation soapAction="urn:Corticon" style="document" /> <input> <soap:body use="literal" namespace="urn:Corticon" /> </input> <output> <soap:body use="literal" namespace="urn:Corticon" /> </output> </operation> </binding> <service name="tutorial_example"> <documentation /> <port name="tutorial_exampleSoap" binding="tns:tutorial_exampleSoap"> <soap:address location="http://localhost:8082/axis/services/Corticon" /> </port> </service> </definitions>
Notice the unique ids for every entity. If not provided by the client, Corticon Server will add them automatically to ensure uniqueness:
<WorkDocuments> <Cargo id="Cargo_id_1">
Page 142
Notice that the optional newOrModified attribute has been set to true, indicating that container was modified by the Business Rules Server. The value of container, oversize, is the new data derived by the Decision Service.
<container newOrModified="true">oversize</container> </Cargo> </WorkDocuments> </CorticonResponse>
Server Integration & Deployment Guide 5.2 The data contained in the CorticonRequest is returned in the CorticonResponse:
<volume>400.000000</volume> <weight>160000.000000</weight> </cargo> </FlightPlan> </WorkDocuments> <Messages version="1">
Page 143
The entityReference contains an href that associates this message with the FlightPlan that caused it to be produced
<entityReference href="#FlightPlan_id_1"/> </Message> </Messages> </CorticonResponse>
Page 144
Page 145
Usage
Modifies the behavior of elements common to both the Corticon Studio and Server. Modifies behavior of the Corticon Deployment Console. Modifies behavior of Corticon Studio . Used to re-brand Corticon components for certain OEM customers. These properties are not described here because end users
Page 146
Properties are described in detail below. Actual property names and settings are shown in bold type, and explanatory comments in plain text.
Masks are divided into 3 categories: dateformat, datetimeformat, timeformat. Use the following chart to decode the date mask formats: The following symbols are used in date/time masks: Symbol
G y
Patterns yy = {00..99} yyyy = {0000..9999} M = {1..12} MM = {01..12} MMM = {Jan..Dec} MMMM = {January..December} d = {1..31} dd = {01..31} h = {1..12} hh = {01..12} H = {0..23} HH = {00..23} m = {0..59}
day of the month hour in AM or PM hour in 24-hour format (023) minute of the hour
Page 147
second of the minute millisecond of the minute day of the week day of the year day of week in the month week of the year week of the month AM/PM marker hour of the day (1-24) hour in AM/PM time zone escape character used to insert text single quote
Number Number Text Number Number Number Number Text Number Number Text Delimiter Literal
s = {0..59} ss = {00..59} S = {0..999} SSS = {000..999} E, EE, or EEE = {Sun..Sat} EEEE = {Sunday..Saturday} D = {0..366} DDD = {000..366} F = {0..6} w = {1..53} ww = {01..53} W = {1..6} a = {AM, PM} k = {1..24} kk = {01..24} K = {1..12} KK = {01..12} z, zz, or zzz = abbreviated time zone zzzz = full time zone
F w
W a k
Any characters in the pattern that are not in the ranges of [a..z] and [A..Z] will be treated as quoted text. For instance, characters like {:, ., <space>, #, @} will appear in the resulting time text even they are not embraced within single quotes. A pattern containing any invalid pattern letter will result in a thrown exception during formatting or parsing. Examples: Sample Pattern
yyyy.MM.dd G 'at' hh:mm:ss z EEE, MMM d, ''yy h:mm a
Resulting Formatted Date 1996.07.10 AD at 15:08:56 PDT Wed, Jul 10, '96 12:08 PM
Page 148 12 o'clock PM, Pacific Daylight Time 0:00 PM, PST 1996.July.10 AD 12:08 PM
Valid Date/Time Formats Studio uses the DateTime datatype to contain both data and time data. The Date datatype handles only date information, and the Time datatype handles only time information. It's also noteworthy that the Corticon XML Translator will maintain the consistency of DateTime, Date, and Time values from input to output documents so long as the masks used are contained in the lists. The first entry for each dateformat, datetimeformat, and timeformat is the default mask. For example, the built-in operator today always returns the current date in the default dateformat mask. The function now returns the current date in the default datetimeformat. The entries can be altered but must conform to the patterns/masks supported by Java class SimpleDateFormat in java.text package.
com.corticon.crml.OclDate.dateformat= MM/dd/yy MM/dd/yyyy M/d/yy M/d/yyyy yyyy/MM/dd yyyy-MM-dd yyyy/M/d yy/MM/dd yy/M/d MMM d, yyyy MMMMM d, yyyy com.corticon.crml.OclDate.datetimeformat= MM/dd/yy h:mm:ss a; MM/dd/yyyy h:mm:ss a; M/d/yy h:mm:ss a; M/d/yyyy h:mm:ss a; yyyy/MM/dd h:mm:ss a; yyyy/M/d h:mm:ss a; yy/MM/dd h:mm:ss a; yy/M/d h:mm:ss a; MMM d, yyyy h:mm:ss a; MMMMM d, yyyy h:mm:ss a;
Page 149
MM/dd/yy H:mm:ss; MM/dd/yyyy H:mm:ss; M/d/yy H:mm:ss; M/d/yyyy H:mm:ss; yyyy/MM/dd H:mm:ss; yyyy/M/d H:mm:ss; yy/MM/dd H:mm:ss; yy/M/d H:mm:ss; MMM d, yyyy H:mm:ss; MMMMM d, yyyy H:mm:ss; MM/dd/yy hh:mm:ss a; MM/dd/yyyy hh:mm:ss a; M/d/yy hh:mm:ss a; M/d/yyyy hh:mm:ss a; yyyy/MM/dd hh:mm:ss a; yyyy/M/d hh:mm:ss a; yy/MM/dd hh:mm:ss a; yy/M/d hh:mm:ss a; MMM d, yyyy hh:mm:ss a; MMMMM d, yyyy hh:mm:ss a; MM/dd/yy HH:mm:ss; MM/dd/yyyy HH:mm:ss; M/d/yy HH:mm:ss; M/d/yyyy HH:mm:ss; yyyy/MM/dd HH:mm:ss; yyyy/M/d HH:mm:ss; yy/MM/dd HH:mm:ss; yy/M/d HH:mm:ss; MMM d, yyyy HH:mm:ss; MMMMM d, yyyy HH:mm:ss; MM/dd/yy h:mm:ss a z; MM/dd/yyyy h:mm:ss a z; M/d/yy h:mm:ss a z; M/d/yyyy h:mm:ss a z; yyyy/MM/dd h:mm:ss a z; yyyy/M/d h:mm:ss a z; yy/MM/dd h:mm:ss a z; yy/M/d h:mm:ss a z;
Page 150
Page 151
If permissive is true (default), then the Corticon date/time parser will be lenient when handling incoming or entered date/times, trying to find a match even if the pattern is not contained in the mask lists. If false, then any incoming or entered date/time must strictly adhere to the patterns defined by dateformat, datetimeformat, timeformat. Default patterns are for United States and other countries that follow the US conventions on date/times.
com.corticon.crml.OclDate.maskliterals=true
If maskliterals is true (default), the system will parse strings and dates more quickly by checking for the presence of mask literals (e.g., "/", "-", ":" or ",") before consulting the date masks (an expensive process). If a string does not contain any of the mask literal characters, it can be immediately deemed a string (as opposed to a date). To take advantage of this feature, all user-specified date masks must contain at least one literal character. If any user-specified masks contain exclusively date pattern characters (e.g., "MMddyy"), maskliterals must be set to false in order to prevent the system from misinterpreting date literals (e.g., '123199') as simple strings.
These 4 properties deal with logging performed by Corticon Server. logpath assigns the directory to which logs are written and saved. By default the value of
%CORTICON_HOME%=<corticon_install_dir> logverbosity options:
VERBOSE : Logging is on. Logged Exceptions include stack trace. Default. BRIEF : Logging is on. Logged Exceptions do NOT include stack trace. SILENT : Turns off all logging. Maximizes Corticon Server performance. DEBUG : All messages are logged, including debugging info. To be used only at the
loglevel options:
direction of Progress technical support. Never deploy Corticon Server in production with loglevel set to DEBUG. Log files created in this mode may become very large and slow down Corticon Servers performance by orders of magnitude.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 152
INFO : All messages except debugging messages are logged. Never deploy Corticon Server in production with loglevel set to INFO. Log files created in this mode may
become very large and slow down Corticon Servers performance by orders of magnitude.
RULETRACE : Logs performance statistics (e.g., total time for rule execution,
percentage of time on each Rulesheet, etc.) and information on what specific rules were fired (not just evaluated). Do not deploy Corticon Server in production with loglevel set to RULETRACE. While log files are not nearly as large as those generated in DEBUG or INFO modes, they still require time to write, and therefore slow Corticon Server performance.
VIOLATION : Only Exceptions are logged. Recommended for deployment because it
all logging. The new Logger would need to implement the com.corticon.log.ICcThirdPartyLogger Interface. If the property is empty, then logging will default back to the Corticon Logger. To use Corticon's Log4JLogger, specify the following logger class for this property: com.corticon.log.CcLog4JLogger
decimalscale=6
This property handles the default precision for Decimal values in Corticon Studio and Server. All Decimal values are rounded to the specified number of places to the right of the decimal point. Default is 6 (e.g. 4.6056127 will be rounded, displayed, and/or returned as 4.605613).
enableNewOrModified=false
Determines whether XML responses from Corticon Server include newOrModified attributes indicating which elements of the XML document are new or have been modified. This flag also impacts the generation of service contracts (XSD, WSDL). Setting the flag to false results in more mainstream XML messaging without the newOrModified attributes. Default value is false.
com.corticon.ccserver.ensureComplianceWithServiceContract=true
Determines whether the returning XML CorticonResponse document must be valid with respect to the generated XSD/WSDL file. Ensuring compliance may require dynamic sorting which, if necessary, will slow performance. Default value is true (ensure compliance and perform the sorting, if necessary).
com.corticon.crml.OclDate.defaultDateForTimeValues=1970-01-01 com.corticon.crml.OclDate.defaultDateFormatForTimeValues=yyyy-MM-dd
Determines the "Default Date" to be used when instantiating or converting to Time data values. It is important that this property matches the database date and date format so that there is consistency
Page 153
between Time values inserted into the database directly and those inserted into the database by rules. Default Date value: 1970-01-01. Default DateFormat value: yyyy-MM-dd
com.corticon.jdom.translation.textmode=NORMALIZE
Determines the type of Corticon translation from JDOM to String. Different settings will yield different results.
NORMALIZE : Mode for text normalization (left and right trim plus internal
Default is NORMALIZE
com.corticon.validate.on.load=true
Determines whether the Foundation APIs will perform automatic validation of assets when they are loaded. API-controlled validation can help improve performance by validating assets only when necessary. If this flag is set to true, the APIs will validate assets at load time if: New validation rules have been added to the APIs. Related assets have been changed in a manner that justifies revalidation.
For example, if a Rulesheets Vocabulary has been changed, the API will automatically revalidate the Rulesheet to ensure that all Rulesheet expressions are valid with respect to the Vocabulary changes. If this flag is set to false, the APIs will not perform any validation when the asset is loaded; thus, the GUI is required to explicitly call the validate API during editor initialization. Default is true.
com.corticon.validate.on.activation=false
Determines whether the Foundation APIs will defer interdependency validation until asset activation. Normally, the APIs immediately revalidate assets within the editing domain as related assets are modified; however, when a large number of interrelated assets are open simultaneously, this instantaneous revalidation may degrade performance. If this flag is set to true, the APIs will defer revalidation of assets until they are explicitly "activated" via method IModelAPI.activate(), typically when a GUI editor gains the focus. The activate method causes the API to trigger deferred validations if any are pending due to changes in related assets. Default is false.
Page 154
com.corticon.localization.setsupportedlocales.swap=true Determines whether foundation API method setSupportedLocales will automatically rearrange
localizations, potentially changing the base locale of the asset. The default setting (true) will cause the API to automatically swap localized values into the base slot if the base locale in the input array is different from the asset base language. This allows the client program to designate what was originally an added (non-base) locale as the new base locale of the asset; however, this setting also imposes a precondition: when setSupportedLocales is called, the asset must contain complete localizations for every localizable element, or the API will throw an exception. This precondition is imposed because the API contract always requires a base value for every localizable element; while localizations are optional, a base value must never be null. If this flag is set to false, the system will allow the client program to indiscriminately change the set of supported locales without preconditions. In this mode, the system will arbitrarily update the asset's language legend and will remove any localizations while leaving the base values unchanged. While this ensures that API contract is not violated (because the base values remain unaffected), it puts the onus on the client program to "manually" update all base values and localizations to match the specified locale array; failure to do so may leave the language legend and localizations out of synch. Default is true.
com.corticon.vocabulary.cache=true
Determines whether the Vocabulary API will use a hash map to speed up Vocabulary element lookups. This can improve Rulesheet parsing performance, particularly for applications with larger Vocabularies. Default is true.
This is a list of Corticon Properties that will be used in the Checksum Calculations during the Post Load of the Models. This will help determine if we need to revalidate the Model.
com.corticon.migration.vocabulary.mandatory.flag=false
In this release, the value of an attributes mandatory property has an impact on engine behavior at runtime, whereas in v4 this was not the case. As a result, migration of v4 assets to this version may result in rule execution behavior that is inconsistent with v4. This property can be used to control this behavior. Here are the allowed values:
preserve : Preserves mandatory property values in migrated asset true : Unconditionally set all mandatory property values to true
January 13, 2012
Page 155
com.corticon.reactor.rulebuilder.maxloops=100
Set max loop interation. Determines what constitutes an endless loop. For .ers files with the Process Logical Loops setting on, it is necessary to have a safety net to prevent endless loops. This is done by designating the maximum number of iterations allowed for any loop. Default is 100.
com.corticon.reactor.rulebuilder.exception=raise
Set maxloop exception handling {raise, bury}. Specifies whether the rule engine will raise a MaxLoopsExceededException if the maximum number of loop iterations is exceeded. Default value is raise.
com.corticon.reactor.engine.CheckForAssociationDuplicates=true
Specifies whether the rule engine conducts an integrity check when adding to an existing association. This integrity check ensures that rules do not add redundant associations between the same two entities. Although, this is a rare that occurrence, it is possible. The downside of this integrity check is that Decision Services that create a significant number of new associations can experience a performance degradation. Such Decision Services would require this configuration property to be set to false. Default value is true.
Support BPEL in WSDL generation. Used to add a partnerlink section to the generated WSDL to make them BPEL compliant. Default is false.
com.corticon.xml.addDefaultNamespace=true
com.corticon.schemagenerator.addDefaultNamespace=true
Page 156
com.corticon.deployment.soapbindingurl_1=http://localhost:8082/axis/services /Corticon
This setting determines the default value of URL used by the Deployment Console. It does NOT determine where Studio looks when testing remote Decision Services (see Controlling Corticon Studio for instructions on changing remote Server locations in Studio). Other listed options include default port settings for other common web or application servers. Defaults are http://localhost:8082/axis/services/Corticon (typically used by the bundled Tomcat Server).
com.corticon.deployment.soapbindingurl_2=http://localhost:9080/axis/services /Corticon (typically used by IBM WebSphere) com.corticon.deployment.soapbindingurl_3=http://localhost:7001/axis/services /Corticon (typically used by Oracle/BEA WebLogic)
com.corticon.deployment.schema.useChoice=true
This property controls whether <choice> or <sequence> tags are used for the <WorkDocuments> section of the generated XSD/WSDL. When useChoice is set to true, <choice> tags are used which results in more flexibility in the order in which entity instances appear in the XML/SOAP message. When useChoise is set to false, <sequence> tags are used which requires that entity instances appears in the same order as they appear in the <WorkDocuments> section of the XSD/WSDL. Some Web Services platforms do not properly support <choice> tags. For these platforms, this property should be set to false. Default is true.
com.corticon.servicecontracts.ensureComplianceWithDotNET_WCF=false
Determines whether generated service contracts (WSDL/XSD) are compliant with Microsoft .NET WCF. This property must be set to true when Corticon Server is deployed inside a Microsoft WCF container. Note: WSDLs meant for .NET consumption should be generated in Hier XML Messaging Style. Default is false.
com.corticon.ccdeployment.sandboxDir=%CORTICON_HOME%/CcDeploymentSandbox
Determines the path to an existing directory used exclusively by the Deployment Console to precompile Ruleflow files into .eds files. Default is %CORTICON_HOME%/DecisionServerSandbox. Note, this is not the same property as the sandboxDir used in CcServer.properties.
com.corticon.deployment.ensureUniqueTargetNamespace=true
This property will tell the XSD and WSDL Generators to create unique Target Namespaces inside the output document.
Page 157
If the property is set to true, the following template will be used to create the Target Namespaces for the XSD and WSDL Documents: XSD: urn:decision/<Decision Service Name> WSDL: <soap binding uri>/<Decision Service Name>
If the property is set to false, the following template will be used to create the Target Namespaces for the XSD and WSDL Documents: XSD: urn:Corticon WSDL: urn:CorticonService
Default is true. For backwards compatibility with Corticon Server version 5.1 and earlier, use false.
com.corticon.designer.undoredo.stack.size=3
Specifies the size of the undo/redo stack. This number corresponds to the number of undo/redo operations the system will permit. Default is 3.
com.corticon.designer.corticon.insertrowstoend=10
Determines the number of rows that are added to the end of a Rulesheet section when Rulesheet>Add Rows to End is selected from the Studio menubar or popup menu. Default is 10.
com.corticon.designer.corticon.insertcolumnstoend=10
Determines the number of columns that are added to the end of a Rulesheet section when Rulesheet>Add Columns to End is selected from the Studio menubar or popup menu. Default is 10.
fileHistoryCount=10
Determines the number of opened files that are persisted in the file history list. This determines the maximum number of files that appear when File>Reopen is selected from the Studio menubar. Default value is 10.
Page 158
dir.uri.Report=%corticonbase%/Report
Determines the directory where the XML-based reporting files (XSL, XSD, HTML, XML) are located. By default, the normal value of %corticonbase% is <corticon_install_dir>/Report
Determines the parameters used by by Vocabulary|Auto-Fill Object Properties function. objectPropertyAutoFillCollectionType determines Object Collection Type when a x-to-many association end is encountered. There are three possible values:
Vector for java.util.Vector Array for Java arrays (e.g. A[]) ArrayList for java.util.ArrayList
If useIsMethodForBoolean is false then the system generates a getXYZ for a property of type Boolean. If it is true then the system generates a isXYZ in the Getter field for a property of type Boolean. Note: the Setter is not impacted by this flag. Default value for objectPropertyAutoFillCollectionType is Vector Default value for useIsMethodForBoolean is false
com.corticon.encoding.standard=UTF-8
Default character encoding for Studio objects, such as Vocabulary, Rulesheet and Ruletest XML files. Examples: UTF-8, UTF-16, ISO-8859-1, US-ASCII. Default value is UTF-8.
com.corticon.designer.useTextualRulesheetTestsheetStatusIndicator=false
Determines whether [Invalid] and [Disable] text will be added to Rulesheet and Ruletest tab names to help users who have difficulty seeing the red and gray colors. Default value is false.
com.corticon.designer.valuesets.compressLargeSetsUsingNot=false
Determines whether Conditional rule column value sets are automatically converted to their logically equivalent negated form upon Rulesheet collapse or compression. This is done in order to compress the value set down to a more manageable size. If the flag is set to true and a value set contains at least 2/3 of the possible Values for the condition then the system converts it to the negated form.
xmi.import.ecore.readonlyflag.default=true
Page 159
Determines whether Vocabulary property values are read-only when the Vocabulary is in edit mode. Read-only values are displayed with a light gray background to differentiate them from modifiable values. Read-only true means values are not modifiable. Read-only false means values are modifiable. Default value: true.
com.corticon.eclipse.platform.io.useuuids=false
Determines whether serialized versions of emf resources use Universally Unique IDs (UUIDs AKA GUIDs) or URI strings to reference other serialized elements. One reason to use UUIDs is to keep related resources in sync if they are moved to different locations. Use of URI strings will only work if the elements are always kept in the same relative locations. The value true means, yes, use UUIDs, while the value false means use URI strings. Default value: false.
com.corticon.tester.ccserver.maxdecisionservices=15
Specifies the max number of Decision Services generated through Tester API that can reside on the Server at one time. Default value is 15.
com.corticon.localize.expressions=true
Specifies whether the logic used to localize rule expressions will be invoked (true) or not (false). Default value is true.
com.corticon.tester.associations.includedomainandtype=true
Specifies whether test tree node association text will display domain and target entity type information. Default value is true.
com.corticon.studio.migration.datesubtype.default=Full DateTime
Specifies what current Date Data that will be mapped to a 4.1 Date Datatype, which doesn't contain a Subtype. Default value is Full DateTime. Other options include Date Only and Time Only.
com.corticon.eclipse.ui.dropdowns.visiblerows=10
Specifies the number of visible rows in a Drop Down Combo Box. Default value is 10.
com.corticon.studio.swt.virtualization=false
Specifies whether SWT virtualization will be enabled. SWT virtualization can improve the initial load times of larger Ruletest assets by deferring the creation of tree items until they are actually needed. Default value is false.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 160
com.corticon.designer.tested.xmlmessagingstyle=hier
This property sets the Studio Tests XML messaging style to one of the following: Hier (hierarchical) Flat Autodetect
These are exactly equivalent to the messaging styles selectable in the Deployment Descriptor file, described here.
com.corticon.crml.CrmlGraphVisualizer.fontname=arial.ttc com.corticon.crml.CrmlGraphVisualizer.fontsize=9
This properties set the font type and size used by the Graphic Visualizer. Default values are arial.ttc and 9, respectively.
com.corticon.eclipse.ui.completeness.check.autosize=true
Specifies whether columns added via the Completeness Checker will be automatically sized based on the data in the columns. Default value is true.
Determines the path to an existing directory used exclusively by Server to persist and retrieve deployment assets. If the path does not exist, the Server attempts to automatically create it. If this fails then the Server is unable to startup. Default is %CORTICON_HOME%/CcServerSandbox
com.corticon.ccserver.serviceIntervals=30000
Server has a maintenance service that is tasked with keeping the state of the Decision Service pools upto-date. The serviceIntervals property determines the number milliseconds elapsed in between service cycles during which Server checks for: Changes in any .cdd loaded to Server by a loadFromCdd or loadFromCddDir call Changes in any .cdd file including new cdds within the directory of cdds from a loadFromCddDir call
Page 161
Changes in any of the Decision Services (.erf files) loaded to the server. This is done via a timestamp check.
If any changes are detected, Server's state is dynamically updated to reflect the changes. Note: The maintenance service can be shutdown and restarted using:
ICcServer.stopDynamicaUpdateMonitoringService() ICcServer.startDynamicUpdateMonitoringService()
com.corticon.ccserver.inactivity=60000
Amount of time (in milliseconds) that a Reactor can remain idle before it's eligible for reclamation by the JVMs garbage collection mechanism. Each Decision Service has pooling parameters for minimum & maximum pool sizes. The pool is initialized to the minimum number of Reactors and grows to meet demand until maximum pool size is reached. When the level of demand drops, any Reactors in the pool that remain idle for the specified period are removed from the pool until the minimum size is reached. This process releases resources and reduces the memory footprint of Corticon Server. Default is 60000 milliseconds (60 seconds).
com.corticon.ccserver.dynamicupdatemonitor.autoactivate=true
Determines whether the Dynamic Update Monitor Service should be started automatically when Server is initialized. Default is true (Starts the Update Monitor Service automatically).
com.corticon.ccserver.servermessages=false
Determines whether to display Server messages to System.out, reflecting the state of the Decision Service pools in Server at initialization and update times. The state of the "wait" queues as well as the Reactor allocations are also reflected. This is primarily a debugging property to be used under instructions from Progress technical support. Default is false (no messages).
com.corticon.ccserver.validateSchema=true
Determines whether the server will invoke the JPOX metadata validation service at Ruleset deployment time. If this property is set to true the service will compare the external JDO document with the database metadata and will prevent deployment if any discrepancies are detected. Default is true.
com.corticon.reactor.rulebuilder.maxloops=100
Set max loop interation. Determines what constitutes an endless loop. For .ers files with the Process Logical Loops setting on, it is necessary to have a safety net to prevent endless loops. This is done by designating the maximum number of iterations allowed for any loop. Default is 100.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 162
com.corticon.reactor.rulebuilder.exception=raise
Set maxloop exception handling {raise, bury}. Specifies whether the rule engine will raise a MaxLoopsExceededException if the maximum number of loop iterations is exceeded. Default value is raise.
com.corticon.ccserver.compiler.javahome.location=
Specifies the location of the JRE that will be used by the Server to compile the Ruleflows into Decision Services. If not specified, the Server will use the same JRE that started the Server by calling into System.getProperty("java.home"). Default value is looked up using System.getProperty("java.home").
Specify which implementation class to be used when a supported interface is used for an association inside the user's mapped Business Object. This is needed by the BusinessObject Listener class, which is compiled during Decision Service deployment. Supported interfaces include: java.util.Collection java.util.List java.util.Set
com.corticon.server.compile.classpath.include.bos=true
Specify whether the Decision Service compile process should dynamically detect the location of the Jars where the Java Business Objects reside. Primary focus is to incorporate customer Java Business Objects in the Ant Classpath so that Listener Generation will succeed. Default value is true.
com.corticon.server.compile.classpath.include.alljarsunderccserver=false
Specify whether the Decision Service compile process should include all the Jars that are in the same directory as the CcServer.jar in the Ant Compile Classpath. This may need to be set to true dependent on the type of Application Server the Decision Services are deployed on. Primary focus is to incorporate customer Java Business Objects in the Ant Classpath so that Listener Generation will succeed. Default value is false.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 163
com.corticon.reactor.engine.CheckForAssociationDuplicates=true
Specifies whether the rule engine conducts an integrity check when adding to an existing association. This integrity check ensures that rules do not add redundant associations between the same two entities. Although, this is a rare that occurance, it is possible. The downside of this integrity check is that Decision Services that create a significant number of new associations can experience a performance degradation. Such Decision Services would require this configuration property to be set to false. Default value is true.
com.corticon.reactor.rulebuilder.UseLoopContainerStrategy=false
Specifies whether the rule engine uses Loop Container Strategy. Loop Container Strategy will create a Rule container object for rules that form a loop, just as when loops are enabled, so that when sequential rules are executed they are executed as if they are in a loop, but without looping. Default value is true.
com.corticon.BuildWaitTime=300000
Specifies the amount of time in milliseconds that the Ant build processor will wait before automatically timing out. Default value is 300000 (5 minutes).
com.corticon.ccserver.batch.retrieveCount=100000
Determines how many records will be retrieve at one time during batch process. The batch process retrieves Work Document Entity records from the database in increments of <batch.retrieveCount> and processes them one at a time. Batch process will continue to retrieve records using this property until all records have been retrieved and processed. Default value is 100000.
com.corticon.ccserver.batch.commitFrequency=100
Determines how frequently a transaction commit is performed during a batch process. The batch process retrieves Work Document Entity records from the database and processes them one at a time. After every <batch.commitFrequency> records a commit is performed. This frequency can be adjusted to achieve better performance and improve batch processing times. Default value is 100.
com.corticon.ccserver.tempdirectorypath=%corticonbase%/Temp/Server com.corticon.ccserver.tempdirectorycleanup=true
Server Temp Directory Settings. When Database Access is enabled, temp files need to be created to facilitate Tester execution using JPOX. The user will be able to specify the directory where these files are created. The user can also instruct the CcServer to cleanup all old Temp files out of the tempdirectorypath when it first gets initialized.
Page 164
com.corticon.server.monitoring.decisionservice.record.times=false com.corticon.server.monitoring.decisionservice.record.times.total=100
Server will auto-start recording time measurements. Note: The performance monitoring service can also be shutdown and restarted using the following methods, which will override this setting.
ICcServer.stopServerPerformanceMonitoringService() ICcServer.startServerPerformanceMonitoringService()
of execution times to be stored for each Decision Service/Version Default value is 100
Corticon Server will auto-start recording time measurements. Note: The data recording monitoring service can be shutdown and restarted using the following API methods, which will override this setting.
ICcServer.stopServerResultsDistributionMonitoringService() ICcServer.startServerResultsDistributionMonitoringService()
Page 165
com.corticon.server.monitoring.decisionservice.record.data.bucket.registrati on.delimiter specifies the delimiter to use when registering range buckets for the monitoring service. Default value is , com.corticon.server.monitoring.decisionservice.record.data.bucket.results.de limiter specifies the delimiter to use between bucket definition and bucket counter when reporting results from the monitoring service. Default value is :
These properties control monitoring execution times of Decision Service/Versions over defined interval periods.
com.corticon.server.monitoring.decisionservice.interval.record.times specifies whether Corticon Server will auto-start recording time interval measurements. Note: The time interval monitoring service can be shutdown and restarted using the following API methods, which will override this setting. ICcServer.stopServerExecutionTimesIntervalService() ICcServer.startServerExecutionTimesIntervalService()
com.corticon.server.soap.collection.results.delimiter=;
Specifies the delimiter to be used when results from an RPC need to be converted from a Collection to a String. Default value is ;
com.corticon.ccserver.autoloaddir.enable=true com.corticon.ccserver.autoloaddir= Specify if and from where .cdd files get "auto loaded" into Corticon Server when it starts up. Note:
This property changed using following method, which will override this setting.
ICcServer.setDeploymentDescriptorDirectoryPath(String)
Default value: If autoloaddir.enable is true, then Corticon Server will automatically read the path specified in autoloaddir and attempt to reload any Decision Services referenced in any .cdd
Page 166
files it finds there. If false, Corticon Server will not try to reload Decision Services deployed via .cdd files. If autoloaddir is empty, the following path is used: <user.dir>\cdd where <user.dir> is the value of environment variable "user.dir" which in Windows and Unix returns the directory where the container application was started in.
com.corticon.ccserver.appendservertimes=false
Specifies whether the Server Execution start and stop times are appended to the CorticonResponse document after ICcServer.execute(String) or ICcServer.execute(Document) is performed. Default value is false.
com.corticon.ccserver.cloneAssociationHashSets=false
Determines whether CDO association accessor ("getter") methods will return clones of their association HashSets. Normally, an association getter will return a direct reference to the association HashSet. The default value (false) provides the best performance, because cloning an association HashSet can trigger unnecessary database I/O due to lazy-loading. You can use this property to overcome ConcurrentModificationException errors which may arise when a Rulesheet has two aliases assigned to the same association, and that Rulesheet contains action statements that modify the association collection. Note that this property only applies to many-to-many associations; for many-to-1 associations, the CDOs will always return a direct reference to the "singleton" HashMap. Default is false
com.corticon.server.serverstate.load=true
Determines whether Corticon Server will initially load the ServerState.xml file to restore the Corticon Server to its previous state. Default is true
com.corticon.server.serverstate.persistchanges=true
Determines whether Corticon Server will persist its state inside of the ServerState.xml. By default this feature is turned on. Default is true
com.corticon.reactor.rulebuilder.DisableNullCheckingOnExtensions=false
By default, attributes are checked for null values to prevent further rule evaluation. This property will disable the null checks on attributes used in an extension call out, thereby allowing null values to be passed into an extended operator call.
Copyright 2000-2012 Progress Software Corporation All rights reserved. January 13, 2012
Page 167
Page 168
Usage Provides the source code used by testServer.bat to create a DOS menu interface on the Server API. Note: uses Corticon Server in the same JVM as the Java test code and can not be executed against Corticon Server inside the Tomcat server (you can, of course, write your own Java client using these APIs to operate against any deployment, including a Tomcat deployment). Shows how to control the Deployment Console via Java API calls. This is the source code used by testDeployConsole.bat to create a DOS menu interface for Server API. The source code used by axis.war, the sample SOAP wrapper shipped with Corticon Server.
\Server\src
CcDeployApiTest.java
\Samples\Server\ Containers\WAR\src
CcMessageHandler.java CcServerAxisTest.java CcServerMessagingAxis.java CcSoapException.java CcSoapSendException.java CcSoapServerInit.java CcSoapUtilities.java CcServerAdminHome.java CcServerAdminImplementation.java CcServerAdminInterface.java CcServerExecuteHome.java CcServerExecuteImplementation.java CcServerExecuteInterface.java
\Samples\Server\ Containers\EAR\src
The source code used by CcServer.ear, the sample Session EJB wrapper shipped with Corticon Server.
Page 169
Page 170
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
Page 171
The screens shown in this document were captured on computers using Windows XP and 7 as their operating systems.
SYSTEM REQUIREMENTS
Corticon Business Rules Server requirements include: All Java-supported processors 512 MB RAM recommended 10 MB disk space (core libraries) 150 MB disk space (full install) Java Runtime Engine, version 1.5.0 or higher
Page 172
The first screen of the Server Installer Wizard appears briefly and requires no action on your part.
This is the Introduction screen of the Server Installer Wizard. Click Next to continue.
Page 173
License Agreement
This screen displays the Corticon Standard License Agreement. Use the scroll bar at the right of the screen to read through this agreement. When you are finished and agree to the terms, choose I accept the terms of the license agreement. Click Next to continue.
If you are installing Corticon Server on Microsoft Vista or Windows 7, the default installation location may appear as C:\Corticon. Regardless of default, be sure to select an Install Folder for which you have full read and write access rights. If you have any doubt about your access rights to C:\Program Files, choose another installation directory outside C:\Program Files (such as C:\Corticon).
Page 174
Page 175
Install Set
Choose the install set, Complete, Minimum or Custom. The Complete option is selected by default. If you want a custom set, select or deselect any of the components from the list Click Next to continue.
Pre-Installation Summary
Verify your selections in the Pre-Installation Summary screen. Click Install to continue.
Page 176
Install Status
This screen displays a status bar as the necessary files are being copied to your computer.
Page 177
Desktop Shortcut
The Installer does not place a Deployment Console shortcut to your desktop. If you would like to add a Deployment Console shortcut icon to your desktop, locate the DepConsole.exe file inside
(create shortcut)
PROGRAM MAINTENANCE
Once Corticon Server is installed, you can modify the program features; repair corrupt files, shortcuts and registry entries; or remove Corticon Server completely. Remove Corticon Server and rerun Corticon Server Installer to change installation.
Remove Program
An Uninstaller named Uninstall Corticon Business Rules Server.exe is available in <corticon_install_dir>\Uninstall_Corticon Business Rules Server. To remove Corticon Server, run this executable. Choose Uninstall to remove all Corticon Server software from your computer Personal files that you have already created will NOT be removed or overwritten during this process.
Page 178
Uninstaller completion. If the Uninstaller program is unable to fully remove components, it will display messages in this window. In this case, \Samples were not removed because it is in use by Studio.
CORTICON
Business Rules Studio 5.2 Extensions User Guide
CONTENTS
Contents ..................................................................................................................................................................... 3 Supported Configurations ...................................................................................................................................... 4 Overview..................................................................................................................................................................... 5 Eclipse and RCP Usage Scenario............................................................................................................................. 6 Non-Eclipse Usage Scenario ................................................................................................................................... 6 Class Locator Files .................................................................................................................................................. 6 Java Class Conventions ............................................................................................................................................... 8 Attribute Extended Operators .................................................................................................................................... 9 Collection Extended Operators ................................................................................................................................ 11 Sequence Extended Operators ................................................................................................................................. 13 Stand-Alone Extended Operators............................................................................................................................. 16 Service Call-out Extensions....................................................................................................................................... 18 Service Call-out API .............................................................................................................................................. 19 Creating an Extension Plug-in ................................................................................................................................... 22 Setting Up Your Development Eclipse IDE ........................................................................................................... 22 Creating Your Plug-in Project ............................................................................................................................... 24 Creating the Extensions Locator File .................................................................................................................... 30 Creating an Extension Class ................................................................................................................................. 31 Coding Your Extension Class ................................................................................................................................ 34 Updating Your Plug-in Manifest ........................................................................................................................... 36 Organizing Imports............................................................................................................................................... 37 Exporting Your Plug-in.......................................................................................................................................... 38 Installing Your Plug-in .......................................................................................................................................... 39 Testing Your Extensions ....................................................................................................................................... 40 Troubleshooting Extensions ..................................................................................................................................... 55 Extension Plug-in Not Resolved By Eclipse .......................................................................................................... 56 Extension Locator File Not Set Up Correctly ........................................................................................................ 56 Extension Classes Not Implementing Marker Interfaces ..................................................................................... 57 Enabling Logging to Diagnose Extensions Issues ................................................................................................. 57 Documenting Your Extensions.................................................................................................................................. 59 Precompiling Ruleflows with Service Call-outs ........................................................................................................ 60 Appendix A: Corticon Studio and Server 5.2 Product Documentation .................................................................... 61
SUPPORTED CONFIGURATIONS
Software Component JDK Eclipse EMF GEF GMF Version 1.5.0 or higher Galileo (3.5.2 or higher) 2.5.0.v2009061510 or higher 3.5.1.v20090910 or higher 1.2.0.v20090615 or higher Certified on Version JDK 1.6.0_20 Galileo 3.5.2 2.2.3.v200705141058 3.2.2.v20070208 1.0.3.v20070202-1200
OVERVIEW
You can extend the set of operators available to your users by writing your own Java classes.
Extension Attribute Extended Operator Description Extensions that you invoke against attributes of a given type. For example, you can define an extension that can be invoked against String attributes. Extensions that operate on collections. For example, you can define an extension that can be invoked against a collection of String attributes. Extensions that operate on sequences. For example, you can define an extension that can be invoked against a sequence Decimal attributes. Function you can use in any Rulesheet expression. A StandAlone extension can take any number of input parameters returns a value. Extensions you can use in a Ruleflow. A Service Call-out is an extension that can directly access and update the universe of rule engine facts via the Service Callout application programming interfaces. Service Call-out Extension CreditLookup retrieves credit data from a consumer credit agency and updates rule engine facts accordingly. The system forwards the updated facts to Rulesheet AssessRisk for analysis. Example Invocation Customer.zip.characterAt(2) String Attribute Extended Operator characterAt returns a String consisting of the second character of Customer.zip. Order.uni=orditm.sku->uniqueCount Collection Extended Operator uniqueCount returns a count of the number of unique String values in collection orditem.sku. Trade.mavg=security.price-> sortedBy(marketDate)->mavg(30) Sequence Extended Operator mavg returns the moving average of a sequence of price values in security.price. Shape.circumference = SeMath.getCircumference(Shape.radius) Stand-Alone Extension SeMath.getCircumference converts Shape.radius to Shape.circumference.
There are several ways to add your extension classes to the system. The approach you use depends on whether you are using Corticon Studio for Eclipse, RCP or the Foundation APIs in a non-Eclipse setting.
Corticon Studio includes a sample implementation of this plug-in to guide your development efforts. This example plug-in includes Java classes plus an EMF file that documents the extensions (see Documenting your extensions on page 59).
A locator file is an empty (0-byte) file that allows the system to locate your classes.
Normally, Eclipse will copy non-Java classes from your /src folder to your output classes directory when you build your project; however, we have seen cases where this did not occur. It is essential that your CcExtensionsLocator.lc be present in your output Jar root when your plug-in is exported (see Exporting Your Plug-in on page 36), so please double-check your plug-in Jar to ensure that the locator is present.
If you use class directories outside of Eclipse, you must place CcExtensionsLocator.lc in the root folder where your classes reside. For example, if your extension classes were located in V:/Extensions, you would place your locator in V:/Extensions:
Corticon Studio is installed with source code examples that illustrate the proper implementation for each type of extension.3
Please refer to our source code examples in folders Extended Operators and Service Call-outs folders.
Assuming that Customer.name is a String attribute, Attribute Extended Operator trimSpaces might perform the "trim" function on the value of attribute name, returning the trimmed value, which the rule engine will assign to Customer.fullname. To create an Attribute Extended Operator, you must code a Java class, and your class must implement the marker interface corresponding to the attribute type. For example, to create a String Attribute Extended Operator, your Java class must implement interface ICcStringExtension. Example:
package com.acme.extensions; import com.corticon.services.extensions.ICcStringExtension; public class S1String implements ICcStringExtension { public static String trimSpaces(String astrThis) { if (astrThis == null) { return null; } return astrThis.trim(); } }
Attribute Extended Operator methods must be declared public static. The first positional parameter will always be a reference to the attribute upon which the function is being performed. In this example, the rules engine will pass the current value of Customer.name to extension method trimSpaces as parameter astrThis; thus, astrThis must be declared as type String.
10
An Attribute Extended Operator may accept any number of additional parameters as needed. Consider the following Rulesheet expression:
Customer.initial = Customer.name.characterAt(1)
In this example, your Java method would return the first character of Customer.name:
public static String characterAt(String astrThis, BigInteger abiIndex) { if (abiIndex == null) { return null; } int liIndex = abiIndex.intValue() - 1; if (liIndex < 0 || liIndex >= astrThis.length()) { return null; } return astrThis.substring(liIndex, liIndex + 1); }
As always, the first positional parameter astrThis will contain a reference to the String upon which to operate (i.e., a reference to the value of Customer.name). The second parameter will contain the character index (i.e., literal 1). Your extension would return the character at the specified index as a String, and the rules engine will assign Customer.initial the value of your returned String. For Attribute Extended Operators, you must limit your parameter and return types to the following:
Java Type java.math.BigInteger java.math.BigDecimal java.lang.Boolean java.util.Date java.lang.String Corticon Type Integer Decimal Boolean Date, Time or DateTime String
Note that you may code any number of extension methods in a Java class, and you can supply one or more Java classes; regardless, the system will discover all of your methods via Java reflection.
11
Assuming that asteriskFlag is a Boolean attribute and orditem.sku refers to a collection of String attributes, Collection Extended Operator allContain will return a Boolean value true if all instances of String attribute sku contain an asterisk. To create a Collection Extended Operator, you must code a Java class, and your class must implement marker interface ICcCollectionExtension. Example:
package com.corticon.operations.extended.examples.operators.set1; import java.util.HashSet; import com.corticon.services.extensions.ICcCollectionExtension; public class S1Collection implements ICcCollectionExtension { public static Boolean allContain(String[] astrInputArray, String astrLookFor) { if (astrInputArray == null || astrInputArray.length == 0) return null; for (String lstrInput : astrInputArray) { if (lstrInput != null) { if (lstrInput.indexOf(astrLookFor) < 0) { return new Boolean(false); } } } return new Boolean(true); } }
Collection Extended Operator methods must be declared public static. In this example, the first positional parameter of method allContain is an array of String instances. The rules engine will populate this array with the String values in orditem.sku (i.e., the collection upon which the method operates). The example Java method analyzes this array and returns a Boolean value. The rules engine will then assign ord.asteriskFlag the Boolean return value.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
12
Note that you cannot code Collection Extended Operators for entity instances, nor can you code extensions for Collections or Sequences of entity instances. For example, the following expression is not allowed:
orditem->allContain(*)
In other words, you can only code Collection Extended Operators to process collections of attribute values. When implementing Collection Extended Operators, you must limit your parameter and return types to the following:
Java Type java.math.BigInteger java.math.BigDecimal java.lang.Boolean java.util.Date java.lang.String Corticon Type Integer Decimal Boolean Date, Time or DateTime String
The first positional parameter must be an array of one of these allowable types.
13
Assuming that Trade.mavg is a Decimal attribute, marketDate a Date attribute, and security.price refers to a collection of Decimal attributes, Sequence Extended Operator mavg might return a Decimal value that is the moving average of the first 30 instances of sequence security.price. To create a Sequence Extended Operator, you must code a Java class, and your class must implement marker interface ICcSequenceExtension. Example:
14
package com.corticon.operations.extended.examples.operators.set1; import java.math.BigDecimal; import java.math.BigInteger; import com.corticon.services.extensions.ICcSequenceExtension; public class S1Sequence implements ICcSequenceExtension { private static final int DECIMAL_SCALE = 4; public static BigDecimal mavg(BigDecimal[] abdInputArray, BigInteger abiElements) { if (abdInputArray == null || abiElements == null) { return new BigDecimal("0"); } int liElements = abiElements.intValue(); BigDecimal lbdSum = new BigDecimal("0").setScale(DECIMAL_SCALE); int liDenominator = 0; for (int liIndex = 0; liIndex < abdInputArray.length && liIndex < liElements; liIndex++) { lbdSum = lbdSum.add(abdInputArray[liIndex]); liDenominator++; } BigDecimal lbdDenominator = new BigDecimal(String.valueOf(liDenominator)); return lbdSum.divide(lbdDenominator, DECIMAL_SCALE, BigDecimal.ROUND_HALF_UP); } }
Sequence Extended Operator methods must be declared public static. In this example, the first positional parameter of method mavg is an array of BigDecimal instances. The rules engine will populate this array with the Decimal values in security.price 4 (i.e., the sequence upon which the method operates). The example Java method analyzes this array and returns a Decimal value. The rules engine will then assign Trade.mavg the Decimal return value. As with Collection Extended Operators, you cannot code Sequence Extended Operators for entity instances, nor can you code extensions for Collections or Sequences of entity instances.
4
Collection security.price has been sorted into marketDate sequence via built-in operator sortedBy.
15
When implementing Sequence Extended Operators, you must limit your parameter and return types to the following:
Java Type java.math.BigInteger java.math.BigDecimal java.lang.Boolean java.util.Date java.lang.String Corticon Type Integer Decimal Boolean Date, Time or DateTime String
The first positional parameter must be an array of one of these allowable types.
16
Assuming Circle.circumference and Circle.radius are both Decimal attributes, Stand-Alone Extended Operator SeMath.getCircumference might convert the radius to circumference, which the rule engine will assign to Circle.circumference. To create Stand Alone Extended Operator, you must code a Java class, and your class must interface ICcStandAloneExtension. Example:
package com.corticon.operations.extended.examples.standalone.set1; import java.math.BigDecimal; import com.corticon.services.extensions.ICcStandAloneExtension; public class SeMath implements ICcStandAloneExtension { public static BigDecimal getCircumference(BigDecimal abdRadius) { BigDecimal lbdBigDecimal = abdRadius.multiply(new BigDecimal(2.0)); lbdBigDecimal = lbdBigDecimal.multiply(new BigDecimal(Math.PI)); return lbdBigDecimal; } }
Stand-Alone Extended Operator methods must be declared public static. Any number of parameters may be specified. The Rulesheet expression parameter list and return value must match the extension class method signature; otherwise, the Rulesheet expression will be flagged as invalid.
The user specifies the unqualified part of the class name, namely the class name without the package name. January 13, 2012
17
In this example, the rules engine will pass the current value of Circle.radius to class com.corticon.operations.extended.examples.standalone.set1.SeMath method getCircumference as parameter abdRadius; thus, abdRadius must be declared as type BigDecimal. Similarly to Attribute Extended Operators, you must limit parameter and return types to the following:
Java Type java.math.BigInteger java.math.BigDecimal java.lang.Boolean java.util.Date java.lang.String Corticon Type Integer Decimal Boolean Date, Time or DateTime String
Note that you may code any number of extension methods in a Java class, and you can supply one or more Java classes; regardless, the system will discover all of your methods via Java reflection.
18
After the rule engine finishes processing Rulesheet SelectCandidates, it will transfer control to Service Call-out Extension class CreditLookup, method retrieveFICO. Using the Service Call-out API, class CreditLookup, method retrieveFICO can create, retrieve, update and remove facts. For example, it might look up a customers FICO score using an external web service, and update the facts accordingly. When CreditLookup.retrieveFICO finishes, the system will transfer control to the next Rulesheet in the Ruleflow. Downstream Rulesheets (e.g., AssessRisks) will evaluate and respond to new facts asserted by your Service Call-out.
19
com.corticon.services.dataobject.ICcDataObjectManager Provides access to the entire fact pool. Allows you to create, retrieve and remove entity instances. com.corticon.services.dataobject.ICcDataObject Provides access to a single entity instance. Allows you to update the entity instance, including setting attributes and creating and removing associations.
Your Service Call-out class must implement marker interface ICcServiceCalloutExtension. Example:
20
package com.corticon.operations.extended.examples.servicecallouts; import com.corticon.services.dataobject.ICcDataObject; import com.corticon.services.dataobject.ICcDataObjectManager; import com.corticon.services.extensions.ICcServiceCalloutExtension; public class SampleDataService implements ICcServiceCalloutExtension { public static void retrievePersonInfo(ICcDataObjectManager aDataObjMgr) { for (ICcDataObject lPerson : aDataObjMgr.getEntitiesByName("Person")) { String lstrName = "Tom"; Boolean lbMarried = new Boolean(true); lPerson.setAttributeValue("name", lstrName); lPerson.setAttributeValue("married", lbMarried); } } }
Service Call-out methods must be declared public static. The system will recognize your Service Call-out method if the method signature takes one parameter and that parameter is an instance of ICcDataObjectManager. Recognized classes and methods will appear in the Ruleflow Properties View/Service Name drop-down list when a Service Call-out shape is selected in the Ruleflow diagram:
21
Example SampleDataService.resetInfoCounter illustrates how a Service Call-out can use the supplied ICcDataObjectManager to find and update entity instances.
ICcDataObjectManager method getEntitiesByName allows you to retrieve a Set of all entity instances with a given name. Each element of the returned Set is an instance of ICcDataObject which
offers additional methods to access and update a specific entity instance. The example finds all Person entities then iterates over them to set attributes Person.name and Person.married using generic method ICcDataObject.setAttributeValue. The Service Call-out API provides your extension class complete access to the fact pool, allowing you to: Find entities in several ways Read and update entity attributes Create and remove entity instances Create and remove associations Post rule messages
Please refer to Service Call-out Java source code examples in your Corticon Studio /Samples/Extended Operators folder, and see the API Javadocs for more information.
22
You can use your Eclipse IDE to create a plug-in project to develop your extensions and ultimately prepare them for deployment.
We recommend you develop plug-ins using an installed Java JDK as opposed to JRE. If you have not already done so, download the latest JDK from www.oracle.com then select: Windows>Preferences>Java>Installed JREs Navigate to your downloaded JDK and select it as your default JRE:
23
In order to successfully compile and test Rulesheets, you must copy tools.jar from your JDKs /lib directory into /jre/lib/ext as shown:
24
25
26
27
The system will display the Content page allowing: 1. In the Version field, enter a version number for your plug-in. You should specify a version greater than the version of Studio you installed. For example, if you installed Studio Version 5.1.2, you might specify version 5.1.3. This will ensure that your plug-in supersedes our example plug-in. 2. Enter Extended Operators Core Plug-in in the Name field. 3. Enter your company name in the Provider field.
4. Uncheck Generate an activator.
28
The system will prompt to switch to the Plug-in Development perspective. Check Remember my decision:
Press Yes to proceed. The system will switch to Plug-in Development perspective and then create a new plug-in project in your workspace.
29
The system will automatically open file plug-in manifest (MANIFEST.MF) to allow you to configure your new plug-in:
30
31
32
Enter a name for your new Java class (e.g., HelloWorld) and press Finish. The system will create an empty class definition:
33
34
35
36
These changes will: Ensure that your plug-in has access to interface ICcStringExtension in
com.corticon.services
Ensure that your locator file CcExtensionLocator.lc and Java package com.acme.extended.operators are visible to the Corticon extensions subsystem Ensure that your plug-in is registered as a buddy with com.corticon.legacy to allow the Corticon class loader to find your extensions
37
ORGANIZING IMPORTS
Activate the HelloWorld Java editor and press CTRL-SHIFT-O to organize imports. The system will add import com.corticon.services.extensions.ICcStringExtension allowing your class to build without errors:
38
39
You may have to use the clean command line option when you restart Eclipse to cause the system to rebuild the bundle cache, ensuring that your changes take effect.
40
41
Right-click in the body of the Rule Project Explorer and select New>Rule Project
42
The system will create a new Rule Project visible in the Rule Project Explorer:
43
44
45
In the Vocabulary Editor, right-click the HelloWorld root node and select Add Entity to create a new entity Customer:
46
Right click Customer and select Add Attribute to create String attribute name:
47
Select the HelloWorld project in the Rule Project Explorer and select New>Rulesheet:
48
Press Next and then select the Vocabulary asset you created in the prior step:
Press Finish and the system will create a new empty Rulesheet.
49
50
Right click on your HelloWorld project and select New>Ruletest. Specify HelloWorld in the File name field:
Press Next
51
Press Finish and the system will create an empty Ruletest asset.
Copyright 2000-2012 Progress Software Corporation. All rights reserved. January 13, 2012
52
53
Drag entity Customer from the Vocabulary view to the Ruletest input tree:
54
Select Ruletest>Testsheet>Run Test and you should see the following test results:
If you see Hello World in the output tree, congratulations! Your extensions are working properly.
55
TROUBLESHOOTING EXTENSIONS
If your extensions are not properly written or deployed, the system will color Rulesheet expressions red and will display validation messages in the Problems tab:
For Attribute Extended Operators, validation messages will indicate that your method is not a valid call on an attribute. There are several possible causes for this type of error.
56
In this example, the plug-in has been installed and properly [Resolved]. If your plug-in is missing from this list, ensure that you have properly copied it into the Eclipse /plugins directory. Remember to start Eclipse with the clean command line option. This will cause the system to rebuild the bundle cache so that your new plug-in code is recognized. If your plug-in is present in the list but not marked as [Resolved] there may be some problem with the plug-in manifest. Carefully review MANIFST.MF to ensure all of your specifications are correct. Tips for troubleshooting bundle start failures can be found in various Eclipse online forums.
57
Note that in the Export-Package clause, you must export period (.) to ensure that CcExtensionsLocator.lc is properly exported. If this specification is in error or missing, the system will fail to locate your classes.
The extensions subsystem will log messages as it tries to locate your extension classes. You might see this type of output if your plug-in fails to properly export (.):
CcUtil.getAllLocationsOfFile() .. START CcUtil.getAllLocationsOfFile() .. astrResourceName = CcExtensionsLocator.lc com.corticon.extensions.CcExtensions|CcExtensions() loadClassesFromJars() == Start com.corticon.extensions.CcExtensions|CcExtensions() loadClassesFromJars() asetJarLocations == [] CcUtil|CcUtil.getAllLocationsOfFile() .. START com.corticon.extensions.CcExtensions|CcExtensions() loadClassesFromDirectories() == Start com.corticon.extensions.CcExtensions|CcExtensions() loadClassesFromDirectories() asetDirectoryLocations == []
n the log output above, the extensions subsystem is unable to find CcExtensionsLocator.lc either because it is missing or not properly exported.
58
In contrast, here is what you will see in the log if the extensions subsystem is able to find your locator and extension classes:
CcUtil.getAllLocationsOfFile() .. START CcUtil.getAllLocationsOfFile() .. astrResourceName = CcExtensionsLocator.lc CcUtil.getAllLocationsOfFile() .. lURLLocationPath = bundleresource://17.fwk25860399/CcExtensionsLocator.lc CcUtil.getAllLocationsOfFile() .. lstrProtocol = bundleresource CcUtil.getAllLocationsOfFile( AFTER RESOLVER ) .. lURLLocationPath = jar:file:/D:/GalileoClassic/eclipse/plugins/com.corticon.eclipse.studio.operations.extended.co re _5.1.3.jar!/CcExtensionsLocator.lc CcUtil.getAllLocationsOfFile(1) .. lstrPath = file:\D:\GalileoClassic\eclipse\plugins\com.corticon.eclipse.studio.operations.extended.core _5.1.3.jar!\CcExtensionsLocator.lc CcUtil.getAllLocationsOfFile(2) .. lstrPath = file:\D:\GalileoClassic\eclipse\plugins\com.corticon.eclipse.studio.operations.extended.core _5.1.3.jar!\CcExtensionsLocator.lc CcUtil|CcUtil.getAllLocationsOfFile() .. END = [file:\D:\GalileoClassic\eclipse\plugins\com.corticon.eclipse.studio.operations.extended.core _5.1.3.jar!\CcExtensionsLocator.lc] com.corticon.extensions.CcExtensions|CcExtensions() loadClassesFromDirectories() == Start com.corticon.extensions.CcExtensions|CcExtensions() loadClassesFromDirectories() asetDirectoryLocations == []
As shown above, getAllLocationsOfFile is able to find your extensions. This is a positive sign and if you see such output in the log, it is very likely that your extensions will work properly.
59
During system initialization, the system will attempt to locate ExtendedOperators.operationsmodel on the Java class path; if the system finds this file, it will automatically merge the documented extended operators into the Rule Operators tree view.
ExtendedOperators.operationsmodel supports internationalization. The object model permits
localization of folder names, extended operator names, parameter names and tooltips. This is accomplished via EMF multi-valued attributes, which are essentially lists (arrays) of values. Each slot in the array contains a particular localization (i.e., a string expressed in one of the supported languages). The first localization in each slot is special and is referred to as the base localization. For class and method names, the base localizations must match the class and method names in your java extension classes. The root object of the model (ExtendedOperatorSet) contains a list of Java LanguageCode instances that defines the set of languages supported. The order of language codes is important and must match the order of localizations expressed elsewhere in the file. The system will merge typed extensions into the Rule Operator tree at the end of the built-in operators. For example, String Attribute Extended Operators will be appended to the "String" data type node of the Rule Operator tree after the built-in String operators. The system will append Stand Alone extensions to the end of the Rule Operator tree. The Stand Alone extensions will be contained within a special folder whose name is declared in ExtendedOperators.operationsmodel (see ExtendedOperatorSet.standAloneFolderName). In our example, the name of the Stand Alone extensions folder is simply Extended Operators. Our example ExtendedOperators.operationsmodel contains English descriptions of operators, and is set up to handle Japanese localizations as well, although the only Japanese localization specified is the Stand Alone folder name. Please refer to example ExtendedOperators.operationsmodel file as a guide documenting your own extensions.
60
61
Model Business Rules: Corticon Studio Documentation Studio 5.2 Installation Guide A step-by-step procedure for installing Studio 5.2 on a PC running Microsoft Windows or in an Eclipse environment. A guide to the Studio 5.2 User Interface and its mechanics, including descriptions of all menu options, buttons, and basic actions. An online .pdf version of all documents in this table, available from within Studio 5.2. An in-depth discussion of several essential Studio 5.2 concepts. Recommended for all Studio 5.2 users. A detailed reference of all operators available in the Studio Vocabulary. An actual Studio Rulesheet example is included for every operator.
Integrate & Deploy Business Rules: Corticon Server Technical Documentation Server Integration & Deployment Guide An in-depth, technical description of Server installation, deployment methods, integration, messaging, APIs, and configuration. Detailed technical explanations describing the Corticon extension framework for extended operators and service call-outs
2012 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved. These materials and all Progress software products are copyrighted and all rights are reserved by Progress Software Corporation. The information in these materials is subject to change without notice, and Progress Software Corporation assumes no responsibility for any errors that may appear therein. The references in these materials to specific platforms supported are subject to change. Actional, Apama, Artix, Business Empowerment, Business Making Progress, Corticon, Corticon (and design), DataDirect (and design), DataDirect Connect, DataDirect Connect64, DataDirect Technologies, DataDirect XML Converters, DataDirect XQuery, DataXtend, Dynamic Routing Architecture, Empowerment Center, Fathom, Fuse Mediation Router, Fuse Message Broker, Fuse Services Framework, IONA, Making Software Work Together, Mindreef, ObjectStore, OpenEdge, Orbix, PeerDirect, Powered by Progress, PowerTier, Progress, Progress DataXtend, Progress Dynamics, Progress Business Empowerment, Progress Empowerment Center, Progress Empowerment Program, Progress OpenEdge, Progress Profiles, Progress Results, Progress Software Business Making Progress, Progress Software Developers Network, Progress Sonic, ProVision, PS Select, RulesCloud, RulesWorld, Savvion, SequeLink, Shadow, SOAPscope, SOAPStation, Sonic, Sonic ESB, SonicMQ, Sonic Orchestration Server, SpeedScript, Stylus Studio, Technical Empowerment, WebSpeed, Xcalia (and design), and Your Software, Our TechnologyExperience the Connection are registered trademarks of Progress Software Corporation or one of its affiliates or subsidiaries in the U.S. and/or other countries. AccelEvent, Apama Dashboard Studio, Apama Event Manager, Apama Event Modeler, Apama Event Store, Apama Risk Firewall, AppsAlive, AppServer, ASPen, ASP-ina-Box, BusinessEdge, Cache-Forward, CloudEdge, DataDirect Spy, DataDirect SupportLink, Fuse, FuseSource, Future Proof, GVAC, High Performance Integration, ObjectStore Inspector, ObjectStore Performance Expert, OpenAccess, Orbacus, Pantero, POSSE, ProDataSet, Progress Arcade, Progress CloudEdge, Progress Cloudware, Progress Control Tower, Progress ESP Event Manager, Progress ESP Event Modeler, Progress Event Engine, Progress RFID, Progress RPM, Progress Responsive Cloud, Progress Responsive Process Management, Progress Software, PSE Pro, SectorAlliance, SeeThinkAct, Shadow z/Services, Shadow z/Direct, Shadow z/Events, Shadow z/Presentation, Shadow Studio, SmartBrowser, SmartComponent, SmartDataBrowser, SmartDataObjects, SmartDataView, SmartDialog, SmartFolder, SmartFrame, SmartObjects, SmartPanel, SmartQuery, SmartViewer, SmartWindow, Sonic Business Integration Suite, Sonic Process Manager, Sonic Collaboration Server, Sonic Continuous Availability Architecture, Sonic Database Service, Sonic Workbench, Sonic XML Server, The Brains Behind BAM, WebClient, and Who Makes Progress are trademarks or service marks of Progress Software Corporation and/or its subsidiaries or affiliates in the U.S. and other countries. Java is a registered trademark of Oracle and/or its affiliates. Any other marks contained herein may be trademarks of their respective owners.
Third Party Acknowledgments: Progress Corticon Studio v5.2 incorporates Apache BCEL v5.1 from The Apache Software Foundation. Such technology is subject to the following terms and conditions: The Apache Software License, Version 1.1 Copyright (c) 2001 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache" and "Apache Software Foundation" and "Apache BCEL" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", "Apache BCEL", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. Progress Corticon Studio v5.2 incorporates Apache SOAP v2.3.1 from The Apache Software Foundation. Such technology is subject to the following terms and conditions: The Apache Software License, Version 1.1 Copyright (c) 1999 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "SOAP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. Progress Corticon Studio v5.2 incorporates Jaxen v1.3. Such technology is subject to the following terms and conditions: JAXEN License - $Id: LICENSE,v 1.3 2002/04/22 11:38:45 jstrachan Exp $ - Copyright (C) 2000-2002 bob mcwhirter & James Strachan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows these conditions in the documentation and/or other materials provided with the distribution.
3. The name "Jaxen" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact license@jaxen.org. 4. Products derived from this software may not be called "Jaxen", nor may "Jaxen" appear in their name, without prior written permission from the Jaxen Project Management (pm@jaxen.org). In addition, we request (but do not require) that you include in the end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following: "This product includes software developed by the Jaxen Project (http://www.jaxen.org/)." Alternatively, the acknowledgment may be graphical using the logos available at http://www.jaxen.org/. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE Jaxen AUTHORS OR THE PROJECT CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Jaxen Project and was originally created by bob mcwhirter <bob@werken.com> and James Strachan <jstrachan@apache.org>. For more information on the Jaxen Project, please see <http://www.jaxen.org/>. Progress Corticon Studio v5.2 incorporates JDOM v1.0 GA. Such technology is subject to the following terms and conditions: $Id: LICENSE.txt,v 1.11 2004/02/06 09:32:57 jhunter Exp $ - Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows these conditions in the documentation and/or other materials provided with the distribution. 3. The name "JDOM" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact <request_AT_jdom_DOT_org>. 4. Products derived from this software may not be called "JDOM", nor may "JDOM" appear in their name, without prior written permission from the JDOM Project Management <request_AT_jdom_DOT_org>. In addition, we request (but do not require) that you include in the end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following: "This product includes software developed by the JDOM Project (http://www.jdom.org/)." Alternatively, the acknowledgment may be graphical using the logos available at http://www.jdom.org/images/logos. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the JDOM Project and was originally created by Jason Hunter <jhunter_AT_jdom_DOT_org> and Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information on the JDOM Project, please see <http://www.jdom.org/>. Progress Corticon Studio v5.2 incorporates Saxpath v1.0. Such technology is subject to the following terms and conditions: Copyright (C) 2000-2002 werken digital. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows these conditions in the documentation and/or other materials provided with the distribution. 3. The name "SAXPath" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact license@saxpath.org. 4. Products derived from this software may not be called "SAXPath", nor may "SAXPath" appear in their name, without prior written permission from the SAXPath Project Management (pm@saxpath.org).
In addition, we request (but do not require) that you include in the end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following: "This product includes software developed by the SAXPath Project (http://www.saxpath.org/)." Alternatively, the acknowledgment may be graphical using the logos available at http://www.saxpath.org/ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SAXPath AUTHORS OR THE PROJECT CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the SAXPath Project and was originally created by bob mcwhirter <bob@werken.com> and James Strachan <jstrachan@apache.org>. For more information on the SAXPath Project, please see <http://www.saxpath.org/>. Progress Corticon Server v5.2 incorporates Apache BCEL v5.1 from The Apache Software Foundation. Such technology is subject to the following terms and conditions: The Apache Software License, Version 1.1 Copyright (c) 2001 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache" and "Apache Software Foundation" and "Apache BCEL" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", "Apache BCEL", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. Progress Corticon Server v5.2 incorporates Apache Commons Discovery v0.2 from The Apache Software Foundation. Such technology is subject to the following terms and conditions: The Apache Software License, Version 1.1 Copyright (c) 1999-2001 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowlegement: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowlegement may appear in the software itself, if and wherever such third-party acknowlegements normally appear. 4. The names "The Jakarta Project", "Commons", and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache" nor may "Apache" appear in their names without prior written permission of the Apache Group. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE
FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. Progress Corticon Server v5.2 incorporates Apache SOAP v2.3.1 from The Apache Software Foundation. Such technology is subject to the following terms and conditions: The Apache Software License, Version 1.1 Copyright (c) 1999 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "SOAP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. Progress Corticon Server v5.2 incorporates Jaxen v1.3. Such technology is subject to the following terms and conditions: JAXEN License - $Id: LICENSE,v 1.3 2002/04/22 11:38:45 jstrachan Exp $ - Copyright (C) 2000-2002 bob mcwhirter & James Strachan. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows these conditions in the documentation and/or other materials provided with the distribution. 3. The name "Jaxen" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact license@jaxen.org. 4. Products derived from this software may not be called "Jaxen", nor may "Jaxen" appear in their name, without prior written permission from the Jaxen Project Management (pm@jaxen.org). In addition, we request (but do not require) that you include in the end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following: "This product includes software developed by the Jaxen Project (http://www.jaxen.org/)." Alternatively, the acknowledgment may be graphical using the logos available at http://www.jaxen.org/. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE Jaxen AUTHORS OR THE PROJECT CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Jaxen Project and was originally created by bob mcwhirter <bob@werken.com> and James Strachan <jstrachan@apache.org>. For more information on the Jaxen Project, please see <http://www.jaxen.org/>.
Progress Corticon Server v5.2 incorporates JDOM v1.0 GA. Such technology is subject to the following terms and conditions: $Id: LICENSE.txt,v 1.11 2004/02/06 09:32:57 jhunter Exp $ - Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows these conditions in the documentation and/or other materials provided with the distribution. 3. The name "JDOM" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact <request_AT_jdom_DOT_org>. 4. Products derived from this software may not be called "JDOM", nor may "JDOM" appear in their name, without prior written permission from the JDOM Project Management <request_AT_jdom_DOT_org>. In addition, we request (but do not require) that you include in the end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following: "This product includes software developed by the JDOM Project (http://www.jdom.org/)." Alternatively, the acknowledgment may be graphical using the logos available at http://www.jdom.org/images/logos. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the JDOM Project and was originally created by Jason Hunter <jhunter_AT_jdom_DOT_org> and Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information on the JDOM Project, please see <http://www.jdom.org/>. Progress Corticon Server v5.2 incorporates Saxpath v1.0. Such technology is subject to the following terms and conditions: Copyright (C) 2000-2002 werken digital. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the disclaimer that follows these conditions in the documentation and/or other materials provided with the distribution. 3. The name "SAXPath" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact license@saxpath.org. 4. Products derived from this software may not be called "SAXPath", nor may "SAXPath" appear in their name, without prior written permission from the SAXPath Project Management (pm@saxpath.org). In addition, we request (but do not require) that you include in the end-user documentation provided with the redistribution and/or in the software itself an acknowledgement equivalent to the following: "This product includes software developed by the SAXPath Project (http://www.saxpath.org/)." Alternatively, the acknowledgment may be graphical using the logos available at http://www.saxpath.org/ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE SAXPath AUTHORS OR THE PROJECT CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the SAXPath Project and was originally created by bob mcwhirter <bob@werken.com> and James Strachan <jstrachan@apache.org>. For more information on the SAXPath Project, please see <http://www.saxpath.org/>.