CommandFactory.newSetGlobal and scope
by Ricardo J. Méndez
Hi everyone,
I'm reading through Michael Bali's Drools JBoss Rules book as well as the
reference guide, and I've got a question of scope about
StatefulKnowledgeSessions.
I understand that if I call setGlobal on a stateful session, this global
value will be shared for all simultaneous calls to executeRules across all
threads. I'm looking into CommandFactory, which has a newSetGlobal
method. From what I gather, a global set via CommandFactory.newSetGlobal
and then executed with a call to
execute(CommandFactory.newBatchExecution(cmds)) would be scoped solely to
that execution, regardless of it is a StatefulKnowledgeSession and there are
other parallel command executions against the same session.
Can anyone confirm if that is accurate?
Thanks in advance,
--
Ricardo J. Méndez
http://www.arquetipos.co.cr/
14 years, 3 months
Guvnor -- Business Rules and RuleFlow groups
by Andrew Waterman
Hi all,
I'm wondering how business rules in the Guvnor are meant to interface with rule-flow groups. If I use a specific flow, where in the cycle will business rules be located? Should I specify the ruleflow-group in Guvnor's business rules editor? Some insight on how these ideas should interoperate would be really appreciated. :)
best wishes,
Andrew
14 years, 3 months
How do I get node ID from workItem?
by Alan.Gairey@tessella.com
In Drools Flow, in a work item handler, I need to get the node ID (from
the .rf file) for the given WorkItem instance (using JPA state
persistence).
Is there a reliable way to do this? Any help gratefully received.
Thanks,
Alan
14 years, 3 months
Unable to Access Facts in second rule.
by Ritesh
Hi,
I am trying to work on below rules, there are no compilation errors and all
rules getting executed.
Obersation:
1. Able print message in first rule consequence.
2. Unable to print message in second rule consequence.
3. Not getting exception in the last rule. The Test Data i am working on
should generate one exception in the last rule.
It would be really very helpful if anyone can help.
Thanks and Regards,
Ritesh
Below is my DRL File:
import java.util.List;
import java.math.*;
import java.util.*;
import java.text.*;
import org.apache.commons.lang.*;
declare DistinctAT
d_auditT : String
end
declare ActualSum
auditT : String
tranType : String
sumOfThree : BigDecimal
end
rule "insert combined sum"
agenda-group "init"
auto-focus true
no-loop true
salience 10
dialect 'java'
when
GNMVT( movTransactionType == 'OD', $movType : idMovMovementType,
$tradeSta : movTradeStatus,
$fndCstPrc : movFundCostPrice, $movTranType : movTransactionType,
$movAuditT : movAuditTrail )
//not ActualSum(auditT == $movAuditT, tranType == $movTranType)
then
BigDecimal actSum =
resltForMovTyp($movType).multiply(resltForMovTrdSts($tradeSta)).multiply($fndCstPrc);
ActualSum $as = new ActualSum();
$as.setAuditT($movAuditT);
$as.setTranType($movTranType);
$as.setSumOfThree(actSum);
insert($as);
System.out.println("AT :" + $movAuditT + " Actual Sum :" + actSum);
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Second").setFocus();
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Third").setFocus();
end
rule "insert distinct AT"
agenda-group "Second"
auto-focus true
dialect 'java'
when
$a : ActualSum( $AT : auditT )
not DistinctAT( d_auditT == $AT )
then
DistinctAT $disAT = new DistinctAT();
$disAT.setD_auditT($AT);
insert($disAT);
//System.out.println("Distinct Audit Trial :" + $AT + "TotlNet :" +
$lfna_MO.getPtnaFundTotalNetAsset());
//System.out.println("TotlNet :" +
$lfna_MO.getPtnaFundTotalNetAsset());
System.out.println("Done!");
//drools.getKnowledgeRuntime().getAgenda().getAgendaGroup("Third").setFocus();
end
global ExceptionList exceptions
rule "gpMiscellaneous_Operation"
agenda-group "Third"
when
$r_MO : RuleMetaData(ruleName == "gpMiscellaneous_Operation" )
$lfna_MO : GLFNA(ptnaFundTotalNetAsset != 0)
DistinctAT( $dAT: d_auditT )
$total : BigDecimal()
from accumulate( ActualSum( auditT == $dAT, $actSum_Main : sumOfThree ),
sum( $actSum_Main ) )
eval(
chkRuleExpre( $total,$lfna_MO,$r_MO )
)
then
BaseExceptionBuilder builder =
BaseExceptionBuilder.createBaseExceptionBuilder($r_MO);
BaseException e = builder.createException();
exceptions.add(e);
System.out.println("Done Main Rule");
end
function boolean chkRuleExpre(BigDecimal ttl, GLFNA l, RuleMetaData r)
{
double val = Math.abs( 100 * ttl.doubleValue() /
l.getPtnaFundTotalNetAsset().doubleValue() );
if (val > (Double) r.getRuleArg("Miscellaneous_Operation_Low"))
{return true;}
else{return false;}
}
function BigDecimal resltForMovTyp(String str)
{
if (str.equals("E") || str.equals("R"))
{ return BigDecimal.valueOf(-1.0); }
else
{ return BigDecimal.valueOf(1.0); }
}
function BigDecimal resltForMovTrdSts(String str)
{
if (str.equals("XX"))
{ return BigDecimal.valueOf(-1.0); }
else
{ return BigDecimal.valueOf(1.0); }
}
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Unable-to-Access-Fact...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
More Information - NoClassDefFoundError when inserting
by John Peterson
We've discovered that if we create a class in Java corresponding to our
DerivedValues class, we do not get the error, however, this takes away
the flexibility we were trying to provide our Guvnor users.
Interestingly enough, if we put a print statement into the setter for
appID in the Java class, we DO NOT see the print message until the 52
record. It appears that Drools does not start looking for the Class
Definition until we've hit some sort of maximum limit of records in
Guvnor. Is there some limit (number of instances, memory, etc.)?
------------------------------
Message: 5
Date: Tue, 24 Aug 2010 09:30:37 -0700
From: "John Peterson" <john.peterson.gv3k(a)statefarm.com>
Subject: [rules-users] NoClassDefFoundError when inserting
Guvnor-declared Fact
To: <rules-users(a)lists.jboss.org>
Message-ID:
<D3A6E68928C9104BB815C83F43A36BDF0E27C9F1(a)WPSCV6NH.OPR.STATEFARM.ORG>
Content-Type: text/plain; charset="us-ascii"
I'm experiencing a stack trace error (which I've pasted below) with a
sample Drools/Guvnor application. I'm running version 5.0.1 right now.
Here's the scenario:
I have a Java application loading data (56 records right now) from a
flat file, creating objects (one per row), parsing the individual fields
on the file into the attributes of the objects, putting them into an
array, and then inserting them into my Guvnor session. In Guvnor, I
have a POJO model to receive the data plus a Declarative Model that
enables the Guvnor user to set derived values based on the input data.
There is a very basic rule that says the following (using the Guided
Editor):
When
AppData[ad]
Then
System.out.println("Creating DerivedValues for " +
ad.getAwards_id()); /* Added as Free Form DRL
Insert DerivedValues appID=ad.getAwards_ID();
System.out.println("DerivedValus for Awards_id " + dv.getAwardsID()); /*
Added as Free Form DRL
Essentially, for each Fact of AppData, I'm creating and linking it to a
Fact of DerivedValues that the user can add attributes to. I runs fine
for the first 51 rows, then blows up on the rule when it is processing
the 52 row (with 4 more to go after that). If I cut the file down to
only have 51 rows, it doesn't blow up. The error -
java.lang.NoClassDefFoundError: com/statefarm/DerivedValues is confusing
because it has used DerivedValues 51 times without issue up to this
point. I've been trying to a handle on this for a couple days without
any luck.
Here is my stack trace:
RuleAgent(default) INFO (Tue Aug 24 11:17:12 CDT 2010): Configuring with
newInstance=false, secondsToRefresh=-1
RuleAgent(default) INFO (Tue Aug 24 11:17:12 CDT 2010): Configuring
package provider : URLScanner monitoring URLs:
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/com
.statefarm/LATEST
RuleAgent(default) INFO (Tue Aug 24 11:17:15 CDT 2010): Applying changes
to the rulebase.
RuleAgent(default) INFO (Tue Aug 24 11:17:16 CDT 2010): Adding package
called com.statefarm
(53 blank rows removed to save space)
Creating DerivedValues for 122932
DerivedValus for Awards_id 122932
Creating DerivedValues for 122440
DerivedValus for Awards_id 122440
Creating DerivedValues for 122433
DerivedValus for Awards_id 122433
Creating DerivedValues for 122295
DerivedValus for Awards_id 122295
Creating DerivedValues for 119677
DerivedValus for Awards_id 119677
Creating DerivedValues for 118089
DerivedValus for Awards_id 118089
Creating DerivedValues for 118055
DerivedValus for Awards_id 118055
Creating DerivedValues for 118047
DerivedValus for Awards_id 118047
Creating DerivedValues for 118001
DerivedValus for Awards_id 118001
Creating DerivedValues for 117969
DerivedValus for Awards_id 117969
Creating DerivedValues for 117750
DerivedValus for Awards_id 117750
Creating DerivedValues for 117685
DerivedValus for Awards_id 117685
Creating DerivedValues for 117679
DerivedValus for Awards_id 117679
Creating DerivedValues for 117607
DerivedValus for Awards_id 117607
Creating DerivedValues for 117520
DerivedValus for Awards_id 117520
Creating DerivedValues for 117492
DerivedValus for Awards_id 117492
Creating DerivedValues for 117432
DerivedValus for Awards_id 117432
Creating DerivedValues for 117413
DerivedValus for Awards_id 117413
Creating DerivedValues for 117292
DerivedValus for Awards_id 117292
Creating DerivedValues for 117230
DerivedValus for Awards_id 117230
Creating DerivedValues for 117137
DerivedValus for Awards_id 117137
Creating DerivedValues for 116971
DerivedValus for Awards_id 116971
Creating DerivedValues for 116748
DerivedValus for Awards_id 116748
Creating DerivedValues for 116662
DerivedValus for Awards_id 116662
Creating DerivedValues for 116579
DerivedValus for Awards_id 116579
Creating DerivedValues for 116101
DerivedValus for Awards_id 116101
Creating DerivedValues for 115834
DerivedValus for Awards_id 115834
Creating DerivedValues for 115730
DerivedValus for Awards_id 115730
Creating DerivedValues for 114885
DerivedValus for Awards_id 114885
Creating DerivedValues for 114837
DerivedValus for Awards_id 114837
Creating DerivedValues for 114760
DerivedValus for Awards_id 114760
Creating DerivedValues for 114728
DerivedValus for Awards_id 114728
Creating DerivedValues for 114652
DerivedValus for Awards_id 114652
Creating DerivedValues for 114317
DerivedValus for Awards_id 114317
Creating DerivedValues for 113944
DerivedValus for Awards_id 113944
Creating DerivedValues for 113908
DerivedValus for Awards_id 113908
Creating DerivedValues for 113251
DerivedValus for Awards_id 113251
Creating DerivedValues for 113230
DerivedValus for Awards_id 113230
Creating DerivedValues for 112949
DerivedValus for Awards_id 112949
Creating DerivedValues for 112397
DerivedValus for Awards_id 112397
Creating DerivedValues for 111749
DerivedValus for Awards_id 111749
Creating DerivedValues for 111313
DerivedValus for Awards_id 111313
Creating DerivedValues for 111035
DerivedValus for Awards_id 111035
Creating DerivedValues for 110646
DerivedValus for Awards_id 110646
Creating DerivedValues for 110617
DerivedValus for Awards_id 110617
Creating DerivedValues for 109918
DerivedValus for Awards_id 109918
Creating DerivedValues for 109821
DerivedValus for Awards_id 109821
Creating DerivedValues for 109439
DerivedValus for Awards_id 109439
Creating DerivedValues for 109154
DerivedValus for Awards_id 109154
Creating DerivedValues for 105709
DerivedValus for Awards_id 105709
Creating DerivedValues for 105333
DerivedValus for Awards_id 105333
Creating DerivedValues for 103269 <- appears to blow up when
creating/inserting the instance of DerivedValues
Exception in thread "main" java.lang.NoClassDefFoundError:
com/statefarm/DerivedValues
at ASMAccessorImpl_320797751282666636960.getValue(Unknown
Source)
at
org.mvel2.optimizers.dynamic.DynamicGetAccessor.optimize(DynamicGetAcces
sor.java:87)
at
org.mvel2.optimizers.dynamic.DynamicGetAccessor.getValue(DynamicGetAcces
sor.java:57)
at
org.mvel2.ast.NewObjectNode.getReducedValueAccelerated(NewObjectNode.jav
a:170)
at
org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:3
7)
at
org.mvel2.ast.TypedVarNode.getReducedValueAccelerated(TypedVarNode.java:
68)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:1
04)
at org.mvel2.MVEL.executeExpression(MVEL.java:978)
at
org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:87)
at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:934)
at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885)
at
org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:660)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemo
ry.java:627)
at com.statefarm.DroolsTest.main(DroolsTest.java:30)
Caused by: java.lang.ClassNotFoundException: com.statefarm.DerivedValues
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 16 more
********************************************
14 years, 3 months
Drools Flow - Replay
by jawa
Hi,
I am writing a drools flow application and I run into a problem. Here is the
scenario:
I have a drools flow which have multiple nodes to ask different questions to
customer And depending on the response of customer Flow decides which
question to ask customer. Customer can answer straight away or can take
hours to come back and answer. The flow is stored in db and it starts
wherever it left last time. Now the problem is if customer has replied some
questions and then he thinks that he selected a wrong answer to one of the
previous questions and wants to edit that. How can I move my flow back to
that question and start over from that question again? I can't have some
many transitions from each question because customer can go to any of the
previous question so it is not possible for have transitions in flow to go
to each previous question from each question. Is there anything in flow that
can have me start again from a specific node? e.g. If customer is question
No.32 and he wants to go back to Question No.2 or uses browsers back button
then how can we have flow to start again from Question No.2? Because the
whole tree the customer was gone through previously can change depending on
his response of Question No.2. Any idea? Let me know if I have not explained
my problem correctly.
Thanks
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-Replay-tp...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 3 months
how to get a node which is runing in processes?
by 亮亮
hi all,
I have some troubles on drools5.0. this is my questions:
1,There is a event node in ruleflow ,Is it able to customize the events? If
its can, is it in the rules file to use @ role (event) to define?
2,In ruleflow, how to get a node which is runing in processes?
Please help me .THS!
14 years, 3 months