Using Drools for Business Rules Validation
by pm-lemos
Hi everybody,
I've started reading about Drools and I quite didn't understand if it's
appropriate for a work I want to do...
I'm posting this in order to get some feedback about what other people may
think about it.
So heres what I need:
I need to develop some sort of application (A) to be used with in order to a
"client" to write a bunch of rules he wants a given software application (B)
to comply with. And as a client I want him to be able to write these rules
in an easy way (proximately to a natural language).
After those rules are defined, I want to run a bunch of processing over
those rules in order to interpret them having in consideration my software
application (B) and execute (for each rule) some kind of validation over
that same software application (B). Ideally those methods will return a
result for the "A" application.
(If need explanations, or more details... just ask)
Thanks in advance.
Pedro
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Using-Drools-for-Busi...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
Help regrading branching of call to a rule depending upon date
by Swapnil Sawant
Hi,
I am evaluating Drool Gunvor for to implement Rules for some finance related functionality.
I need help from users to implement following scenario is Drools-Guvnor
I have created simple Rule to Calculate House Rent Allowance i.e. HRA as
HRA = 0.12 * Basic salary .(Basic will come as Input Parameter).
This rule is valid from e.g. 01-Jan-2005 to 31-July-2010 as HRA rule is changed from 1st Aug 2010
I will have to create new Rule for HRA Rule with new formula as
HRA = 0.15 * Basic salary .(Basic will come as Input Parameter).
This rule is valid from 01-Aug-2010 to 01-Aug-2999
>From 1st Aug HRA should be calculated using New Rule. But at the same time if any Arrears to be calculated(back dated calculation) depending on the date old HRA rule should be applicable.
Can I achieve this in Gunor Drool? I could achieve first half by specifying date-expires . But I am not able to achieve second half i.e. referring old rule depending on the date. I would appreciate help to solve this problem .
Thanks in advance.
Swapnil Sawant
________________________________
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.
______________________________________________________________________
14 years, 5 months
Query on Performance Improvement in Drools 5 while dealing with huge data
by senthij
Hi There,
We are using Drools 5 in our project, the requirement was to have huge
database, the data is being fetched from DB and inserted into drools working
memory.
For eg:
Cell - 50k
ExternalCell - 50k
CellRelation - 2500000
Topology hiearchy:
------------------------
-Subnetwork
- PLMN (Contained in Subnetwork)
- RNC (Contained in PLMN)
- Cells (Contained in RNC)
Problem statement:
Check if bidirectional relation not exist between cells in different
subnetwork.
How to prove?
Prove that,
First check:
- CellObA and ExternalCellObB in subnetwork 1, both are related using
CellRelationX. - Unidirectional
note: CellObA will have List property contains all ExternalCellOb names,
so ExternalCellObB name should be part of List if
there is an CellRelation relating CellObA and ExternalCellObB.
Second check:
- CellObB and ExternalCellObA in subnetwork 2, both are related using
CellRelationY. - Unidirectional (inturn proves that bi-directional relation
exist)
note: CellObB will have List property contains all ExternalCellOb names,
so similarly ExternalCellObA should be part of List if
there is an CellRelation relating CellObB and ExternalCellObA.
Check if there is missing/no relation exist between CellObB and
ExteranlCellObA.
Cell table has oneToMany relation to CellRelation table. We are using
eclipselink for ORM, since Cell and CellRelation tables are related, while
reteriving Cell, CellRelation are also part of the it (using fetch.type =
LAZY). Since Cell table is kind of master table, we are creating the
required objects by from cell entities and inserting the newly created
objects into working memory.
Cell table contains master data and ExternalCell table contains proxy
(duplicate copy of master) data.
Mapping from Entities to Objects
Entity - Objects
----------------------------------
Cell - CellOb
ExternalCell - ExternalCellOb
CellRelation - CellRelation
CellOb & ExternalCellOb contains following attributes which are used for
comparison.
- mcc,mnc,rncId,cellId and nodeId are all of type integer used for
comparsion.
- mcc, mnc, rncId and cellId are used to uniquely identify CellOb and its
ExternalCellOb through object equality. These fours attributes are used in
overrided equals() and hashcode() method.
--------------------------------------------------------------------------------------------------------------------------------------------------
Rule file:
rule "Cell Selection Rule"
salience 50
dialect "java"
when
$ucell:CellOb() from TopologyService.getInstance().getCellObs()
then
insert($ucell); // inserts each CellOb into working memory.
end
rule "External Cell Selection Rule"
salience 49
dialect "java"
when
$extucell:ExternalCellOb() from
TopologyService.getInstance().getExternalCellObs()
then
insert($extucell); // inserts each ExternalCellOb into working memory.
end
rule "Bidirectional Relations Evaluation Rule"
salience 10
dialect "java"
when
//Takes ExternalCellObB from Subnetwork 1
$extuccell : ExternalCellOb(subnetworkMgrId==1)
// Takes CellObA from Subnetwork 1, not matching cgiParam (is
mcc+mnc+rncId+cellId) of ExternalCellObB, and seeing if there is
CellRelation exist
// between ExternalCellObB and CellObA using contains check
$cell :
CellObA(subnetworkMgrId==$extuccell.subnetworkMgrId,cgiParam!=$extuccell.cgiParam,adjacentCells
contains $extuccell.fdnReverse)
//Takes ExternalCellObA from Subnetwork 2, matching CellObA cgiParam (is
mcc+mnc+rncId+cellId)
$adjextcell : ExternalCellOb (subnetworkMgrId!=$cell.subnetworkMgrId,
cgiParam==$cell.cgiParam)
//Takes CellObB from Subnetwork 2, matching ExternalCellObB, and seeing if
there is no CellRelation exist between CellObB and
//ExternalCellObA
$adjcell : CellOb ( subnetworkMgrId==$adjextcell.subnetworkMgrId,
cgiParam==$extuccell.cgiParam,adjacentCells
not contains $adjextcell.fdnReverse)
then
// FDN format looks like the one mentioned below.
//
SubNetwork=ROOT_OB,SubNetwork=1,Context=01,MElement=1,Rnc=1,Cell=RNC01-104
System.out.println("Missing Cell Relation from " + $cell.getFdn() + " to "
+ $adjcell.getFdn());
end
--------------------------------------------------------------------------------------------------------------------------------------------------
Tried following and gave performance imporvements after each change:
- Initially, we use to check the following attributes individually, like
mcc, mnc, rncId and cellId but later we combined and it
gave some performance improvements.
- Used subnetworkId to search CellOb/ExternalCellOb with in a appropriate
subnetwork.
- Java string search trick, cellNames are very lengthy but they vary at the
end of the string, so reverse the string and it improved in the
contains/not contains check in the List of strings.
What we wanted to know is from Drools part any scope of improvement/tuning
is still possible to deal with huge data and give much better performance??
Your help and guidance is much appreciated.
Regards,
Senthil Jayakumar
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Query-on-Performance-...
Sent from the Drools - User mailing list archive at Nabble.com.
14 years, 5 months
Drools-Guvnor doubt regarding firing of rules
by Pardeep Ruhil
Hi All,
I have a doubt regarding drools-guvnor, as I am going to use Drools-Guvnor and integrate it with my application.
1. Can I make two rules with the same name having different date-expires attributes.
Like depending upon the date the corresponding rule fires.
rule "discount"
date-effective "01-July-2010 12:00:00 AM"
date-expires "26-July-2010 12:00:00 AM"
when
<condition for 10% discount>
then
<result>
rule "discount"
date-effective "01-October-2010 12:00:00 AM"
date-expires "26-October-2010 12:00:00 AM"
when
<condition for 20% discount>
then
<result>
2. Can I fire the rule which are expired programmatically?
Thanks & Regards
Pradeep Ruhil
L& T Infotech
Mahape, Vashi
Mumbai
________________________________
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.
______________________________________________________________________
14 years, 5 months
CEP Stream Mode
by Jean-Philippe Steinmetz
Hello all,
I'd like to get Drools working in such a way that it is always running
and I can just stream new events into the runtime and have it execute
rules against them. From what I can tell I need to use stream mode in
order to do this. I've got everything set up for how I think it should
work (based on what I can decipher from the documentation) but what's
happening is that I'm never getting a hit on the rules I write. I can
see the event be asserted but nothing happens.
Here is my set up...
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
setKnowledgeBase(KnowledgeBaseFactory.newKnowledgeBase(config));
// Create a knowledge agent to pull load the necessary resources
kagent = KnowledgeAgentFactory.newKnowledgeAgent("MyAgenda",
getKnowledgeBase());
initResources(kagent);
setKnowledgeBase(kagent.getKnowledgeBase());
getSession().addEventListener(new DebugAgendaEventListener());
getSession().addEventListener(new DebugWorkingMemoryEventListener());
And here is how I start up Drools...
thread = new Thread() {
@Override
public void run() {
getSession().fireUntilHalt();
}
};
thread.run();
I then feed events into the engine like this...
WorkingMemoryEntryPoint stream =
getSession().getWorkingMemoryEntryPoint(origin);
stream.insert(event);
I'm obviously missing something in my setup. Any help on understanding
how this is supposed to work is greatly appreciated. Again, the goal
here is to get Drools in a state that is always running so I can pipe in
events to it and have rules execute against them.
Jean-Philippe
14 years, 5 months
Using from with named queries
by rouvas@di.uoa.gr
Hello list,
I'm using Drools.5.0.1 and I am trying to comprehend how to used the
"from" keyword over a named query.
I've googled this:
http://blog.athico.com/2007/06/chained-from-accumulate-collect.html
where it states:
p : Person( )
Restaurant( food == p.favouriteFood )
from hs.getNamedQuery( "list restaurants by postcode" )
.setProperties( [ "postcode" : p.address.zipcode ] )
.list()
If I understand the above correctly, the "hs.getNamedQuery" returns
"Restaurant" objects using values from "Person" object.
There are a couple of issues that I would like to resolve.
Where and how is the "hs" object in "hs.getNamedQuery" statement is declared?
If the "Person" object itself is the result of a NamedQuery, could the
above statement be rewritten as:
p : Person( ) from ps.getNamedQuery("return list of persons")
Restaurant( food == p.favouriteFood )
from hs.getNamedQuery( "list restaurants by postcode" )
.setProperties( [ "postcode" : p.address.zipcode ] )
.list()
Thank you for your time.
-Stathis
PS: Please take note that this is a newbie (in Drools) speaking.
14 years, 5 months
How to compare java.sql.Dates in a Drools 'when'
by Stephen Mcgruer
Hi there,
Sorry for so many questions today. How would one compare dates in a
Drools when/then rule? I have an object, Tool, that has a last used
field which is a java.sql.Date (yes, this is a fairly bad type for it
to be. Long story.). I want to write a rule to check if there is a
Tool that has this date set in the future. Now, to get the current
date/time (in Java!) you would do:
java.util.Date today = new java.util.Date();
java.sql.Date sqlToday = new java.sql.Date(today.getTime());
But how do I do something like this in a Drools rule?! (Where I want
to compare last used to sqlToday).
Thanks,
Stephen
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
14 years, 5 months
How do I totally clear out an installation of Guvnor (Tomcat 6.0)
by Stephen Mcgruer
Hi there,
I'm migrating to Guvnor RC atm, and was wanting to completely clear
out my Guvnor Packages files before I did so - I wanted everything
gone. I thought that all information was stored in the Guvnor folder
created in Tomcat/webapps, so I deleted that, restarted the server and
dragged in the new Guvnor RC WAR file. This built itself fine and is
up and running on the server - but my packages are still there! Where
abouts are these kept in Apache Tomcat? I can't just delete them from
within Guvnor because despite me being able to delete most of the
files/packages/etc, there are three categories that claim to be 'still
in use' and won't let me delete them... even though there are *no*
other files left!
Any help is much appreciated.
Stephen
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
14 years, 5 months