Customizing WebSphere ILOG JRules for rule authoring, Part 1: Exploring dynamic domains

Integration with Back-End Systems

This series of articles explores various techniques for customizing the authoring environment of the WebSphere ® ILOG Rule Team Server. Part 1 of the series covers a method of integrating business rules with back-end systems in order to populate drop-down menus in the rule editor, which allows users to select valid values when authoring rules. Part 2 of the series assists the user with the creation of pop-up widgets in the rule editor that can be used to search back-end systems for information to help users to populate business rules with accurate data during rule authoring.

Share:

Tamer M. Nassar (tamer@us.ibm.com), Software Engineer, IBM

Tamer NassarTamer Nassar is a software engineer in the office of the IBM CIO, and has been with IBM since 2000. He has been involved in different projects, with a variety of technologies, designing, implementing, and testing many end-to-end enterprise solutions. His areas of interest and expertise include SOA, IT architecture and methodology, WebSphere Application Server, WebSphere Process Server, WebSphere MQ, and WebSphere Message Broker.



Terrence E. White (tewhite@us.ibm.com), Software Engineer, IBM

Terrence White is a software engineer from IBM Global Services. He is currently working with the Enterprise Component Business Architecture team, with a focus on Web services and business process development using process choreography.


developerWorks Contributing author
        level

29 September 2010

Overview

WebSphere ILOG JRules is IBM's best-of-breed Business Rule Management System (BRMS) that allows business users to dynamically control automated business decisions with business rules. JRules is used to define, deploy, execute, monitor and maintain decision logic that can be externalized from core enterprise systems allowing them to be more responsive to the rapidly changing needs of the business.

JRules provides functionality for authoring, executing and managing business rules. This article focuses on a specific technique for customizing the authoring environment involving integrating the JRules system with other back-end enterprise systems. Using the method introduced in this article, data can be pulled from any back-end system to be used in the JRules rule editor to populate drop-down boxes.

Prerequisites

This article is written for the intermediate JRules developer and focuses on a specific area of implementation. It is assumed that the reader has a basic understanding of the ILOG JRules product from a developer's perspective. Please review the Resources section for relevant links to acquire the prerequisite knowledge for completing this article. Note the product versions used in this article:

  • WebSphere ILOG Rule Studio V7.0.2
  • WebSphere ILOG Rule Execution Server V7.0.2
  • WebSphere ILOG Rule Team Server V7.0.2

This article and the sample are compatible with JRules V7.1.

Exploring the sample projects

The sample project provides a baseline for the work that we will do in this article. It is intended to provide a simple starting point for our exploration of the core topics that we are targeting in the article without spending time on the basics of rule development. Please refer to the prerequisites for more information.

Import the sample project

To import the sample project, complete the following steps:

  1. Download SampleProjectPart1.zip from the Downloads section.
  2. Open Rule Studio and select File => Import => General => Existing Project into Workspace to import the sample project, as shown in Figure 1.
    Figure 1. Import dialog
    Import dialog
  3. Select Next and import the DevWorksSample, as shown in Figure 2.
    Figure 2. Import DevWorksSample
    Import DevWorksSample

Defining a dynamic domain

A domain is a model construct created inside of a Business Object Model (BOM) that is used to place a restriction on the values that can be assigned to attributes in a business rule. A dynamic domain allows an enumeration of values to be set and updated dynamically by the execution of Java™ code. In order to create a dynamic domain, you must first create a Java class that implements the IlrBOMDomainValueProvider interface, which allows you to provide the collection of values with information on their verbalization and BOM to XOM mapping. Next you must associate the domain value provider with a BOM class and use the dynamic domain in a business rule.

Create a domain value provider

To create a domain value provider, complete the following steps:

  1. Switch to the plug-in Development perspective, as shown in Figure 3.
  2. Create a new plug-in project, as shown in Figure 4.
  3. Set the Java compliance compiler level to 1.5, as shown in Figure 5.
    Figure 3. Select plug-in project
    Select plug-in project
    Figure 4. Create plug-in project
    Enter project name
    Figure 5. Set the Java compliance compiler level to 1.5
    Set Java compliance compiler level
  4. With the plug-in manifest editor open, add the following dependencies, as shown in Figure 6:
    • ilog.rules.vocabulary.bom(7.0.2)
    • ilog.rules.studio.model(7.0.2)
    Figure 6. Add required plug-ins
    Add required plug-ins
  5. Create a class and implement the interface IlrBOMDomainValueProvider, as shown in Figure 7.
    Figure 7. Create new class
    Create new class
  6. Provide a simple BOM2XOMMapping as shown in Listing 1:
    Listing 1. BOM2XOMMapping
     public String getBOM2XOMMapping(Sting valueName)  {
                    return "return \"" + valueName + "\";";
    }
  7. Provide the collection of domain values as shown in Listing 2:
    Listing 2. Domain values
    public Collection<String> getValues (IlrClass ilrClass)  {
    
    	HashSet<String> domainValues = new HashSet<String>();
    	domainValues.add("abcd")
    	domainValues.add("efgh")
    	domainValues.add("ijkl")
    
    	return domainValues;
    
    }

    Note: This code should be adapted to pull the domain values from an external data source. We are hardcoding them here so that we can focus on the creation of the domain value provider.

  8. With the plug-in manifest editor open, select the Extension tab, then select Add to define the plug-in extension for the class created above by selecting the ilog.rules.studio.model.bomDomainValueProviders extension point, as shown in Figure 10:
    Figure 10. Add the extension point
    Add the extension point
  9. Complete the extension element details, as shown in Figure 11.
    Figure 11. Complete the extension element details
    Complete the extension element details
  10. Add the package containing the domain value provider to the exported packages list, as shown in Figure 12:
    Figure 12. Add the package
    Deploy the plug-in
  11. Deploy the plug-in by selecting File => Export => Plug-in Development => Deployable plug-ins and fragments. Then export the plug-in to the /InstallDir/studio/eclipse directory, as shown in Figure 13.

    Note:The plug-in must be re-deployed each time changes are made to the domain value provider code.

    Figure 13. Deploy the plug-in
    Deploy the plug-in
  12. Restart Eclipse.

