Workflow Engine rule governance sample details

You can run and rebuild this sample, and you can also look at source files to understand how this sample works.

Running this sample

In this sample, when you complete certain tasks, the Workflow Engine sends an email to the user who completes the next task in the Workflow Instance. This email is the start of the next step in the Workflow Instance. It contains a list of permanent links to the rules that you update, validate, or deploy in the task.

CAUTION:

The email process is virtualized in this sample. The Samples console displays a message indicating that the email is sent, and prints the contents of the email to a file. To read this email, use your browser to open the generated file.

Run this sample in the following sequence to illustrate the Workflow Instance:

  1. Create and initiate a Workflow Instance

  2. Associate rules with a Workflow Instance

  3. Update or delete rules attached to a Workflow Instance

  4. Verify the work of a policy manager

  5. Fix errors identified by a business analyst

  6. Verify rule fixes

  7. Test updated rules

  8. Deploy a ruleset

  9. Detach a rule from a Workflow Instance

Use the following step-by-step description to complete the creation task in this sample. For more information, see the Steps in the Workflow Model.

Create and initiate a Workflow Instance

To create a new Workflow Instance:

  1. Open a Web browser and enter the following URL to access Decision Center:

    http://localhost:<PORT>/teamserver/

  2. Sign in to Decision Center as the configuration manager using the following details:

    • User: rtsAdmin

    • Password: rtsAdmin

  3. Select the loanvalidation-rules project.

  4. Click the Workflow tab.

  5. Click Workflow Models.

  6. Click New.

    This creates a new Workflow Instance from the Workflow Model. Your browser is redirected to the Workflow Instance page automatically.

  7. In the Name column of the Workflow Instance table, change the Workflow Instance name to myupdate.

  8. Click Save to save your changes.

  9. Click Preview to edit the Workflow Instance.

  10. The business analyst tells the policy manager to delete a rule that is no longer used and update the default insurance rate from 0.02 to 0.04.

    To do this, add the following to the Comment field:

    Update the defaultInsurance rule to the new rate of 0.04.

    When a person borrows more than a certain amount, insurance is required by the lender. This rule sets the insurance rate for such a loan.

    Delete the checkSSNareanumber rule. We no longer check the SSN Number.

  11. Click Save.

    Decision Center has added the comments to the comments history. To view them in the Details section, select Comments History.

  12. Click the Tasks tab and click Refresh.

    You see that Decision Center has created and assigned a task to the business analyst. Note that this task is created when the workflow instance is created.

After you have created a Workflow Instance, you select items of the Details list at the bottom of the Workflow Instance page to view status information about the current Workflow Instance.

The Details list for the myupdate Workflow Instance contains the following information:

Detail list item Description
Process Graph The process graph opens. The progress icon shows the Workflow Instance is in the creation step.
Comments History The comments added to the process and the name of the user who added the comment.
Tasks History A list of the tasks created. At this stage, no tasks are created in the Workflow Instance.
Logs History Displays the contents of the single log file that traces the creation of this Workflow Instance.

You now associate the rules with a Workflow Instance. In this step, the business analyst first creates a simple query which lists all the rules in the Decision Center, and then uses the result of this query to attach rules to a Workflow Instance.

Associate rules with a Workflow Instance

To create a basic query:

  1. Select the loanvalidation-rules project.

  2. Click the Query tab.

  3. Create a new query called All Rules with the following definition:

    Find all business rules

  4. Click Save.

  5. Click Run Query.

    Decision Center displays the results of the All Rules query.

The business analyst now associates rules from the list with the Workflow Instance.

  1. Select the checkSSNareanumber and defaultInsurance rules from the query list.

  2. Click Add in the toolbar.

    Decision Center attaches the rules that you selected to the myupdate Workflow Instance.

  3. Click the Workflow tab.

    You see the rules that you added.

    Note:

    To remove a rule from a Workflow Instance, click the remove icon in the toolbar.

  4. Select the To Delete check box next to the checkSSNareanumber rule.

  5. Click Save.

    Decision Center creates one update task and one delete task for the policy manager.

  6. Click the Tasks tab.

  7. Click Apply in the Decision column to end this task.

    The task ends for the business analyst and the workflow creates tasks for the policy manager.

    Note:

    In this sample, the policy manager is the Decision Center user that can update and delete tasks.

  8. Click Sign Out in the upper corner of Decision Center.

