Sie sind auf Seite 1von 192

TIBCO Collaborative Information Manager Rulebase Guide

Software Release 8.1.0 January 2011

Important Information
SOME TIBCO SOFTWARE EMBEDS OR BUNDLES OTHER TIBCO SOFTWARE. USE OF SUCH EMBEDDED OR BUNDLED TIBCO SOFTWARE IS SOLELY TO ENABLE THE FUNCTIONALITY (OR PROVIDE LIMITED ADD-ON FUNCTIONALITY) OF THE LICENSED TIBCO SOFTWARE. THE EMBEDDED OR BUNDLED SOFTWARE IS NOT LICENSED TO BE USED OR ACCESSED BY ANY OTHER TIBCO SOFTWARE OR FOR ANY OTHER PURPOSE. USE OF TIBCO SOFTWARE AND THIS DOCUMENT IS SUBJECT TO THE TERMS AND CONDITIONS OF A LICENSE AGREEMENT FOUND IN EITHER A SEPARATELY EXECUTED SOFTWARE LICENSE AGREEMENT, OR, IF THERE IS NO SUCH SEPARATE AGREEMENT, THE CLICKWRAP END USER LICENSE AGREEMENT WHICH IS DISPLAYED DURING DOWNLOAD OR INSTALLATION OF THE SOFTWARE (AND WHICH IS DUPLICATED IN THE LICENSE FILE) OR IF THERE IS NO SUCH SOFTWARE LICENSE AGREEMENT OR CLICKWRAP END USER LICENSE AGREEMENT, THE LICENSE(S) LOCATED IN THE LICENSE FILE(S) OF THE SOFTWARE. USE OF THIS DOCUMENT IS SUBJECT TO THOSE TERMS AND CONDITIONS, AND YOUR USE HEREOF SHALL CONSTITUTE ACCEPTANCE OF AND AN AGREEMENT TO BE BOUND BY THE SAME. This document contains confidential information that is subject to U.S. and international copyright laws and treaties. No part of this document may be reproduced in any form without the written authorization of TIBCO Software Inc. TIBCO, The Power of Now, TIBCO BusinessConnect, TIBCO ActiveMatrix BusinessWorks, TIBCO Enterprise Message Service are either registered trademarks or trademarks of TIBCO Software Inc. in the United States and/or other countries. EJB, Java EE, J2EE, and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All other product and company names and marks mentioned in this document are the property of their respective owners and are mentioned for identification purposes only. THIS SOFTWARE MAY BE AVAILABLE ON MULTIPLE OPERATING SYSTEMS. HOWEVER, NOT ALL OPERATING SYSTEM PLATFORMS FOR A SPECIFIC SOFTWARE VERSION ARE RELEASED AT THE SAME TIME. SEE THE README FILE FOR THE AVAILABILITY OF THIS SOFTWARE VERSION ON A SPECIFIC OPERATING SYSTEM PLATFORM. THIS DOCUMENT IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS DOCUMENT COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THIS DOCUMENT. TIBCO SOFTWARE INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS DOCUMENT AT ANY TIME. THE CONTENTS OF THIS DOCUMENT MAY BE MODIFIED AND/OR QUALIFIED, DIRECTLY OR INDIRECTLY, BY OTHER DOCUMENTATION WHICH ACCOMPANIES THIS SOFTWARE, INCLUDING BUT NOT LIMITED TO ANY RELEASE NOTES AND "READ ME" FILES. This Product is covered by U.S. Patent No. 7,472,101. Copyright 1999-2011 TIBCO Software Inc. ALL RIGHTS RESERVED. TIBCO Software Inc. Confidential Information

| iii

Contents

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Changes from the Previous Release of this Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Related Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi TIBCO Collaborative Information Manager Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Other TIBCO Product Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii How to Contact TIBCO Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiv

Chapter 1 Getting Started with Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Establishing an XML Rules File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 New Record File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Validation File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Search Control Rules File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Structure of a Rulebase File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Variable Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 declare . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 var. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 datatype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 assign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 check . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 disconnect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 duplicate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 enum. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 propagate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 refresh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 slice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 softlink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
TIBCO Collaborative Information Manager Rulebase Guide

iv

| Contents
usefor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Access Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Global Property Settings for Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 LogFlag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Checking Attribute Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

Chapter 2 Expressions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
SQL Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Locations of datasource and classifications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Selecting Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . where . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Placeholders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . sql Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Debugging Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Context Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . SESSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WORKITEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PREVIOUS_VERSION, PREVIOUS_CONFIRMED_VERSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CONTEXT_RELATIONSHIP/NAME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RECORD_ACTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RECORD_SUB_ACTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RECORD_IS_TOPMOST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RECORD_IS_BOTTOMMOST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . PARENT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . CHILD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 60 60 60 64 64 65 66 68 69 69 70 71 72 73 75 76 76 77 78

Chapter 3 Operator and Character Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79


Overview of Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Math . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Other . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . and compute logical and . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . not compute logical not . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . or compute logical or . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 80 80 81 81 81 83 83 85 85

Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 changed test an attribute to see if it has changed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 defined determine if value is defined. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

TIBCO Collaborative Information Manager Rulebase Guide

Contents v

eq equals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 geq greater than or equal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 gt greater than . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 in check if argument contained in a list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 leq less than or equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 lt less than . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 match regular expression match . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 neq not equal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 undefined determine if value is undefined . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 String Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 concat concatenate string values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 length compute length of string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 pad pads a string on left or right . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 substring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 trim trims leading and trailing spaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 uppercase returns uppercase of input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Math Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 div divides values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 minus calculates subtraction of values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 mult multiplies values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 percent computes percentage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 plus calculates addition of values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 round rounds to a defined set of decimal places . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Other Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 checkdigit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 count count number of (non-null, non-false) entries in array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 distinct returns distinct values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 filter filter a list of records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 lookup lookup value in database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 max maximum value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 min minimum value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 nvl substitute non-NULL value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 sequence returns a database sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 strip removes all null values from an array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 synchstatus. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 SyncOperationAttribute used to find the operation date (GDSN Only) . . . . . . . . . . . . . . . . . . . . . . . . . . 114 validate_checkdigit - validates checkdigit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Syntax for Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 var. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Undefined (Null) Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 Literal Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
TIBCO Collaborative Information Manager Rulebase Guide

vi

| Contents
Character Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Position Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Repetition Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Alternation, Grouping, Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 119 120 121

Built-in Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Creating a Custom Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

Chapter 4 Rulebase Patterns. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127


Non-Negative Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Dependent Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Dependent Drop-Down Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 Specify Data Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 Checking Child Records for Value. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134

Chapter 5 Rulebase Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137


