[rules-users] How best to get back the updates that rules perform on declarative fact objects onto the domain objects (Dynamic fact generation with Declarative Fact Model)

Davide Sottara dsotty at gmail.com
Sat Mar 31 15:22:12 EDT 2012


Hi Vidya,
I would suggesting trying one of the following two options. Both exploit
recently introduced
features: they are experimental, so it would be great to see them in action
and get feedback.
You'll need 5.4-SNAPSHOT or 5.4RC1 (coming out on Monday)

----------------------------------------------------------

1) Use property-specific
http://blog.athico.com/2012/01/fine-grained-property-change-listeners.html

use "listener" rules to synchronize your fields:

declare Bean
@propertyReactive
  a : String
end

rule "Link field A"
when
 $b: Bean( $a : a ) @watch( a )
 $x : DomainObject( a != $a ) 
then
 $x.setA( $a );
end

The main disadvantage is that you have to write rules for each field (you
could generate them automatically from templates and add the resulting DRL)
----------------------------------------------------------

2) Use traits
http://blog.athico.com/search/label/traits

declare trait Bean
  a : String
end

rule "Don"
no-loop
when
  $x : DomainObject()
then
  don( $x, Bean.class )
end

Afterwards, any update on the "Bean" instance will be refelected on the
underlying DomainObject.

----------------------------------------------------------

Please get back to us in case you have problems
Best
Davide

--
View this message in context: http://drools.46999.n3.nabble.com/How-best-to-get-back-the-updates-that-rules-perform-on-declarative-fact-objects-onto-the-domain-obje-tp3873966p3874001.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list