[rules-users] Cant check complex boolean expressions with Collections.disjoint

aitchnyu jesvinj at technovia.co.in
Tue Mar 20 08:56:27 EDT 2012


I have a `SubjectTeacherPeriod` object which has a property `strAttributeMap`
which is a map of `String` and `List<String>`. I want to check if
`HardConstraint.strAttributeValue` and
`SubjectTeacherPeriod.strAttributeMap[$attribute]` *intersect*. Here is the
rule:

    rule "hardConflictIsIn"
        when
    	$hc : HardConstraint(
    			    $attribute  : attribute,
    			    operator == "is in",
    			    $values : strAttributeValue,
    			    $period : period
    			    )
    	$stp : SubjectTeacherPeriod(
    				    period == $period,
    				    //ERROR IN FOLLOWING LINE
    				    Collections.disjoint(strAttributeMap[$attribute], $values) ==
false
    				    )
        then
    	insertLogical(new IntConstraintOccurrence("hardConflictIsIn", 
    		ConstraintType.NEGATIVE_HARD,1,
                    $hc,$stp));
    end

But the rule (actually two of them) throws the error:

Exception in thread "main" java.lang.IllegalStateException: There are errors
in the scoreDrl's:
Unable to Analyse Expression
Collections.disjoint(strAttributeMap[$attribute], $values) == false:
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast
to java.lang.Class : [Rule name='hardConflictIsIn']

Unable to Analyse Expression
Collections.disjoint(strAttributeMap[$attribute], $values) == true:
sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast
to java.lang.Class : [Rule name='hardConflictNotIn']


	at
org.drools.planner.config.solver.SolverConfig.buildRuleBase(SolverConfig.java:238)
	at
org.drools.planner.config.solver.SolverConfig.buildSolver(SolverConfig.java:170)
	at
org.drools.planner.config.XmlSolverConfigurer.buildSolver(XmlSolverConfigurer.java:103)
	at
in.co.technovia.timetabler.TimeTableApp.createSolver(TimeTableApp.java:61)
	at in.co.technovia.timetabler.TimeTableApp.main(TimeTableApp.java:45)

I got it from an answer from my own question at
http://stackoverflow.com/a/9241089/604511 . Is this a bug in Drools itself?

--
View this message in context: http://drools.46999.n3.nabble.com/Cant-check-complex-boolean-expressions-with-Collections-disjoint-tp3842259p3842259.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list