Rulebase Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Specify Mandatory Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 Access Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Check for a Value (GTIN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 CATALOG_NAME Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Specify Valid Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 Assign TRUE or FALSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Check Values of Related Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 Check Values of Attributes Related to MINIMUM_SHIP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Check Code Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Validate Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Validate Temperature Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Skip First Pass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Specify Valid Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Check for DIMENSIONUOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Specify Types For a Drop-Down Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Check Length of UPC Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Validate Against First Order Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Validate Against First Ship Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Validate Net Weight. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Calculate Volume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162

TIBCO Collaborative Information Manager Rulebase Guide

Contents vii

Specify New Size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Propagate Attribute Value to Children . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164

Chapter 6 Embedding Rulebases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .165


Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Error Handling and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

Appendix A Synch_History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169


SYNCH_HISTORY. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

Appendix B System Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175


System Implicit Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177

TIBCO Collaborative Information Manager Rulebase Guide

viii

| Contents

TIBCO Collaborative Information Manager Rulebase Guide

| ix

Preface

The TIBCO Collaborative Information Manager delivers functionality to administer processes for management and governance of master data. This ensures accuracy and efficiency both inside the enterprise as well as throughout the value chain so that multiple processes are optimally coordinated. TIBCO Collaborative Information Manager delivers a horizontal platform to manage all types of information including products, customers, vendors, reference data, trading partners, and so on.

Topics
Changes from the Previous Release of this Guide, page x Related Documentation, page xi Typographical Conventions, page xiii How to Contact TIBCO Support, page xiv

TIBCO Collaborative Information Manager Rulebase Guide

| Changes from the Previous Release of this Guide


Changes from the Previous Release of this Guide
This release does not include any changes to this Guide.

TIBCO Collaborative Information Manager Rulebase Guide

Preface xi

Related Documentation
This section lists documentation resources you may find useful.

TIBCO Collaborative Information Manager Documentation


The following documents form the TIBCO Collaborative Information Manager documentation set: TIBCO Collaborative Information Manager Installation and Configuration Guide: Read this manual for instructions on site preparation, installation, and configuration. TIBCO Collaborative Information Manager Users Guide: This manual explains features and benefits of TIBCO Collaborative Information Manager from the business users viewpoint. It describes the features and functionality as well as all the screens. TIBCO Collaborative Information Manager System Administrators Guide: This manual explains features relevant to the system administrator. TIBCO Collaborative Information Manager Customization Guide: Read this manual to understand how the application can be customized to your enterprise needs. TIBCO Collaborative Information Manager Catalog Rulebase Guide: This manual is a language guide and reference for rulebase. It describes the underlying structure and also provides rulebase examples for definition of rulebase. TIBCO Collaborative Information Manager Workflow Reference: This manual is a reference for automation of business processes. TIBCO Collaborative Information Manager Web Services Guide: This manual is a reference for using web services in the application. TIBCO Collaborative Information Manager Release Notes: Read the release notes for a list of new and changed features. This document also contains lists of known issues and closed issues for this release.

Other TIBCO Product Documentation


You may find it useful to read the documentation for the following TIBCO products: TIBCO Collaborative Information Manager Process Designer Users Guide: This guide is a reference for designing workflows using the TIBCO Collaborative Information Manager Process Designer graphical user interface.
TIBCO Collaborative Information Manager Rulebase Guide

xii

| Related Documentation
TIBCO Collaborative Information Manager Process Designer Tutorial: This guide is a tutorial for designing workflows using the TIBCO Collaborative Information Manager Process Designer graphical user interface. TIBCO Collaborative Information Manager Repository Designer Users Guide: This guide is a reference for designing repositories using the TIBCO Collaborative Information Manager Repository Designer graphical user interface. TIBCO Collaborative Information Manager Repository Designer Tutorial: This guide is a tutorial for designing repositories using the TIBCO Collaborative Information Manager Repository Designer graphical user interface. TIBCO Enterprise Message Service software: This software allows the application to send and receive messages using the Java Message Service (JMS) protocol. It also integrates with TIBCO Rendezvous and TIBCO SmartSockets messaging products. TIBCO BusinessWorks software: This is a scalable, extensible and easy to use integration platform that allows you to develop and test integration projects. It includes a graphical user interface (GUI) for defining business processes and an engine that executes the process. TIBCO BusinessConnect software: This software allows your company to send and receive XML or non-XML business documents over the Internet. Based on a mutually agreed process flow and common document format, you and your trading partners can conduct secure and verifiable business transactions online.

TIBCO Collaborative Information Manager Rulebase Guide

Preface xiii

Typographical Conventions
The following typographical conventions are used in this manual. Table 1 General Typographical Conventions Convention
code font

Use Code font identifies commands, code examples, filenames, pathnames, and output displayed in a command window. For example: Use M y C o m m a n d to start the foo process.

bold code font

Bold code font is used in the following ways: In procedures, to indicate what a user types. For example: Type a d m i n . In large code samples, to indicate the parts of the sample that are of particular interest. In command syntax, to indicate the default parameter for a command. For example, if no parameter is specified, M y C o m m a n d is enabled: MyCommand [e n a b l e | disable]

italic font

Italic font is used in the following ways: To indicate a document title. For example: See TIBCO BusinessWorks Concepts. To introduce new terms For example: A portal page may contain several portlets. Portlets are mini-applications that run in a portal. To indicate a variable in a command or code syntax that you must replace. For example: M y C o m m a n d pathname

Key combinations

Key name separated by a plus sign indicate keys pressed simultaneously. For example: Ctrl+C. Key names separated by a comma and space indicate keys pressed one after the other. For example: Esc, Ctrl+Q. The note icon indicates information that is of special interest or importance, for example, an additional action required only in certain circumstances. The tip icon indicates an idea that could be useful, for example, a way to apply the information provided in the current section to achieve a specific result. The warning icon indicates the potential for a damaging situation, for example, data loss or corruption if certain steps are taken or not taken.

TIBCO Collaborative Information Manager Rulebase Guide

xiv

| How to Contact TIBCO Support


How to Contact TIBCO Support
For comments or problems with this manual or the software it addresses, please contact TIBCO Support as follows. For an overview of TIBCO Support, and information about getting started with TIBCO Support, visit this site: http://www.tibco.com/services/support If you already have a valid maintenance or support contract, visit this site: https://support.tibco.com Entry to this site requires a user name and password. If you do not have a user name, you can request one.

TIBCO Collaborative Information Manager Rulebase Guide

|1
Chapter 1

Getting Started with Rules

This chapter provides in-depth information for getting started with the TIBCO Collaborative Information Manager Rulebase.

Topics
Overview, page 2 Establishing an XML Rules File, page 3 Structure of a Rulebase File, page 5 Header, page 7 Variable Declarations, page 9 Actions, page 18 Global Property Settings for Rules, page 56

TIBCO Collaborative Information Manager Rulebase Guide

| Chapter 1

Getting Started with Rules

Overview
A repository consists of a list of records, each with its own set of attributes. Each attribute is defined as being of a particular type and having a certain length. A repository rule allows you to specify more complex constraints on attributes. For example, a repository defines Price as a Number. Using a repository rule, you can specify that this number must be between 0 and 100. You can also specify that, if Price is not zero, another attribute (Currency) must have a specified value. A repository rule is an encapsulated piece of business logic that specifies validations, transformations, and access controls for a record. Some examples are: The storage temperature must be between 20F and 80F. The product effective date must be before the product first ship date. The subclass code must be Chicken, Beef, or Vegetable when the product class code is Soup. Volume is calculated by multiplying height x depth x length. Only Supervisors can access records with Product Code equal to HS.

Repository rules are specified in XML files. Two files can be defined for a repository: New record file called to initialize a new record Validation file called for existing records Search control rules file called from record search.

For detailed information on the XML files, refer to the section , Establishing an XML Rules File, page 3. The XML file of a repository rule consists of a header, variable declarations, and a constraint. The header gives the name and description of the rule. The constraint contains a condition and an action. The condition describes when the rule needs to be applied. The action describes what the rule actually does and controls which attributes the rule is applicable to. For detailed information, refer to the section, Structure of a Rulebase File, page 5.

TIBCO Collaborative Information Manager Rulebase Guide

Establishing an XML Rules File 3

Establishing an XML Rules File


Following rulebase files can be defined for a repository: New record file called to initialize a new record Validation file called for existing records Search control rules file called from record search.

The new record file is called when adding a new record. Subsequently, the validation file is called when modifying the record. The names of these files are defined using the Configurator. The default names are as follows: InitialConfig > Rule Base > New Record Data Population Rulebase File Name = n e w r e c o r d . x m l InitialConfig > Rule Base > Record Save Validation File Name =
catalogvalidation.xml

InitialConfig > Rule Base > Record Search Rules File Name =
searchcontrolrules.xml

Do not rename the default rulebase file, c a t a l o g v a l i d a t i o n . x m l , generated by the system. When a repository is created, these files are created in folder
$MQ_COMMON_DIR/<enterprise-internal-name>/catalog/master/<reposito ry id>.

The <r e p o s i t o r y

id>

can be obtained from the Repository List page.

These validation files are also supported for a relationship catalog. This catalog is created when any relationship attribute is defined for the relationship. The initialization or validation for relationship attributes can be defined in these files. The ID of relationship catalog can be obtained from the database by executing the following SQL:
select relationshipcatalogid from relationshipdefinition where o w n e r i d = <r e p o s i t o r y i d > a n d n a m e = < r e l a t i o n s h i p n a m e > a n d a c t i v e = ' Y

Note: Upload or download of rulebase files through UI is not supported for relationship catalog. For a list of supported actions for a relationship catalog, refer to the Relationship and Multi-value Attributes Vs Regular Attributes section of the TIBCO Collaborative Information Manager Users Guide. The system looks for these files in the following order:

TIBCO Collaborative Information Manager Rulebase Guide

| Chapter 1

Getting Started with Rules

1. $MQ_COMMON_DIR/<enterprise-internal-name>/catalog/master/<reposi tory id>

2.

$MQ_COMMON_DIR/standard/rulebase

The second location is checked only when no file is specified in the first location.

Refer to Chapter 1 of the TIBCO Installation and Configuration Guide for details on MQ_HOME and MQ_COMMON_DIR, under the environment variables section.

New Record File


A new record file is used to assign default values to the attributes of a new record. Assigned values must come from constants or function calls. This file is also used for propagation of attribute values to child records. Some rules from the Validation File also come into play for new records. Drop downs can be filled up only through a constraint in the c a t a l o g v a l i d a t i o n . x m l file.

Validation File
The validation file usually contains the bulk of the rules. All kinds of rules are applicable: assignments validations propagations access controls

Search Control Rules File


The search control rules file is used to configure dropdown for attributes on the Record Search screen. Upload or download of this rulebase file through UI is not supported.

TIBCO Collaborative Information Manager Rulebase Guide

Structure of a Rulebase File 5

Structure of a Rulebase File


A rulebase file is composed of a header, variable declarations, and a constraint. Header: A rule begins with a header consisting of name, description, error_severity, and threshold. It controls which attributes the rule is applicable to. For more information on the header, refer to the section, Header, page 7. Variable declarations: A list of variable declarations follows the header section. Each declaration section can have the following parts:
declare: var:

starts a declaration.

names the variable. contains the data type stored as a t y p e attribute.

datatype: link:

defines a relationship by pointing to data.

For more information on the variable declarations, refer to the section, Variable Declarations, page 9. Constraint: A constraint consists of the following sections. condition section: the condition when the rule needs to be applied. action section: the action that the rule actually takes. For more information on the actions, refer to the section, Actions, page 18. Rules are executed in the order in which they are defined in the rulebase. Sample Here is a sample rulebase that shows the syntax of a rulebase:
<?xml version="1.0" encoding="UTF-8"?> <rulebase metaversion="0.1"> <name>Sample Rulebase</name> <description>Rulebase that defines all basic constructs</description> <declare> <var>CONTAINSREL</var> <link type="relationship_record"> <literal>contains</literal> </link> </declare> <constraint> <name>UseCase1</name> <description>This constraint makes Quantity Field of Contains Relationship view only</description> <action> <access mode="view">CONTAINSQUANTITY</access>

TIBCO Collaborative Information Manager Rulebase Guide

| Chapter 1

Getting Started with Rules

</action> </constraint> <constraint> <name>UseCase2</name> <description>This constraint provides view only access to records with UOM as EA</description> <usefor> <var>UOM</var> </usefor> <condition> <eq> <var>UOM</var> <const type="string">EA</const> </eq> </condition> <action> <access mode="view_record"/> </action> </constraint> </rulebase>

TIBCO Collaborative Information Manager Rulebase Guide

Header 7

Header
The header of a rulebase consists of a name, description, error severity, and threshold settings. The header is followed by explicit variable declarations. name, and description The name tag identifies the constraint and the description tag provides a short description of the constraint, as shown in the following example:
<name>FirstArrivalDate</name> <description>Validations against First Arrival Date.</description> ... ... ...

The name tag is mandatory and should not contain spaces. The name should be unique across the rulebase. The description tag can contain spaces. severity and threshold Each validation has a severity assigned to it. Each assignment has a level assigned to it. You can set various parameters to control the behavior of the rules depending on these values. The defaults for these values can be set in the header, but they can also be assigned values dynamically in the assignment rules. See, assigns to error severity, warning and information threshold, page 22. element <error_severity> Default 9 Description All validations with severity <= error_severity are considered errors. All validations with severity > error_severity are considered warnings. Note: This parameter was previously called <severity>. <severity> will still work, but it should be renamed to <error_severity> when file is updated. <warning_threshold> 99 All warnings with severity <= warning_threshold are displayed on the UI.

TIBCO Collaborative Information Manager Rulebase Guide

| Chapter 1

Getting Started with Rules

element <information_thresho ld>

Default 1

Description All assignments with level <= information_threshold are displayed on the UI.

The e r r o r _ s e v e r i t y tag can be used to define the default severity for the rulebase, as shown in the following example:
<name>StandardCatalogValidationst</name> <description>Implements Standard Validations</description> <error_severity>4</error_severity> <warning_threshold>8</warning_threshold> <information_threshold>6</information_threshold>

Skipping First Pass When saving records, a rulebase is executed twice. The first time the rulebase handles propagations and the second time the actual assignment or validations are done. If a rulebase is triggered based on a condition and if the condition is always true, the rulebase is executed. The value of the variable in the rulebase is incremented when the rulebase is executed based on a condition and the condition is met. This multi-pass approach is useful when some constraints are dependent on the attribute value changed in the propagate actions. You can set the execution_directive first_pass flag to skip the first pass if there are no propagations defined in the rulebase. By default, the first pass is skipped. This improves the performance of record save. On the other hand, if the parent record needs to propagate values to a child, you need the first pass processing. In that case, set the execution_directive first_pass to r e q u i r e d . See, Skip First Pass, page 152 for an example.

TIBCO Collaborative Information Manager Rulebase Guide

Variable Declarations 9

Variable Declarations
A list of variable declarations follows the header section. Each d e c l a r e section can have the following parts:
declare var

starts a declaration.

names the variable. contains the data type stored as a t y p e attribute.

datatype

l i n k defines relationship by pointing to another record in the same repository or a record in a different repository (cross-repository relationship).

declare
The d e c l a r e tag starts a declaration. A u s a g e attribute describes the type of variable. Usage input local output regular Default No No No Yes Description The variable is input from outside (that is, by the user.) Value has to be assigned in rulebase. Local variable that is exported to caller. Comes from repository or session.

You need to declare only r e g u l a r variables associated with a link. Since a specified repository is being used, all other variables are implicitly declared.
<declare> <var>EFFECTIVEDATE</var> <datatype type="date"/> </declare>

In the above example, the declaration is redundant since it is already known (from the repository definition) that EFFECTIVEDATE is a DATE variable. Local and input variables should have type declarations, if the correct type is known. Otherwise, the data type of the assigned value is adopted. Input variables are used during mass-updates and ApplyRulebase activity from workflow. The following is an example of a local variable declaration.
<declare usage="local"> <var>SUPERID</var>

TIBCO Collaborative Information Manager Rulebase Guide

10

| Chapter 1

Getting Started with Rules

<datatype type="string"/> </declare>

The following is an example of an input variable declaration:


<declare usage="input"> <var>SENDER_ORGANIZATION_TYPE</var> </declare>

Output variables are used to pass information to the caller of the rulebase. Other components in TIBCO Collaborative Information Manager define configurations specified by setting a variable in the rulebase. These variables should be declared as output so their value is visible outside the rulebase. The following is an example of output variable declaration:
<declare usage="output"> <var>RELATIONSHIP_LIST</var> </declare>

var
The var tag is mandatory, and contains the name of the variable. Variable names are not case sensitive.

datatype
The datatype tag contains the data type of the variable. Only variables with usage equal to local, input, or output require a datatype. The actual data type is stored in an attribute called type. The type attribute has the following valid variables: Data Type array boolean date number string Repository Type Array Boolean Date Decimal, Amount, Integer String Description An array of values. See, Exception for null assign to array variables, page 20. True or False. Date. Any number format. Declaration is optional if the variable has a string type.

If you are not sure what type of data a variable will hold, it is best not to declare a type:

TIBCO Collaborative Information Manager Rulebase Guide

Variable Declarations 11

<declare usage="input"> <var>SENDER_ORGANIZATION_TYPE</var> </declare>

In this case, the variable will adopt the type of the object assigned to it. There is an important difference for variables that are declared as array. If you assign a null value to an array variable, a null entry will be made into the array. This will result in an array of length 1 with the first entry being null. For all other types, the assignment would be ignored because it is null. Refer to, assign and null values, page 19 for more details.

link
You can use link declarations to access related objects during the execution of a rule. Links can be of the following types. The type is specified as an attribute to the link tag. type catalog classification Description Used to write SQL statements accessing repository tables. Used to access classification codes and descriptions. Currently maps to a datasource which holds classification data. Used to write SQL statements accessing Data Source Values. Records pointed at by following a chain of relationships. Points to a list of record objects. The relationship itself (to access relationship specific attributes). Record pointed at by a relationship.

datasource multi_relationship_record record relationship relationship_record

TIBCO Collaborative Information Manager Rulebase Guide

12

| Chapter 1

Getting Started with Rules

relationship_record The relationship_record link follows the relationship to the target record and retrieves an attribute value. If no attribute is specified, the whole record is returned, and the attribute can subsequently be accessed using the "/" notation. You can declare links in the rulebase header, so they are applied during execution. Argument 1 2 Explanation Relationship name. Attribute name at target record (optional).

The following are examples of relationship_record links.


< v a r > C H I L D W E I G H T < / v a r > will return an array of the netweights from all the records pointed at by CONTAINS relationships emanating from the current record. <declare> <var>CHILDWEIGHT</var> <link type="relationship_record"> <literal>CONTAINS</literal> <literal>NETWEIGHT</literal> </link> </declare> < v a r > C H I L D S T A T U S < / v a r > will return an array of the status from all the records pointed at by relationships emanating from the current record. <declare> <var>CHILDSTATUS</var> <link type="relationship_record"> <literal>CONTAINS</literal> <literal>STATUS</literal> </link> </declare>

If you declare a link without the second attribute, you can use the "/" notation to access the attribute, as shown in the following example:
<declare> <var>CONTAINSREL</var> <link type="relationship_record"> <literal>CONTAINS</literal> </link> </declare> ... <eq> <var>CONTAINSREL/STATUS</var> <const type="string">400</const> </eq>

TIBCO Collaborative Information Manager Rulebase Guide

Variable Declarations 13

multi_relationship_record The multi_relationship_record link follows a chain of relationships and retrieves all the target records. For example, if you have a three level hierarchy of records (product->sku->component), with two relationships (product_sku and sku_component), you can directly retrieve all components for a product by specifying the two relationships in a multi_relationship_record. Argument 1..n Explanation Relationship names

The following is an example of how to use multi_relationship_record links:


<declare> <var>PRODUCT_COMPONENT</var> <link type="multi_relationship_record"> <literal>PRODUCT_TO_SKU_REL</literal> <literal>SKU_TO_COMPONENT_REL</literal> </link> </declare> <constraint> <name>ProductFlammableFlag</name> <description>If any component has a flammable flag set, then set the flammable flag of the product</description> <condition> <and> <eq> <var>RECORD_TYPE</var> <const type="string">PRODUCT</const> </eq> <!-- the count function will count all non-FALSE entries --> <op func="count"> <eq> <const type="string">Y</const> <var>PRODUCT_COMPONENT/COMPONENT_FLAMMABLE_FLAG</var> </eq> </op> </and> </condition> <action> <assign> <var>PRODUCT_FLAMMABLE_FLAG</var> <const type="string">Y</const> </assign> </action> <!-- clear flag is not true. --> <action> <assign> <var>PRODUCT_FLAMMABLE_FLAG</var> <const type="string">N</const> </assign> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

14

| Chapter 1

Getting Started with Rules

</rulebase>

Another use of the multi_relationship_record is to access all siblings of a particular child record. For example, when writing a constraint for a SKU, you might want to check that the UOM for the SKU is unique. To retrieve all other SKUs in the product, we first traverse the relationship from the SKU to the PRODUCT and then back down to all the SKUs.
<?xml version="1.0" encoding="UTF-8"?> <rulebase metaversion="0.1"> <declare> <var>SKU_SIBLING</var> <link type="multi_relationship_record"> <literal>SKU_TO_PRODUCT_REL</literal> <literal>PRODUCT_TO_SKU_REL</literal> </link> </declare> <constraint> <name>SKUDistinctUOM</name> <description>UOM of SKUs must be unique.</description> <usefor> <var>UOM</var> </usefor> <condition> <eq> <var>RECORD_TYPE</var> <const type="string">SKU</const> </eq> </condition> <action> <check> <explanation>Uom of SKU must not be the same.</explanation> <eq> <op func="count"> <var>SKU_SIBLING/UOM</var> </op> <op func="count"> <op func="distinct"> <var>SKU_SIBLING/UOM</var> </op> </op> </eq> </check> </action> </constraint> </rulebase>

TIBCO Collaborative Information Manager Rulebase Guide

Variable Declarations 15

relationship A relationship link retrieves relationship specific attributes from a target. If no attribute is specified, a relationship object is returned. Relationship attributes can be retrieved using "/" notation. Argument 1 2 Explanation Relationship name Relationship specific attribute (optional)

The following example returns a relationship object and quantity:


<declare> <var>RelationshipQuantity</var> <link type="relationship"> <literal>CONTAINS</literal> <literal>QUANTITY</literal> </link> </declare> CONTAINSREL

will be an array of all the Contains relationships emanating from the current record.

<declare> <var>CONTAINSREL</var> <link type="relationship"> <literal>Contains</literal> </link> </declare>

You can then access the Quantity for those relationships as in:
<declare> <var>CONTAINSLINK</var> <link type="relationship_record"> <literal>Contains</literal> </link> </declare> <constraint> <name>RollUpGrossWeight</name> <description>Roll-up GrossWeight times Quantity.</description> <action> <assign> <var>GROSSWEIGHT</var> <op func="plus"> <op func="mult"> <var>CONTAINSREL/QUANTITY</var> <var>CONTAINSLINK/GROSSWEIGHT</var> </op> </op> </assign> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

16

| Chapter 1

Getting Started with Rules

To count the relationships, use the array directly:


<constraint> <name>ContainsCount</name> <description>Count relationships.</description> <action> <assign> <var>ContainsCount</var> <op func="count"> <var>CONTAINSREL</var> </op> </assign> </action> </constraint>

record This link type points to a list of records. It can be populated by passing the variable name in the usefor clause of softlink action only. After evaluation, this variable points to a list of records. Example: Using link type "record" The following is an example where the variable is populated by passing the variable name in the usefor clause of the softlink action.
<?xml version="1.0" encoding="UTF-8"?> <rulebase metaversion="0.1"> <declare> <var>RECORDS</var> <link type="record"/> </declare> <constraint> <name>Softlink recordlist</name> <description> Softlink recordlist </description> <usefor>RECORDS</usefor><!-- record link--> <action> <softlink mode="record"> <table source="sql"> <where> <sql> <eq> <literal> MC1/ID </literal> <var>ID</var> </eq> </sql> </where> </table> </softlink> </action>

TIBCO Collaborative Information Manager Rulebase Guide

Variable Declarations 17

</constraint> </rulebase>

After evaluation, RECORDS will point to a list containing records returned by softlink. datasource, catalog and classification Datasources can be stored in the current organization, or a shared copy can be stored in the T I B C O C I M enterprise. In other words, the rulebase will first look in the current organization, and only if the datasource is not found, it will look in the global T I B C O C I M enterprise. NOTE: Currently, classification links point to a datasource, which has the same name as the classification scheme. Other than that, a classification variable can be treated just like a datasource. For details on datasource, classification and catalog links, refer to section, SQL Expressions, page 60.

TIBCO Collaborative Information Manager Rulebase Guide

18

| Chapter 1

Getting Started with Rules

Actions
The action specifies what the rule actually does. The action that is executed depends on whether the condition evaluates to TRUE or FALSE. There can be two action tags. One action tag is mandatory, however, the second is optional. The following rules apply to action tag usage: If there is no condition or the condition is TRUE then the first action tag executes. If the condition is FALSE and there is a second action tag then the second action tag executes. If the condition is FALSE and no second action is present then no action executes. If the condition cannot be evaluated because some of the variables are undefined then no action executes.

The types of actions are listed in the following table: Action access assign check clear condition connect disconnect duplicate enum propagate refresh Description Specifies whether an attribute is hidden, read-only, or variable. Assigns a value to a variable. Checks whether the attribute meets a specified constraint. Clears a variable. Determines whether the action is executed or not. Establishes a relationship between accessed records and the record that is being processed. Removes a relationship between records. Checks for record attributes having a duplicate value. Lists values for a drop-down menu. Belongs inside the select tag. Rolls down action to another record. Specifies whether attributes should be refreshed when one of the variables it depends on is changed.

TIBCO Collaborative Information Manager Rulebase Guide

Actions 19

Action select slice softlink table usefor

Description Defines a list of values for the attribute in the usefor section. Slices a table into columns. Indicates that a softlink is to be evaluated. References externally defined values. Specifies which attribute a select, softlink, check or access rule applies to, and serves two purposes: Defines which attribute is applicable for the rule Allows the use of the same rule for multiple attributes

You can combine multiple tags in one action. Only one select is allowed (since a value can only have one drop-down option).

assign
You can assign a value to a variable with the assign tag. If the variable is a catalog attribute or relationship attribute, that attribute is also assigned the value. The assignment occurs after the rulebase is executed. If you use the user interface to edit the product data, the post-assignment values dynamically update the screen display attributes. The following is an example of a post-assignment:
<assign> <var>PRICE</var> <const type="number">20.56</const> </assign>

Although the first tag after the assign must be a variable, the second tag can be any tag that evaluates to a value. In other words, it can be a nested expression or a constant. assign and null values With one exception, assign will not assign a value if the value to be assigned is null.
<assign> <var>DISCOUNT</var> <op func="mult"> <const type="number">0.20</const> <var>PRICE</var> </op> </assign>

TIBCO Collaborative Information Manager Rulebase Guide

20

| Chapter 1

Getting Started with Rules

So if PRICE is null, the result of the mult operation will be null, and no assignment will be made to DISCOUNT. For DISCOUNT to be null, use the following rule:
<constraint> <name>ComputeDiscount</name> <description>Compute Discount</description> <condition> <defined> <var>PRICE</var> </defined> </condition> <action> <assign> <var>DISCOUNT</var> <op func="mult"> <const type="number">0.20</const> <var>PRICE</var> </op> </assign> </action> <action> <clear> <var>DISCOUNT</var> </clear> </action> </constraint>

So if price is undefined, the condition is false, and the discount is cleared. Exception for null assign to array variables The exception for null inserts is for variables that are explicitly declared as array datatypes:
<declare usage="output"> <var>RECEIVER_ORGANIZATION</var> <datatype type="array"/> </declare>

In this case even a null value will result in an entry being made into the array. The exception is because arrays are often constructed in parallel to hold tabular data. For example, lets say you want to pass the following values to the workflow: Col1 A B Col2 null D

TIBCO Collaborative Information Manager Rulebase Guide

Actions 21

Since the best way to pass this data to other programs is by column, declare two variables Col1 and Col2.
<declare usage="output"> <var>Col1</var> <datatype type="array"/> </declare> <declare usage="output"> <var>Col2</var> <datatype type="array"/> </declare>

If null assignments are ignored, this would result in:


Col1 = [A, B] Col2 = [D]

A recipient of this data would now not know how to reconstruct the data because Col1 and Col2 are no longer of equal length. To achieve the above result, do not declare the variables as arrays.
<declare usage="output"> <var>Col1</var> </declare> <declare usage="output"> <var>Col2</var> </declare>

priority Each assign action can have a priority. The value assigned to a variable is that of the highest priority assignment. One use of this is to define a "catch-all" default value at the end of the rulebase, which is assigned if no other value has been assigned to the variable. Priority values can be between -9 and 9. If no value is specified, the priority is 1.
<constraint> <name>LargeSizeDesignator</name> <description>Size greater than 100 is Large.</description> <condition> <geq> <var>SIZE</var> <const type="number">100</const> </geq> </condition> <action> <assign priority="9"> <var>SIZE_DESIGNATOR</var> <const type="string">LARGE</const> </assign> </action> </constraint> <constraint> <name>SmallSizeDesignator</name>

TIBCO Collaborative Information Manager Rulebase Guide

22

| Chapter 1

Getting Started with Rules

<description>Size less than or equal to 10 is small.</description> <condition> <leq> <var>SIZE</var> <const type="number">10</const> </leq> </condition> <action> <assign priority="-9"> <var>SIZE_DESIGNATOR</var> <const type="string">SMALL</const> </assign> </action> </constraint> <constraint> <name>MediumSizeDesignator</name> <description>If not large/small, it must be medium.</description> <action> <!-- priority 0 is less than the priority of the small and large assignments, --> <!-- so will only be used if as a default a value. --> <assign priority="0"> <var>SIZE_DESIGNATOR</var> <const type="string">MEDIUM</const> </assign> </action> </constraint>

level Each assignment can have a level associated with it and can be used to control display of information messages on UI. All assignment messages with level less than or equal to information_threshold are displayed on the UI. The default value for level is 1.
<assign level="2"> <var>PRICE</var> <const type="number">20.56</const> </assign>

assigns to error severity, warning and information threshold It is possible to assign new values to severity levels and thresholds (for more details, see, severity and threshold, page 7). You can set thresholds based on user profiles or actions. The following is a very basic example to check if "NEW_THRESHOLD" is defined (in actual usage, more specific and relevant conditions would be used).
<constraint> <name>AssignNewInformationThreshold</name> <description>Assign New Information Threshold</description> <condition> <defined>

TIBCO Collaborative Information Manager Rulebase Guide

Actions 23

<var>NEW_THRESHOLD</var> </defined> </condition> <action> <assign> <information_threshold/> <var>NEW_THRESHOLD</var> </assign> </action> </constraint>

Assigning values to multi-value attributes For multi-value attributes, you can assign constant values using the <sep/> tag as follows:
<constraint> <name>TestAssign</name> <description>Test assign using sep tag</description> <usefor> <var>MTEST</var> </usefor> <action> <assign> <var>MTEST</var> <const type="string">red<sep/>blue</const> </assign> </action> </constraint>

You can also assign values using the input (or local) array variable:
<declare usage="input"> <var>TEMP</var> <datatype type="array"/> </declare> <constraint> <name>TestAssign2</name> <description>Assign using input variable</description> <usefor> <var>MTEST</var> </usefor> <action> <assign> <var>MTEST</var> <var>TEMP</var> </assign> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

24

| Chapter 1
check

Getting Started with Rules

The check action evaluates an expression as TRUE or FALSE. If the expression is true, the attribute is in compliance. If it is false, the check failed and an explanation is shown.
<constraint> <name>GTIN</name> <description>GTIN checks.</description> <usefor> <var>GTIN</var> <var>REPLACES_GTIN</var> </usefor> <action> <check> <explanation>GTIN cannot start with 0980, 0981, 0982, 0983, 0984, 0985, 0986,098, 0988, 0989, 099</explanation> <not> <or> <in> <op func="substring"> <var>GTIN</var> <const type="number">0</const> <const type="number">4</const> </op> <const type="string">0980</const> <const type="string">0981</const> <const type="string">0982</const> <const type="string">0983</const> <const type="string">0984</const> <const type="string">0985</const> <const type="string">0986</const> <const type="string">0988</const> <const type="string">0989</const> </in> <in> <op func="substring"> <var>GTIN</var> <const type="number">0</const> <const type="number">3</const> </op> <const type="string">098</const> <const type="string">099</const> </in> </or> </not> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Actions 25

severity Each validation can have a severity level. The lower the severity, the more serious the error. For example, a severity level of 2 is more serious than a severity of 4. The severity level interpretation can vary depending on when a rule is executed. It is up to the user to interpret the implication and act accordingly. Severity levels can range from 1 (most critical) to 99 (least critical). Severity is specified as a severity attribute to the check and select tags, as shown in the following example.
<check severity="3"> <gt> <var>VOLUME</var> <const type="number">0</const> </gt> </check>

You can specify the level of severity that must be reached for an operation to fail. For example, if you specify the error severity as 4, all validations with severities less than or equal to 4 cause the operation to fail. All other errors appear as warning or information messages.

clear
Assign will NOT assign a null value to a variable. In other words, if the value of an assign evaluates to null, no assignment will be done. To clear a variable, use the clear action. Multi-value attributes can also be cleared using clear action.

<clear> <var>PRICE</var> </clear>

Note: Priorities can also be used for clear. Refer to, Global Property Settings for Rules, page 56 for details on priority.

condition
The condition determines whether the action is executed or not. The condition should evaluate to TRUE or FALSE or be undefined (evaluate to null). Note that if there is no condition, the action is always executed. The following rules apply: When TRUE, the first action following the condition tag is executed.

TIBCO Collaborative Information Manager Rulebase Guide

26

| Chapter 1

Getting Started with Rules

When FALSE, the second action is executed. When the condition cannot be evaluated, because the variables do not have a value, neither action is executed. If there is no condition, the first action is executed.

The following is an example of condition tag usage:


<constraint> <name>UPC12</name> <description>Check length of UPC code based on type.</description> <usefor> <var>UPC</var> </usefor> <condition> <or> <eq> <var>UPC_TYPE</var> <const type="string">UN</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UP</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UA</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UD</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UE</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UG</const> </eq> </or> </condition> <action> <check> <explanation>For UPC Type UN,UP,UA,UD,UE,UG UPC must have length 12 </explanation> <eq> <op func="length"> <var/> </op> <const type="number">12</const> </eq> </check> </action> <action> <check>

TIBCO Collaborative Information Manager Rulebase Guide

Actions 27

<explanation>For UPC Type not equal to UN,UP,UA,UD,UE,UG UPC must have length 10</explanation> <eq> <op func="length"> <var/> </op> <const type="number">10</const> </eq> </check> </action> </constraint>

If UPC_TYPE is not assigned a value, neither action executes because the condition will evaluate to null. The condition code will also convert other values to TRUE or FALSE. Datatype string number TRUE TRUE; YES; T, Y, 1 not 0 FALSE All other non-null values 0

For example, when using the count operator, the two expressions will give the same result:
<condition> <gt> <op func="count"> <var>CONTAINSREL</var> </op> <const type="number">0</const> </gt> </condition>

and
<condition> <op func="count"> <var>CONTAINSREL</var> </op> </condition>

In the second case, if count evaluates to 0, it will automatically be converted to FALSE.

TIBCO Collaborative Information Manager Rulebase Guide

28

| Chapter 1
connect

Getting Started with Rules

This action establishes a relationship between accessed records and the record that is being processed. This action will access related records (argument 2) and establish the specified relationship (argument 1) with the specified quantity (argument 3). To filter records based on any repository attribute and to create relationships using a rulebase, use the connect action in conjuction with the softlink action. NOTE: To use connect action with the EvaluateRulebase activity, the name of the relationship specified in the connect constraint must be specified in the relationship name list of the ManageRecordCollection activity. Also, the BundlingOption parameter of the ManageRecordCollection activity must be set to true. Table 2 connect Argument 1 2 Argument Type Literal Var (link type = record) Required? N Y Argument Description Relationship type name using which relationship will be established Variable pointing to a list of record objects. See, record, page 16. 3 4 Literal Var/Const N N Name of the relationship attribute. Value to be assigned to the relationship attribute.

Note: When specifying a relationship attribute, the Literal tag must be followed by the Var/Const tag. Multiple relationship attributes can be passed to the connect action. Example: connect used in conjuction with softlink Let us consider two repositories: CUSTOMER and ADDRESS. The records in these two repositories are related using the customer ID. Let us say, you want to find address records for a particular customer and then create a relationship using a rulebase. To do this, you need to run a SQL query to find the address records which match a given customer ID and then issue a create relationship command.
<?xml version="1.0" encoding="UTF-8"?> <rulebase metaversion="1.0"> <name>Cconnect sample</name>

TIBCO Collaborative Information Manager Rulebase Guide

Actions 29

<description>Place this rulebase in catalogvalidattion.xml ofcatalog to automatically create "Shipping Address".</description> <declare> <var>ADDRESSCATALOG</var> <link type="catalog"> <literal>ADDRESS</literal> <literal>STATE/CONFIRMED</literal> <!-- consider only confirmed records --> </link> </declare> <declare> <var>ADDRESSRECORDS</var> <link type="record"/> </declare> <constraint> <name>AddressSoftlink</name> <description>Returns ADDRESS records having same CUSTOMERID as thatthe record being processed.</description> <usefor> <var>ADDRESSRECORDS</var> </usefor> <!-- record link--> <action> <softlink mode="record"> <!-- note the mode here --> <table source="sql"> <where> <sql> <eq> <literal>ADDRESSCATALOG/CUSTOMERID</literal> <var>CUSTOMERID</var> </eq> </sql> </where> </table> </softlink> </action> </constraint> <constraint> <name>AddressConnect</name> <description>Connect Address records using 'Shipping Address'</description> <action> <connect> <literal>Shipping Address</literal> <!-- relationship name--> <var>ADDRESSRECORDS</var> <literal>TYPE</literal> <!-- name --> <const type="string">MAILING</const> <!-- value --> <literal>PREFERRED </literal> <const type="string">yes</const> </connect> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

30

| Chapter 1

Getting Started with Rules

</rulebase>

disconnect
This action allows you to remove relationships between records. If any relationship attributes are defined with the relationship, such attributes are also removed. The action accepts a record list and a relationship name. The record list can be generated using: relationship_record link The relationship_record link can be used to get the related records. The filter function can be applied to the relationship_link result to get the required records. For more information on relationship_record link, refer to, relationship_record, on page 12. softlink action The record list can also be populated using the softlink action. However, softlink does not allow you to filter out the related record, and may return unrelated records. For more information on the softlink action, refer to, softlink, on page 42. A sample rulebase is available in
$MQ_COMMON_DIR/standard/samples/rulebase/disconnectsample.xml.

Table 3 disconnect Argument 1 2 Argument Type Literal Var (link type = record) Required? Y Y Argument Description Name of the relationship to be removed. Variable pointing to a list of records. See, record, page 16.

Example: Selecting records The relationship_record link can be used to get the related records. The filter function can be applied to the relationship_link result to get the required records.
<declare> <var>UPSELL_RELATIONSHIP</var> <link type="relationship_record"> <literal>Upsell</literal> </link> </declare> <declare> <var>RECORD_LIST</var> <datatype type="array"/>

TIBCO Collaborative Information Manager Rulebase Guide

Actions 31

</declare> <constraint> <name>SelectChildren</name> <description>Obtain list of records for disconnect</description> <action> <assign> <var>RECORD_LIST</var> <op func="filter"> <var>UPSELL_RELATIONSHIP</var> <condition> <eq> <var>SHORTDESC</var> <const type="string">test</const> <!-- Select all records with short description as test --> </eq> </condition> </op> </assign> </action> </constraint>

Example: disconnect The disconnect action accepts a list of records and relationship name as follows:
<constraint> <name>testDisconnect</name> <description>disconnect</description> <condition> <defined> <var>RECORD_LIST</var> </defined> </condition> <action> <disconnect> <literal>Contains</literal> <var>RECORD_LIST</var> </disconnect> </action> </constraint>

duplicate
The duplicate action checks for record attributes having a duplicate value. For example, if value of RECORD_TYPE attribute needs to be unique, apply a duplicate check on it. A duplicate check is not supported for multi-value attributes.

TIBCO Collaborative Information Manager Rulebase Guide

32

| Chapter 1

Getting Started with Rules

Let us say, you now add record A with RECORD_TYPE = A. Then, you add record B with RECORD_TYPE = A. An error is displayed. Here is an example of the syntax:
<name>duplicateCheck</name> <description>Checking for duplicates.</description> <error_severity>4</error_severity> <constraint> <name>DuplicateRECORDTYPECheck</name> <description>DuplicateRECORDTYPECheck</description> <usefor> <var>RECORD_TYPE</var> <var>UOM</var> </usefor> <action> <check severity="1"> <explanation>This record type already exists.</explanation> <duplicate> <var>RECORD_TYPE</var> <var>UOM</var> </duplicate> </check> </action> </constraint> </rulebase>

enum
The enum tag belongs inside the select tag, and explicitly lists values for a drop-down menu. Multiple values can be specified using the empty sep (separator). The enum tag has two attributes: header, which determines whether the first row of data is the column headers and col, which defines the number of columns in the table. header The header attribute specifies whether the first row of data is the description of the columns or column data. The default if no value is specified is <enum header="no">, that is, the first row contains data. header Option <enum header="no"> <enum header="yes"> Description There are no column names in the data. The first row is a data column. The first row of data contains the column headers.

TIBCO Collaborative Information Manager Rulebase Guide

Actions 33

header Option <enum>

Description same as <enum header="no">

col The number of columns is solely determined by the col attribute, not by the use of the sep tag. When more than two columns are specified, the select tag interprets the first column as the value stored in the database. Each subsequent value is a display value. The following example creates a list of three items, under a header Soup Styles.
<select novalue="default"> <enum header=yes> <const type="string">Soup Styles</const> <const type="string">Classic</const> <const type="string">Chunky</const> <const type="string">Light</const> </enum> </select>

The next example creates a list of three items (because novalue is set to "no"). Since showoninput="2", only the second column is displayed in the drop-down: Classic, Chunky, and Light. However, the values stored in the database are CL,CH,LT. The use of col="2" indicates the two sets of values, otherwise the drop-down menu would display all six items.
<select showoninput="2"> <enum col="2"> <const type="string">CL<sep/>Classic</const> <const type="string">CH<sep/>Chunky</const> <const type="string">LT<sep/>Light</const> </enum> </select>

TIBCO Collaborative Information Manager Rulebase Guide

34

| Chapter 1

Getting Started with Rules

propagate
You can propagate changes of the rulebase to other records with the propagate action. In case of cross repository relationships, for propagation to work during add and modify record place rules in the c a t a l o g v a l i d a t i o n . x m l file of the parent repository. For example, if CUSTOMERID attribute of the CUSTOMER repository needs to be propagated to the ADDRESS repository, place the rules in the CUSTOMER repositorys c a t a l o g v a l i d a t i o n . x m l . Also, for propagation to work correctly, first pass must be set to r e q u i r e d . To do this, add the following in the rulebase file:
<execution_directive first_pass="required"/>

If you want propagation during add record only, place the rules in the n e w r e c o r d . x m l file of the child record. The propagate tag can be of two types: rulebase or inline. Type: rulebase The following table lists the arguments for propagate of type="rulebase": Argument 1 2 Explanation Relationship variable Rulebase

In the following example, the current record context is passed down as a record CONTAINSLINK variable.
<action> <propagate type="rulebase"> <var>CONTAINSLINK</var> <literal>custom/rulebase/RollDownStatus</literal> </propagate> </action>

The rulebase is described by a file relative to the environment variable $MQ_COMMON_DIR.

TIBCO Collaborative Information Manager Rulebase Guide

Actions 35

Type: inline The following table lists the arguments for propagate of type="inline": Argument 1 2 Explanation Relationship variable Action

In the following example, the current record context is passed down as a record variable called CONTAINSLINK. The LINK/HAZMATFLAG refers to the HAZMATFLAG where the propagate tag was defined. This traverses the CONTAINS link to the child record, and then copies the parent HAZMATFLAG to the child. The end result is a child record with the same HAZMATFLAG value as its parent.
<action> <propagate type="inline"> <var>CONTAINSLINK</var> <action> <assign> <var>HAZMATFLAG</var> <var>LINK/HAZMATFLAG</var> </assign> </action> </propagate> </action>

refresh
When the user enters a new value in a drop-down list, all attributes that use that value in their computation are refreshed. This refresh involves a trip to the server. Sometimes, however, the benefit of having an updated value does not compensate for the delay incurred in having to wait for that value. If that is the case, the system allows you to set the refresh to no. This means that the attribute is not refreshed when one of the variables it depends on is changed. The attribute can be added to the following tags: <assign> <select> <condition> <clear>

TIBCO Collaborative Information Manager Rulebase Guide

36

| Chapter 1

Getting Started with Rules

Select In the following rule:


<constraint> <name>SubCategorySoup</name> <description>Sub Category for Soup</description> <usefor> <var>CLASSIFICATIONLEVEL5</var> </usefor> <condition> <eq> <var>CLASSIFICATIONLEVEL4</var> <const type="string">Soup</const> </eq> </condition> <action> <select novalue="no"> <enum> <const type="string">Classic</const> <const type="string">Chunky</const> <const type="string">Light</const> </enum> </select> </action> </constraint>

The code checks variables that could affect the value of CLASSIFICATIONLEVEL5. In this case, the analysis is:
CLASSIFICATIONLEVEL4 -> CLASSIFICATIONLEVEL5

which means that when CLASSIFICATIONLEVEL4 changes, you need to refresh CLASSIFICATIONLEVEL5. With the refresh flag, this is suppressed:
<constraint> <name>SubCategorySoup2</name> <description>Sub Category for Soup</description> <usefor> <var>CLASSIFICATIONLEVEL9</var> </usefor> <condition> <eq> <var>CLASSIFICATIONLEVEL8</var> <const type="string">Soup</const> </eq> </condition> <action> <select novalue="no" refresh="no"> <enum> <const type="string">Classic</const> <const type="string">Chunky</const> <const type="string">Light</const>

TIBCO Collaborative Information Manager Rulebase Guide

Actions 37

</enum> </select> </action> </constraint>

In this case, when CLASSIFICATIONLEVEL8 changes, there will be no refresh for CLASSIFICATIONLEVEL9. Assignment Assignments work in a similar manner:
<constraint> <name>EnumLookup</name> <description>Lookup based on enum values.</description> <action> <assign> <var>TEMPDESCRIPTION</var> <op func="lookup"> <var>TEMPCODE</var> <enum col="2"> <const type="string">FA<sep/>Fahrenheit</const> <const type="string">CE<sep/>Celsius</const> <const type="string">KA<sep/>Kelvin</const> <const type="string">EA<sep/>Each</const> <const type="string">CS<sep/>Case</const> <const type="string">PA<sep/>Pallet</const> </enum> </op> </assign> </action> </constraint>

Without the refresh flag, any changes to TEMPCODE will refresh the screen. With the refresh flag, this rule will not trigger a refresh. A change to TEMPCODE could still trigger a refresh if some OTHER rule used it on the right hand side of the assign. In other words, even if only 1 rule out of 10 does not have refresh set to no, it will refresh if the variables in that rule change. Condition The refresh flag on assign and select suppresses the refresh for all variables, including those used in the <condition>. However, you might sometimes want to ignore those variables in the <condition> but still refresh if a variable in the <action> changed. For this, you can selectively disable the trigger on the <condition>. For example:

TIBCO Collaborative Information Manager Rulebase Guide

38

| Chapter 1

Getting Started with Rules

<constraint> <name>EnumLookup</name> <description>Lookup based on enum values.</description> <action> <condition refresh=no> <or> <eq> <var>UOM</var> <const type="string">EACH</const> </eq> <eq> <var>UOM</var> <const type="string">CASE</const> </eq> </or> </condition> <assign> <var>ATTRIBUTE3</var> <op func="lookup"> <var>ATTRIBUTE3</var> <enum col="2"> <const type="string">FA<sep/>Fahrenheit</const> <const type="string">CE<sep/>Celsius</const> <const type="string">KA<sep/>Kelvin</const> <const type="string">EA<sep/>Each</const> <const type="string">CS<sep/>Case</const> <const type="string">PA<sep/>Pallet</const> </enum> </op> </assign> </action> </constraint> Will refresh if ATTRIBUTE3 changes, but NOT if UOM changes. Normally, it would refresh if any of the above variables changed.

select
The select tag is of two types, and specifies a list of values allowed for an attribute: Uses the enum tag to explicitly list out the values that can appear. Uses the table tag to refer to an external source for the values.

In the user interface, the select action is used to construct a drop-down list. For non-interactive loading, it is used to check if an attribute is one of the values allowed in the list. The select action expects a table of values. The first column in the table is assumed to be the value stored in the database. All subsequent values are display values. Although the first column value is stored in the database, the user can choose the columns that are displayed using the showoninput tag.
TIBCO Collaborative Information Manager Rulebase Guide

Actions 39

novalue The novalue attribute for the select tag specifies whether an empty value appears in the drop-down menu. The attribute options are listed in the following table. The default is <select novalue="no">. Note: The novalue attribute is not supported in case of multi-value attributes. novalue Option <select novalue="default"> <select novalue="option"> <select novalue="no"> Description The empty value appears as the first value in the list. The empty value appears at the bottom of the list. The empty value does not appear in the list.

novalue and automatic attribute initialization Depending on the novalue attribute, the behavior for automatically assigning values to the attribute is different. novalue=default The attribute is not initialized but remains null. novalue=option During new record creation only, the attribute is assigned the first value in the drop-down list. If the value is set to null after that, it remains null. novalue=no If the attribute value is null, it is always initialized to the first value in the drop-down. In other words, this attribute should never have a null value. This is true both for creation and modification of records.

TIBCO Collaborative Information Manager Rulebase Guide

40

| Chapter 1

Getting Started with Rules

order The order attribute of the select tag specifies the sort order of the dropdown in the rulebase. The sort order can be mentioned as ascending or descending for particular columns in the dropdown. Table 4 Syntax for order attribute Syntax
<select order="1,-2" novalue="default">

Sort Details Dropdown is sorted in the ascending order of the first column and descending order of the second column. Dropdown is sorted in the descending order of the first column and the ascending order of the second column. Dropdown is sorted in the descending order of the second column. Option "1" is ignored.

<select order="-1,2" novalue="default">

<select order="-2,1" novalue="default">

To get the expected results, the correct syntax is:


<select order="1,-2" novalue="default">

and not:
<select order="-2,1" novalue="default">

The order attribute works only for select of type table.

showoninput The showoninput attribute for the select tag specifies the columns that appear in a multi column drop-down. For example, if your drop-down has 3 columns, you might decide to show only columns 2 and 3, since the first column is the database code, which is not relevant to the user. The default is to show all columns, with column numbers starting at 1. novalue Option <select> <select showoninput="2"> <select showoninput="1,3"> Description Show all columns. Show only the second column. Show the first column and the third column. Do not show the second column.

TIBCO Collaborative Information Manager Rulebase Guide

Actions 41

slice
This action allows you to slice a table into columns. Each column is assigned to a different variable. These variables are usually passed into the rulebase for further processing. For example, let us say, a table contains the following rows:
PRODUCTKEYID 100 101 102 PRODUCTID 00009000000034 00009000000126 00009000000560 UOM BASE_UNIT_OR_EACH CASE PALLET

Use the slice action as follows:


<declare> <var>MC1</var> <link type="catalog"> <literal>MC1</literal> </link> </declare> <declare usage="output"> <var>ARR_PROD_KEY_ID</var> <datatype type="array"/> </declare> <declare usage="output"> <var>ARR_PROD_ID</var> <datatype type="array"/> </declare> <declare usage="output"> <var>ARR_UOM</var> <datatype type="array"/> </declare> <constraint> <name>SliceTest</name> <description>Get record keys</description> <action> <slice> <var>ARR_PROD_KEY_ID</var> <var>ARR_PROD_ID</var> <var>ARR_UOM</var> <table source="sql"> <literal>MC1/PRODUCTKEYID</literal> <literal>MC1/PRODUCTID</literal> <literal>MC1/UOM</literal> <where> <sql> <and> <eq> <literal>MC1/RECORD_TYPE</literal> <const type="string">MIXES</const> </eq> <neq> <literal>MC1/PRODUCTIDEXT</literal> <const type="string">DNB</const> </neq> </and>

TIBCO Collaborative Information Manager Rulebase Guide

42

| Chapter 1

Getting Started with Rules

</sql> </where> </table> </slice> </action> </constraint>

After the slice, you will have the following arrays:


ARR_PROD_KEY_ID = [100, 101,102] ARR_PROD_ID = [00009000000034, 00009000000126, 00009000000560] ARR_UOM = [BASE_UNIT_OR_EACH, CASE, PALLET]

softlink
Records are typically stored in more than one repository. For example, vendors could be stored in one repository and customers in another. However, almost all the time, the records from one repository need to be linked to records in other repositories. The links can be made in two ways: 1. Soft links: That is, links are evaluated every time they are accessed. As data changes, each evaluation can result in different results. There is no permanent binding. 2. Hard links: This is supported for records within the same repository, that is, contains. The softlink action indicates that a soft link is to be evaluated. Modes The softlink action supports two modes: view (display mode) Creates a hyperlink. When the hyperlink is clicked, a query is executed and it returns a list of records matching the selection criteria. record (non-display mode) Executes a query and returns a list of records matching the selection criteria. In addition, it populates a record link variable and the Usefor variable points to the record link variable.

To use softlink action with connect action, set softlink action mode to 'record'.

Softlink definitions with mode=record should precede corresponding connect actions.

TIBCO Collaborative Information Manager Rulebase Guide

Actions 43

The following table lists the arguments for softlink: Argument 1 Explanation Link Attribute Required? Y Description The attribute hyperlink that should be shown. For non display operations, this input is ignored. Define the criterion for selection of records. Only supported type will be SQL. Table must contain SQL element.

Table

Example In the following example of softlink, the PRICETYPE attribute is linked to one or more records from MASTER3 repository that have the UOM=PACK.
<declare> <var>MASTER3</var> <link type="catalog"> <literal>MASTER3</literal> </link> </declare> <constraint> <name>PRICETYPE</name> <description>Select possible PriceTypes from Master3 where UOM is PACK</description> <usefor> <var>PRICETYPE</var> </usefor> <action> <softlink mode=view> <table source="sql"> <where> <sql> <eq> <literal>MASTER3/UOM</literal> <const type="string">PACK</const> </eq> </sql> </where> </table> </softlink> </action> </constraint>

To fetch the latest records with state CONFIRMED or UNCONFIRMED, declare the catalog link as follows:
<declare> <var>MASTER3</var>

TIBCO Collaborative Information Manager Rulebase Guide

44

| Chapter 1

Getting Started with Rules

<link type="catalog"> <literal>MASTER3</literal> <literal>STATE/UNCONFIRMED</literal> </link> </declare>

table
The table tag references externally defined values. Option source Description The source attribute defines the location of the source data. A valid value for source is: distinct datasource - See, source="datasource", page 61. sql - See, sql Function, page 66.

The distinct attribute allows you to filter duplicates and display only distinct or unique values from retrieved values. For example, let us say, a city column has the following values: San Francisco Palo Alto San Jose Palo Alto You can ensure that a result set displays only three entries and not four (since Palo Alto appears twice) by specifying the distinct="true" attribute.

order

The order attribute allows you to sort the result set based on the columns specified. The value for order must be specified in the following format.
order="[-]<columnpostion1>[,[-]<columnposition2>,..]"

Where: - indicates descending order


<columnpositon> specifies column position based on the columns selected.

Multiple columns can be specified separated by comma.

Example The following example selects a distinct countrycode and countryname from the countrycodes datasource sorted by countrycodes:
<constraint> <name>ConstraintToGetCountryCodes</name>

TIBCO Collaborative Information Manager Rulebase Guide

Actions 45

<description>Get country codes from COUNTRYCODES</description> <usefor> <var>COUNTRY</var> </usefor> <action> <select> <table source="datasource" distinct="true" order="1"> <literal>COUNTRYCODES</literal> <literal>COUNTRYCODE</literal> <literal>COUNTRYNAME</literal> </table> </select> </action> </constraint>

usefor
The usefor tag specifies which attribute a <select>, <softlink>, <check> or <access> rule applies to, and serves two purposes: Defines which attribute is applicable for the rule Allows the use of the same rule for multiple attributes

The <assign> actions do not require the use of a <usefor> tag.

If you use multiple var tags within a usefor tag, the rule applies to each attribute. For example, you could define Boolean values to have a drop-down menu showing TRUE and FALSE (two values) as follows:
<?xml version="1.0" encoding="UTF-8"?> <rulebase metaversion="0.1"> <constraint> <name>TrueFalse</name> <description>True or False.</description> <usefor> <var>HAZMATFLAG</var> <var>RECYCLEDMATERIALS</var> <var>FREIGHTINCFLAG</var> <var>CONSUMER_UNIT</var> <var>ORDERABLE</var> </usefor> <action> <select novalue="default"> <enum> <const type="string">TRUE</const> <const type="string">FALSE</const> </enum> </select> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

46

| Chapter 1

Getting Started with Rules

</rulebase>

The previous rule applies to the following variables: HAZMATFLAG, RECYCLEDMATERIALS, FREIGHTINCFLAG, CONSUMER_UNIT, and ORDERABLE. These variables must be present in the repository. If you refer to usefor variables for which the rule is configured, you can abbreviate the notation using an empty var tag. In the following example, the var tag refers to the GTIN and then REPLACES_GTIN.
<constraint> <name>GTIN</name> <description>GTIN checks.</description> <usefor> <var>GTIN</var> <var>REPLACES_GTIN</var> </usefor> <action> <check> <explanation>GTIN has to be 14 numeric characters.</explanation> <match> <var/> <const type="string">/^\d{14}$/</const> </match> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Access Modes 47

Access Modes
The access tag controls viewing, modification, and visibility of the attribute group or an attribute. The access mode does not have a direct effect on the execution of the rule, other than being returned as a directive to the user interface to hide certain elements. Certain access modes apply to the complete record and take precedence over the access modes specified for the attributes and attributes groups of such records. Access modes allow you to control the visibility and access to entire record, an attribute group or an attribute. For access mode specification to work correctly, the names of the attribute and the attribute group must not be the same. Access for multi-value attributes can also be controlled using the access tag. In case of rulebase evaluation with relationship attribute values, the access modifiers on records based on relationship attribute are not applied on the record list. For example, if you try to hide some records from a record list based on their relationship attribute value for a particular relationship, the records are not hidden.

The following table lists the levels of access and their effects. Attribute <access mode="hide"> Effect The attribute or attribute group will not be visible in the UI. Note: Though a repository validation rulebase allows any attribute to be hidden, including required attributes, TIBCO recommends that you do not hide any of the required attributes (such as PRODUCTID) during create and/or modify as this will not allow you to create or modify a record. <access mode="view"> <access mode="modify"> The attribute or attribute group appears on the screen as read-only. The attribute or attribute group appears on the screen and can be modified by the user.

TIBCO Collaborative Information Manager Rulebase Guide

48

| Chapter 1

Getting Started with Rules

Attribute <access mode="hide_record"> <access mode="view_record">

Effect This access mode applies to the entire record. The record does not appear in the record list or in relationships. This access mode applies to the entire record. The record appears in the record list, but cannot be modified. Refer to, Restrictions on Record Access Conditions, page 54.

Rules are executed in the order in which they are defined in the rulebase. For this reason, exceptional cases should appear at the top of the file and general cases near the bottom. In other words, as soon as an access mode is assigned to a particular attribute, all subsequent ones will be ignored. Which one is first, of course, depends on the <condition> of that rule. Since record level access actions are translated into SQL, some restrictions exist as to which operators can be used. Refer to, Restrictions on Record Access Conditions, page 54. Order of Precedence for Attribute Group Permissions It is recommended that you manage the attribute group permission through one method either the user interface or the Rulebase. When the attribute group permissions are specified in both the places, permissions specified in the user interface take precedence. The order is: 1. Use the Administration > Resource Security menu decide a set of permissions on the attribute groups. If you hide an attribute group using this menu, modifiers cannot be applied in the rulebase. 2. Apply rulebase modifiers on the attribute groups obtained from Administration > Resource Security. HIDE takes precedence irrespective of whether it is set using the Administration > Resource Security menu or the Rulebase. Repository Attributes In the following example, the shipping code is hidden (does not display on the screen), since it is only relevant to the Logistics department. This is an exceptional case and should be defined at the top of the rulebase with a rule defining the defaults following.

TIBCO Collaborative Information Manager Rulebase Guide

Access Modes 49

<constraint> <name>LogisticsOp</name> <description>Show fields for logistics Op</description> <usefor> <var>ShippingCode</var> </usefor> <condition> <eq> <var>ACTIVITY_NAME</var> <const type="string">EnterLogisticInfo</const> </eq> </condition> <action> <access mode="modify"/> </action> </constraint> <constraint> <name>DefaultAttributeMode</name> <description>Default attribute values</description> <action> <!--Only executed if first rule was not executed. The attribute name is explicitly mentioned here. --> <access mode="hide">SHIPPING_CODE</access> </action> </constraint>

Restrictions on Attribute Access Conditions When hiding attributes during Record List displays, the condition will not evaluate any attribute values. The only values that can be used are those based on the SESSION or repository. The reason is that it is not possible to evaluate the attribute access for each record in the list. The results might well be contradictory. Relationship Attributes Relationship attributes can also have their access mode controlled. To define the access mode on the relationship attribute, it is necessary to <declare> the relationship first. Two styles of relationship definitions can be used: declaring the relationship attribute in the declaration using the / notation. In most cases, the / style of the definition is more convenient, as the relationship will already be declared.

TIBCO Collaborative Information Manager Rulebase Guide

50

| Chapter 1

Getting Started with Rules

Example The Default rule at the end will only be valid if UOM is undefined. It will provide access when a new record is added.
<declare> <var>CONTAINSREL</var> <link type="relationship"> <literal>Contains</literal> </link> </declare> <!-- the following declaration is only here for illustration purposes --> <!-- it could be more convenient to use <var>CONTAISREL/QUANTITY</var> instead --> <declare> <var>CONTAINSQUANTITY</var> <link type="relationship"> <literal>Contains</literal> <literal>Quantity</literal> </link> </declare> <declare> <var>CONTAINEDREL</var> <link type="relationship"> <literal>ContainedBy</literal> </link> </declare> <!-- the following declaration is only here for illustration purposes --> <!-- it could be more convenient to use <var>CONTAINEDREL/QUANTITY</var> instead --> <declare> <var>CONTAINEDQUANTITY</var> <link type="relationship"> <literal>ContainedBy</literal> <literal>Quantity</literal> </link> </declare> <!-- We assume the following 3 Level structure UOM = PL contains UOM = CS contains UOM = EA --> <declare usage="local"> <var>IS_SUPERVISOR</var> </declare> <constraint> <name>IsSupervisor</name> <description>User is supervisor if role contains Admin or Supervisor.</description> <action> <assign> <var>IS_SUPERVISOR</var>

TIBCO Collaborative Information Manager Rulebase Guide

Access Modes 51

<or> <in> <const type="string">Work Supervisor</const> <var>SESSION/USER_ROLES</var> </in> <in> <const type="string">Admin</const> <var>SESSION/USER_ROLES</var> </in> </or> </assign> </action> </constraint> <constraint> <name>PalletAccess</name> <description>If UOM is PL, access for contains Quantity is modify and access for containedby quantity is view.</description> <condition> <and> <eq> <var>UOM</var> <const type="string">PL</const> </eq> <not> <var>IS_SUPERVISOR</var> </not> </and> </condition> <action> <access mode="modify">CONTAINSQUANTITY</access> <access mode="view">CONTAINEDREL/QUANTITY</access> </action> </constraint> <constraint> <name>CaseAccess</name> <description>If UOM is CS then access for contains Quantity is hide, containedby Quantity is view.</description> <condition> <and> <eq> <var>UOM</var> <const type="string">CS</const> </eq> <not> <var>IS_SUPERVISOR</var> </not> </and> </condition> <action> <access mode="hide">CONTAINSREL/QUANTITY</access> <access mode="view">CONTAINEDQUANTITY</access> </action> </constraint> <constraint> <name>EachAccess</name>

TIBCO Collaborative Information Manager Rulebase Guide

52

| Chapter 1

Getting Started with Rules

<description>If UOM is EA, access for contains quantity is view and access for containedby quantity is hide.</description> <condition> <and> <eq> <var>UOM</var> <const type="string">EA</const> </eq> <not> <var>IS_SUPERVISOR</var> </not> </and> </condition> <action> <access mode="view">CONTAINSQUANTITY</access> <access mode="hide">CONTAINEDREL/QUANTITY</access> </action> </constraint> <constraint> <name>Default</name> <description>Default values (for ADD, for example): access for contains quantity is view and access for containedby quantity is modify.</description> <condition> <and> <not> <var>IS_SUPERVISOR</var> </not> </and> </condition> <action> <access mode="view">CONTAINSREL/QUANTITY</access> <access mode="modify">CONTAINEDREL/QUANTITY</access> </action> </constraint>

The following figure shows a pictorial representation of this example.

TIBCO Collaborative Information Manager Rulebase Guide

Access Modes 53

Figure 1 Access modes based on UOM

Record Access It is possible to completely hide a record from a user using hide_record access, or restrict a users edit access to a record by using view_record. Take as example the following rulebase definition:
<rulebase metaversion="0.1"> <!-- rulebase metaversion="0.1" --> <name>rbrecordlistsecurity1</name> <description>Rulebase to test view and hide record.</description> <declare usage="local"> <var>IS_SUPERVISOR</var> </declare> <constraint> <name>IsSupervisor</name> <description>User is supervisor if role contains Admin or Supervisor.</description> <action> <assign> <var>IS_SUPERVISOR</var> <or> <in> <const type="string">Work Supervisor</const> <var>SESSION/USER_ROLES</var> </in> <in>

TIBCO Collaborative Information Manager Rulebase Guide

54

| Chapter 1

Getting Started with Rules

<const type="string">Admin</const> <var>SESSION/USER_ROLES</var> </in> </or> </assign> </action> </constraint> <constraint> <name>ViewRecordEACH</name> <description>Make certain fields read only.</description> <condition> <and> <eq> <var>UOM</var> <const type="string">EACH</const> </eq> <not> <var>IS_SUPERVISOR</var> </not> </and> </condition> <action> <access mode="view_record"/> </action> </constraint> <constraint> <name>HideRecordCASE</name> <description>Make certain fields read only.</description> <condition> <and> <eq> <var>UOM</var> <const type="string">CASE</const> </eq> <not> <var>IS_SUPERVISOR</var> </not> </and> </condition> <action> <access mode="hide_record"/> </action> </constraint> </rulebase>

This rulebase sets the record access to view only if UOM is EACH and hides the record completely if UOM is CASE. Both rules are only active if the user is not a supervisor. Restrictions on Record Access Conditions For performance reasons, the <condition> of rules containing record level access actions are converted to SQL in some cases. This means only functions that are translatable into SQL can be used. These include:

TIBCO Collaborative Information Manager Rulebase Guide

Access Modes 55

and, or, not, eq, neq, in, lt, leq, gt, geq, defined, undefined Conditions containing expressions other than those listed above will fail. Record Level Access and Composites The child of a composite will take the most restrictive attribute based on its own and that of the root of the composite record. The exception to this is the Record List screen, which shows all child composites, unless they are explicitly hidden.

TIBCO Collaborative Information Manager Rulebase Guide

56

| Chapter 1

Getting Started with Rules

Global Property Settings for Rules


The TIBCO Collaborative Information Manager stores some system wide configuration parameters for rules in the C o n f i g V a l u e s . x m l file. These properties are set using the Configurator.

LogFlag
This parameter produces rulebase execution logs in the $ M Q _ C O M M O N _ D I R / T e m p directory. It should be used for development or debugging only and should not be enabled in a production environment. This parameter can be specified in System Debugging > RuleBase Debug Mode of the Configurator. Below is an example of how to set it to true so a detailed stack trace can be obtained for rule base execution. Log files start with "r b " and end with ". x m l ". Several files can be produced in one go; browse to locate the right file. Table 5 Log Files Prefix
rbb1*.xml rbb2*.xml rbb3*.xml

Description First pass of rulebase. Computes propagations. Propagations. Second pass of rulebase. This is the file you need for debugging validations and assignments.

Checking Attribute Names


Setting the Configurator > Miscellaneous > Check Attribute Names parameter to true halts the processing (throw an exception) if an attribute in the rulebase is not present in the repository. If this parameter is set to false, an error is logged in e r r o r . l o g and a null value is returned for that attribute and normal processing continues. This parameter is provided mainly for backward compatibility with previous versions. In past versions, attributes not found in the repository were ignored. Now, more stringent checking is present, which can cut down on "typo" type errors, but it also means a rulebase that references a deleted attribute will no longer work.

TIBCO Collaborative Information Manager Rulebase Guide

Global Property Settings for Rules 57

The recommended approach is to set this flag to true in the system where you need to use the rulebase so that the system will alert you immediately if a rulebase contains an invalid attribute reference.

TIBCO Collaborative Information Manager Rulebase Guide

58

| Chapter 1

Getting Started with Rules

TIBCO Collaborative Information Manager Rulebase Guide

| 59
Chapter 2

Expressions

This chapter describes the Expression syntax.

Topics
SQL Expressions, page 60 Context Variables, page 69

TIBCO Collaborative Information Manager Rulebase Guide

60

| Chapter 2

Expressions

SQL Expressions
SQL expressions are used to access data in datasources and repositories. The result of these expressions can then be used in select functions, or even assigned to other variables.

Restrictions
The following restrictions apply for the use of SQL expressions: The following logical expressions are supported: and, or, not, in, defined, undefined, like. The following operands are supported: eq, neq, leq, lt, geq, gt. You have to use a where clause if you have a table where source is sql. Multi-column results can only be used in select and slice actions. All other functions require a single column result (that is, a list of values). Built-in functions such as concat, count, and so on cannot be used within an SQL expression. The multi-value attribute can only be used in where clause and not supported in a select column list. Only supported operators for multi-value are eq, neq, in and like.

Locations of datasource and classifications


Datasources and classifications can be stored in the shared T i b c o C i m enterprise. Datasources and classifications stored here can be accessed by all other enterprises. If the datasource exists in the current organization, it is used by the application. Otherwise, it is looked for in the global T i b c o C i m enterprise. If it cannot be found in either organization, the SQL expression throws an error.

table
All SQL expressions start with the table tag. The table tag can be thought of as a function that returns a table of values.

TIBCO Collaborative Information Manager Rulebase Guide

SQL Expressions 61

There are three forms of the table function that can be selected with the source attribute: source datasource sql classification Description Optimized for datasource access General SQL expression builder.

source="datasource" source="datasource" data is assumed to come from a single datasource table. The first value is assumed to be the datasource name, and the following values are the column names in that datasource. For datasource tables the arguments are as follows: Argument 1 2 3-n First Column Second, Third, ... Column Default Value Description Name of datasource. Name of database column. Name(s) of display columns.

The following example selects three columns from the COUNTRY3 datasource, and displays them in a drop-down menu.
<constraint> <name>Country3</name> <description>COUNTRY3 datasource.</description> <usefor> <var>COUNTRYOFORIGINCODE</var> </usefor> <action> <select novalue="option"> <table source="datasource"> <literal>COUNTRY3</literal> <literal>CODE</literal> <literal>NAME</literal> <literal>SCALE</literal> </table> </select> </action> </constraint>

The following example selects only specific language codes from the datasource.
<constraint>

TIBCO Collaborative Information Manager Rulebase Guide

62

| Chapter 2

Expressions

<name>Language2</name> <description>LANGUAGE2 datasource with SQL query.</description> <usefor> <var>PRODUCTNAMELANG</var> </usefor> <action> <select novalue="default"> <table source="datasource"> <literal>LANGUAGE2</literal> <literal>CODE</literal> <where> <sql> <or> <eq> <literal>CODE</literal> <const type="string">EN</const> </eq> <eq> <literal>CODE</literal> <const type="string">ES</const> </eq> <eq> <literal>CODE</literal> <const type="string">DE</const> </eq> <eq> <literal>CODE</literal> <const type="string">FR</const> </eq> </or> </sql> </where> </table> </select> </action> </constraint>

source="sql" For source="sql" tables, you have to declare the datasources, classifications and repositories to use. The columns in those repositories are then accessed with the "/" notation. For example, if you declare a repository called MC1, you can access its UOM MC1/UOM. Follow this procedure: 1. declare the datasource, classification and repositories in the expression. 2. List the columns to return as a result using table-name/column-name notation.

TIBCO Collaborative Information Manager Rulebase Guide

SQL Expressions 63

3. Build the where clause. An SQL expression is built in the background. The list of columns to be returned is the select portion, and the where tag is translated into the where clause of the SQL expression. The from portion of the SQL expression is built implicitly by the tables used in the expression. Currently, the where tag is mandatory. The table tag supports multi-value attributes in the where tag only. Supported operators are eq (or in) and neq.

The source of the SQL data is declared using the link mechanism, as used in relationship declarations. Valid link types are: datasource, classification and catalog. By restricting access to these entities, the system ensures that no unauthorized system table is accessed. link type datasource classification Argument Datasource Name Classification Scheme Description References a datasource. See, Locations of datasource and classifications, page 60. Currently references a Datasource with the same name as the Classification Scheme. Refer to, Locations of datasource and classifications, page 60. References a repository. Specifies the state of the records to be selected. Legal values are CONFIRMED and UNCONFIRMED.

catalog

Repository Name STATE/<input>

The following example declares the variable C3, which represents the datasource COUNTRY3. The available datasources can be viewed in the application using the Datasource menu.
<declare> <var>C3</var> <link type="datasource"> <literal>COUNTRY3</literal> </link> </declare>

The following example declares a variable that points to a repository named MASTER3:
<declare> <var>Master3</var> <link type="catalog"> <literal>MASTER3</literal> </link> </declare>

TIBCO Collaborative Information Manager Rulebase Guide

64

| Chapter 2

Expressions

The name of a variable can be the same or different from that of the repository. This allows for the possibility of self-joins and other options. The following example declares a variable that can be used to select the latest version of the records from Master3.
<declare> <var>Master3</var> <link type="catalog"> <literal>MASTER3</literal> <literal>STATE/UNCONFIRMED</literal> </link> </declare>

Selecting Columns
To select columns, combine the variable that points to the SQL source, and the column name. Use the literal tag. The literal tag is used rather than the <var> tag to point out the fact that we are referring to the column name, not its value. The column name is the logical column name, meaning it is the same name that appears in the datasource and repository attribute screens. You do not need to know the actual column name in the database. The following example, selects the Code from datasource COUNTRY3.
<literal>C3/CODE</literal>

The following example selects the UOM column from Master3.


<literal>Master3/UOM</literal>

where
The where tag represents the where clause of a SQL expression. It has two parts: the text string representing the where clause, and any arguments substituted for placeholders. Argument 1 2-n Description string representing where clause. Values to substitute in for expression placeholders: <const type="string">?</const>

TIBCO Collaborative Information Manager Rulebase Guide

SQL Expressions 65

The where clause is a string in the SQL expression. It is important that it is a string. You can enter in your own SQL expression directly, or use the sql function, as follows. One difference between a table of source="datasource" and source="sql" is that for datasource the tablename is implied for all columns. In the following example, <literal>BUC</literal> is a column in the datasource RULE2. There is no need to declare the datasource explicitly.
<select novalue="no"> <table source="datasource"> <const type="string">RULE2</const> <const type="string">BRANDCODE</const> <const type="string">BRANDCODE</const> <where type="SQL"> <sql> <eq> <literal>BUC</literal> <const type="string">?</const> </eq> </sql> <var>BUC</var> </where> </table> </select>

You can also present the previous example in the following way:
<select novalue="no"> <table source="datasource"> <const type="string">RULE2</const> <const type="string">BRANDCODE</const> <const type="string">BRANDCODE</const> <where type="SQL"> <const type="string">CBUC = '?'</const> <var>BUC</var> </where> </table> </select>

The advantage of using rulebase syntax is in not having to know exact column names. The general rule is that a column name is the same as the attribute, only prepended with C. This may not be the case for repository column names that have been renamed or deleted. Also, you can provide a column name for user-defined attributes. So it may not necessarily be the same as attribute name with "C" prepended.

Placeholders
Placeholders are the equivalent to the ? used in an SQL prepared statement. In the following example, the ? placeholder is replaced by the value of CLASSIFICATIONLEVEL1.

TIBCO Collaborative Information Manager Rulebase Guide

66

| Chapter 2

Expressions

<constraint> <name>ClassificationLevel2</name> <description>Classification Level 2</description> <usefor> <var>CLASSIFICATIONLEVEL2</var> </usefor> <condition> <defined> <var>CLASSIFICATIONLEVEL1</var> </defined> </condition> <action> <select novalue="no"> <table source="datasource"> <literal>CATEGORY</literal> <literal>CAT2</literal> <literal>CAT2DESC</literal> <where> <sql> <eq> <literal>CAT1</literal> <const type="string">?</const> </eq> </sql> <var>CLASSIFICATIONLEVEL1</var> </where> </table> </select> </action> </constraint>

sql Function
The sql function takes a rulebase expression and returns the equivalent SQL string. When using sql, you do not have to know the database table and column names, which are not the same as the names appearing in the application. For example, the repository records could be stored in a table called MCT_12334. Even then, the table name changes in different installations (development, staging, production). The sql function makes sure that the correct table is always accessed. Argument 1-n Description rulebase expressions. One of: and, or, not, eq, neq, geq, gt, leq, lt, like, defined, undefined. There are some restrictions on which rulebase functions are translated into SQL equivalents. The following is an example of a join between two datasources:
<declare>

TIBCO Collaborative Information Manager Rulebase Guide

SQL Expressions 67

<var>C3</var> <link type="datasource"> <literal>COUNTRY3</literal> </link> </declare> <declare> <var>S2</var> <link type="datasource"> <literal>SCALE</literal> </link> </declare> <constraint> <name>Scale</name> <description>Do a datasource join</description> <usefor> <var>HI</var> </usefor> <action> <select novalue="option"> <table source="sql"> <literal>S2/SCALE</literal> <literal>S2/SCALE</literal> <literal>C3/CODE</literal> <literal>C3/NAME</literal> <literal>S2/DESCRIPTION</literal> <where> <sql> <eq> <literal>C3/SCALE</literal> <literal>S2/SCALE</literal> </eq> </sql> </where> </table> </select> </action> </constraint>

The following is an example using a repository:


<declare> <var>Master3</var> <link type="catalog"> <literal>MASTER3</literal> </link> </declare> <constraint> <name>PRICETYPE</name> <description>Select possible PriceTypes from Master3 where UOM is PACK</description> <usefor> <var>PRICETYPE</var> </usefor> <action> <select> <table source="sql"> <literal>MASTER3/PRICEUOMCODE</literal>

TIBCO Collaborative Information Manager Rulebase Guide

68

| Chapter 2

Expressions

<where> <sql> <eq> <literal>MASTER3/UOM</literal> <const type="string">PACK</const> </eq> </sql> </where> </table> </select> </action> </constraint>

For a multi-value attribute, eq/like/in would return the result if any of the value matches with the specified value. For example, when a COLOR attribute has RED, YELLOW, BLUE, the following expression would return true.
<eq> <literal>COLOR</literal> <const type="string">RED</const> </eq>

Debugging Statements
When debugging SQL statements, look in elink.log for the following string:
"execStatement:" and "execStatement:sql"

SQL generated by your expression is executed here. Null Values No special provisions are made for null values in the input values. Check if inputs to SQL can have null values in the condition, and do not execute the SQL if null values are not provided for.

TIBCO Collaborative Information Manager Rulebase Guide

Context Variables 69

Context Variables
The followings special variables can be used in a rulebase: SESSION, page 69 WORKITEM, page 70 PREVIOUS_VERSION, PREVIOUS_CONFIRMED_VERSION, page 71 RECORD_ACTION, page 73 RECORD_SUB_ACTION, page 75 RECORD_IS_TOPMOST, page 76 RECORD_IS_BOTTOMMOST, page 76 PARENT, page 77 CHILD, page 78

SESSION
The following table lists session variables that can be used without explicit declaration. Variable
SESSION/DATE SESSION/USER_ID SESSION/USER_ROLES

Type date string array string string string string

Value Current date and time. User ID of current user. Roles this user belongs to. Organization Name. Organization type. Enterprise Name. Enterprise Internal Name.

SESSION/ORGANIZATION_NAME SESSION/ORGANIZATION_TYPE SESSION/ENTERPRISE_NAME SESSION/ENTERPRISE_INTERNAL_NAME

TIBCO Collaborative Information Manager Rulebase Guide

70

| Chapter 2

Expressions

The following example shows an access rule which restricts access to the attribute SENSITIVE_ATTRIBUTE only to Admin users. Notice that in has to be used, because a user can belong to more than 1 role, and USER_ROLES therefore returns an array of values.
<constraint> <name>HideSensitiveAttribute</name> <description>Only Admin Role can see Sensitive Attribute</description> <condition> <in> <const type="string">Admin</const> <var>SESSION/USER_ROLES</var> </in> </condition> <action> <access mode="modify">SENSITIVE_ATTRIBUTE</access> </action> <action> <access mode="hide">SENSITIVE_ATTRIBUTE</access> </action> </constraint>

WORKITEM
Each step in the workflow has dependent criteria, and requires specific variables to be defined. The following table lists variables, their types, and values. Variable
WORKITEM/ACTIVITY_NAME WORKITEM/SEVERITY WORKITEM/STEP_SEVERITY WORKITEM/DOCTYPE

Type string number number string string number number

Value Name of current activity. Workitem Severity. Workitem Step Severity. Document Type that created workitem. Document Sub-Type that created workitem. Number of errors in the record bundle. Number of warnings in the record bundle.

WORKITEM/DOCSUBTYPE

WORKITEM/ERRORS

WORKITEM/WARNINGS

TIBCO Collaborative Information Manager Rulebase Guide

Context Variables 71

Variable
WORKITEM/REJECTIONS

Type number string string string string

Value Number of rejections in the record bundle. Trading Partner Name. Trading Partner Organization Type. Marketplace name. Name of the repository of the record being processed. Repository Version. Intent passed in to WorkItem activity. Total number of records in the bundle. Number of records with no errors. Any Parameter starting with Custom that is passed to Workitem Activity.

WORKITEM/TRADING_PARTNER WORKITEM/TRADING_PARTNER_TYPE

WORKITEM/MARKETPLACE_NAME WORKITEM/MASTER_CATALOG_NAME

WORKITEM/MASTER_CATALOG_VERSI ON WORKITEM/INTENT

Number String Number Number String

WORKITEM/RECORD_COUNT

WORKITEM/SUCCESS_COUNT

Custom*

PREVIOUS_VERSION, PREVIOUS_CONFIRMED_VERSION
You can access previous unconfirmed and confirmed versions of the records with two explicitly defined contexts. The following table lists these contexts. Context
PREVIOUS_VERSION PREVIOUS_CONFIRMED_VERSI ON

Description Latest confirmed or unconfirmed version. Last confirmed version.

TIBCO Collaborative Information Manager Rulebase Guide

72

| Chapter 2

Expressions

The following example shows how to access the weight attribute value of the last confirmed version:
<var>PREVIOUS_CONFIRMED_VERSION/WEIGHT</var>

CONTEXT_RELATIONSHIP/NAME
While adding a new record and executing the newrecord rulebase, the CONTEXT_RELATIONSHIP variable contains the name of a relationship if the record is added by selecting the add action and then the relationship name on an existing record. For example, if you are keeping a Vendor repository which has a relationship for multiple addresses, then you can automatically set the RECORD_TYPE to address if the user is adding a new address relationship.
<constraint> <name>Vendor_Record_Type</name> <condition> <undefined> <var>CONTEXT_RELATIONSHIP/NAME</var> </undefined> </condition> <action> <assign> <var>RECORD_TYPE</var> <const type="string">VENDOR</const> </assign> </action> </constraint> <constraint> <name>Address_Record_Type</name> <condition> <eq> <var>CONTEXT_RELATIONSHIP/NAME</var> <const type="string">ADDRESS_REL</const> </eq> </condition> <action> <assign> <var>RECORD_TYPE</var> <const type="string">ADDRESS</const> </assign> </action> </constraint>

The following is another example of assigning the RECORD_TYPE based on the Context Relationship.
<constraint> <name>PRODUCT</name> <condition> <undefined> <var>CONTEXT_RELATIONSHIP/NAME</var>

TIBCO Collaborative Information Manager Rulebase Guide

Context Variables 73

</undefined> </condition> <action> <assign> <var>RECORD_TYPE</var> <const type="string">PRODUCT</const> </assign> </action> </constraint> <constraint> <name>SKU</name> <condition> <eq> <var>CONTEXT_RELATIONSHIP/NAME</var> <const type="string">PRODUCT_TO_SKU_REL</const> </eq> </condition> <action> <assign> <var>RECORD_TYPE</var> <const type="string">SKU</const> </assign> </action> </constraint>

RECORD_ACTION
Possible values: RECORD_ACTION ADD EDIT COPY VIEW MASS_UPDATE Escaped Version New record is being added. Existing record is being edited. New Record is being copied from another record. Record is being viewed. Executes a constraint only when the mass update is in process, that is, the same validation file can be used for record edit and mass update. Refer to, mass_update, page 74. RECORD_SEARCH The record search is being executed. If a constraint is defined with this action, the same catalog validation file can be used for record search screen if the property c o m . t i b c o . c i m . r e c o r d s e a r c h . r u l e s f i l e is configured with catalog validation file name.

TIBCO Collaborative Information Manager Rulebase Guide

74

| Chapter 2

Expressions

The following example restricts view access to the B A S E _ U N I T , I T E M _ B R A N D _ N A M E , and B R A N D _ O W N E R _ I D attributes, if the record is being viewed or edited:
<constraint> <name>ViewOnlyGeneralAttributesForViewAndChange</name> <description>View only attributes for View and Change</description> <condition> <or> <eq> <var>RECORD_ACTION</var> <const type="string">EDIT</const> </eq> <eq> <var>RECORD_ACTION</var> <const type="string">VIEW</const> </eq> </or> </condition> <action> <access mode="view">BASE_UNIT</access> <access mode="view">ITEM_BRAND_NAME</access> <access mode="view">BRAND_OWNER_ID</access> </action> </constraint>

mass_update This value allows you to execute a constraint only when the mass update is in process, that is, the same validation file can be used for record edit and mass update. The RecordAction filter can be used for mass update as shown in the following example:
<constraint> <name>Check-int</name> <description>Check-int</description> <usefor> <var>TEST_INT</var> </usefor> <condition> <eq> <var>RECORD_ACTION</var> <const type="string">MASS_UPDATE</const> </eq> </condition> <action> <check> <explanation>TEST_INT should only be 1</explanation> <and> <defined> <var>TEST_INT</var> </defined> <eq>

TIBCO Collaborative Information Manager Rulebase Guide

Context Variables 75

<var/> <const type="number">1</const> </eq> </and> </check> </action> </constraint>

record_search The following is an example of a constraint to be used when RECORD_ACTION=RECORD_SEARCH is used:


<constraint> <name>TestSQLIN</name> <description>Test Get with SQL query using IN</description> <usefor> <var>Installments</var> </usefor> <condition> <eq> <var>RECORD_ACTION</var> <const type="string">RECORD_SEARCH</const> </eq> </condition> <action> <select> <table source="datasource"> <literal>CUSTDS1</literal> <literal>INSTALLMENT</literal> <where> <sql> <in> <literal>INSTALLMENT</literal> <const type="number">34000</const> <const type="number">23000</const> </in> </sql> </where> </table> </select> </action> </constraint>

RECORD_SUB_ACTION
Currently, the only possible value that can be assigned to this variable is RESTORE.

TIBCO Collaborative Information Manager Rulebase Guide

76

| Chapter 2

Expressions

When a record is restored, for all UI based rulebase validations for restored record, RECORD_SUB_ACTION is set to RESTORE. RECORD_SUB_ACTION is bound to RESTORE only for UI based validations and not during workflow processing.

RECORD_IS_TOPMOST
This variable allows you to check whether the record is the topmost in the hierarchy. Example
<constraint> <name>Test for parent</name> <description>To Check if this is the parent</description> <usefor> <var>SHORTDESC</var> </usefor> <condition> <and> <eq> <var>RECORD_TYPE</var> <const type="string">CUST</const> </eq> <var>RECORD_IS_TOPMOST</var> </and> </condition> <action> <assign> <var>SHORTDESC</var> <const type="string">Parent Record</const> </assign> </action> </constraint>

RECORD_IS_BOTTOMMOST
This variable allows to check whether the record is bottommost in the hierarchy. Example
<constraint> <name>Test for child/leaf node</name> <description>To Check if this is the leaf node in a hierarchy of records</description> <usefor> <var>SHORTDESC</var> </usefor>

TIBCO Collaborative Information Manager Rulebase Guide

Context Variables 77

<condition> <and> <eq> <var>RECORD_TYPE</var> <const type="string">CUST</const> </eq> <var>RECORD_IS_BOTTOMMOST</var> </and> </condition> <action> <assign> <var>SHORTDESC</var> <const type="string">Child Record</const> </assign> </action> </constraint>

PARENT
This variable allows to access attribute values of a parent record during relationship catalog rulebase execution. This context variable is only available in relationship catalog rulebase execution. The parent/child record is always determined in context of forward relationship. Example
<constraint> <name>checkForAssetType</name> <description>To Check if asset type is defined</description> <usefor> <var>ASSET_TYPE</var> </usefor> <condition> <defined> <var>PARENT/HAS_ASSETS</var> </defined> </condition> <action> <check> <explanation>Asset type should be defined.</explanation> <defined> <var>ASSET_TYPE</var> </defined> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

78

| Chapter 2
CHILD

Expressions

This variable allows to access attribute values of child record during relationship catalog rulebase execution. This context variable is only available in relationship catalog rulebase execution. The parent/child record is always determined in context of forward relationship. Example
<constraint> <name>checkForRegion</name> <description>To Check if region is defined</description> <usefor> <var>REGION</var> </usefor> <condition> <defined> <var>CHILD/ZIPCODE</var> </defined> </condition> <action> <check> <explanation>REGION type should be defined.</explanation> <defined> <var>REGION</var> </defined> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

| 79
Chapter 3

Operator and Character Reference

This chapter details the operators and regular expressions.

Topics
Overview of Operators, page 80 Logical Operators, page 83 Syntax for Expressions, page 116 Regular Expressions, page 118 Built-in Functions, page 122 Custom Functions, page 123

TIBCO Collaborative Information Manager Rulebase Guide

80

| Chapter 3

Operator and Character Reference

Overview of Operators
This section provides detailed information for rulebase operators, and is organized alphabetically by operator name.

Logical

and page 83 not page 95 or page 85

Comparison

changed page 87 defined page 107 eq page 108 geq page 90 gt page 90 in page 90 leq page 91 lt page 91 match page 112 neq page 95 undefined page 93

TIBCO Collaborative Information Manager Rulebase Guide

Overview of Operators 81

String

concat page 94 length page 94 pad page 95 substring page 113 trim page 114 uppercase page 114

Math

div page 108 minus page 112 mult page 100 percent page 101 plus page 102 round page 103

Other

checkdigit page 106 count page 107 distinct page 107

TIBCO Collaborative Information Manager Rulebase Guide

82

| Chapter 3

Operator and Character Reference

filter page 108 lookup page 109 like page 110 max page 112 min page 110 sequence page 112 strip page 113 synchstatus page 113 SyncOperationAttribute page 114 validate_checkdigit page 114 This chapter also includes references for the following characters: Literal Characters Character Classes Position Characters

TIBCO Collaborative Information Manager Rulebase Guide

Logical Operators 83

Logical Operators

and compute logical and


Synopsis: <and> Arguments: 1 or more boolean expressions. TRUE if all arguments are true. FALSE if any argument is false. Null if any argument is null. By default, and stops evaluating new arguments when the current value is FALSE or null. To optimize execution time, place expressions based on single attributes first in the condition, and expressions involving complicated relationship traversals or database accesses last. In that way, if the first condition is FALSE the system does not evaluate subsequent expressions. Truth Tables for AND (&): Argument 1 F F T T Null Scalar: Argument1 Argument2 Result Scalar and Array Argument1 Argument2 B1,1 [B2,1 , B2,2 , B2,3 ... B2,n]
TIBCO Collaborative Information Manager Rulebase Guide

Argument 2 F T F T T or F or Null

Result F F F T Null

B1,1 B2,1 B1,1 & B2,1

84

| Chapter 3

Operator and Character Reference

Scalar: Result Array and Array Argument1 Argument2 Result 1 Argument Argument1 Result [B1,1 , B1,2 , B1,3 ... B1,n] B1,1 & B1,2 & B1,3 ... & B1,n [B1,1 , B1,2 , B1,3 ... B1,m] [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1 & B2,1 , B1,2 & B2,2 , B1,3 & B2,3 ... B1,m & B2,n] [B1,1 & B2,1 , B1,1 & B2,2 , B1,1 & B2,3 ... B1,1 & B2,n]

If m is not equal to n, an error is generated. Each null value generates one null entry. If only one argument is given, all entries in the array are combined (anded together). Optimization Arguments into and are evaluated on a need basis when the expression is evaluated. As an optimization, the rulebase engine stops evaluating arguments when the current result is either FALSE or null. This is an efficient way of bypassing arguments that affect the result. For example, if the UOM is CASE and you want to look at all Products in the Contains relationship to make sure that they are of type EACH. This expression might be as follows:
<and> <eq> <var>UOM</var> <const type="string">CASE</const> </eq> <eq> <var>CONTAINS_RELATIONSHIP/UOM</var> <const type="string">EACH</const> </eq> </and>

Traversing the Contains relationship to get the UOM of the Contained product(s) should be avoided if possible. Therefore, if UOM of the parent product is not CASE, the engine stops evaluating the expression before it starts fetching all the records pointed at by the Contains relationship. Arrays are considered one argument - as a result, individual array entries are not optimized.
TIBCO Collaborative Information Manager Rulebase Guide

Logical Operators 85

not compute logical not


Synopsis: <not> Arguments: 1 boolean expression. Returns: TRUE if argument is FALSE. FALSE if argument is TRUE. null if argument is NULL.

or compute logical or
Synopsis: <or> Arguments: 2 or more boolean expressions. Returns: TRUE if any argument is true. FALSE if all arguments are false. Null if any argument is Null. By default, or stops evaluating new arguments when the current value is TRUE or null. To optimize execution time, put expressions based on single attributes first in the condition, and expressions involving complicated relationship traversals or database accesses last. In that way, if the first condition is FALSE, the system does not evaluate subsequent expressions. For more information, see Optimization on page 82. Truth Tables for | : Argument 1 F F T T Null Argument 2 F T T T T or F or Null Result F T T T Null

TIBCO Collaborative Information Manager Rulebase Guide

86

| Chapter 3

Operator and Character Reference

Scalar Argument1 Argument2 Result Scalar and Array Argument1 Argument2 Result Array and Array Argument1 Argument2 Result 1 Argument Argument1 Result [B1,1 , B1,2 , B1,3 ... B1,n] B1,1
\/

B1,1 B2,1 B1,1 | B2,1

B1,1 [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1


\/

B2,1 , B1,1

\/

B2,2 , B1,1

\/

B2,3 ... B1,1

\/

B2,n]

[B1,1 , B1,2 , B1,3 ... B1,n] [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1
\/

B2,1 , B1,2

\/

B2,2 , B1,3

\/

B2,3 ... B1,m

\/

B2,n]

B1,2

\/

B1,3 ...

\/

B1,n

If m is not equal to n, an error is generated. Each null value generates one null entry. If only one argument is given, all the entries in the array are combined ("anded" together). As an optimization, or stops evaluating arguments when it encounters the first TRUE or null value.

TIBCO Collaborative Information Manager Rulebase Guide

Comparison Operators 87

Comparison Operators

changed test an attribute to see if it has changed


Synopsis: <changed> Arguments: 1 var, see table, 2 flag. Returns: TRUE if attribute value has changed from its previous version. FALSE if attribute value has not changed. Arguments 1 2 Keyword Variable Keyword:
PREVIOUS_CONFIRMED_VERSION PREVIOUS_VERSION

(default)

Description: Check if SHORTDESC has changed since the previous confirmed version:
<condition> <changed> <var>SHORTDESC</var> <const type="string">PREVIOUS_CONFIRMED_VERSION</const> </changed> </condition>

For multi-value attribute, it returns true if the previous set of values is different from the current values:
<constraint> <name>TestChanged</name> <description>test changed</description> <condition> <changed> <var>Installments</var> <const type="string"> PREVIOUS_CONFIRMED_VERSION</const> </changed> </condition> <action> <assign>

TIBCO Collaborative Information Manager Rulebase Guide

88

| Chapter 3

Operator and Character Reference

<var>AmtPaid</var> <const type="number">12000</const> </assign> </action> </constraint>

defined determine if value is defined


Synopsis: <defined> Arguments: 1 <var> tag. Returns: TRUE if <var> has a non-null, non-empty value. FALSE if otherwise (see undefined on page 93). Description:
<defined> <var>SIZE_UOM</var> </defined>

Returns true if SIZE_UOM attribute is defined.

eq equals
Synopsis: <eq> or <eq scalarMatching=false> Arguments: 2 expressions. Note: When checking for a multi-value attribute, you must pass the s c a l a r M a t c h i n g = f a l s e as follows:
<constraint> <name>TestEq</name> <description>test</description> <condition> <and> <defined> <var>MTEST</var> </defined> <eq scalarMatching="false"><!-NEW flag scalarMatching ' <var>MTEST</var> <var>TEMP</var> </eq> </and> </condition> <action> <access mode="hide">SHORTDESC</access>

TIBCO Collaborative Information Manager Rulebase Guide

Comparison Operators 89

</action>

</constraint> Returns:

Argument 1 String1 Number1 Boolean1 Date1 Null Null Scalar Argument1 Argument2 Result Scalar and Array Argument1 Argument2 Result Array and Array Argument1 Argument2 Result Result (scalarMatching=true)

Argument 2 String2 Number2 Boolean2 Date2 Any of the above Null

Result Case insensitive compare of String1 and String2 Number1 = Number2 Boolean1 = Boolean2 Date1 = Date2 Null Null

B1,1 B2,1 B1,1 = B2,1

B1,1 [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1 = B2,1 , B1,1 = B2,2 , B1,1 = B2,3 ... B1,1 = B2,n]

[B1,1 , B1,2 , B1,3 ... B1,n] [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1 = B2,1 , B1,2 = B2,2 , B1,3 = B2,3 ... B1,m = B2,n] [B1,1 , B1,2 , B1,3 ... B1,n] = [B2,1 , B2,2 , B2,3 ... B2,n]

TIBCO Collaborative Information Manager Rulebase Guide

90

| Chapter 3
Scalar

Operator and Character Reference

1 Argument Argument1 Result [B1,1 , B1,2 , B1,3 ... B1,n] B1,1 = B1,2 = B1,3 ... = B1,n If m is not equal to n, an error is generated. Each null value generates one null entry.

geq greater than or equal


Synopsis: <geq> Arguments: 2 expressions. Returns: TRUE if first argument is >= second argument. FALSE if first argument is < second argument. For array behavior, see, filter filter a list of records, page 108.

gt greater than
Synopsis: <gt> Arguments: 2 expressions. For array behavior, see, filter filter a list of records, page 108. Returns: TRUE if first argument is > second argument. FALSE if first argument is < second argument.

in check if argument contained in a list


Synopsis: <in> Arguments: 1 variable to check; 2 list of n value.

TIBCO Collaborative Information Manager Rulebase Guide

Comparison Operators 91

Returns: TRUE if arg1 in (arg2, arg3, ...,argn). FALSE if otherwise. Description: Equivalent to: (arg1 == arg2)||(arg1 == arg3)||...||(arg1 == argn)

leq less than or equal


Synopsis: <leq> Arguments: 2 expressions. Returns: TRUE if first argument is <= second argument. FALSE if first argument is > second argument. For array behavior, see, filter filter a list of records, page 108.

lt less than
Synopsis: <lt> Arguments: 2 expressions. Returns: TRUE if first argument is < second argument. FALSE if first argument is >= second argument. For array behavior, see , filter filter a list of records, page 108.

match regular expression match


Synopsis: <match> Arguments: 1 variable to match; 2 regular expression. For information on regular expression syntax, see, Regular Expressions, page 118.

TIBCO Collaborative Information Manager Rulebase Guide

92

| Chapter 3
Example:

Operator and Character Reference

<check> <explanation lang="en">GTIN has to be 14 numeric characters.</explanation> <match> <var/> <const type="string">/^\d{14}$/</const> </match> </check> <check> <explanation>Has to be a non-negative number.</explanation> <match> <var/> <const type="string">/^((\d+(\.\d*)?)|(\d*\.\d+))$/</const> </match> </check>

Returns: TRUE if argument 1 matches regular expression argument 2. FALSE if first argument does not match second argument.

neq not equal


Synopsis: <neq> Arguments: 2 expressions. Note: When checking for a multi-value attribute, you must pass the s c a l a r M a t c h i n g = f a l s e as follows:
<constraint> <name>TestEq</name> <description>test</description> <condition> <and> <defined> <var>MTEST</var> </defined> <neq scalarMatching="false"><!-NEW flag scalarMatching ' <var>MTEST</var> <var>TEMP</var> </neq> </and> </condition> <action> <access mode="hide">SHORTDESC</access> </action>

</constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Comparison Operators 93

Returns: TRUE if first argument is not equal to second argument. FALSE if first argument is equal to second argument. For information on array behavior, see , filter filter a list of records, page 108.

undefined determine if value is undefined


Synopsis: <undefined> Arguments: 1 <var> tag. Returns: TRUE if the <var> is null or empty. FALSE if otherwise (see defined on page 107).

TIBCO Collaborative Information Manager Rulebase Guide

94

| Chapter 3

Operator and Character Reference

String Operators

concat concatenate string values


Synopsis: <op func="concat"> Arguments: 1 to n string expressions. Returns: String, which is the concatenation of all input strings. Description: Concatenates two or more strings.
<assign> <var>SEQ</var> <op func="concat"> <const type="string">PREFIX-</const> <op func="pad"> <var>PRODUCT_NUMBER</var> <const type="number">9</const> <const type="string">0</const> </op> <const type="string">-SUFFIX</const> </op> </assign>

Constructs a string from a prefix, product number, and suffix.

length compute length of string


Synopsis: <op func="length"> Arguments: 1 string expression. Returns: Returns the length of the specified string. Description:
<op func="length"> <const type="string">ABCDEF</const> </op>

TIBCO Collaborative Information Manager Rulebase Guide

String Operators 95

This example would return a value of 6.

pad pads a string on left or right


Synopsis: The option determines whether we pad to the left or right. Any null argument returns a null expression.
<op func="pad"> <op func="pad" option="left"> <op func="pad" option="right"> Arguments:

Argu ment 1

Use string to pad

Type string or array of strings

Comment If array, pad each string in array.

final length of padded string character to pad with

number

The final length will be max of (original length, final length). That is, the string will never shrink. Optional. If omitted, pad with spaces.

string

Returns: The option="left" Any null argument returns a null expression. String ABC ABC ABC Length 1 5 null Character * ** Result ABC **ABC null

Example:
<assign> <var>PADABC</var> <op func="pad" option="right"> <var>ABC</var> <const type="number">6</const> <const type="string">0</const>

TIBCO Collaborative Information Manager Rulebase Guide

96

| Chapter 3

Operator and Character Reference

</op> </assign>

substring
Synopsis: < o p Arguments: Argu ment 1 Use string to subset Type string or array of strings 2 start position number Comment If array, compute substring for each string in array. 0 is first position. If less than 0, set to start of string. 3 number of characters number Optional. If omitted, return until end of string. Returns:
func="substring">

String ABCDEF ABCDEF ABCDEF

Start 1 4 null

Length 2

Result BC EF null

Any null argument returns a null expression. Description: Returns a new string that is a substring of this string.
<op func="substring"> <const type="string">ABCDEF</const> <const type="number">0</const> <const type="number">3</const> </op>

TIBCO Collaborative Information Manager Rulebase Guide

String Operators 97

This example will return string as "ABC".

trim trims leading and trailing spaces


Synopsis: <op func="trim"> Arguments: 1 string expression. Returns: String with leading and trailing spaces removed. Description:
<op func="trim"> <const type="string"> </op> ABCDEF </const>

This example returns a value of "ABCDEF".

uppercase returns uppercase of input


Synopsis: <op func="uppercase"> Arguments: 1 string expression. Returns: String with all characters converted to uppercase equivalent. Description:
<op func="uppercase"> <const type="string">aBc</const> </op>

This would return a string "ABC".

TIBCO Collaborative Information Manager Rulebase Guide

98

| Chapter 3

Operator and Character Reference

Math Operators

div divides values


Synopsis:< o p
func="div"> <op func="div" round="<n>"> <!-- n is the number of decimal places the result should round to -->

Arguments: 1...n numeric expressions. Returns: Calculated numerical Arg1 / Arg2 / Arg3 / ... Argn Division by 0 returns null. By default results are rounded to 8 decimal places. Scalar Argument1 Argument2 Result Scalar and Array Argument1 Argument2 Result Array and Array Argument1 Argument2 Result 1 Argument Argument1 Result [B1,1 , B1,2 , B1,3 ... B1,n] B1,1
/

B1,1 B2,1 B1,1 / B2,1

B1,1 [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1


/

B2,1 , B1,1

B2,2 , B1,1

B2,3 ... B1,1

B2,n]

[B1,1 , B1,2 , B1,3 ... B1,n] [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1
/

B2,1 , B1,2

B2,2 , B1,3

B2,3 ... B1,m

B2,n]

B1,2 / B1,3 ...

B1,n

TIBCO Collaborative Information Manager Rulebase Guide

Math Operators 99

Description:
<op func="div"> <const type="number">10</const> <const type="number">2</const> </op>

<op func="div" round="4"> <const type="number">1</const> <const type="number">3</const> </op>

minus calculates subtraction of values


Synopsis:< o p
places --> func="minus"> <op func="minus" round="4"> <!-- Round the result by 4 decimal

Arguments: 1...n numeric expressions. Returns: Calculated numerical Arg1 - Arg2 - Arg3 - ... Argn Scalar Argument1 Argument2 Result Scalar and Array Argument1 Argument2 Result Array and Array Argument1 Argument2 Result 1 Argument [B1,1 , B1,2 , B1,3 ... B1,n] [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1
-

B1,1 B2,1 B1,1 - B2,1

B1,1 [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1


-

B2,1 , B1,1

B2,2 , B1,1

B2,3 ... B1,1

B2,n]

B2,1 , B1,2

B2,2 , B1,3

B2,3 ... B1,m

B2,n]

TIBCO Collaborative Information Manager Rulebase Guide

100

| Chapter 3

Operator and Character Reference

Scalar Argument1 Result Date Argument Date 1 Date 2 Result D1 D2 D1 - D2 : returns the difference in seconds. [B1,1 , B1,2 , B1,3 ... B1,n] B1,1
-

B1,2

B1,3 ...

B1,n

Description: Example of operator minus on numbers:


<op func="minus"> <const type="number">10</const> <const type="number">2</const> </op>

Example of operator minus on dates:


<op func="minus"> <var>SESSION/DATE</var> <var>OPERATION_DATE</var> </op>

mult multiplies values


Synopsis: <op func="mult"> Arguments: 1...n numeric expressions. Returns: Calculated numerical Arg1 * Arg2 * Arg3 * ... Argn Scalar Argument1 Argument2 Result Scalar and Array B1,1 B2,1 B1,1 * B2,1

TIBCO Collaborative Information Manager Rulebase Guide

Math Operators 101

Scalar Argument1 Argument2 Result Array and Array Argument1 Argument2 Result 1 Argument Argument1 Result [B1,1 , B1,2 , B1,3 ... B1,n] B1,1
*

B1,1 [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1


*

B2,1 , B1,1

B2,2 , B1,1

B2,3 ... B1,1

B2,n]

[B1,1 , B1,2 , B1,3 ... B1,n] [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1
*

B2,1 , B1,2

B2,2 , B1,3

B2,3 ... B1,m

B2,n]

B1,2

B1,3 ...

B1,n

Description:
<op func="mult"> <const type="number">10</const> <const type="number">2</const> </op>

percent computes percentage


Synopsis:< o p
func="percent"> <op func="percent" round="<n>"> <!-- replace n with the actual number to use for rounding -->

Arguments: 1...n numeric expressions. Returns: Calculated numerical (Arg2 - Arg1) / Arg1 Division by 0 returns null. By default results are rounded to 8 decimal places. Scalar Argument1 B1,1

TIBCO Collaborative Information Manager Rulebase Guide

102

| Chapter 3

Operator and Character Reference

Scalar Argument2 Result Scalar and Array Argument1 Argument2 Result Array and Array Argument1 Argument2 Result 1 Argument Argument1 Result [B1,1 , B1,2 , B1,3 ... B1,n] B1,1
%

B2,1 B1,1 % B2,1

B1,1 [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1


%

B2,1 , B1,1

B2,2 , B1,1

B2,3 ... B1,1

B2,n]

[B1,1 , B1,2 , B1,3 ... B1,n] [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1
%

B2,1 , B1,2

B2,2 , B1,3

B2,3 ... B1,m

B2,n]

B1,2

B1,3 ...

B1,n

Description:
<op func="percent"> <const type="number">10</const> <const type="number">2</const> </op>

<op func="percent" round="4"> <const type="number">1</const> <const type="number">3</const> </op>

plus calculates addition of values


Synopsis: < o p
func="plus"> <op func="plus" round="<n>"> <!-- n is the number of decimal places to round to -->

Arguments: 1...n numeric expressions.

TIBCO Collaborative Information Manager Rulebase Guide

Math Operators 103

Returns: Calculated numerical Arg1 + Arg2 + Arg3 +... Argn Scalar Argument1 Argument2 Result Scalar and Array Argument1 Argument2 Result Array and Array Argument1 Argument2 Result 1 Argument Argument1 Result [B1,1 , B1,2 , B1,3 ... B1,n] B1,1
+

B1,1 B2,1 B1,1 + B2,1

B1,1 [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1


+

B2,1 , B1,1

B2,2 , B1,1

B2,3 ... B1,1

B2,n]

[B1,1 , B1,2 , B1,3 ... B1,n] [B2,1 , B2,2 , B2,3 ... B2,n] [B1,1
+

B2,1 , B1,2

B2,2 , B1,3

B2,3 ... B1,m

B2,n]

B1,2

B1,3 ...

B1,n

Description:
<op func="plus"> <const type="number">10</const> <const type="number">2</const> </op>

round rounds to a defined set of decimal places


Synopsis: < o p
func="round">

TIBCO Collaborative Information Manager Rulebase Guide

104

| Chapter 3

Operator and Character Reference

Arguments: Argu ment 1 2 Use number(s) to round number of decimal places to round to rounding method. Type number or array of numbers number Comment if array, then round each entry in the array. optional. Default to 0. String optional. Default is HALF_UP. See description below. The rounding methods available are as follows (they are available from java.math.BigDecimal class): Rounding Method CEILING Comment Rounding mode to round towards positive infinity. If the BigDecimal is positive, behaves as for ROUND_UP; if negative, behaves as for ROUND_DOWN. Note that this rounding mode never decreases the calculated value. Rounding mode to round towards zero. Never increments the digit prior to a discarded fraction (i.e., truncates). Note that this rounding mode never increases the magnitude of the calculated value. Rounding mode to round towards negative infinity. If the BigDecimal is positive, behave as for ROUND_DOWN; if negative, behave as for ROUND_UP. Note that this rounding mode never increases the calculated value. Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down. Behaves as for ROUND_UP if the discarded fraction is > .5; otherwise, behaves as for ROUND_DOWN.

DOWN

FLOOR

HALF_DOWN

TIBCO Collaborative Information Manager Rulebase Guide

Math Operators 105

Rounding Method HALF_EVEN

Comment Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor. Behaves as for ROUND_HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for ROUND_HALF_DOWN if it's even. Note that this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations. Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up. Behaves as for ROUND_UP if the discarded fraction is >= .5; otherwise, behaves as for ROUND_DOWN. Note that this is the rounding mode that most of us were taught in grade school. Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. If this rounding mode is specified on an operation that yields an inexact result, an ArithmeticException is thrown. Rounding mode to round away from zero. Always increments the digit prior to a non-zero discarded fraction. Note that this rounding mode never decreases the magnitude of the calculated value.

HALF_UP

UNNECESSARY

UP

Returns: Numbers rounded to appropriate number of decimal places. Description:


<assign> <var>RES20</var> <op func="round"> <var>NUM13</var> <const type="number">2</const> <const type="string">HALF_UP</const> </op> </assign>

TIBCO Collaborative Information Manager Rulebase Guide

106

| Chapter 3

Operator and Character Reference

Other Operators

checkdigit
Synopsis: <op func=checkdigit> Arguments: 1 checkdigit type, see table, 2 input value. Returns: Input value + checkdigit CheckDigit Type EAN/UCC-8 UPC-11 UCC-12 or UPC-12 EAN/UCC-13 or UPC-13 or GLN EAN/UCC-14 or UPC-14 or GTIN B.O.L. S.S.C.C. Description: Checks the number of digits in an attribute (GTIN). For example:
<op func="checkdigit"> <const type="string">14</const> <var>GTIN</var> </op>

Keyword 8 11 12 13, GLN 14, GTIN BOL, B.O.L. SSCC, S.S.C.C.

The same example can be rewritten as:


<op func="checkdigit"> <const type="string">GTIN</const> <var>GTIN</var> </op>

TIBCO Collaborative Information Manager Rulebase Guide

Other Operators 107

count count number of (non-null, non-false) entries in array


Synopsis: <op func="count"> Arguments: 1 : array of values (or single value). Returns: Number of entries in array that are not null and not false. Description: Returns the count of non-null entries in an array.
<op func="count"> <var>CHILDCITIES</var> </op>

This function goes through an array and counts the number of non-null, non-False entries. For example, you might want to check whether a parent field exists, or if a child has a CREDITCARD payment method. If the count function returns 1 or greater, the condition is assumed to be true.
<condition> <op func="count"> <eq> <const type="string">CREDITCARD</const> <var>CHILDRECORDS/PAYMENT_METHOD</var> </eq> </op> </condition>

distinct returns distinct values


Synopsis: <op func="distinct"> Arguments: 1 : array of values. Returns: Array with duplicate values removed. Description:
<op func="distinct"> <var>CHILDCITIES</const> </op>

TIBCO Collaborative Information Manager Rulebase Guide

108

| Chapter 3

Operator and Character Reference

When getting values from an array, remove duplicate values. For example, used in conjunction with the count function, you can check if a value is unique within a set of records:
<check> <explanation>UOM of Siblings must not be the same.</explanation> <eq> <op func="count"> <var>SIBLING_REL/UOM</var> </op> <op func="count"> <op func="distinct"> <var>SIBLING_REL/UOM</var> </op> </op> </eq> </check>

filter filter a list of records


Synopsis: <op func="filter"> Arguments: 1 : array of records, 2: selection criteria. Returns: Array of records that match filter criteria. Description: The filter operator takes an array of records and extracts the ones that match the filter criteria. In the sample below, for records with P E R I S H A B L E = Y E S and where the child record count is greater than 1, S T O R A G E _ T E M P E R A T U R E is assigned a value of 20.56. If no record is present with P E R I S H A B L E = Y E S , no value is assigned to S T O R A G E _ T E M P E R A T U R E .
<?xml version="1.0" encoding="UTF-8"?> <rulebase metaversion="1.0"> <name>Repository Validations</name> <description>Repository Validations</description> <constraint> <name>filterFunction</name> <description>filterFunction.</description> <declare> <var>CHILD_RECORDS</var> <link type="relationship_record"> <literal>Contains</literal> </link> </declare> <usefor> <var>STORAGE_TEMPERATURE</var>

TIBCO Collaborative Information Manager Rulebase Guide

Other Operators 109

</usefor> <condition> <and> <undefined> <var/> </undefined> <op func="count"> <assign> <var>PERISHABLE_LIST</var> <op func="filter"> <var>CHILD_RECORDS</var> <condition> <eq> <var>PERISHABLE</var> <const type="string">YES</const> </eq> </condition> </op> </assign> </op> </and> </condition> <action> <assign> <var>STORAGE_TEMPERATURE</var> <const type="string">20.56</const> </assign> </action> </constraint> </rulebase>

lookup lookup value in database


Synopsis: <op func="lookup"> Arguments: 1 expression to look up; 2 table expression. First column is used to lookup value, second column is the value returned. Returns: The corresponding value in the database or null if not found. Description: The following example looks up the value of UOM in datasource UOMCODES in column VALUE, and returns the value in column CODE. The returned value is then assigned to variable UOM_CODE. The result of lookup can be used in other functions.
<assign> <var>UOM_CODE</var>

TIBCO Collaborative Information Manager Rulebase Guide

110

| Chapter 3

Operator and Character Reference

<op func="lookup"> <var>UOM</var> <table source="datasource"> <const type="string">UOMCODES</const> <const type="string">VALUE</const> <const type="string">CODE</const> </table> </op> </assign>

max maximum value


Synopsis: <op func="max"> Arguments: 1 .. n: single or array values. Returns: Maximum value encountered. Nulls are ignored. Description:
<op func="max"> <var>CHILDPRICES</var> </op>

This function goes through all its arguments (arrays are expanded) and returns the maximum value found. Null values are ignored.

min minimum value


Synopsis: <op func="min"> Arguments: 1 .. n : single or array values. Returns: Minimum value encountered. Nulls are ignored. Description:
<op func="min"> <var>CHILDPRICES</var> </op>

This function goes through all its arguments (arrays are expanded) and returns the minimum value found. Null values are ignored.

TIBCO Collaborative Information Manager Rulebase Guide

Other Operators 111

nvl substitute non-NULL value


Synopsis: <op func="nvl"> Arguments: 2 expressions Returns: If expression1 is null, returns expression2; otherwise it returns expression1. Description: The nvl function offers a concise way to return or substitute a non-NULL value if the specified value is NULL.
<op func=nvl> <var> expression1</var> <const type="number">expression2</const> </op>

Example:
<?xml version="1.0" encoding="UTF-8"?> <rulebase metaversion="0.1"> <!-- rulebase metaversion="0.1" --> <name>rbtest1</name> <description>Test Rulebase.</description> <declare> <var>CONTAINSREL</var> <link type="relationship"> <literal>CONTAINS</literal> </link> </declare> <declare> <var>CONTAINS_RECORD</var> <link type="relationship_record"> <literal>CONTAINS</literal> </link> </declare> <constraint> <name>Add up weight1</name> <description>Test roll-up of all child records gross weights and assign to parent gross weight.</description> <usefor> <var>NETWEIGHT</var> </usefor> <action> <assign> <var>NETWEIGHT</var> <op func="plus"> <op func="mult"> <var>CONTAINSREL/QUANTITY</var> <op func="nvl"> <var>CONTAINS_RECORD/NETWEIGHT</var>

TIBCO Collaborative Information Manager Rulebase Guide

112

| Chapter 3

Operator and Character Reference

<const type="number">100</const> </op> </op> </op> </assign> </action> </constraint> </rulebase>

sequence returns a database sequence


Synopsis: < o p
func="sequence">

Arguments: 1 : name of the database sequence. Returns: Next sequence value converted to string. Description:
<op func="sequence"> <const type="string">MQ_SEQUENCE_1</const> </op>

To automatically generate names for records you often want to have access to, a sequential number generator is defined in the database. This function lets you get the next value from a database sequence. Note that care must be given to only call this function once, otherwise too many sequences will be generated. One way to ensure this is to put it into the n e w r e c o r d . x m l file, not the general repository validation file.
<constraint> <name>SequenceGenerator</name> <description>Generate a sequence</description> <action> <assign> <var>SEQ</var> <op func="concat"> <const type="string">HS-</const> <op func="pad"> <op func="sequence"> <const type="string">MQ_SEQUENCE_1</const> </op> <const type="number">9</const> <const type="string">0</const> </op> <const type="string">-JAL</const> </op> </assign> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Other Operators 113

strip removes all null values from an array


Synopsis: < o p
func="strip">

Arguments: 1 : array. Returns: Array with all null values removed. Description:
<op func="strip"> <var>CHILDWEIGHT</var> </op>

When getting values from a records child, you might want to strip out all null values before doing a computation. This will ensure that the result of the computation does not become null due to the array containing a null value. For example, if the gross weights of a child record were [8.2, 5.2, null, 9.2] then doing a <op func=plus> on this array would yield null. However, if you strip out null values first, the result is the expected value:
<op func="plus"> <op func="strip"> <var>CHILDWEIGHT</var> </op> </op>

synchstatus
Synopsis: <op func="synchstatus"> Arguments: Argument 1 2 Use Marketplace Operation Type string string Comment Marketplace/Datapool Organization name. Valid values are: ADD (default) PUBLISH LINK COMMIT

TIBCO Collaborative Information Manager Rulebase Guide

114

| Chapter 3
Returns:

Operator and Character Reference

true - if this record has ever been Added/Published/Linked/Committed to this Marketplace/Datapool. false - otherwise. Example:
<!-- no operation is defined. Will check for ADD. -->

<op func="synchstatus"> <const type="string">1Sync</const> </op> <!-- explicitly defined operation. --> <op func="synchstatus"> <const type="string">UCCnet</const> <const type="string">PUBLISH</const> </op>

SyncOperationAttribute used to find the operation date (GDSN Only)


It allows you to get the latest sync date for the given Operation (only ADD is supported), Datapool, or Trading Partner (optional). Its syntax :
<var>OPERATION_DATE</var> <op func="SyncOperationAttribute"> <const type="string">ADD</const> <const type="string">WWRE</const> <!--const type="string">Trading Partner Name</const-->

</op> For this function, three in parameters can be specified. The second parameter is the marketplace or datapool name. This is optional, if not specified, the rulebase will evaluate it. The third parameter is the trading partner name (and is not mandatory). If not specified, it will look for all TP; if specified, it will look for the operation for the given TP.

validate_checkdigit - validates checkdigit


Synopsis: < o p
func=validate_checkdigit>

Arguments: 1 checkdigit type, see table, 2 input value.


TIBCO Collaborative Information Manager Rulebase Guide

Other Operators 115

Returns: True - string contains valid checkdigit. False - checkdigit is not correct. CheckDigit Type GTIN-8 GTIN-12 GTIN-13 GTIN-14 S.S.C.C. Description:
<op func="validate_checkdigit"> <var>GTIN-14</var> <var>GTIN</var> </op>

Number of Digits 8 12 13 14 18

TIBCO Collaborative Information Manager Rulebase Guide

116

| Chapter 3

Operator and Character Reference

Syntax for Expressions


The general syntax of an expression consists of an operator tag followed by arguments, such as the following:
<eq> <var>A</var> <var>B</var> </eq>

In this example, a logical expression "A is equal to B" is evaluated. The arguments to a function can be var (variable) tags, const (constant) values, logical expressions, or built-in functions.

Special Characters
Since validation is stored in XML, you must use escaped version special characters for them to be read correctly. The following table lists special characters and their escaped versions. Special Character < & (single quote) " (double quotes) Escaped Version &lt; &amp; &apos; &quot;

const
The const tag defines a constant, and the data type is defined by the t y p e attribute. The following is a list of valid data types: Datatype <const type="boolean"> <const type="date"> <const type="number"> <const type="string"> Description TRUE or FALSE. Date constant. Number constant. String constant.

TIBCO Collaborative Information Manager Rulebase Guide

Syntax for Expressions 117

The following is an example.


<const type="string">0980</const> <const type="number">1</const>

To define a list of values, use the sep tag inside the const tag, as follows:
<enum> <const type="string">Soup<sep/>Cookies<sep/>Pasta</const> </enum>

var
In an expression, the var tag refers to a variables value. If you use an empty var tag, then it refers to the variable in the usefor section. This is an easy way to reuse the same rule for multiple attributes. You list out all the attributes in the usefor section, and then use the var tag when you need to refer to the value of the currently executing variable. The following is an example.
<constraint> <name>Valid Numbers</name> <description>Valid non-negative number</description> <usefor> <var>UNITPRICE</var> <var>PREPRICED_AMOUNT</var> <var>SIZE</var> </usefor> <action> <check> <explanation>Has to be a non-negative number</explanation> <match> <var> <const type="string">/^((\d+(\.\d*)?)|(\d*\.\d+))$/</const> </match> </check> </action> </constraint>

Undefined (Null) Values


If a condition contains a variable with a null value, the condition is not evaluated and any associated action is skipped. Similarly, if an action contains a variable with a null value, it is not executed. The exception to this is when either expression uses defined or undefined tags. With these functions you can check if a variable has a value and take action appropriately. The following is such an example:
<undefined> <var>PRODUCTHEIGHT</var> </undefined>

TIBCO Collaborative Information Manager Rulebase Guide

118

| Chapter 3

Operator and Character Reference

Regular Expressions
In a regular expression, most characters map to themselves. Such as the expression /TIBCO/ matching any string containing TIBCO.

Literal Characters
There are some characters, however, with special usage within a regular expression and their escaped versions must be used. This is done through the use of a backward slash (\), causing them to be used as literal characters. The following table lists special use literal characters and their meanings. Character \f \n \r \t \v \/ \\ \. \* \+ \? \| \( \) \[ \] Description Form feed New line Carriage return Tab Vertical tab Literal / Literal \ Literal . Literal * Literal + Literal ? Literal | Literal ( Literal ) Literal [ Literal ]

TIBCO Collaborative Information Manager Rulebase Guide

Regular Expressions 119

Character \{ \} \xxx \xnn \cX

Description Literal { Literal } ASCII character of octal value xxx ASCII character with hex number nn ASCII character ^X

Character Classes
There are sets of characters and position characters that can be used in conjunction with literal characters. They include the following: Individual literal characterscombine into character classes when placed between square brackets. A character class matches any one character contained within the brackets. For example, /[abc]/ matches a, b, or c. Negated character classesmatch any character not inside the brackets. These are specified by placing a caret (^) as the first character. For example, /[^abc]/ matches any character except a, b, or c. Ranges of charactersspecified with a hyphen (-). For example, /[a-z]/ matches all lowercase characters. All alphanumeric characters are matched in this example: /[a-zA-Z0-9]/.

Position Characters
Position characters specify the position in a string. The most useful of these are the caret (^), which matches the beginning of a string, and the dollar sign ($) which matches the end of the string. The following table provides a list of regular expression character classes and their descriptions. Character [...] [^...] . Description Any one character between the brackets. Any one character not between the brackets. Any character except newline; equal to [^\n].

TIBCO Collaborative Information Manager Rulebase Guide

120

| Chapter 3

Operator and Character Reference

Character \w \W \s \S \d \D [\b] ^ $ \b \B

Description Any word character; equal to [a-zA-Z0-9]. Any non-word character; equal to [^a-zA-Z0-9]. Any whitespace character; equal to [\t\n\f\r\v]. Any non-whitespace characters; equal to [^\t\n\f\r\v]. Any digit; equal to [0-9]. Any character other than a digit; equal to [^0-9]. A literal backspace; a special case. The beginning of a string. The end of a string. Word boundary. Not a word boundary.

Repetition Characters
Repetition characters specify how many characters are matched. Character {n,m} {n,} {n} ? + * Description Match the previous item at least n times, but no more than m times. Match the previous item no more than n times. Match the previous item exactly n times. Match zero or one occurrence; equal to {0,1}. Match one or more occurrences; equal to {1,}. Match zero or more occurrences; equal to {0,}.

TIBCO Collaborative Information Manager Rulebase Guide

Regular Expressions 121

Alternation, Grouping, Reference


The following special characters separate alternatives, group items, and provide references: Pipe (|) character Separates alternatives. For example, /ab|cd|ef/ matches either ab or cd or ef. Parentheses Group items as a single unit so that they can be acted on by the repetition operators. For example, /(ab|cd)+/ matches one or more repetitions of the strings ab or cd. Backslash followed by a number Matches the same characters that were matched in group number n. Description Match either subexpression. Group several items. Match the same characters matched when group number n was first matched. Groups are subexpressions within (possibly nested) parenthesis. Group numbers are assigned by counting left parentheses from left to right.

Character | (...) \

TIBCO Collaborative Information Manager Rulebase Guide

122

| Chapter 3

Operator and Character Reference

Built-in Functions
The built-in function is called with the following syntax:
<op func="funcname"></op>

Child values are considered arguments to the function. In turn, each function returns a result value which can be used by another function.

TIBCO Collaborative Information Manager Rulebase Guide

Custom Functions 123

Custom Functions
In addition to the built-in functions, you can write your own functions. During rulebase execution, if an unknown function is encountered, the application looks for the custom function definition from RulebaseCustomFunction.class. It is located in the following directory:
$MQ_COMMON_DIR/<internal_enterprise_name>/rulebase

Creating a Custom Function


1. Copy the sample R u l e b a s e C u s t o m F u n c t i o n . j a v a file from $MQ_HOME/common/standard/rulebase. This class has a predefined method, e x e c C u s t o m F u n c t i o n , with the following signature.
public HashMap execCustomFunction(HashMap args)

This method takes one argument, which is a HashMap and expects HashMap in return. The following is a list of predefined constants that can be used: Input HashMap The input HashMap has the following entries: Rulebase Constant FUNCTION_NAME FUNCTION_ARGUMENTS Equivalent String Constant FUNC_NAME FUNC_ARGUMENTS Description The name of the function to execute. ArrayList of input arguments.

FUNCTION_ARGUMENTS are passed in an ArrayList with the same order as that specified in the rulebase constraint. The following is a list of data types in the rulebase and corresponding Java types: Rulebase Type string number Java Type String Long BigDecimal

TIBCO Collaborative Information Manager Rulebase Guide

124

| Chapter 3

Operator and Character Reference

Rulebase Type boolean date array Output HashMap

Java Type Boolean java.util.Date java.util.ArrayList

The output HashMap has the following entries: Rulebase Constant


FUNCTION_SUCCESS

Equivalent String Constant


FUNC_SUCCESS

Description Set to Boolean. TRUE, if function found and executed successfully else Boolean. FALSE.

FUNCTION_RETURN_VALUE FUNCTION_ERROR_MESSAGE

FUNC_RETURN_VALUE FUNC_ERROR_MESSAGE

Output of the function. Error message in case error occurred in function execution. This error message is logged in the $ M Q _ H O M E / e l i n k . l o g file.

2. Implement custom function as a separate method and call it from e x e c C u s t o m F u n c t i o n depending upon the F U N C T I O N _ N A M E passed in. For example:
if (funcName.equals("checkNumber")) { retValue = checkNumber(inArgs); }

3. Compile the R u l e b a s e C u s t o m F u n c t i o n . j a v a . For example:


javac RulebaseCustomFunction.java -classpath $MQ_HOME/lib/mq/AllECMClasses.jar:$MQ_HOME/lib/external/log4j-1 .2.14.jar

Ensure that $ M Q _ H O M E / l i b / m q / A l l E C M C l a s s e s . j a r and $ M Q _ H O M E / l i b / e x t e r n a l / l o g 4 j - x . x . j a r are in the classpath for compilation.

TIBCO Collaborative Information Manager Rulebase Guide

Custom Functions 125

4. Copy the R u l e b a s e C u s t o m F u n c t i o n . c l a s s file to


$MQ_COMMON_DIR/<internal_enterprise_name>/rulebase

folder and

restart the application server. Custom Rulebase Class Example For an example, refer to
$MQ_HOME/common/standard/rulebase/RulebaseCustomFunction.java.

TIBCO Collaborative Information Manager Rulebase Guide

126

| Chapter 3

Operator and Character Reference

TIBCO Collaborative Information Manager Rulebase Guide

| 127
Chapter 4

Rulebase Patterns

This chapter deals with various rulebase patterns.

Topics
Non-Negative Numbers, page 128 Dependent Variables, page 129 Dependent Drop-Down Values, page 130 Specify Data Sources, page 133 Checking Child Records for Value, page 134

TIBCO Collaborative Information Manager Rulebase Guide

128

| Chapter 4

Rulebase Patterns

Non-Negative Numbers
The following rule pattern matches any number of the form 1, 1., 1.0, 0.1,.1.
<constraint> <name>ValidNumbers</name> <description>Valid non-negative number.</description> <usefor> <var>UNITPRICE</var> </usefor> <action> <check> <explanation>Has to be a non-negative number.</explanation> <match> <var/> <const type="string">/^((\d+(\.\d*)?)|(\d*\.\d+))$/</const> </match> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Dependent Variables 129

Dependent Variables
In this scenario, if one variable is defined, another variable must also be defined. For example, if size is specified, its unit must also be specified.
<constraint> <name>SIZE_UOM</name> <description>See that they are defined.</description> <usefor> <var>SIZE_UOM</var> </usefor> <action> <check> <explanation>Units need to be defined if size specified.</explanation> <and> <defined> <var>SIZE</var> </defined> <defined> <var>SIZE_UOM</var> </defined> </and> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

130

| Chapter 4

Rulebase Patterns

Dependent Drop-Down Values


This scenario shows how the value of one menu item (CATEGORYX2) display depends on another (CATEGORYX1). The last rule illustrates how to specify data sources. These examples may be used as templates for custom repository constraints.

These examples establish a category with three subcategories. The drop-down menu displayed is dependent upon the menu option (subcategory) selected. When you choose Soup, Cookies, or Pasta, their related options are shown. Soup Classic, Chunky, Light Cookies Sugar, Chocolate, Fudge Pasta Spaghetti, Fettuccine, Macaroni

Create a Category With Three Subcategories


<!-- The following constraints are examples of the types of constraints that can be specified. They can be used as templates for custom repositories. --> <constraint> <name>CategoryName</name> <description>Category Name has to be a set of valid values.</description> <usefor> <var>CATEGORYX1</var> </usefor> <action> <select novalue="no"> <enum> <const type="string">Soup<sep/>Cookies<sep/>Pasta</const> </enum> </select> </action> </constraint>

Create First Subcategory: Soup


<constraint> <name>SubCategorySoup</name> <description>Sub Category for Soup</description> <usefor> <var>CATEGORYX2</var> </usefor> <condition>

TIBCO Collaborative Information Manager Rulebase Guide

Dependent Drop-Down Values 131

<eq> <var>CATEGORYX1</var> <const type="string">Soup</const> </eq> </condition> <action> <select novalue="no"> <enum> <const type="string">Classic</const> <const type="string">Chunky</const> <const type="string">Light</const> </enum> </select> </action> </constraint>

Create Second Subcategory: Cookies


<constraint> <name>SubCategoryNameCookies</name> <description>Sub Category for Cookies</description> <usefor> <var>CATEGORYX2</var> </usefor> <condition> <eq> <var>CATEGORYX1</var> <const type="string">Cookies</const> </eq> </condition> <action> <select novalue="no"> <enum> <const type="string">Sugar</const> <const type="string">Chocolate Chip</const> <const type="string">Fudge</const> </enum> </select> </action> </constraint>

Create Third Subcategory: Pasta


<constraint> <name>SubCategoryNamePasta</name> <description>Sub Category for Pasta</description> <usefor> <var>CATEGORYX2</var> </usefor> <condition> <eq> <var>CATEGORYX1</var> <const type="string">Pasta</const> </eq> </condition>

TIBCO Collaborative Information Manager Rulebase Guide

132

| Chapter 4

Rulebase Patterns

<action> <select novalue="no"> <enum> <const type="string">Spaghetti</const> <const type="string">Fettuccine</const> <const type="string">Macaroni</const> </enum> </select> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Specify Data Sources 133

Specify Data Sources


The following is an example of using a datasource to specify the values of a drop-down list. The datasource name is DSX1. The database value is stored in a column called VALUE and the text of the message is stored in a column called DESCRIPTION.
<constraint> <name>DataSourceValues</name> <description>Get values from data source</description) <usefor> <var>DATASOURCEX1</var> </usefor> <action> <select novalue="no"> <table source="datasource"> <const type="string">DSX1</const> <const type="string">VALUE</const> <const type="string">DESCRIPTION</const> </table> </select> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

