[rules-users] How to write Drools rule basing on a changed property?

2011-11-09 Thread kapokfly
Requirement: 1) Rule When Person.address.address1 is changed THEN 2) Ideally we should have 2 objects, 1 for the old person instance, the other for the new person instance so contextually the LHS equals to oldPerson.address.address1 != newPerson.address.address1. A

Re: [rules-users] How to write Drools rule basing on a changed property?

2011-11-09 Thread Wolfgang Laun
The agent that is responsible for the address change must take care to provide information about what it does. This could be done by creating an UpdateEvent fact referencing the Person fact and indicating the attribute (address). Or a listener reacts to the change and insert the UpdateEvent fact.

Re: [rules-users] How to write Drools rule basing on a changed property?

2011-11-09 Thread kapokfly
Thanks, when I am saying person address is changed, our app only concerns about its initial value and its final value, any change in the middle, we don't care. Examples: person.address.address1 starts with 'my addr1' later a couple of changes were made, say its final value is 'my

Re: [rules-users] How to write Drools rule basing on a changed property?

2011-11-09 Thread Wolfgang Laun
It seems that this is more of a technical problem on the Java side: how to register the fact that a certain property of an element has changed. You'll need somthing like a clone method. The old version of Person need and should not remain in Working Memory, but a simple wrapper fact referencing

Re: [rules-users] How to write Drools rule basing on a changed property?

2011-11-09 Thread kapokfly
Yes, that is a Map base approach I am thinking. Now more questions: global MapObject, Object oldObjectContext WHEN $person: Person() eval(((Person)oldObjectContext[$name]).jobTitle == $person.name) THEN Q1: without eval, the compiler will report error Q2: without type cast, the compiler