[rules-users] drl execution problem
Wolfgang Laun
wolfgang.laun at gmail.com
Thu Mar 29 04:10:15 EDT 2012
You have, say,
Person( "Joe" )
Person( "Jim" )
This happens:
person1 <- match any Person: (1) match Joe, and (2) match Jim
person2 <- match any Person name2!=name1: when (1) then match Jim,
when (2) then match Joe
To avoid this, you can
(a) retract person2 in rule "FirstNameDifference"
(b) add a constraint asserting an ordering between Persons, e.g.,
some unique number
(c) use compareTo with names, test for -1
(d) post-process dataDifferenceVO.getDataDiffArray()
-W
On 29/03/2012, arup <arup4u2007 at gmail.com> wrote:
> i have one drl like below:
>
> rule "FirstNameDifference"
> no-loop true
> lock-on-active true
> when
> person1: Person( $firstName1: firstName )
> person2: Person( firstName != $firstName1 )
>
> then
> dataDifferenceVO.getDataDiffArray().add("Person/FirstName");
> end
>
> i'm passing a list of objects in which i have 2 person type objects. my aim
> is to check if the firstnames are same or different. if its different i need
> to add one String to the DataDiffArray that is declared inside
> DataDifferenceVO class.
>
> but as i pass 2 person objects in the WM the rule is getting executed twice.
> i.e, the string "Person/FirstName" is getting added twice in the array list.
> why is this happening?... the rule should compare 2 firstnames and return
> one String...is not that?... what step should i take to achive what i
> want....
> Thanks a lot i advance... :) :) :)
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/drl-execution-problem-tp3866929p3866929.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
More information about the rules-users
mailing list