After you have created a Workflow Instance, and initiated and associated rules with it, the policy manager receives an email from the Workflow Engine indicating that you have assigned them an update task. The policy manager uses the comments defined in the Create and initiate a Workflow Instance section to complete update or delete tasks.

Use the following step-by-step description to complete the update task in this sample. For more information, see the Steps in the Workflow Model.

Update or delete rules attached to a Workflow Instance

To update or delete the rules in this task:

  1. Open a web browser and enter the following URL to access Decision Center:

    http://localhost:<PORT>/teamserver/

  2. Sign in to Decision Center as a policy manager using the following details:

    • User: rtsUser1

    • Password: rtsUser1

  3. Select the loanvalidation-rules project.

  4. Click the Tasks tab.

    Two tasks are visible in the Desc. column of the task list. Both tasks are in plain text because the policy manager has not started them.

  5. Select the check boxes in the first column for both of these tasks.

  6. Click the start button in the toolbar.

    The policy manager is the owner of the tasks, and the task description links are enabled.

  7. Click Delete Rule : checkSSNareanumber.

  8. Click Delete in the toolbar, and then click Yes to confirm the command.

  9. Click the Tasks tab.

  10. Click Apply in the Decision column for the Delete Rule task.

    The task is removed from the list.

  11. Click Update Rule : defaultInsurance.

  12. Click Edit in the toolbar.

  13. In the Compose tab, click Step 2: Content, and then change the rate from 0.02 to 0.05, and then click Finish.

    Note:

    In this step you create an error intentionally to see what happens when a rule update is rejected later in the Workflow Instance.

  14. Click the Tasks tab, and then click Apply for the Update Rule task.

    The task is removed from the list.

  15. Click Sign Out in the upper corner of Decision Center.

Verify the work of a policy manager

To verify the work of a policy manager and start all tasks at the same time:

  1. Open a Web browser and enter the following URL to access Decision Center:

    http://localhost:<PORT>/teamserver/

  2. Sign in to Decision Center as a business analyst using the following details:

    • User: rtsAdmin

    • Password: rtsAdmin

  3. Ensure that loanvalidation-rules is the project in use.

  4. Accept the delete task completed by the policy manager in 3. To do this:

    1. Click the Tasks tab.

    2. Select all tasks, and then click Start.

      By selecting all tasks and clicking start, all tasks are started at the same time. You can also select and start tasks one by one.

    3. Click Check the rule: checkSSNareanumber.

      Decision Center displays the following error message: Cannot select item : The specified element was not found. This is the expected result, because Decision Center has deleted this rule.

    4. Click Back.

    5. In the Check the rule: checkSSNareanumber row, select End in the Decision drop-down list, and click Apply to end the task.

      The Workflow Engine sets the status for this task to Approved.

  5. Reject the update task completed by the policy manager in 3. To do this:

    1. Click Check the rule : defaultInsurance.

      The content definition shows the rate is set to 0.05 instead of the 0.04 requested in 1. You reject the work done by the policy manager.

    2. Click the Workflow tab, and then click Workflow Instances.

    3. Click the preview button for the myupdate task.

    4. Add the following in the Comment field:

      Change incorrect. Set to 0.04 and not 0.05.

    5. Click Save.

    6. Click the Tasks tab, select Error in the Decision drop-down list, and click Apply to reject the task.

      The Workflow Engine sets the status property for the rule to Rejected.

  6. Click Sign Out in the upper corner of Decision Center.

The policy manager fixes the errors that the business manager identified.

Use the following step-by-step description to complete the update task in this sample. For more information, see the Steps in the Workflow Model.

Fix errors identified by a business analyst