134

| Chapter 4

Rulebase Patterns

Checking Child Records for Value


Below is an example of requiring an attribute to be present. (MATERIAL_CODE_AGENGY) if one of the children has a certain value. First, declare 2 variables. RELA_REL points to all the records pointed at by the RelA relationship. The RELA_LIST variable is a local variable which will store the children that contain a value. This is not necessary, but the list can be used in the <information> tag. The list of values will then show up in the validation page of the record.
<declare> <var>RELA_REL</var> <link type="relationship_record"> <literal>RelA</literal> </link> </declare> <declare usage="local"> <var>RELA_LIST</var> </declare>

The condition checks that the RECORD_TYPE is correct and that the value is not already defined. Through this optimization, looking at all the children can be skipped if the variable is already defined. Looking at the children is an expensive operation, so if it is known that MATERIAL_CODE_AGENCY is set to the correct value, the check can be skipped altogether.
<constraint> <name>MaterialCodeAgency</name> <description>Material Code Agency is mandatory if LevelA has Coupon Family Code set to SI.</description> <usefor> <var>MATERIAL_CODE_AGENCY</var> </usefor> <condition> <and> <eq> <var>RECORD_TYPE</var> <const type="string">LEVEL1</const> </eq> <undefined> <var/> </undefined> </and> </condition> <action> <check> <explanation>Material Code Agency is mandatory if LevelA has Coupon Family Code set to SI.</explanation> <information> <var>RELA_LIST</var>

