[rules-users] "collection contains" problem

Mike Dougherty mjdougherty at gmail.com
Sun Jan 24 02:16:51 EST 2010


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





More information about the rules-users mailing list