Reputation: 23095
I have a use-case where I need to maintain separate drl
file for separate entities.
For example,
entity 1
has a set of facts
which should be driven by drl1
entity 2
has a set of facts
which should be driven by drl2
How should I implement this?
I do not know how to achieve 2
Upvotes: 0
Views: 2633
Reputation: 31290
If you build your Knowledge Base along the lines given below, you can repeat adding another FileInputStream to the KieFileSystem.
KieServices kieServices = KieServices.Factory.get();
KieFileSystem kfs = kieServices.newKieFileSystem();
// repeat
FileInputStream fis = new FileInputStream( "simple/simple.drl" );
kfs.write( "src/main/resources/simple.drl",
kieServices.getResources().newInputStreamResource( fis ) );
// end
KieBuilder kieBuilder = kieServices.newKieBuilder( kfs ).buildAll();
Results results = kieBuilder.getResults();
if( results.hasMessages( Message.Level.ERROR ) ){
System.out.println( results.getMessages() );
throw new IllegalStateException( "### errors ###" );
}
KieContainer kieContainer =
kieServices.newKieContainer( kieServices.getRepository().getDefaultReleaseId() );
KieBase kieBase = kieContainer.getKieBase();
kieSession = kieContainer.newKieSession();
Upvotes: 1