To fix errors identified previously:

  1. Open a web browser and enter the following URL to access Decision Center:

    http://localhost:<PORT>/teamserver/

  2. Sign in to Decision Center as a policy manager using the following details:

    • User: rtsUser1

    • Password: rtsUser1

  3. Ensure that loanvalidation-rules is the project in use.

  4. Click the Tasks tab.

  5. Click Apply to start the task.

  6. Click Fix tasks : defaultInsurance.

  7. Change the rate in the rule to 0.04.

  8. Click the Tasks tab.

  9. Select End in the Decision drop-down list, and click Apply to end the task.

    Decision Center sets this task as Completed.

  10. Click Sign Out in the upper corner of Decision Center.

The business analyst now verifies the work done by the policy manager. In this section, you assume that the business analyst considers the fix to be correct and ends the task.

Use the following step-by-step description to complete the validation task in this sample. For more information, see the Steps in the Workflow Model.

Verify rule fixes

To verify rule fixes:

  1. Open a web browser and enter the following URL to access Decision Center:

    http://localhost:<PORT>/teamserver/

  2. Sign in to Decision Center as a policy manager using the following details:

    • User: rtsAdmin

    • Password: rtsAdmin

  3. Ensure that loanvalidation-rules is the project in use.

  4. Click the Tasks tab.

  5. Click Apply to start the task.

  6. Click Check the rule : defaultInsurance.

  7. Validate the rule rate is 0.04.

  8. Click the Tasks tab, and then click Apply to end the task.

  9. Select End in the Decision drop-down list, and click Apply to end the task.

    Decision Center sets this task as Approved.

  10. Click Sign Out in the upper corner of Decision Center.

In this step, you assume that the issue found by the developer in testing updated rules is corrected by the policy manager and the fix is approved by the business analyst.

Use the following step-by-step description to complete the test task in this sample. For more information, see the Steps in the Workflow Model.

Test updated rules

To test and approve an updated rule:

  1. Open a web browser and enter the following URL to access Decision Center:

    http://localhost:<PORT>/teamserver/

  2. Sign in to Decision Center as a developer using the following details:

    • User: tesUser

    • Password: tesUser

  3. Select the loanvalidation-rules project.

  4. Click the Tasks tab, and then click Apply to start the task.

    The developer tests the changes to the rule, and then terminates the task.

  5. Select End from the Decision drop-down list, and click Apply to end the Test the rules task.

    The Workflow Engine sets the status property of the rule to Deployable and the developer has the task Deploy the ruleset.

You can now deploy the ruleset. In this step, you assume that the developer deploys the updated rules in the context of the Workflow Instance tasks.

Here you assume that a new ruleset is generated and deployed to Rule Execution Server. For more information, see the Steps in the Workflow Model.

Deploy a ruleset

To update the task:

  1. Click Apply to end the Deploy the ruleset task.

    The Workflow Engine sets the status property to Deployed.

  2. Click Sign Out in the upper corner of Decision Center.

After all tasks are complete, the business analyst must terminate the Workflow Instance and remove the rules from the control of the Workflow Engine.

Use the following step-by-step description to perform the completion task in this sample. For more information, see the workflow diagram.

Detach a rule from a Workflow Instance

To detach rules from the Workflow Instance:

  1. Open a web browser and enter the following URL to access Decision Center:

    http://localhost:<PORT>/teamserver/

  2. Sign in to Decision Center as a business analyst using the following details:

    • User: rtsAdmin

    • Password: rtsAdmin

  3. Ensure that loanvalidation-rules is the project in use.

  4. Click the Tasks tab, and then click Apply to end the task.

  5. To validate that all rules have been detached, run the All Rule query created previously.

    The defaultInsurance rule is no longer attached to a Workflow Instance, and the Process Id and Process Instance values are no longer set.

Rebuilding this sample

To rebuild this sample:

  1. In the Samples Commands view, navigate to Samples Commands > Decision Center > Workflow Engine rule governance.

  2. Execute the build command to recompile the code.

How this sample works

This sample uses:

The Workflow Engine receives commands from the custom UI, and checks whether the command is valid for the current step and task. If the command is valid, the Workflow Engine calls the Java™ method designated by the Workflow Model and moves to the next task in the Workflow methods. The methods called use the Decision Center API to lock or unlock the rules attached to the Workflow Instance and inform the user who completes the next task.

The Decision Center data model is customized to add the following attributes:

The XML files contained in <InstallDir>/teamserver/samples/serverworkflow/data/process/osworkflow/Sample.xml define the steps in a Workflow Model. This sample uses the OSWorkflow workflow engine. For more information about how to design a process, see the OSWorkflow documentation.

For this sample, the business process describes the update, testing, and deployment of rules attached to a Workflow Instance in Decision Center. Each rule has a status to indicate the progression of the Workflow Instance to which it is attached. The Workflow Instance controls the interactions between three actors: a business analyst, a policy manager, and a developer. Actors can edit only rules attached to a Workflow Instance when a task is assigned to them. The process updates the rule status automatically whenever it moves from step to step.

The Workflow Model for this sample implements the following scenario:

When you deploy this sample, the process uploads a Workflow Model that implements the scenario, to Decision Center. For information about how to upload a Workflow Model, see the list of useful procedures at the end of this topic.

The following figure shows the steps defined in the Workflow Model for this sample and the actor who works on each step:

The sample workflow.

At any time in a Workflow Instance, you can view a graph showing the status of a particular Workflow Instance, that is, the history of the tasks, comments, and actions that have occurred in the Workflow Instance.

The following table explains the steps in the Workflow Model in greater detail:

Table 1. Steps in the Workflow Model
Step overview Step tasks
The business analyst creates a Workflow Instance in Decision Center and attaches rules to it.

The business analyst takes the following steps:

Creation step tasks

  1. Creates a new Workflow Instance from a Workflow Model.

  2. Gives a name and a short description to the Workflow Instance.

  3. Adds comments to the Workflow Instance that describe the work that is required.

  4. Attaches rules to the Workflow Instance using the Explore or the Query pages.

When this step is complete, the Workflow Engine:

  1. Sets the status of the rules to Assigned.

  2. Selects the policy manager completes the update tasks.

  3. Assigns the update tasks to a policy manager and sends an email that lists the tasks that are assigned.

Note:

Until the first business analyst task (Add rules to the Workflow Instance) is complete, the business analyst can add or remove rules to the workflow instance.

The policy manager updates or deletes the rules attached to the Workflow Instance.

The policy manager receives an email from the Workflow Engine, and then:

Update step tasks

  1. Navigates to the tasks attached to the Workflow Instance using the permanent links in the task description email.

  2. Starts the tasks.

  3. Updates or deletes the rules attached to the Workflow Instance.

  4. Ends this task.

Attention:

In this sample, the email process is virtualized. The samples console displays message indicating that the email is sent and prints the content of the email to a file. To read this email, use your browser to open the file generated.

When the policy manager completes all the tasks, the Workflow Engine:

  1. Sends an email to the business analyst requesting verification of the work done by the policy manager.

    The Workflow Engine the status of the rules to Defined.

  2. Creates a task to verify each rule attached to the Workflow Instance. The Workflow Engine assigns these verification tasks to the business analyst.

The business analyst validates or rejects work done by the policy manager.

The business analyst receives an email from the Workflow Engine, and then:

Validation step tasks

  1. Navigates to the tasks attached to the Workflow Instance using the permanent links in the task description email.

    Note:

    When the business analyst clicks the link for a rule that was deleted previously, Decision Center displays an error message.

  2. Validates the work done by the policy manager:

    • If the work done on a rule is correct:

      1. The business analyst completes the task by setting it to End.

      2. The Workflow Engine sets the task status to Validated.

    • If the work done is incorrect:

      1. The business analyst rejects the rule and adds a comment to the Workflow Instance explaining the issues found.

      2. The Workflow Engine creates a task for the policy manager, and then sets the status of the rule to Rejected. No status is set for a deleted rule.

      3. The Workflow Engine creates an update task for the rules attached to the Workflow Instance.