TIBCO Collaborative Information Manager Rulebase Guide

Checking Child Records for Value 135

</information> <eq> <const type="number">0</const> <op func="count"> <assign> <var>RELA_LIST</var> <op func="filter"> <var>RELA_REL</var> <condition> <eq> <var>COUPON_FAMILY_CODE</var> <const type="string">SI</const> </eq> </condition> </op> </assign> </op> </eq> </check> </action> </constraint>

Below is an example of an actual run of the rule (obtained by setting System Debugging > RuleBase Debug Mode to true in the Configurator). The test fails because 2 children exist that have the value.
<constraint> <name>MaterialCodeAgency</name> <usefor> <var>MATERIAL_CODE_AGENCY</var> </usefor> <condition> <and> <eq> <var>RECORD_TYPE<result><![CDATA[LEVEL1]]></result> </var> <const type="string">LEVEL1</const> <result><![CDATA[true]]></result> </eq> <undefined> <var> <result/> </var> <result><![CDATA[true]]></result> </undefined> <result><![CDATA[true]]></result> </and> </condition> <action> <check> <explanation>Material Code Agency is mandatory if LevelA has Coupon Family Code set to SI.</explanation> <information> <var>RELA_LIST<result><![CDATA[[k5-A-1/1/1, k5-A2/1/1]]]></result> </var> </information>