Integrate the dynamic domain into Rule Studio

You have to associate the domain value provider with a BOM class.

  1. Switch to the Rule perspective and create a new class called RoleCodes in the BOM, as shown in Figure 14.
    Figure 14. RoleCodes class
    RoleCodes class
  2. Set the execution class name to java.lang.String, as shown in Figure 15.
    Figure 15. Execution class name
    Execution class name
  3. Add a domainValueProviderName custom property and set it to the domain provider (name property), as shown in Figure 16.
    Figure 16. Custom domainValueProviderName property
    Custom domainValueProviderName property
  4. Ensure that the RoleCodes class has a default verbalization, as shown in Figure 17.
    Figure 17. Default verbalization
    Default verbalization
  5. In the domain section, select Create a domain, Static References as the domain type, and select OK to create the dynamic domain, as shown in Figure 18.
    Note: If the OK button is not active, switch the domain type to Other, and then back to Static References, then select OK.
    Figure 18. Create the domain
    Create the domain
  6. After the previous step is completed, an empty enumerated domain is created and the Synchronize link appears in the domain section. Select this link to populate the enumerated domain, as shown in Figures 19 and 20.
    Note: If the value of the domainValueProviderName property is invalid, the following message appears in the domain section: The value provider is invalid. Check the custom properties.
    Figure 19. Create the domain
    Create the domain
    Figure 20. Synchronized domain
    Synchronized domain

    Note: When the values of the domain change, the BOM can be updated using the Update the dynamic domains of this BOM entry link, as shown in Figure 21.

    Figure 21. Update the dynamic domain
    Update domain
  7. Ensure that each member of the dynamic domain has a verbalization and a label, as shown in Figure 22.
    Figure 22. Verbalization and a label
    Verbalization and a label
  8. Change the data type of the roleCode member of the RuleInput class, as shown in Figure 23.
    Figure 23. Data type setting
    Data type setting

    Save all changes.

Use the Dynamic Domain in a Business Rule

  1. Locate the Approvers decision table and change the Role Code condition column to use the new dynamic domain, as shown in Figure 24.
    Figure 24. Change the role code
    Data type setting

    Save all changes.

  2. Ensure that the dynamic domain is being used, as shown in Figure 25:
    Figure 25. Domain being used
    Domain being used
  3. Locate the UserRestrictions business rule and change the Role Code entry to use the new dynamic domain, as shown in Figure 26.
    Figure 26. UserRestrictions business rule
    Data type setting

    Save all changes.


Integrate the Dynamic Domain into Rule Team Server

In order to make the dynamic domain available to Rule Team Server, the Java class implementing the IlrBOMDomainValueProvider interface must be packaged into the Rule Team Server EAR. This is typically done with an ant command: ant repackage-ear ... -DadditionalJars=../CustomDomainValueProvider.jar, where CustomDomainValueProvider.jar contains the IlrBOMDomainValueProvider implementation class.

The deployment process may vary depending on the application server being used. In this article, we are using WebSphere Application Server. Instead of reinstalling the Rule Team Server EAR, we will be deploying our domain value provider by placing our JAR file directly into the EAR directory on the file system.

  1. Create a properties file named preferences.properties and place it into the src folder of the plug-in project, as shown in Figures 27 and 28. The property to be placed inside of the file will take the following format: teamserver.myProviderName=fully qualified implementation class name , where myProviderName represents the domain provider (name property) used in Figure 10 above.
    Figure 27. Create a properties file
    preferences.properties
    Figure 28. preferences.properties
    preferences.properties
  2. Select File - > Export - > Java - > JAR file to export the domain value provider, as shown in Figure 29.
    Figure 29. Export domain value provider
    Export domain value provider
  3. Use a method recommended by your application server to package the JAR file into the Rule Team Server EAR and re-deploy. as stated above, this will typically involve the use of the ant command. In this article, we will be placing the JAR file into the /profileDirectory/installedApps/cellDirectory/teamserver-WAS61.ear/teamserver.war/WEB-INF/lib directory on the server.
  4. Deploy the rule project to the Rule Team Server, as shown in Figure 30.
    Figure 30. Deploy the rule project
    Publish domain value provider
  5. Logon to the Rule Team Server and verify that the dynamic domain is being used by the rules, as shown in Figures 31 and 32.
    Figure 31. Approvers Table
    Approvers Table
    Figure 32. UserRestrictions Business Rule
    UserRestrictions Business Rule
  6. When the values of the dynamic domain changes, the domain needs to be refreshed. In the Rule Team Server under the Project tab, select Reload Dynamic Domains, as shown in Figures 33 and 34.
    Figure 33. Reload Dynamic Domains
    Reload Dynamic Domains
    Figure 34. Dynamic Domains Refreshed
    Reload Dynamic Domains

Downloads

DescriptionNameSize
Sample project for this tutorialSampleProjectPart1.zip12KB
Solution project for this tutorialSolutionProjectPart1.zip18KB

Resources

Learn

Get products and technologies

Discuss

  • Get involved in the My developerWorks community: Connect with other developerWorks users while exploring the developer-driven blogs, forums, groups, and wikis.

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Business process management on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Business process management, WebSphere
ArticleID=525342
ArticleTitle=Customizing WebSphere ILOG JRules for rule authoring, Part 1: Exploring dynamic domains
publish-date=09292010