Samples > Rule Team Server Authoring Extensions > How to Use Web Components for Rule Editing

This sample shows how to build a web application using ILOG JRules web components to display and edit action rules and decision tables. It also manages permissions on a project. The web application opens a connection with Rule Team Server to get data from its database. The rules and decision tables are displayed and edited in the user web application using the following web components:

This sample contains a configuration file to describe the new user roles and permissions needed for the sample.

Key Features

Key features of this sample include:

Installing this Sample

To install this sample:

  1. In the Samples Console, locate the teamserver > servercomponents sample.
  2. Check that the Samples Server is started.
  3. For information on how to start and stop the Samples Server, see Stopping and Restarting the Samples Server from the Samples Console.
  4. Execute the run command to compile and package the application, and then deploy it to JBoss.
  5. Wait until you see the following message before continuing: The application has been deployed

Executing the run target builds and deploys the Server Components application on JBoss. In addition, the loanvalidation-rules project is modified as follows:

Running this Sample

Before running the sample, note that Rule Team Server manages different user groups. The user rtsAdmin provided by default belongs to the rtsAdministrator group, which has all permissions. In this sample, the user rmtuser is defined with permissions described in data/rmtUserGroup.properties. They specify that users belonging to this group can:

The following describes:

How to View Project Security Settings

To view the security settings of the loanvalidation-rules project:

  1. Open a web browser and enter the following URL to access Rule Team Server:
  2. http://localhost:8080/teamserver/
  3. Sign in to Rule Team Server using the following details:
  4. Username: rtsAdmin
    Password: rtsAdmin
  5. In the Home tab, select loanvalidation-rules as the project in use.
  6. Click the Admin tab.
  7. Click Edit Project Security. Note that security is enforced for this project and a number of groups are associated with the project.
  8. Click Cancel to return to the Admin tab.
  9. On the Admin tab, click Edit Permissions.
  10. Select rmtUserGroup from the drop-down list and view its current security settings. Note that users belonging to this group can update the content of action rules created by members of their own group.
  11. Sign out of Rule Team Server.
How to Use the Web Application Connected to Rule Team Server as rmtuser

To use the web application connected to Rule Team Server:

  1. Open a web browser and enter the following URL:
  2. http://localhost:8080/rtsclient
  3. Sign in using the following details::
  4. Username: rmtuser
    Password: rmtuser
  5. The page displays a tree showing the folders of the loanvalidation-rules project. Open the computation folder to see the action rules and decision tables it contains.
  6. Click on neverBankruptcy: the definition of the action rule is displayed on the right part of the page (this may take a few seconds).
  7. Notice how the Edit, Save, Cancel, and Delete buttons are disabled: since you signed in as rmtuser can only update rules that were created by your group.
  8. Click on bankruptcyScore.
  9. The definition of the decision table is displayed on the right part. Notice also that for action rules, all buttons are disabled since they ware not created by your group.
  10. Click on the computation package on the left tree.
  11. Create a new action rule and name it NewRule.
  12. Notice how the Edit and the Delete buttons are enabled this time.
  13. Sign out
How to Check the Permissions by Signing in as rtsAdmin

To check the permission of the loanvalidation-rules project:

  1. Open a web browser and enter the following URL:
  2. http://localhost:8080/rtsclient
  3. Sign in using the following details::
  4. Username: rtsAdmin
    Password: rtsAdmin
  5. Open the computation folder and select the rule neverBankruptcy.
  6. Notice that this time the Edit and Delete buttons are enabled. By signing is as rtsAdmin, you have permission to update any rule.

Note
You can restore the initial security settings for the loanvalidation-rules project by executing the run.remove.permission Ant command

Source Files

This sample is located in <InstallDir>/teamserver/samples/servercomponents.

The sample is based on the Sun JSF framework. A typical JavaServer Faces application includes one or more backing beans (JavaBean components associated with UI components used in a page). A backing bean defines UI component properties, each of which is bound to either a component's value or a component instance. A backing bean also defines methods that perform functions associated with a component. In our case, the beans feed the model that will be displayed and handle navigation processing.

The beans are in the package ilog.rule.sample.tree:

The editors part is in the package ilog.rule.sample.editor:

The JSF specific part is in package ilog.rule.sample.jsf:

The utilities class are in the package ilog.rule.sample.util:

The installer package is used to modify the loanvalidation-rules project security with Ant tasks. They are not used by the web application.

Highlights

In this sample you learn:

To set/unset the permissions on a project

The main of the class PermissionHelper unsets the permission if there is an argument, otherwise it sets them. To set the permissions, see the setPermissionsForRole() function:

To unset the permissions, see function disableSecurity(session, project). It calls the Rule Team Server API to disable the security for the given project.

To use the ILOG JRules web components

Editing of components is managed by a controller. This controller is a servlet declared in the WEB-INF/web.xml description file. The components are:

To lock/unlock objects

The class RTSHelper provides functions calling the Rule Team Server API. They are called in the TreeBean function before and after editing:

Rebuilding this Sample

To rebuild this sample:

  1. Open the Samples Console.
  2. Execute the build command to compile the code.

Note
You can restore the initial security settings for the loanvalidation-rules project by executing the run.remove.permission Ant command

Related Concepts

Rule Model API

Related Tasks

Using the Rule Team Server API

Related Samples and Tutorials

How to Implement Rule Governance in Rule Team Server
How to Customize the Rule Team Server Interface