TIBCO Collaborative Information Manager Rulebase Guide

136

| Chapter 4

Rulebase Patterns

<eq> <const type="number">0</const> <op func="count"> <assign> <var>RELA_LIST</var> <op func="filter"> <var>RELA_REL</var> <condition> <eq> <var>COUPON_FAMILY_CODE</var> <const type="string">SI</const> </eq> </condition> <result><![CDATA[[k5-A-1/1/1, k5-A2/1/1]]]></result> </op> </assign> <result><![CDATA[2]]></result> </op> <result><![CDATA[false]]></result> </eq> <result><![CDATA[false]]></result> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

| 137
Chapter 5

Rulebase Examples

This section has extensive rulebase code examples divided into functional segments (modules) to call attention to each of their functions.

Topics
Rulebase Header, page 139 Specify Mandatory Attributes, page 140 Access Modes, page 141 Check for a Value (GTIN), page 142 CATALOG_NAME Variable, page 143 Specify Valid Numbers, page 144 Assign TRUE or FALSE, page 145 Check Values of Related Attributes, page 146 Check Values of Attributes Related to MINIMUM_SHIP, page 147 Check Code Length, page 148 Validate Code, page 149 Validate Temperature Values, page 150 Skip First Pass, page 152 Specify Valid Values, page 154 Check for DIMENSIONUOM, page 155 Specify Types For a Drop-Down Menu, page 156 Check Length of UPC Code, page 157 Validate Against First Order Date, page 159 Validate Against First Ship Date, page 160 Validate Net Weight, page 161

