RuleFlow and facts
by paf84
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-tp26525344p26525344.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years
GUI help
by SzA84
Hi!
I have some questions about the guided editor.
I try to build a rule in the guided editor. I added some conditions and this
is the generated DRL:
Rule "grafikus"
dialect "mvel"
when
orvosimeres$Adattipus( ertek == "/heart_rate" )
orvosimeres$Mertadat( mertekegyseg == "/min" , mozgas == "true" ,
vernyomas > ( 140 ) , vernyomas < ( 180 ) )
then
end
My imports in the rule.package file are the following:
package orvosi;
import orvosi.orvosimeres.Adattipus;
import orvosi.orvosimeres.Mertadat;
And I have this error message: unknown:4:2 Unexpected token 'orvosimeres' .
So that is my first question. What can cause the problem?
And my other question is, how can I execute a rule, that was made in the
guided editor?
Thanks in advance for the reply!
--
View this message in context: http://old.nabble.com/GUI-help-tp26518461p26518461.html
Sent from the drools - user mailing list archive at Nabble.com.
15 years
Rule runs twice without explicit call to update($fact).
by Jason Smith
My colleague has confirmed that this behavior has been around since Drools 4, and it continues to be a problem for Drools 5.0.1 and 5.1.0.M1, assuming it's a problem and not working as intended.
$fact.setPath("...") implements the correct PropertyChangeSupport mechanism for Drools. At least Drools is using it and responding mostly as expected.
This runs once:
rule "Constrain to owner or published to public"
when
$fact : ListFact(
$path : path not matches ".*owner.*",
noopResponse == true
)
$model : Model()
then
modify($fact)
{
setPath($fact.getPath() + "[owner]")
}
update($fact);
end
This runs twice:
rule "Constrain to owner or published to public"
when
$fact : ListFact(
$path : path not matches ".*owner.*",
noopResponse == true
)
$model : Model()
then
modify($fact)
{
setPath($fact.getPath() + "[owner]")
}
end
If I don't use modify(...) and simply change the $fact bean path property, the same thing occurs. If I explicitly call update($fact), the rule runs once. If I don't it runs twice.
I get "/path[owner][owner]" when I actually wanted "/path[owner]", because it ran twice, not once.
Why doe update(...) work differently from the PropertyChangeSupport mechanism??? Shouldn't I be able to depend on Drools to run this rule only one time?
I am, admittedly, a bit of a noob at this, but I ran this by my local Drools resident expert, and he doesn't know the answer either.
Thanks so much!
Jason Smith
Software Engineer
InfoTrust Group, Inc.
500 Discovery Parkway, Suite 200
Superior, CO 80027
Office 303-627-6571
Fax 303-666-6711
Email jsmith(a)infotrustgroup.com<mailto:jsmith@infotrustgroup.com>
WEB www.infotrustgroup.com<http://www.infotrustgroup.com/>
This e-mail and all information included herein do not constitute a legal agreement accorded by INFOTRUST GROUP and its affiliates and subsidiaries. All legal agreements must be formulated in writing by a legal representative of INFOTRUST GROUP. This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail by mistake, please inform us and destroy this e-mail and any documents it might contain. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. Thank you for your cooperation.
15 years
Question on Rule Flow and Web Console
by ramram8
Hi All,
I have a question about rule flow and web console:
- Can we create a Rule Flow scenario in which the User tasks in it is
dynamic. I created a Rule Flow using Fluent Api but what will happen is
that in this case I wont have a single Rule Flow scenario with dynamic
number of user tasks I ended up by having multiple scenarios. I used also
the ForEach loop but what happened is that the user tasks are all created at
the same level.
what i am looking to is to have according to certain parameter of (2) for
example
start > task 1 > task 2 > end
if the parameter value is (3) then I will have
start > task 1 > task 2 > task 3 > end
Can this be achieved in Rule Flow ???
And if it Cant?? is there any Alternative ???
--
View this message in context: http://old.nabble.com/Question-on-Rule-Flow-and-Web-Console-tp26508838p26...
Sent from the drools - user mailing list archive at Nabble.com.
15 years
Returned mail: Data format error
by Post Office
The original message was received at Thu, 26 Nov 2009 14:05:34 +0800 from [161.48.62.85]
----- The following addresses had permanent fatal errors -----
rules-users(a)lists.jboss.org
15 years
Returned mail: Data format error
by The Post Office
The original message was received at Thu, 26 Nov 2009 10:30:47 +0800 from lists.jboss.org [198.121.175.118]
----- The following addresses had permanent fatal errors -----
rules-users(a)lists.jboss.org
----- Transcript of the session follows -----
... while talking to lists.jboss.org.:
554 <rules-users(a)lists.jboss.org>... Message is too large
554 <rules-users(a)lists.jboss.org>... Service unavailable
15 years
5.10M samples
by Chris Richmond
I loaded the latest (5.1M) sample for fusion into eclipse and it builds and
runs, but does anyone else get this exception from time to time?
Thanks,
Chris
=============================================================
Unexpected exception caught: [Error: cannot invoke getter: getSymbol
[declr.class: org.drools.examples.broker.model.SuddenDropEvent; act.class:
null]]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
org.drools.runtime.rule.ConsequenceException: [Error: cannot invoke getter:
getSymbol [declr.class: org.drools.examples.broker.model.SuddenDropEvent;
act.class: null]]
[Near : {... Unknown ....}]
^
[Line: 1, Column: 0]
at
org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleExcept
ion(DefaultConsequenceExceptionHandler.java:23)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:980)
15 years
Drools bootcamp schedules
by Chris Richmond
Hello all,
Is there a list of scheduled boot camps with dates/locations anywhere? I
can't seem to find it on the site/blog.
Thanks,
Chris
15 years
Drools Flow 5.1 - Update JPA Entity - while workitem is in pending state - variable persistence strategy
by Vijay K Pandey
Hi,
In Drools Flow (5.1) , if for a work item "Wait For Completion" is true - what is the best way of updating the variables (JPA entities) configured through the Variable Persistence strategy - from a session (loaded through JPAKnowledgeService) while the work item is in the "Pending" state. These variables (JPA entities) were passed to the "startProcess" method of the session (StatefulKnowledgeSession) when the process was earlier started.
Thanks
Vijay
15 years