Hello,
I try to understand how to use Drolls.
It's not the first time i work with rules (i know JRules).
I have a probleme when i execute my ruleflow.
I have some rules which belong to different ruleflow-group.
I have put my ruleflow-group in my ruleflow.
THe probleme is that my ruleflow never execute the "then" part of my rules.
If i delete le ruleflow-group of my rules and i execute the drl file, all my
"then" part are executed.
I think i have a problem to give my facts to the ruleflow...
Is somebody can help me ?
thx!!
Pierre
my .java
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
// start a new process instance
System.out.println("init");
Parametre parametre = new Parametre();
parametre.para1 = "para1";
parametre.para2 = "para2";
Parametre parametre2 = new Parametre();
parametre2.para1 = "para1";
parametre2.para2 = "para2";
ksession.insert(parametre);
WorkItemHandler handler = new WorkItemHandler() {
public void executeWorkItem(WorkItem workItem,WorkItemManager manager) {
System.out.println(">" + workItem.getParameters());
System.out.println("Executing work item " + workItem);
manager.completeWorkItem(workItem.getId(), null);
}
public void abortWorkItem(WorkItem workItem,
WorkItemManager manager) {
// Do nothing
}
};
Map<String, Object> parametersDispo = new HashMap<String, Object>();
parametersDispo.put("parametre", parametre);
ksession.getWorkItemManager().registerWorkItemHandler("groupe1",
handler);
ksession.startProcess("com.sample.ruleflow1", parametersDispo);
ksession.fireAllRules();
logger.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase() throws Exception {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newClassPathResource("Sample4.drl",
RuleFlowTest.class), ResourceType.DRL);
kbuilder.add(ResourceFactory.newClassPathResource("ruleFlow1.rf"),
ResourceType.DRF);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors.size() > 0) {
for (KnowledgeBuilderError error: errors) {
System.err.println(error);
}
throw new IllegalArgumentException("Could not parse knowledge.");
}
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kbase;
}
public static class Parametre {
private String para1;
private String para2;
public String getPara1(){
return this.para1;
}
public String getPara2(){
return this.para2;
}
}
One of my rules :
rule "test 1"
ruleflow-group "groupe1"
when
p : Parametre( para1 : para1)
eval (para1 == "para1")
then
System.out.println( "groupe1 test 1" );
end
--
View this message in context:
http://old.nabble.com/RuleFlow-and-facts-tp26525341p26525341.html
Sent from the drools - user mailing list archive at
Nabble.com.