TIBCO Collaborative Information Manager Rulebase Guide

138

| Chapter 5

Rulebase Examples

Calculate Volume, page 162 Specify New Size, page 163 Propagate Attribute Value to Children, page 164

TIBCO Collaborative Information Manager Rulebase Guide

Rulebase Header 139

Rulebase Header
< ! - - r u l e b a s e m e t a v e r s i o n = ?0 . 1 ?> <name>Client Validations</name> <description>Implements client validations</description> <declare> <var>CONTAINSLINK</var> <link type="relationship_record"> <literal>CONTAINS</literal> </link> </declare>

TIBCO Collaborative Information Manager Rulebase Guide

140

| Chapter 5

Rulebase Examples

Specify Mandatory Attributes


<constraint> <name>Mandatory</name> <description>Mandatory attributes</description> <usefor> <var>PRODUCTID</var> <var>SHORTDESC</var> </usefor> <action> <check> <explanation>it is a mandatory attribute</explanation> <defined> <var/> </defined> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Access Modes 141

Access Modes
Mode: allow_merge In this example, if the value of RECORD_TYPE is CUST, the record data is merged with the previous version's data. That is, previous version data is used in the final merged version. RECORD_TYPE will have the attribute value of the previous version. Previous version will be selected based on the input parameter of the record merge activity.
<constraint> <name>AllowMergeForRecordTypeCUST</name> <description>Allow merge if value of RECORD_TYPE is CUST.</description> <condition> <eq> <var>RECORD_TYPE</var> <const type="string">CUST</const> </eq> </condition> <action> <access mode="allow_merge"/> </action> </constraint> </rulebase>

