Drools Condition matching failing -
Drools Condition matching failing -
i using drools 4 , when comparing 2 hashmap values == not working. other operators >=,<=,<,>,!= working fine. comparing below. using map . there thing wrong statement. map values updated in actions of rules. able see updated values in map comparing of values failing. using update(abc) update values.
eval((abc.getvalue("123")).intvalue() == (abc.getvalue("456")).intvalue())
rule:
rule "008" salience -18 agenda-group "cap" auto-focus true when testobj: testobj(eval(firenextpriority==true), categorycount==18, eval(!firedrules.contains(integer.valueof(23449))) && (date >= 1263925800000) && (date <= 4102338600000) && (date >= 1263925800000) && (date <= 4102338600000) && eval(1 == 1) && eval(testobj.getvariablevalue("c1tc") == testobj.getvariablevalue("y1tc"))) system.out.println("firing rule: cap - 008"); testobj.setstatus(true); testobj.setpriority(1); testobj.addtofiredrules(23449); update(testobj); testobj.addvariablevalue("c1pc", testobj.getvariablevalue("c1pc")- testobj.getvariablevalue("c1of")); end object using:
public class testobj{ long date; integer categorycount; boolean status = false; boolean executefinalrule = false; boolean executefinalruleforcatg = true; boolean firenextpriority = true; set<integer> firedrules = new hashset<integer>(); private int priority; map<string, integer> variablevalues = new hashmap<string, integer>(); public integer getcategorycount() { homecoming categorycount; } public void setcategorycount(integer categorycount) { this.categorycount = categorycount; } public void increasecategorycount(){ this.categorycount++; } public void addvariablevalue(string variablecode, integer count){ if (count < 0) count = 0; this.variablevalues.put(variablecode, count); } public integer getvariablevalue(string variablecode){ integer value = this.variablevalues.get(variablecode); homecoming value == null? 0 : value; } public boolean isstatus() { homecoming status; } public set<integer> getfiredrules() { homecoming firedrules; } public void setfiredrules(set<integer> firedrules) { this.firedrules = firedrules; } public void addtofiredrules(int l){ this.firedrules.add(l); } } thanks in advance.
i've never used drools 4.x, these observations based of (old) knowledge of 5.1.1 - may not accurate in case.
eval(firenextpriority==true) it's remarkable works. eval not maintain context of enclosing pattern (fact), you'd have write
eval(!firedrules.contains(integer.valueof(23449)) same thing.
eval(testobj.getvariablevalue("c1tc") == testobj.getvariablevalue("y1tc")) this i'd write 5.1 onwards.
the unusual thing
testobj.addvariablevalue("c1pc", testobj.getvariablevalue("c1pc") testobj.getvariablevalue("c1of")); (did mess while editing?) these changes after update call, means won't seen engine. has update of map entries "c1tc" and/or "y1tc" been done likewise in rule? won't equal drools, if java...
drools
Comments
Post a Comment