-1

I'm trying to include more number of rules under single RuleTable in decision table (excel), which means including two or more rows with conditions and actions under single RuleTable as shown in the figure. If I include, I'm getting only single action out of three action items. Example, if I give value claim value as 11 --> I get action output as Done-2. But if I give claim value as 12, I'm not getting any output.

enter image description here

Please let me know if there is error in my approach.

EDIT:

I've done the changes mentioned as shown in the figure, now it is not giving me any output.

enter image description here

CentosUser
  • 201
  • 1
  • 4
  • 14

1 Answers1

0

This section from an Excel table isn't written according to the rules for Drools decision tables. I'm merely pointing out all the deviations - please read the documentation to learn how to write decision tables. (Cells are numbered according to the posted PNG from A1 to H9. Also, please note that for simplicity's sake I'm using value, value1 and value2 rather than the original access code to fact values.)

  1. Cell H3 contains tm, which produces invalid RHS code (tm.System.out.println(...)).
  2. Due to the omitted comment line in the rule table header (it should be in row 5) only rows 6, 7, 8 and 9 produce rules.
  3. After inserting row #5, five rules are generated due to rows 6 to 10 (originally 5 to 9), but all constraints are derived from the cell in row 4.
  4. Column B produces a pattern from the entries in rows 4 and 6 (originally 5) resulting in the text Age < 2 which is not a valid pattern. This is due to B3 being empty.
  5. Column A, cells A6 through A10 (originally A5 through A9) results in rules where the pattern is alternatively Claim(value == 10 == "true") and Claim(value == 10 == "value == 11") or similar. This compiles, but is hardly what you need to test the value in the Claim fact.
  6. Similarly, the RHS code resulting from the action column (column E) is alternatively System.out.println("Done-1"); (or similar) and System.out.println("System.out.println(\"$param\");");

There isn't much point in trying to guess why you don't get the expected output. You have columns defining rule attributes agenda-group and activation-group but you don't provide the code setting and switching the agenda-group. As far as can be seen from this Excel snippet, neither column makes much sense.

The documentation contains enough examples for valid decision tables, so I refrain from repeating easily available information.

Edit A CONDITION must be written as cells in four rows. (You are using only three.) Here is how to write a pair of constraints, for attributes of the same class. Note that the 2nd and 3rd rule don't have a constraint based on age.

CONDITION         CONDITION
-------------- Claim -------------
value ==          age <
Value must match  Age must be less
10                2
11
12

The above shows 7 rows, 2 columns.

ACTION

System.out.println( "$param" )
Print something...
Done-1
Done-2
Done-3

Again 7 rows, 1 column.

There are almost identical examples for both in the documentation.

laune
  • 31,114
  • 3
  • 29
  • 42
  • I made changes according to your points but it didn't help me. I went through the documentation before posting here. I'm new to drools and I need some advice on the syntax part. Please let me know if you can help me. Also, my expected output is : If claim value is 11, I need to get action output as "Done-2" this is what I'm expecting. – CentosUser Aug 11 '15 at 14:30
  • Please add the (reduced) Java code for Claim (does it contain Age?) and Diag to your question, and a screenshot of what you have now. – laune Aug 11 '15 at 15:26
  • I made changes according to your comment and it didn't help me :( Now it's not even giving me single output. Please let me know if there are any syntax errors in the image I attached. – CentosUser Aug 12 '15 at 13:21