Mode: skip_merge In this example, if the value of UOM is CASE, the record data is not merged with the target record. The data from the source record is used in the final merged version.
<constraint> <name>SkipMergeForUOMCASE</name> <description>Skip merge if value of UOM is CASE.</description> <condition> <eq> <var>UOM</var> <const type="string">CASE</const> </eq> </condition> <action> <access mode="skip_merge"/> </action> </constraint> </rulebase>

TIBCO Collaborative Information Manager Rulebase Guide

142

| Chapter 5

Rulebase Examples

Check for a Value (GTIN)


<constraint> <name>GTIN</name> <description>GTIN checks</description> <usefor> <var>GTIN</var> </usefor> <action> <check> <explanation lang="en">GTIN has to be 14 numeric characters </explanation> <match> <var/> <const type="string">/^\d{14}$/</const> </match> </check> <check> <explanation lang="en">GTIN cannot start with 0980,0981,0982, 0983,0984,0985,0986,098,0988,099</explanation> <not> <or> <in> <op func="substring"> <var>GTIN</var> <const type="number">0</const> <const type="number">4</const> </op> <const type="string">0980</const> <const type="string">0981</const> <const type="string">0982</const> <const type="string">0983</const> <const type="string">0984</const> <const type="string">0985</const> <const type="string">0986</const> <const type="string">0988</const> <const type="string">0989</const> </in> <in> <op> <var>GTIN</var> <const type="number">0</const> <const type="number">3</const> </op> <const type="string">098</const> <const type="string">099</const> </in> </or> </not> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

CATALOG_NAME Variable 143

CATALOG_NAME Variable
The CATALOG_NAME variable gets the name of the repository for the current record. This is useful when the rulebase in the ApplyRulebase activity of import workflow has constraints that need to be applied depending on the repository name. For example, while creating a cross-repository relationship on the CAT1 and CAT2 repositories, if the rulebase has one constraint that needs to be applied for only the CAT2 Repository, then you can use the CATALOG_NAME as follows:
<constraint> <name>ASSIGN_EXISTING_PRODUCT</name> <description>Assign the existing product</description> <condition> <eq> <var>CATALOG_NAME</var> <const type="string">CAT2</const> </eq> </condition> .......... .......... .......... </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

144

| Chapter 5

Rulebase Examples

Specify Valid Numbers


<constraint> <name>Valid Numbers</name> <description>Valid non-negative number</description> <usefor> <var>UNITPRICE</var> <var>PREPRICED_AMOUNT</var> <var>SIZE</var> <var>PRODUCTWIDTH</var> <var>PRODUCTHEIGHT</var> <var>PRODUCTDEPTH</var> <var>NETWEIGHT</var> <var>GROSSWEIGHT</var> <var>VOLUME</var> <var>TI</var> <var>HI</var> <var>MINIMUMORDER</var> <var>MAXIMUMORDER</var> <var>MINIMUM_SHIP</var> <var>MAXIMUM_SHIP</var> <var>ORDER_INCREMENT</var> <var>FLASHPOINT_TEMP1</var> <var>FLASHPOINT_TEMP2</var> <var>HAZMAT_NUM1</var> <var>HAZMAT_NUM2</var> <var>UNITS_PER_CONTAINER</var> <var>UNITS_PER_INNER_CONTAINER</var> </usefor> <action> <check> <explanation>Has to be a non-negative number</explanation> <match> <var/> <const type="string">/^((\d+(\.\d*)?)|(\d*\.\d+))$/</const> </match> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Assign TRUE or FALSE 145

Assign TRUE or FALSE


This example shows how to assign TRUE or FALSE drop down values to boolean type attributes.
<constraint> <name>TrueFalse</name> <description>TRUE or FALSE</description> <usefor> <var>HAZMATFLAG</var> <var>RECYCLEDMATERIALS</var> <var>FREIGHTINCFLAG</var> <var>PUNCHOUTENABLED</var> <var>DELETE</var> <var>CONSUMER_UNIT</var> <var>ORDERABLE</var> <var>PRIVATE</var> </usefor> <action> <select novalue="default"> <enum> <const type="string">TRUE</const> <const type="string">FALSE</const> </enum> </select> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

146

| Chapter 5

Rulebase Examples

Check Values of Related Attributes


This example shows how to check values of related attributes: MAXIMUMORDER, MINIMUMORDER and MAXIMUMSHIP.
<constraint> <name>MaximumOrder/name> <description>Relationships</description> <usefor> <var>MAXIMUMORDER</var> </usefor> <condition> <defined> <var>MAXIMUMORDER</var> </defined> </condition> <action> <check> <explanation>maximum order has to be greater than minimum order </explanation> <and> <defined> <var>MINIMUMORDER</var> </defined> <lt> <var>MINIMUMORDER</var> <var>MAXIMUMORDER</var> </lt> </and> </check> <check> <explanation>maximum order should be greater than maximum ship </explanation> <and> <defined> <var>MAXIMUM_SHIP</var> </defined> <gt> <var>MAXIMUM_SHIP</var> <var>MAXIMUMORDER</var> </gt> </and> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Check Values of Attributes Related to MINIMUM_SHIP 147

