I am a newbie with Jboss Rule. I have gone through the documentation but I fail to find the approach to begin writing rule for following code sample.
For each User code in the list
{
If User code = ‘11’
{
If User code ‘17’ present in the group
{
Add letter id 1
}
Else If User code ‘18’ present in the group
{
Add letter id 2
}
}
Else
{
Add letter id 3 which is the letter need to be sent for code 11
}
}
EDIT:
So far this is what i can develop for the user case discussed above.
- I am inserting (List of
UserDetailVo) to the drools session. - Object (
UserDetailVo) contains (List ofUserInfoVo). EveryUserInfoVocontains a code.
Now I want to iterate over the (List of UserInfoVo) and update (letterId) to every (UserDetailVo) as i am trying to do below.
Case1 : when codeList has 110,121
rule "USER LETTER GROUPING 110,121"
salience 300
no-loop true
when
userDetailVo : UserDetailVo ()
UserInfoVo(code=="110") from userDetailVo.codeList
UserInfoVo(code=="121") from userDetailVo.codeList
then
userDetailVo.addLetterId(1);
//modify(trrDetailRequestVo)
end
Case2 : when codeList has 110,127
rule "USER LETTER GROUPING 110,127"
salience 300
no-loop true
when
userDetailVo : UserDetailVo ()
UserInfoVo(code=="110") from userDetailVo.codeList
UserInfoVo(code=="127") from userDetailVo.codeList
then
userDetailVo.addLetterId(2);
//modify(trrDetailRequestVo)
end
Case3 : when codeList has only 110
rule "USER LETTER GROUPING 110"
salience 300
no-loop true
when
userDetailVo : UserDetailVo (this.letterID.size() == 0) // Checking size of the list
UserInfoVo(code=="110") from userDetailVo.codeList
then
userDetailVo.addLetterId(3);
//modify(trrDetailRequestVo)
end
Issues that I am facing is if I user modify/update at the end of rule. It goes into an infinite loop. If I remove modify/update, in case 3 though list size if greater than 0 still rule is fired.
User,Letterbut don't understand whatGroupis and how it relates toUser. - andbi