<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Edson,<div><br></div><div>Thanks for your reply. Yes, I believe I am implementing equals and hashCode property in the StatusProperty class:</div><div><br></div><div><div> @Override</div><div> public boolean equals(Object o) {</div><div> if (this == o) return true;</div><div> if (o == null || getClass() != o.getClass()) return false;</div><div><br></div><div> StatusProperty that = (StatusProperty) o;</div><div><br></div><div> if (!name.equals(<a href="http://that.name">that.name</a>)) return false;</div><div> if (!value.equals(that.value)) return false;</div><div><br></div><div> return true;</div><div> }</div><div><br></div><div> @Override</div><div> public int hashCode() {</div><div> int result = name.hashCode();</div><div> result ^= value.hashCode();</div><div> return result;</div><div> }</div><div><br></div><div>Yes, I am adding to the properties list before inserting the TrainingStatus object into the session. </div><div><br></div><div>Also, I tried changing from update to modify and it broke the rule. I'm using Drool 5.0.1, has that method been deprecated?</div><div><br></div><div><br></div><div>Thanks again for your help,</div><div>Mike</div><div><br></div><div><br></div><div><br></div><div><div>On Jan 24, 2010, at 6:36 AM, Edson Tirelli wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br> The rule looks fine, so the problem is somewhere else: <br><br>* Are you properly implementing the equals()/hashcode() methods in the StatusProperty class? or are you checking for the exact same instance (in which case the defaul equals()/hashcode() would work)<br>
<br>* are you adding the properties to the TrainingStatus.properties collection before inserting TrainingStatus into the session? or are you calling update/modify after inserting it?<br><br> Also, not related to the problem at all, but we recommend you to use modify() instead of update() in your rules consequence:<br>
<br>modify( t ) {<br> setNextSection( "section_b" ),<br> setPreviousSection( "section_overview" )<br>}<br>
<br> []s<br> Edson<br>
<br><br><div class="gmail_quote">2010/1/24 Mike Dougherty <span dir="ltr"><<a href="mailto:mjdougherty@gmail.com">mjdougherty@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello all,<br>
<br>
I've been getting more and more into using Drools Expert, but I certainly still have a lot to learn. I have almost a complete rules file ready to go. But I am having an issue with the LHS checking that a collection contains a certain object value. The rule currently looks like this:<br>
<br>
rule "Rule Name"<br>
no-loop true<br>
when<br>
property : StatusProperty( name == "propertyName", value == "valueA" )<br>
t : TrainingStatus( currentSection == "section_a", properties contains property )<br>
then<br>
t.setNextSection( "section_b" );<br>
t.setPreviousSection( "section_overview" );<br>
update( t );<br>
end<br>
<br>
<br>
The TrainingStatus object has the following fields:<br>
<br>
public class TrainingStatus implements Serializable {<br>
private String currentSection;<br>
private String nextSection;<br>
private String previousSection;<br>
private Set<StatusProperty> properties = new TreeSet<StatusProperty>();<br>
}<br>
<br>
And the StatusProperty object has the following:<br>
<br>
public class StatusProperty implements Serializable {<br>
private String name;<br>
private String value;<br>
}<br>
<br>
<br>
I'm inserting a TrainingStatus object that should match this rule. But the resulting object does not have the nextSection and previousSection fields set to the values they should.<br>
<br>
Can anyone advise on how to get this rule working as expected?<br>
<br>
Thanks for your help!<br>
<br>
Mike<br>
<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss by Red Hat @ <a href="http://www.jboss.com/">www.jboss.com</a><br>
_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/rules-users<br></blockquote></div><br></div></body></html>