-1

All,

Am using Drools Workbench 6.2.0.Final to declaratively create Guided Rules...

My situation is something like this:

Have a Loan Data Object with the following attributes:

  • state - String
  • amount - double
  • interestRate - double
  • message - String
  • requirement - boolean

The auto-generated drl file is:

rule "Arizona"
    when
        loan : Loan( state == "Arizona", amount >= 1000 , amount <= 3000, 
                     interestRate >= 0.15, interestRate <= 0.50 )
    then
        loan.setRequirement( true );
end

Question(s):

(1) How can I declaratively use the Guided Rules Editor to set the following when this rule fails:

loan.setMessage( "Allowed values for amount should be in the range of 1000 to 3000"); 

or

loan.setMessage( "Allowed values for interest rate values should be in the range of 15% to 50%" );

(2) Is there a way to declaratively customize the SOAP Response:

e.g.

<requirement>true</true>

or

<requirement>false</requirement>
<message>Allowed values for amount should be in the range of 1000 to 3000</message>

or

<requirement>false</requirement>
<message>Allowed values for interest rate values should be in the range of 15% to 50%</message>

Do not want to do this programmatically...

Thanks to all...

PacificNW_Lover
  • 4,746
  • 31
  • 90
  • 144
  • 1
    The title doesn't really match the text of your question. – laune Oct 09 '15 at 04:10
  • Seems like you don't appreciate the spirit of StackOverflow, given you haven't corrected your completely inaccurate title. Boo000 – cellepo Dec 17 '20 at 17:32

1 Answers1

0

There is a fundamental misunderstanding in the way this question is formulated as there is no such state as "when this rule fails". A rule fires when its conditions match for a matched set of facts, which may happen any number of times for the current set of facts in Working Memory.

There are, of course, scenarios when a rule does not fire - but even with a simple rule such as "Arizona" there is more than one reason why it fails.

  1. There may not be any Loan fact in WM.
  2. There may be a Loan fact in WM, but with state "Texas" (or any of the other 48 possibilities).
  3. The value of either or both of amount and interest rate aren't in the expected bracket.

There is no way a program could know that you are interested in #3 alone (to say nothing about the detailed analysis, i.e., is it just one or both values). But a program can be made to know: just implement all the rules detecting the reasons for failure, the ones you are interested in, which can be done (I think) with a couple of rules for #3.

It seems that your design of Loan foresees only a single message, but this can be fixed.

Further reading: a white paper on rule design patterns, section "Handling Failure to Match" which is too long as an answer.

laune
  • 31,114
  • 3
  • 29
  • 42