Check Values of Attributes Related to MINIMUM_SHIP


This example shows you how to check values of attributes related to MINIMUM_SHIP, namely MAXIMUMSHIP and MINIMUMORDER.
<constraint> <name>MinimumShip</name> <description>Check the values of related attributes of MinimumShip</description> <usefor> <var>MINIMUM_SHIP</var> </usefor> <condition> <defined> <var>MINIMUM_SHIP</var> </defined> </condition> <action> <check> <explanation>minimum ship has to be less than or equal to maximum ship </explanation> <and> <defined> <var>MAXIMUM_SHIP</var> </defined> <leq> <var>MINIMUM_SHIP</var> <var>MAXIMUM_SHIP</var> </leq> </and> </check> <check> <explanation>minimum ship has to be greater or equal to minimum order</explanation> <and> <defined> <var>MINIMUMORDER</var> </defined> <geq> <var>MINIMUM_SHIP</var> <var>MINIMUMORDER</var> </geq> </and> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

148

| Chapter 5

Rulebase Examples

Check Code Length


<constraint> <name>HazMatCodeLength</name> <description>Check HazMat code and description length</description> <usefor> <var>HAZMAT_CODE1</var> <var>HAZMAT_CODE2</var> <var>HAZMAT_DESCRIPTION1</var> <var>HAZMAT_DESCRIPTION2</var> </usefor> <action> <check> <explanation>Must be at least four characters</explanation> <geq> <op func="length"> <var/> </op> <const type="number">4</const> </geq> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Validate Code 149

Validate Code
<constraint> <name>HazMatCodeQualifier1</name> <description>Check HazMat code qualifier and class code validation</description> <condition> <defined> <var>HAZMAT_CODE_QUALIFIER1</var> </defined> </condition> <action> <check> <explanation>Hazmat Class code is mandatory if HAZMAT_CODE_QUALIFIER1 is defined</explanation> <defined> <var>HAZMAT_CLASS_CODE</var> </defined> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

150

| Chapter 5

Rulebase Examples

Validate Temperature Values


This example shows you how to validate temperature values, units and define drop down for temperature units.
<constraint> <name>FlashpointMax</name> <description>Validate maximum temperature</description> <usefor> <var>FLASHPOIONT_TEMP1</var> <var>FLASHPOIONT_TEMP2</var> </usefor> <action> <check> <explanation>Temperature must be less than 999</explanation> <leq> <var/> <const type="number">999</const> </leq> </check> </action> </constraint> <constraint> <name>FlashpointUnit1</name> <description>See that units are defined</description> <usefor> <var>FLASHPOIONT_UNITS1</var> </usefor> <action> <check> <explanation>If temperature is defined, units must be present </explanation> <or> <undefined> <var>FLASHPOIONT_TEMP1</var> </undefined> <defined> <var>FLASHPOIONT_UNITS1</var> </defined> </or> </check> </action> </constraint> <constraint> <name>FlashpointUnit2</name> <description>See that units are defined</description> <usefor> <var>FLASHPOIONT_UNITS2</var> </usefor> <action> <check> <explanation>If temperature is defined, units must be present </explanation> <or>

TIBCO Collaborative Information Manager Rulebase Guide

Validate Temperature Values 151

<undefined> <var>FLASHPOIONT_TEMP2</var> </undefined> <defined> <var>FLASHPOIONT_UNITS2</var> </defined> </or> </check> </action> </constraint> <constraint> <name>FlashpointUnitSelect</name> <description>Temperature drop-down menu</description> <usefor> <var>FLASHPOIONT_UNITS1</var> <var>FLASHPOIONT_UNITS2</var> </usefor> <action> <select novalue="default"> <enum col="2"> <const type="string">FA<sep/>Fahrenheit</const> <const type="string">CE<sep/>Celsius</const> <const type="string">KA<sep/>Kelvin</const> </enum> </select> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

152

| Chapter 5

Rulebase Examples

Skip First Pass


<?xml version="1.0" encoding="UTF-8"?> <rulebase metaversion="0.1"> <name>rbfirstpass_sample</name> <description>Rulebase to test first pass skip functionality.</description> <execution_directive first_pass="skip"/> <constraint> <name>test1</name> <description>Assign value to localvar</description> <condition> <undefined> <var>TESTINT</var> </undefined> </condition> <action> <assign> <explanation>Initializing TESTINT value...</explanation> <var>TESTINT</var> <const type='number'>1</const> </assign> </action> <action> <assign> <explanation>Incrementing TESTINT value...</explanation> <var>TESTINT</var> <op func='plus'> <var>TESTINT</var> <const type='number'>1</const> </op> </assign> </action> </constraint> </rulebase>

first_pass set to skip 1. Run sample rulebase with e x e c u t i o n _ d i r e c t i v e


first_pass

set to skip.

2. Define a new Repository and copy the sample rulebase in the catalog directory. 3. Modify the repository and create a new attribute, TESTINT, of type integer. 4. Click on the Add new record link. 5. Check the value of TESTINT; it should be initialized to 1. 6. Save the record and check the value of TESTINT. It should be 2.

TIBCO Collaborative Information Manager Rulebase Guide

Skip First Pass 153

first_pass set to required 1. Run sample rulebase with e x e c u t i o n _ d i r e c t i v e Required.


first_pass

set to

2. Define a new Repository and copy the sample rulebase in the catalog directory. 3. Modify the repository and create a new attribute, TESTINT, of type integer. 4. Click on the Add new record link. 5. Check the value of TESTINT; it should be initialized to 1. 6. Save the record and check the value for TESTINT. It should be 3. This is because rulebase was executed twice incrementing the TESTINT value twice.

TIBCO Collaborative Information Manager Rulebase Guide

154

| Chapter 5

Rulebase Examples

Specify Valid Values


<constraint> <name>HazMatNum</name> <description>Valid values for HazMatNum</description> <usefor> <var>HAZMAT_NUM1</var> </usefor> <action> <select novalue="default"> <enum> <const type="number">1</const> <const type="number">2</const> <const type="number">3</const> <const type="number">4</const> <const type="number">5</const> </enum> </select> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Check for DIMENSIONUOM 155

Check for DIMENSIONUOM


This example shows how to check for DIMENSIONUOM if linear attribute values are defined.
<constraint> <name>DIMENSIONSUOM</name> <description>See that dimensions are defined for linear values</description> <usefor> <var>DIMENSIONSUOM</var> </usefor> <action> <check> <explanation>Units need to be defined if linear dimensions are specified</explanation> <and> <or> <defined> <var>PRODUCTWIDTH</var> </defined> <defined> <var>PRODUCTHEIGHT</var> </defined> <defined> <var>PRODUCTDEPTH</var> </defined> </or> <defined> <var>DIMENSIONSUOM</var> </defined> </and> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

156

| Chapter 5

Rulebase Examples

Specify Types For a Drop-Down Menu


<constraint> <name>UPCTypes</name> <description>UPC_TYPE drop-down menu</description> <usefor> <var>UPC_TYPE</var> </usefor> <action> <select novalue="default"> <enum> <const type="string">UN</const> <const type="string">UP</const> <const type="string">UA</const> <const type="string">UD</const> <const type="string">UE</const> <const type="string">EN</const> <const type="string">UK</const> <const type="string">U2</const> <const type="string">UG</const> <const type="string">UH</const> <const type="string">UI</const> </enum> </select> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Check Length of UPC Code 157

Check Length of UPC Code


<constraint> <name>UPC12</name> <description>Check length of UPC code</description> <usefor> <var>UPC</var> </usefor> <condition> <or> <eq> <var>UPC_TYPE</var> <const type="string">UN</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UP</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UA</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UD</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UE</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">UG</const> </eq> </or> </condition> <action> <check> <explantion> For UPC Type UN,UP,UA,UD,UE,and UG,UPC must have length 12</explanation> <eq> <op func="length"> <var/> </op> <const type="number">12</const> </eq> </check> </action> </constraint> <constraint> <name>UPC13</name> <description>Check length of UPC code</description> <usefor> <var>UPC</var>

TIBCO Collaborative Information Manager Rulebase Guide

158

| Chapter 5

Rulebase Examples

</usefor> <condition> <or> <eq> <var>UPC_TYPE</var> <const type="string">EN</const> </eq> <eq> <var>UPC_TYPE</var> <const type="string">U2</const> </eq> </or> </condition> <action> <check> <explantion> For UPC Type EN,and U2,UPC must have length 13</explanation> <eq> <op func="length"> <var/> </op> <const type="number">13</const> </eq> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Validate Against First Order Date 159

Validate Against First Order Date


<constraint> <name>FirstOrderDate</name> <description>Validations against First Order Date</description> <usefor> <var>LAST_ORDER_DATE</var> <var>FIRST_SHIP_DATE</var> </usefor> <condition> <defined> <var>FIRST_ORDER_DATE</var> </defined> </condition> <action> <check> <explanation>LAST_ORDER_DATE and FIRST_SHIP_DATE cannot be earlier than First Order Date. </explanation> <geq> <var/> <var>FIRST_ORDER_DATE</var> </geq> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

160

| Chapter 5

Rulebase Examples

Validate Against First Ship Date


<constraint> <name>FirstShipDate</name> <description>Validations against First Ship Date</description> <usefor> <var>LAST_SHIP_DATE</var> </usefor> <condition> <defined> <var>FIRST_SHIP_DATE</var> </defined> </condition> <action> <check> <explanation>LAST_SHIP_DATE cannot be earlier than First Ship Date </explanation> <geq> <var/> <var>FIRST_SHIP_DATE</var> </geq> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Validate Net Weight 161

Validate Net Weight


<constraint> <name>NetWeight</name> <description>Validations against Net Weight</description> <usefor> <var>NETWEIGHT</var> </usefor> <condition> <defined> <var>GROSSWEIGHT</var> /defined> </condition> <action> <check> <explanation>Net Weight has to be less than Gross Weight </explanation> <leq> <var/> <var>GROSSWEIGHT</var> </leq> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

162

| Chapter 5

Rulebase Examples

Calculate Volume
<constraint> <name>ComputeVolume</name> <description>Calculate Volume</description> <usefor> <var>VOLUME</var> </usefor> <action> <assign> <var>VOLUME</var> <op func="mult"> <var>PRODUCTWIDTH</var> <var>PRODUCTHEIGHT</var> <var>PRODUCTDEPTH</var> </op> </assign> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

Specify New Size 163

Specify New Size


<constraint> <name>PreviousSize</name> <description>New size cannot change by more than 2 from previous version </description> <action> <check> <explanation>Size cannot increase by more than 2 from previous version</explanation> <lt> <op func="minus"> <var>SIZE</var> <var>PREVIOUS_VERSION/SIZE</var> </op> <const type="number">2.0</const> </lt> </check> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

164

| Chapter 5

Rulebase Examples

Propagate Attribute Value to Children


<constraint> <name>PropagateHazMatFlag</name> <description>Roll-down HazMatFlag to contain children</description> <usefor> <var>HAZMATFLAG</var> </usefor> <condition> <changed> <var>HAZMATFLAG</var> </changed> </condition> <action> <propagate type="inline"> <declare> <var>CONTAINSLINK</var> <link type="relationship_record"> <literal>CONTAINS</literal> </link> </declare> <var>CONTAINSLINK</var> <action> <assign> <var>HAZMATFLAG</var> <var>LINK/HAZMATFLAG</var> </assign> </action> </propagate> </action> </constraint>

TIBCO Collaborative Information Manager Rulebase Guide

| 165
Chapter 6

Embedding Rulebases

This chapter describes how to embed one rulebase into another so that duplication of rules in more than one rulebases can be avoided.

Topics
Overview, page 166 Procedure, page 167 Error Handling and Debugging, page 168

TIBCO Collaborative Information Manager Rulebase Guide

166

| Chapter 6

Embedding Rulebases

Overview
Managing all rules in a single rulebase file tends to be difficult as the number of rules increase. It also becomes difficult to reuse parts of one rulebase in other rulebases. To avoid duplication of rules in more than one rulebases, CIM allows you to embed one rulebase into another. The embedding can be done up to any levels. That is, rulebase A may embed rulebase B, which may embed rulebase C and so on. However, cyclic embedding is not supported. That is, Rulebase A can include B and B can includes C but C cannot include A. The embedding works as if the embedded rulebase was part of the original rulebase (in which embedding happens). An example of embedded rulebases is the use of the rulebase for the EvaluateRulebase activity. This activity accepts only ONE rulebase as input but the records being processed may belong to different repositories and hence different rulebases. In this case, we can create one MAIN rulebase that will embed the rulebases for the other repositories. Another case where rulebases could be embedded: For each repository associated with a cross-repository relationship, a separate rulebase is created. However, there may be some validations for bundles which must be applied irrespective of which record is being validated. For example, if there is a mandatory one-to-one relationship (such as, customer must have one and only one address). To validate such constraints, rules must be added to both the rulebases. To avoid duplicate rules which require more efforts to maintain, common rules can be separated in a third rulebase, which is then embedded within other rulebases as required. All rulebase features, including propagation, are available in embedded rulebases.

TIBCO Collaborative Information Manager Rulebase Guide

Procedure 167

Procedure
To embed a rulebase, define a new action as shown in the following example. This way, you can also control the include based on conditions.
<constraint> <name>Include another rulebase</name> <description>Some descr </description> <condition> Any condition here </condition> <action> <include> <literal>/standard/rulebase/testrulebase.xml</literal> <literal>LogicalName</literal> </include> </action> </constraint>

The first literal specifies the rulebase file location. This is mandatory. The rulebase being embedded must be a complete and valid rulebase. It must not be a fragment and it should be possible to use this rulebase independently. The embedded rulebase file is looked for in the following order: Standard enterprise rulebase directory or standard rulebase relative to c o m m o n d i r. Absolute path specified by the literal

The second literal is optional and specifies a logical name for the embedded rulebase. This name is used to add a prefix to all constraints to generate unique constraint name. Though there is no limit, we recommend that you keep the logical name between 8 to 12 characters. Also, no check is done to see whether the same logical name is assigned to more than one embedded rulebases. If duplicate constraint names are generated because of the same logical name being assigned to more than one embedded rulebases, it does not affect the functionality but debugging will become a little difficult. The order of rules is maintained. For example, if rulebase B is embedded after constraint "test_constraint", all constraints of rulebase B are executed or applied after constraint "test_constraint".

TIBCO Collaborative Information Manager Rulebase Guide

168

| Chapter 6

Embedding Rulebases

Error Handling and Debugging


If duplicate declarations are present in both rulebases, an error is displayed. Duplicate declarations within a rulebase are also not allowed. If duplicate constraints are present in both rulebases (Constraint A appears in Rulebase A as well as Rulebase B), they are considered as separate constraints. All rulebases share the same context. If the same rulebase is embedded more than once (Rulebase A embeds Rulebase B twice), it is reported as a "duplicate declaration". Any severity, threshold definitions in the embedded rulebase are ignored.

As the constraint names include the logical name assigned to the rulebase, the name of the constraint in the trace file will help in finding out which rulebase the constraint came from. The execution trace of embedded rulebase is included along with parent rulebase.

TIBCO Collaborative Information Manager Rulebase Guide

| 169
Appendix A

Synch_History

This chapter describes how the synchronization history of a record can be accessed using the SYNCH_HISTORY variable.

Topics
SYNCH_HISTORY, page 170

TIBCO Collaborative Information Manager Rulebase Guide

170

| Appendix A

Synch_History

SYNCH_HISTORY
The synchronization history of a record can be accessed using SYNCH_HISTORY variable. This variable is only active during a synchronization. SYNCH_HISTORY
IS_DISCONTINUED IS_ADDED HAS_BASE_ATTRIBUTE_SET_CHANGED HAS_ATTRIBUTE_SET_CHANGED HAS_PARTNER_ATTRIBUTE_SET_CHANGED IS_PUBLISHED IS_PUBLISHED_TO_ANY_PARTNER IS_LINKED IS_DELETED IS_REVIEWED IS_ACCEPTED IS_REJECTED IS_SYNCHRONIZED HAS_PUBLISHED_RELATION_CHANGED HAS_LINKED_RELATION_CHANGED HAS_CHILDREN HAS_PREVIOUSLY_PUBLISHED_PARENT HAS_ANY_CHILD_CHANGED HAS_INPROGRESS_SYNC_EVENT IS_ROOT_RECORD

Explanation Is Discontinued Is_Added Has_Base_Attribute_Set_Changed Has_Attribute_Set_Changed Has_Partner_Attribute_Set_Changed Is_Published Is_Published_To_Any_Partner Is_Linked Is_Deleted Is_Reviewed Is_Accepted Is_Rejected Is_Synchronized Has_Published_Relation_Changed Has_Linked_Relation_Changed Has_Children Has_Previously_Published_Parent Has_Any_Child_Changed Has_Inprogress_Sync_Event Is_Root_Record

TIBCO Collaborative Information Manager Rulebase Guide

SYNCH_HISTORY 171

SYNCH_HISTORY
IS_PARENT IS_CHILD IS_ADD_REQUESTED IS_CORRECTION_REQUESTED IS_DELETE_REQUESTED IS_PUBLISH_REQUESTED IS_RELOAD_REQUESTED IS_CANCEL_REQUESTED IS_DISCONTINUE_REQUESTED IS_INCREMENTAL_REQUESTED IS_ACCEPT_REQUESTED IS_REJECT_REQUESTED IS_REVIEW_REQUESTED IS_SYNCHRONIZE_REQUESTED VALID_NEXT_OPERATIONS OPERATION_REQUESTED MASTERCATALOG_ID MASTERCATALOG_NAME BUYER_ID BUYER_NAME TRADING_PARTNER_ID TRADING_PARTNER_NAME TRADING_PARTNER_TYPE

Explanation Is_Parent Is_Child Is_Add_Requested Is_Correction_Requested Is_Delete_Requested Is_Publish_Requested Is_Reload_Requested Is_Cancel_Requested Is_Discontinue_Requested Is_Incremental_Requested Is_Accept_Requested Is_Reject_Requested Is_Review_Requested Is_Synchronize_Requested Valid_Next_Operations Operation_Requested Mastercatalog_Id Mastercatalog_Name Buyer_Id Buyer_Name Trading_Partner_Id Trading_Partner_Name Trading_Partner_Type

TIBCO Collaborative Information Manager Rulebase Guide

172

| Appendix A

Synch_History

SYNCH_HISTORY
DATAPOOL_ID DATAPOOL_NAME INCREMENTAL_FLAG RELOAD_FLAG ADD_FLAG CORRECTION_FLAG DELETE_FLAG PUBLISH_FLAG CANCEL_FLAG DISCONTINUE_FLAG ACCEPT_FLAG REJECT_FLAG REVIEW_FLAG SYNCHRONIZE_FLAG CONFIRM_OPERATION_REQUESTED ROOT_ADD_OPERATION ROOT_LINK_OPERATION ROOT_UNLINK_OPERATION ROOT_PUBLISH_OPERATION

Explanation Datapool_Id Datapool_Name Incremental_Flag Reload_Flag Add_Flag Correction_Flag Delete_Flag Publish_Flag Cancel_Flag Discontinue_Flag Accept_Flag Reject_Flag Review_Flag Synchronize_Flag Confirm_Operation_Requested Root_Add_Operation Root_Link_Operation Root_Unlink_Operation Root_Publish_Operation

Example:
<constraint> <name> Get operation when its a root record and is published before and attribute set changed</name> <description>Constraint to return operation when its a root record and is published before and attribute set changed.</description> <condition> <var>SYNCH_HISTORY/IS_ROOT_RECORD</var>

TIBCO Collaborative Information Manager Rulebase Guide

SYNCH_HISTORY 173

</condition> <action> <assign> <explanation>Operation.</explanation> <var>PUBLISH_OPERATION</var> <const>PUBLISH:::ADD</const> </assign> </action>

TIBCO Collaborative Information Manager Rulebase Guide

174

| Appendix A

Synch_History

TIBCO Collaborative Information Manager Rulebase Guide

| 175
Appendix B

System Variables

This appendix lists the implicit system variables.

Topics
System Implicit Variables, page 176

TIBCO Collaborative Information Manager Rulebase Guide

176

| Appendix B

System Variables

System Implicit Variables

The following is a list of implicit system variables. These variables are used to access the values of the system attribute for the record. Table 6 Implicit System Variables Variable STATE RECORD_VERSION RECORD_ACTION RECORD_CHECKSUM RECORD_LAST_MODIFIED_ON RECORD_CREATED_DATE RECORD_ACTIVE_FLAG RECORD_LAST_MODIFIED_BY RECORD_KEY RECORD_ID RECORD_IDEXT RECORD_KEYID CATALOG_NAME RECORD_IS_ROOT Description Gets the product state of the current record. Gets the product version of the current record. Gets current record action of the record. Gets current record checksum. Gets current record last modified time. Gets current record creation date. Gets current record active flag. Gets modify member ID of the member who modified current record in last. Gets internal bundle key. Contains record key ID and repository ID. Gets record ID for the current record. Gets record ID and Ext for the current record. Gets recordkey ID for the current record. Gets the name of the repository for the current record. Gets information on whether the record is the root of the bundle.

TIBCO Collaborative Information Manager Rulebase Guide

| 177

Index

C
Context Variables 69 customer support xiv

Operators - logical 80 Operators - other 81 Operators by name 83

R D
Dependant variables 129 Regular Expressions 118 Rulebase Examples 137 Rulebase Patterns 127

E S
Establishing XML rules file 3 Expressions 59, 175 Expressions - Syntax 116 SQL Expressions 60 support, contacting xiv Synch_History 169

G T
Getting started with rules 1 Global property settings 56 technical support xiv

N
Non-negative numbers 128

V
Variable declarations 9

O
Operator and character reference 79 Operators - by area 80 Operators - comparison 80
TIBCO Collaborative Information Manager Rulebase Guide

178

| Index

TIBCO Collaborative Information Manager Rulebase Guide

Das könnte Ihnen auch gefallen