• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Need some help on Drools 5.1.1 code syntax and logic for the issue described below

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
Need a quick help on the drools syntax for the below code snippet . We are using Drools 5.1.1 . The code snippet was given below.

when
$rulesSupport : RulesSupport() from RulesSupportFactory.instance();
$policyUnit : PolicyUnit();
Boolean() from $rulesSupport.logStart(212, $policyUnit, result, null);
Boolean(booleanValue == false) from $rulesSupport.isHashCodeEqual($policyUnit, result);

$divisionID : String() from $policyUnit.groupID;


/* When there is no dependent for the policy subscriber then the line of code fails and causing non-execution of then clause S.O.P statement. The solution expected is we need a condition when there is no dependent
(i.e $policyUnit.dependentInfoList) then only we need to skip the below code line execution */

$memberInfo : Member(maintenanceInfo != null, enrollmentInfo != null)
from $policyUnit.dependentInfoList;




$subscriberInfo : SubscriberMember(maintenanceInfo != null, enrollmentInfo != null);

then
System.out.println("Testing $divisionID ="+$divisionID);
end



Usually in case of any health care policy, a policy holder may or may not have dependents. That means in the earlier XML input i have sent we will not get DependentInfo block when the policy subscriber don't have any dependents.
Now the issue is with the above bold line of code. when there is no dependent then $policyUnit.dependentInfoList; will be empty, so the condition will fail and then clause wont be executed.
This issue needs to be fixed in such a way that when there is no dependent and when there is a dependent also we have to execute the then clause.
Some thing like the below java equivalent code ( the bold line need to be surrounded with a conditional check) .

if(dependentInfo != null)
{


$memberInfo : Member(maintenanceInfo != null, enrollmentInfo != null)
from $policyUnit.dependentInfoList;


}
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srinivasa, welcome to CodeRanch!

Unfortunately, I haven't seen many responses to threads that involve Drools, in these forums. We don't seem to have enough expertise around that library. You might want to try the Drools user mailing list which as far as I know is pretty active.
 
Srinivasa Rao Ch
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Jaikiran Pai!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!