Note that this feature does not work for update(), and this is one of the reasons why we promote modify() since it encapsulates the field changes within the statement.
Historically these editors supported the olderupdate(x)syntax and hence rules created within the Workbench would not respond correctly to@PropertyReactiveand associated annotations within a model. This has now been rectified with the use ofmodify(x){...}blocks.
On 2 Jun 2016, at 20:15, Adrian McGrath <aussi...@gmail.com> wrote:Use Case:1. I have a java object with the @PropertyReactive annotation2. I have one rule with a salience of 50 which sets the field names: 'make' and 'model'3. I have another rule with a salience of 40 which, given certain values of the 'make' field, will modify the value of: 'model'4. I have a final rule with a salience of 30 which triggers a hardcoded java function with various parameters to do the rest of the processingIssue:Section '8.8.3.5. Fine grained property change listeners' of the Documentation (http://docs.jboss.org/drools/release/6.4.0.Final/drools-docs/html/ch08.html) says to use modify() in the drl files with the @PropertyReactive annotation in the java class.When I attempt to do this, I receive a compiler error saying modify() is undefined.
A google search indicated to me that I should use update() instead, since modify() has been removed.
When I use update(), it doesn't work as expected - the value of 'make' set in the first rule is not available in the when clause for the second rule.
Further reading of the documentation lead to this quote:Note that this feature does not work for update(), and this is one of the reasons why we promote modify() since it encapsulates the field changes within the statement.Even more looking at the documentation (including the 6.4.0 release notes) suggests that the update() syntax is the older one and modify() should be used (https://docs.jboss.org/drools/release/latest/drools-docs/html/ch02.html#d0e1660):Historically these editors supported the olderupdate(x)syntax and hence rules created within the Workbench would not respond correctly to@PropertyReactiveand associated annotations within a model. This has now been rectified with the use ofmodify(x){...}blocks.Based on everything I'm reading in the documentation, the only way to properly use PropertyReactive is with the modify() syntax however according the drools compiler, the modify() syntax no longer exists. Is all of the documentation wrong or is there something else I'm missing?
--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/4d958d9d-5210-48aa-a4c7-fd6c318bc8a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
rule "Test Modify"
salience 50
when
$scanMessage : ScanMessage(obj.descr != null)
$oidD1 : Oid () from $scanMessage.obj.descr Boolean(booleanValue == true) from $oidD1.oid == "v1"
$oidD2 : Oid () from $scanMessage.obj.descr2
Boolean(booleanValue == true) from $oidD2.oid == "v2"
then
String newMake = StringUtils.splitPreserveAllTokens($oidD1.getAttrvalue(), " ")[0].toUpperCase();
modify($scanMessage) { getObj().setMake(newMake); getObj().setName($oidD1.getAttrvalue()); }endRule Compilation error : [Rule name='Test Modify']
com/x/rules/Rule_Test_Modify1738095096.java (8:885) : The method modify(ScanMessage) is undefined for the type Rule_Test_Modify1738095096
com/x/rules/Rule_Test_Modify1738095096.java (8:904) : Syntax error, insert ";" to complete Statement
com/x/rules/Rule_Test_Modify1738095096.java (9:915) : The method getObj() is undefined for the type Rule_Test_Modify1738095096
com/x/rules/Rule_Test_Modify1738095096.java (10:953) : The method getObj() is undefined for the type Rule_Test_Modify1738095096
rule "Test Modify"
salience 50
when
$scanMessage : ScanMessage(obj.descr != null)
$oidD1 : Oid () from $scanMessage.obj.descr
Boolean(booleanValue == true) from $oidD1.oid == "v1"
$oidD2 : Oid () from $scanMessage.obj.descr2
Boolean(booleanValue == true) from $oidD2.oid == "v2"
then
String newMake = StringUtils.splitPreserveAllTokens($oidD1.getAttrvalue(), " ")[0].toUpperCase();
modify($scanMessage) {
getObj().setMake(newMake);
}
modify($scanMessage) {
getObj().setName($oidD1.getAttrvalue());
}
endgetObj().setMake(newMake);
--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/c501c243-2f29-4874-a44b-979f81cdeaff%40googlegroups.com.