3.4. Defining the traffic violations DMN decision logic


To calculate the fine and to decide whether the driver is to be suspended or not, you can define the traffic violations DMN decision logic using a DMN decision table and context boxed expression.

図3.8 Fine decision table

dmn gs fine decision table

図3.9 Should the driver be suspended?

dmn gs context table

Prerequisites

  • You have assigned the DMN custom data types to the appropriate decision and input nodes in the traffic violations DRD in Business Central.

Procedure

  1. To calculate the fine, in the DMN designer canvas, select the Fine decision node and click the Edit icon to open the DMN boxed expression designer.

    図3.10 Decision node edit icon

    decision node edit
  2. Click Select expression Decision Table.

    図3.11 Select Decisiong Table logic type

    select logic type
  3. For the Violation.Date, Violation.Code, and Violation.Speed Limit parameter fields, right-click and select Delete for each field.
  4. Click the Violation.Actual Speed column header and enter the expression Violation.Actual Speed - Violation.Speed Limit in the Expression field.
  5. Right-click the Fine parameter field and select either Insert left or Insert right.
  6. Click the output-2 column sub-header, enter Amount in the Name field, and select number from the Data Type pull-down menu.
  7. Similarly, click the output-1 column sub-header, enter Points in the Name field, and select number from the Data Type field.
  8. Next, enter the following values in the first row of the decision table:

    • Violation.Type: "speed"
    • Violation.Actual Speed - Violation.Speed Limit: [10..30)
    • Amount: 500
    • Points: 3

      Right-click the first row and select Insert below to add another row.

  9. Enter the following values in the second row of the decision table:

    • Violation.Type: "speed"
    • Violation.Actual Speed - Violation.Speed Limit: >= 30
    • Amount: 1000
    • Points: 7

      Right-click the second row and select Insert below to add another row.

  10. Enter the following values in the third row of the decision table:

    • Violation.Type: "parking"
    • Violation.Actual Speed - Violation.Speed Limit: -
    • Amount: 100
    • Points: 1

      Right-click the third row and select Insert below to add another row.

  11. Enter the following values in the fourth row of the decision table:

    • Violation.Type: "driving under the influence"
    • Violation.Actual Speed - Violation.Speed Limit: -
    • Amount: 1000
    • Points: 5
  12. Click Save.
  13. To define the driver suspension rule, return to the DMN designer canvas, select the Should the driver be suspended? decision node, and click the Edit icon to open the DMN boxed expression designer.
  14. Click Select expression Context.
  15. Click ContextEntry-1, enter Total Points as the Name, and select number from the Data Type pull-down menu.
  16. Click the cell next to Total Points, select Literal expression from the context menu, and enter Driver.Points + Fine.Points as the expression.
  17. In the cell below Driver.Points + Fine.Points, select Literal Expression from the context menu, and enter if Total Points >= 20 then "Yes" else "No".
  18. Click Save.

    You have defined how to calculate the fine and the context for deciding when to suspend the driver. You can navigate to the traffic-violation project page and click Build to build the example project and address any errors noted in the Alerts panel.

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

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

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

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

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

会社概要

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

© 2024 Red Hat, Inc.