[rules-users] Cutom Attributes in Drools

Davide Sottara dsotty at gmail.com
Fri Sep 14 10:41:04 EDT 2012


Hi, 
this is definitely something in scope for the type of "Defeasible rules" i'm
working on right now.
I have just one last question:
do you need the second rule to override the activation of the first, or do
you need the VALUE set
by the second rule to override the value set by the first?
In your example, the effect would be the same, but let me show two other
examples:
(Also please notice the currently proposed metadata)

Example #1
rule "High"
@Defeasible
@Cuts( "Low" )
when
  $p : Person( age > 25 )
then
  $p.setPolicyType( "A" );
  *log( "A policy"  );*
end

rule "Low"
@Defeasible
when
  $p : Person( age > 25 )
then
  $p.setPolicyType( "B" );
  log( "B policy" );
end

If you just override the values, you'll see TWO logs and $p.policyType ==
"A".
If you override the activations, only the consequence of "High" will fire.
The attributes here would override the activations: notice that, unlike
salience, the activation
of High will prevent the activation of Low altogether


Example #2 :

rule "High"
@Defeasible
@Defeats( "Low" )
when
  $p : Person( age > 25 )
  $c : Car( color == "red" )
then
  $p.setPolicyType_Logical( "A" );  // syntax to be determined yet! 
end

rule "Low"
@Defeasible
when
  $p : Person( age > 25 )
then
  $p.setPolicyType_Logical( "B" );
end

In this case, the override would be at the value level: unlike salience or
the previous example,
here the TMS will keep track of both attempts at setting the policy type
value. This means that
the policyType will be "A" BUT, should e.g. the Car be retracted, the
policyType will automatically
be modified to "B" since now that unblocked "set" would support the value.
(This case will actually require some more time to support)

Davide





--
View this message in context: http://drools.46999.n3.nabble.com/Cutom-Attributes-in-Drools-tp4019692p4019791.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list