1

I want to load a new drl file based on the "when then " condition of some rule. In the following example i want to include a new "checkMasterData.drl" file when getFilteredMasterData().size()>3 from the another drl file

rule "Check for mouse catch"
  dialect "java" 
when
  $notification:NotificationVO(getFilteredMasterData()!=null
 ,getFilteredMasterData().size()>3);
then
  #include checkMasterData.drl

end

is it possible? Or do i need to do this from the java code after the fireall is succes of the first drl file

abhijeet mane
  • 121
  • 1
  • 7
  • 1
    Very likely, this is not a good idea: you'll need to create a new session with everything that goes with it. - Please describe the *problem* you need to solve before discussing a technical solution. – laune Mar 07 '15 at 13:41

1 Answers1

1

It seems you cannot include drl file from another , but you can do so programatically .. as per this thread the following code can be use to merge 2 drl files to the same ruleBase and works as if they were in the same file.

PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader(getClass().getResourceAsStream( "common.drl" ) ) );
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "rules1.drl" ) ) );
RuleBase ruleBase  = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( builder.getPackage()  );
Community
  • 1
  • 1
k.elgohary
  • 403
  • 8
  • 21
  • Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Enamul Hassan Mar 09 '16 at 04:27