When all rules are correct, the Workflow Engine:

  1. Assigns a task to the developer.

  2. Sends an email to the developer requesting testing of the ruleset which includes the rules modified by the policy manager.

The developer tests the rules altered in previous steps.

The developer receives an email from the Workflow Engine, and then:

Test step tasks

  1. Navigates to the tasks attached to the Workflow Instance using the permanent links in the task description email.

  2. Tests the rules:

    • If the rules fail:

      1. The developer selects the rules that failed the tests.

      2. The Workflow Engine creates an update task for each failed rule in the Workflow Instance.

      3. The developer adds a comment to the Workflow Instance explaining the issue found.

    • If the rules pass:

      1. The developer ends the task.

When all the rules have passed the tests, the Workflow Engine:

  1. Assigns a new deployment task to the developer.

  2. Sets the status of the rules attached to the Workflow Instance to Deployable.

A developer deploys the updated ruleset.

The developer:

Deployment step tasks

  1. Navigates to the tasks attached to the Workflow Instance using the permanent links in the task description email.

    Note that the task is started automatically.

  2. Deploys the new ruleset.

  3. Ends the tasks.

When the task has ended, the Workflow Engine:

  1. Sends an email to the business analyst explaining that the new version of the ruleset is deployed.

  2. Sets the status of the rules attached to the Workflow Instance to Deployed.

  3. Creates a new task for the business analyst to end this Workflow Instance.

Business Analyst completes the Workflow Instance.

The business analyst receives an email from the Workflow Engine, and then:

Completion step tasks

  1. Navigates to the tasks attached to the Workflow Instance using the permanent links in the task description email.

  2. Sets the Workflow Instance to End.

The following figure shows the status of the Workflow Instance for this sample:

A process diagram for a workflow.

The software layer that controls the graphical user interface (GUI) in this sample uses JSF beans. The layer is independent of the base business process management (BPM) engine implementation. All JSF beans interact with the ilog.rules.sample.rts.workflow.BPMEngine interface. The BPM implementation referenced by this sample is loaded at runtime by the ilog.rules.sample.rts.workflow.EngineService factory class.

The following figure shows the relationship between the different layers of this sample:

The relationship between the sample and third party technologies.

This sample uses the open source OSWORKFLOW engine. The BPM functionality is packaged in a Java library. This library includes a service to manage and execute processes.

To configure this sample:

Workflow Instance configuration

Note:

This sample does not manage transactions between the Decision Center database and OSWORKFLOW database. You must adapt the sample or use another BPM Engine to implement this feature.

To modify or create a process of this sample:

  1. Use the OSWORKFLOW Designer to modify or create it.

  2. Create or modify the Java classes you require.

  3. Upload the process.

  4. Redeploy the Java classes to Decision Center.

To use another BPM Engine:

  1. Implement a class implementing the ilog.rules.sample.rts.workflow.BPMEngine interface.

    This class is the glue between Decision Center and the BPM Engine

  2. Create a process with the tools coming along with the BPM engine.

  3. Develop all Java classes required by the workflow model.

  4. Redeploy the process and the Java classes.

All Decision Center project elements include additional information referred to as their properties. You can customize or extend rule projects to capture information specific to your company business domain. For this Workflow Engine sample, the Decision Center model is extended to with two new properties:

Table 2. Decision Center model customization
Property name Description
processInstanceName The name of the Workflow Instance to which a rule is attached.
processInstanceId The ID of the Workflow Instance to which a rule is attached.

Decision Center is a JSF based application. Use the items in the following list to customize different graphical aspects of Decision Center:

Decision Center GUI customization

Useful procedures that are not used in this sample

This section lists small but useful procedures that are not used in this sample.

Source files

This sample is located in <InstallDir>/teamserver/samples/serverworkflow/src/ilog/rules/sample/rts.

You can also view and modify the sample source files in Rule Designer. To import the sample into your workspace, click the Import projects link in the Samples and Tutorials view, and switch to the Java perspective.