このコンテンツは選択した言語では利用できません。

Chapter 12. Rules in case management


Cases are data-driven, rather than following a sequential flow. The steps required to resolve a case rely on data, which is provided by people involved in the case, or the system can be configured to trigger further actions based on the data available. In the latter case, you can use business rules to decide what further actions are required for the case to continue or reach a resolution.

Data can be inserted into the case file at any point during the case. The process engine constantly monitors case file data, meaning that rules react to data that is contained in the case file. Using rules to monitor and respond to changes in the case file data provides a level of automation that drives cases forward.

12.1. Using rules to drive cases

Refer to the the case management IT Orders sample scenario in Business Central.

Suppose that the particular hardware specification provided by the supplier is incorrect or invalid. The supplier needs to provide a new, valid order so that the case can continue. Rather than wait for the manager to reject the invalid specification and create a new request for the supplier, you can create a business rule that will react immediately when the case data indicates that the provided specification is invalid. It can then create a new hardware specification request for the supplier.

The following procedure demonstrates how to create and use a business rule to execute the described scenario.

Prerequisites

  • The IT Orders sample project is open in Business Central, but it is not deployed to the Process Server.
  • The ServiceRegistry is part of the jbpm-services-api module, and must be available on the class path.

    Note

    If building the project outside of Business Central, the following dependencies must be added to the project:

    • org.jbpm:jbpm-services-api
    • org.jbpm:jbpm-case-mgmt-api

Procedure

  1. Create the following business rule file called validate-document.drl:

    package defaultPackage;
    
    import java.util.Map;
    import java.util.HashMap;
    import org.jbpm.casemgmt.api.CaseService;
    import org.jbpm.casemgmt.api.model.instance.CaseFileInstance;
    import org.jbpm.document.Document;
    import org.jbpm.services.api.service.ServiceRegistry;
    
    rule "Invalid document name - reupload"
    when
        $caseData : CaseFileInstance()
        Document(name == "invalid.pdf") from $caseData.getData("hwSpec")
    
    then
    
        System.out.println("Hardware specification is invalid");
        $caseData.remove("hwSpec");
        update($caseData);
        CaseService caseService = (CaseService) ServiceRegistry.get().service(ServiceRegistry.CASE_SERVICE);
        caseService.triggerAdHocFragment($caseData.getCaseId(), "Prepare hardware spec", null);
    end

    This business rule detects when a file named invalid.pdf is uploaded to the case file. It then removes the invalid.pdf document and creates a new instance of the Prepare hardware spec user task.

  2. Click Build, then Deploy to deploy the IT Orders project.
  3. Create a file called invalid.pdf and save it locally.
  4. Create a file called `valid-spec.pdf`and save it locally.
  5. Open the IT Orders project in Business Central under Menu Projects IT Orders.
  6. Click Import Asset in the upper-right corner of the page.
  7. Upload the validate-document.drl file to the default package (src/main/resources).

    case management validate document upload

    The validate-document.drl rule is shown in the rule editor. Click Save or close to exit the rule editor.

  8. Open the Showcase application by either clicking the Apps launcher (if it is installed), or go to http://localhost:8080/rhpam-case-mgmt-showcase/jbpm-cm.html.
  9. Start a new case for the IT Orders project.

    In this example, Aimee is the case owner, Katy is the manager, and the supplier group is supplier.

    showcase start case
  10. Log out of Business Central, and log back in as a user that belongs to the supplier group.
  11. Go to Menu Track Task Inbox.
  12. Open the Prepare hardware spec task and click Claim. This assigns the task to the logged in user.
  13. Click Start and click choose file to locate the invalid.pdf hardware specification file. Click the upload button to upload the file.

    case management invalid spec

    Click Complete.

    Instead of the Task Inbox showing the Prepare hardware spec as Complete, it shows as Ready.

  14. In Showcase, click Refresh in the upper-right corner. Notice that a Prepare hardware task appears in the Completed column and another appears in the In Progress column.

    case management new spec task

    This is because the first Prepare hardware spec task has been completed with the specification file invalid.pdf. As a result, the business rule causes the task and file to be discarded, and a new user task created.

  15. In the Business Central Task Inbox, repeat steps 12 and 13, but upload the valid-spec.pdf file instead of invalid.pdf.
  16. Log out of Business Central and log back in again as Katy.
  17. Go to Menu Track Task Inbox. There are two Manager approval tasks for Katy, one with the invalid.pdf hardware specification file, the other with the valid-spec.pdf file.
  18. Open, claim, and complete each task:

    1. Check the approve box for the task that includes the valid-spec.pdf file, then click Complete.
    2. Do not check the approve box on the task with the invalid.pdf file, then click Complete.
  19. Go to Menu Manage Process Instances and open the Order for IT hardware process instance.
  20. Open the Diagram tab. Note that the process both Order rejected and Place order tasks as completed.

    case management two orders

    Similarly, the case details page in Showcase lists two Manager approval tasks in the Completed column.

Related information

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.