Re: [rules-users] Implementaion of Rule Flow in Guvnor
by Ambika Goel
Hi All,
I have attached the Guvnor repository and the java code that I am using to run a ruleflow.
The two tables 'MasterHud' and 'FeeCalc' are decision tables made in Guvnor.
* MasterHud decision table is used to get the hudLineNumber based on lienPosition and productType.
* FeeCalc table is used to get the fee based on hudLineNumber.
I have created a ruleflow 'Fee.rf' which connects these two tables.
Below is the code I use to call Fee.rf:
public static void main(String args[]){
try{
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
LoanDetail l = new LoanDetail();
l.setLienPosition("Second Lien");
l.setProductType("ABC");
ksession.insert(l);
ksession.startProcess("hudRule");
ksession.fireAllRules();
System.out.println("Hud Line Number: " +l.getHudLineNumber());
System.out.println("Fee: " +l.getFee());
ksession.dispose();
}catch(Throwable t){
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase()throws Exception{
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newUrlResource("http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/com.example..."),ResourceType.PKG);
kbuilder.add(ResourceFactory.newClassPathResource("Fee.rf", Test.class), 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;
}
When I run this code, I get the Hud Line Number as 801 but the fee displayed is 0.0
The expected output is Hud Line Number as 801 but the fee displayed as 450.
There is no exception but I don't get the desired output.
________________________________
From: Ambika Goel
Sent: Monday, October 12, 2009 1:09 PM
To: 'rules-users(a)lists.jboss.org'
Subject: Implementaion of Rule Flow in Guvnor
I am using the following code to add to knowledge builder and run it:
knowledgeBuilder.add(ResourceFactory.newClassPathResource("QueueFlow.rf", GuvnorTest.class), ResourceType.DRF) // ruleflow
knowledgeBuilder.add(ResourceFactory.newUrlResource("http://..."), ResourceType.PKG) // guvnor package
My rule flow is connection of two tables. I set a property in action of one decision table and use it as a condition in another decision table to get the desired result.
If I run the above code, I don't get any exception but the output is 'null'.
15 years
Re: [rules-users] Agenda Groups basic question
by Rongala, Kanthi
Hi,
As suggested, I made the following changes, to get the desired output. I have some questions regarding the approach to agenda-groups (in drools 5 context)
1. I had to enable auto-focus once per each agenda-group. I thought agenda-groups were stacked internally by drools engine, and auto-focus might be acting as a directional mechanism (help determine which rule under which agenda is to be triggered). Clearly, I am mistaken and it seems that auto-focus is the way to go.
I would like to know about other ways to set focus on agenda-groups. I have seem code snippets on google bearing session.setFocus("[agenda-group-name]"). I am currently using statefulsession and cann't figure out this 'setFocus()' method
2. I was 'compelled' to comment out lock-on-active directive. I understand that lock-on-active is an variant of no-loop causing each fact to be passed to the rule only once in a active agenda (correct me if I am mistaken). With lock-on-active set, I was expecting the messages to be print once atleast, but the current behavior beats me.
Code is given below:
package com.mscibarra.examples.drools.controllers;
import com.mscibarra.examples.drools.domainentities.*;
rule "Detect and Remove Duplicate Shelves"
agenda-group "Phase1"
//lock-on-active
dialect "mvel"
auto-focus
when
$universe : LibraryUniverse()
$shelf : Shelf() from $universe.shelves
$shelf2 : Shelf(this != $shelf) from $universe.shelves
then
System.out.println("Duplicate Shelves found::"+$shelf);
// without the modify(), drools is not alerted about changes
/*
modify($universe) {
shelves.remove($shelf);
};
*/
end
rule "Singleton Shelf Detector"
agenda-group "Phase2"
//lock-on-active
dialect "mvel"
auto-focus
when
$universe : LibraryUniverse(shelves.size > 1)
then
System.out.println("Multiple Shelves found::"+$universe.shelves.size);
end
With Regards,
Swaroop
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
Message: 3
Date: Mon, 2 Nov 2009 10:51:32 -0500
From: Edson Tirelli <ed.tirelli(a)gmail.com>
Subject: Re: [rules-users] Agenda Groups basic question
To: Rules Users List <rules-users(a)lists.jboss.org>
Message-ID:
<e6dd5ba30911020751nb973184r73cd6dc46e4e50c0(a)mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"
You need to set the focus for an agenda group to execute.
[]s
Edson
2009/11/2 Rongala, Kanthi <Kanthi.Rongala(a)mscibarra.com>
> Hi,
>
>
>
> I am new to Drools and trying my hands out at Drools 5. I cann?t figure out
> how to use agenda- groups. I have a small drl file with two agenda groups
> and one rule per agenda-group. This doesn?t seem to work. However if I
> happen to comment out the agenda-group attribute, the results are as
> expected.
>
>
>
> Please let me know what I am missing.
>
>
>
> *package* com.mscibarra.examples.drools.controllers;
>
>
>
> *import* com.mscibarra.examples.drools.domainentities.*;
>
>
>
>
>
> *rule* "Detect and Remove Duplicate Shelves"
>
> *agenda-group* "Phase1"
>
> *lock-on-active*
>
> *dialect* "mvel"
>
> *when*
>
> $universe : LibraryUniverse()
>
> $shelf : Shelf() *from* $universe.shelves
>
> $shelf2 : Shelf(*this* != $shelf) *from*$universe.shelves
>
> *then*
>
> System.out.println("Duplicate Shelves found::"+$shelf);
>
> // without the modify(), drools is not alerted about changes
>
> // $universe.shelves.remove($shelf);
>
> /*
>
> *modify*($universe) {
>
> shelves.remove($shelf);
>
> };
>
> */
>
>
>
> *end*
>
>
>
> *rule* "Singleton Shelf Detector"
>
> *agenda-group* "Phase1"
>
> *lock-on-active*
>
> *dialect* "mvel"
>
> *when*
>
> $universe : LibraryUniverse(shelves.size > 1)
>
> *then*
>
> System.out.println("Multiple Shelves found::"+$universe.shelves.size);
>
>
> *End*
>
>
>
>
>
>
>
> With Regards,
>
> Kanthi Swaroop Rongala
>
> * *
>
>
>
> ------------------------------
> NOTICE: If received in error, please destroy and notify sender. Sender does
> not intend to waive confidentiality or privilege. Use of this email is
> prohibited when received in error.
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
Edson Tirelli
JBoss Drools Core Development
JBoss by Red Hat @ www.jboss.com
15 years
Re: [rules-users] Rule flow skip ruleSet node.
by liuzhikun
Thanks.I can't understand .When process reaches a ruleSet a ruleflow-group be set no-loop remain long time.Why is not reinitialize per reache a ruleSet?
liuzhikun
2009-11-03
15 years
Drools Flow Persistence : How can I use Geronimo Transaction Manager Instead of Bitronix Transaction Manager.
by Pardeep.Ruhil@lntinfotech.com
Hi,
I have query regarding the Transaction Manager in Drools persistence.
I am working on OFBiz project an application in which I have integrated it
with Drools. When I try to use the persistence of Drools with OFBiz, there
is a transaction conflict between them. Since I want to use OFBiz
transaction manager i.e. Geronimo. So can you provide me the settings to
change the default Bitronix Transaction Manager to Geronimo Transaction
Manager.
BTW I am using Tomcat as an application server.
Thanks & Regards
Pardeep Ruhil
L&T Infotech Ltd
Mumbai
Ph: +919820283884
Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com
This Document is classified as:
L&T Infotech Proprietary L&T Infotech Confidential L&T Infotech
Internal Use Only L&T Infotech General Business
This Email may contain confidential or privileged information for the
intended recipient (s) If you are not the intended recipient, please do
not use or disseminate the information, notify the sender and delete it
from your system.
______________________________________________________________________
15 years
import static function with varargs as one of the parameters doesn't work?
by Jane James
Hi guys,
I have a question regarding the import function feature in Drools 5.1.0M.
I am reading the Drools JBoss Rules 5.0 book Developer's guide by Michal Bali and tried one of the examples but somehow I couldn't get my rules work with the method that has varargs.
Here's what I have (copied from page 123):
public class ValidationHelper {
public static void error (RuleContext kcontext, Object... context) {
KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();
ValidationReport validationReport = (ValidationReport)knowledgeRuntime.getGlobal("validationReport");
ReportFactory reportFactory = (ReportFactory) knowledgeRuntime.getGlobal("reportFactory");
kcontext.insertLogical(reportFactory.createMessage(
Message.Type.ERROR, kcontext.getRule().getName(),
context));
}
}
then in my drools file (copied from page 42):
i have
import org.drools.runtime.rule.RuleContext;
import function ValidationHelper.error;
...
rule test
when
#condition
then
error(drools)
but when I ran the test, I got error message:
Exception in thread "main" org.drools.runtime.rule.ConsequenceException: [Error: unable to resolve method: ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper) [arglength=1]]
If I remove the parameter Object... context, then everything worked. But I do need the varargs here because I need my error message to be more specific.
Did anyone else encounter the same problems?
thanks!
15 years
Best way to get fix from JIRA into local drools install?
by Adam Rinehart
I have been paying attention to
https://jira.jboss.org/jira/browse/JBRULES-2230 because I am hoping to use
decision tables from within a changeset in a project I am developing. Code
to fix this issue was checked in on Oct 18th. What is the best way to use
this updated code?
>From what I've been able to find, it sounds like I will need to build my own
local instance of drools; I can't find a source of dot-revisions, or nightly
builds.
So are my options:
1. Grab trunk, manually apply the patch to the one file, build
2. Grab a snapshot of svn and build
3. Is there a nightly build process that I can download a compiled version
from?
Of these 3 which is "best", for some definition of "best"?
Adam
15 years
Re: [rules-users] Build package 'default' Guvnor
by Eugenio Abello
thanks for your help,
So this error occurs when you are trying to build the "default" package
in Guvnor?
Yes.
The process you are adding to Guvnor, which one is that? Could you share
that with us?
is a simple hello world
<?xml version="1.0" encoding="UTF-8"?>
<process xmlns="http://drools.org/drools-5.0/process"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/drools-5.0/processdrools-processes-5.0.xsd"
type="RuleFlow" name="ruleflow" id="com.sample.ruleflow"
package-name="com.sample" >
<header>
</header>
<nodes>
<start id="1" name="Start" x="16" y="16" width="48" height="48" />
<actionNode id="2" name="Hello" x="96" y="16" width="80" height="48" >
<action type="expression" dialect="mvel" >System.out.println("Hello
World");</action>
</actionNode>
<end id="3" name="End" x="226" y="14" width="48" height="48" />
</nodes>
<connections>
<connection from="1" to="2" />
<connection from="2" to="3" />
</connections>
</process>
Another antecedent. When add hellow_world.rf to Guvnor to 'defaultPackage'
and build this packet, everything works properly. 'defaultPackage' has
already been created. 'defualt' I define it.
Thx
eugenio
15 years