[rules-users] "collection contains" problem
Edson Tirelli
ed.tirelli at gmail.com
Sun Jan 24 09:36:50 EST 2010
The rule looks fine, so the problem is somewhere else:
* 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)
* 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?
Also, not related to the problem at all, but we recommend you to use
modify() instead of update() in your rules consequence:
modify( t ) {
setNextSection( "section_b" ),
setPreviousSection( "section_overview" )
}
[]s
Edson
2010/1/24 Mike Dougherty <mjdougherty at gmail.com>
> Hello all,
>
> 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:
>
> rule "Rule Name"
> no-loop true
> when
> property : StatusProperty( name == "propertyName", value ==
> "valueA" )
> t : TrainingStatus( currentSection == "section_a", properties
> contains property )
> then
> t.setNextSection( "section_b" );
> t.setPreviousSection( "section_overview" );
> update( t );
> end
>
>
> The TrainingStatus object has the following fields:
>
> public class TrainingStatus implements Serializable {
> private String currentSection;
> private String nextSection;
> private String previousSection;
> private Set<StatusProperty> properties = new
> TreeSet<StatusProperty>();
> }
>
> And the StatusProperty object has the following:
>
> public class StatusProperty implements Serializable {
> private String name;
> private String value;
> }
>
>
> 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.
>
> Can anyone advise on how to get this rule working as expected?
>
> Thanks for your help!
>
> Mike
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100124/6e0990e8/attachment.html
More information about the rules-users
mailing list