Writing rules using java..
by Kolla, Sandeep
Hi Rahul,
Its not about storing the whole file into the database.
I would have a Table representing the parameteres required to construct
a rule.
For example.
Tables:
RuleSetTable:
Ruleset_id
Ruleset_name
RuleTable:
Rule_id
Rule_name
Rule_saliance
Rule_condition
Rule_consequence
Ruleset_id
Now while loading the rules the application basically should read from
the DB, and construct the rules, as everything required to construct the
rules is avaliable in the tables.
This requirement had come up because as the rules keep changing quite
frequently, we don't want to bring down the application to load a new
DRL file.
Hope you understood what I want to achieve.
Thanks much,
Sandeep.
16 years, 1 month
RE: Rules with Lookup Tables...
by Rahul Phadnis
Have you looked at
http://labs.jboss.com/portal/jbossrules/subversion.html
I think that page is not uptodate since at the bottom
it says "Trunk is unstable and may often not build. If
you wish to build form Subversion source the latest
tag is:
http://anonsvn.labs.jboss.com/labs/jbossrules/tags/3.0.3-GA/
"
Are n't we at 3.0.5 already?
-Rahul
--- jjdepaul(a)us.ibm.com wrote:
> Rahul -
>
> Where can I find Maven2 repository that has the
> nightly builds for Drools project?! I've looked
> around on a couple of well-known ones abut no luck
> finding anything above D3.0.5
>
> thanks,
> james
> >
> > The "from" CE (conditional expression) is not
> > available in the current released jboss rules
> version
> > (3.0.5) and you probably have to use the nightly
> build
> > to use it.
> >
> > -Rahul
> >
> >
>
>
16 years, 5 months
RE: [rules-users] Using rules with database scenario
by Uday Kamath
We had similar use case. What we do is we model the Schema elements,
generate Java Beans (pojo), and write rules using these Pojo. Now we
have written a Service on top which takes Hibernate QL and gets the
database records as the same Pojos that Rules are defined on and fire
the Rules. Thus the service is generic and can be changed to take any
Query. The Rules can me modified and changed anytime and redeployed but
business objects in form of Pojos remain the same. Hope this helps
-Uday
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Joe Chuby
Sent: Friday, March 09, 2007 3:53 AM
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Using rules with database scenario
Hi all,
First time trying to learn JBoss Rules here. We have a pretty large
database (DBMS), we want to build some rules and retrieve data based on
the rules.
Could someone give a hint or an example of this usage scenario? I mean,
how can I use rules for database query, without writing my rules in SQL
directly? We are currently writing everything in HQL (Hibernate), but
the rules change every 3 months on average, so that's not a way to
maintain the system. Therefore, we want to extract that portion of the
business logic out of the code. The data structure does not change, but
the rules keep on changing.
I'm reading the user's guide, running thru the examples, writing some of
my own, but still no clue how to make it work with database.
If someone could give a sample, that would be greatly appreciated.
Thanks a lot.
________________________________
Bored stiff? <http://us.rd.yahoo.com/evt=49935/*http:/games.yahoo.com>
Loosen up...
Download and play hundreds of games for free
<http://us.rd.yahoo.com/evt=49935/*http:/games.yahoo.com> on Yahoo!
Games.
17 years, 4 months
Need Help: Errors while running FibonacciExample
by venkatesh devalapura nagabhushana
Hi,
After successfully compiling the example code FibnacciExample.java, I
tried to run it, I get the following error, let me know how to solve it:
java FibonacciExample
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
at org.drools.semantics.java.RuleBuilder.<clinit>() (Unknown Source)
at java.lang.Class.initializeClass() (/usr/lib/libgcj.so.6.0.0)
at
org.drools.compiler.PackageBuilder.addRule(org.drools.lang.descr.RuleDescr) (Unknown Source)
at
org.drools.compiler.PackageBuilder.addPackage(org.drools.lang.descr.PackageDescr) (Unknown Source)
at
org.drools.compiler.PackageBuilder.addPackageFromDrl(java.io.Reader)
(Unknown Source)
at FibonacciExample.main(java.lang.String[]) (Unknown Source)
at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
Caused by: java.util.regex.PatternSyntaxException: At position 2 in
regular expression pattern:
expected end of character class
(.*)\bmodify\s*\(([^)]+)\)(.*)
^
at java.util.regex.Pattern.Pattern(java.lang.String, int)
(/usr/lib/libgcj.so.6.0.0)
at java.util.regex.Pattern.compile(java.lang.String, int)
(/usr/lib/libgcj.so.6.0.0)
at org.drools.semantics.java.KnowledgeHelperFixer.<clinit>() (Unknown
Source) at java.lang.Class.initializeClass()
(/usr/lib/libgcj.so.6.0.0)
...8 more
Is it require to place .drl file in the same directory as that of the
source code ?
Thanks,
Venkatesh
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
WARNING: Computer viruses can be transmitted via email. 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.
www.wipro.com
17 years, 5 months
RE: Hi.
by Anstis, Michael (M.)
Hi Sanjay,
To firstly answer your questions (in my opinion):
1. You can't do nested whens in the LHS but you can do nested if / else
in the RHS (although you'd fore go the benefits of a RETE-based
inference engine; but possible if you've got very few rules and
facts...). I believe that there is work to have an "otherwise" statement
for rule syntax, how progressed this is and how it will work I don't
know - over to Mark and team?!?
2. Yes, take a look at the "from" statement (new for 3.1-M1, see
http://wiki.jboss.org/wiki/Wiki.jsp?page=3.1M1ReleaseNotes)
3. Yes, take a look at rule-flow at
http://labs.jboss.com/portal/index.html?ctrl:cmd=render&ctrl:window=defa
ult.blog.PrjBlogPortletWindowDefaultBlog&project=jbossrules&from=1&link=
RuleFlow_%28Kris_Verlaenen%29#RuleFlow_%28Kris_Verlaenen%29 (although I
don't know if this is complete if 3.1-M1 - I think it's not). Although I
don't think your rules really need rule-flow; you just need to identify
and isolate the patterns (IF's) that would cause each "Do Something" to
be ran and create a rule for each - this has the benefit of separating
each action into a separate rule making maintenance a whole bunch
easier).
Anyway, I'd try some rules like the following examples (the rest are
based upon these):-
Rule "Rule 1"
when
NewItem ( itemStatusCode == null)
then
//do something
end
Rule "Rule 2"
when
$u : User( )
$ni : NewItem ( $isc : itemStatusCode != null )
not Codes ( codes contains $isc ) from
valDao.getValidItemStatusCodesForUser($u)
then
//Do something
end
Rule "Rule 3"
when
$u : User( )
$ni : NewItem( itemStatusCode == ItemVO.DELETED )
Codes ( codes contains $isc ) from
valDao.getValidCrossReferencePrimeCodesForUser($u)
then
//Do something
end
I've posted to the news group so everyone can contribute - don't be shy
;-)
With kind regards,
Mike
________________________________
From: Sanjay Singh - s0singh [mailto:Sanjay.Singh@wal-mart.com]
Sent: 26 March 2007 14:24
To: Anstis, Michael (M.)
Subject: Hi.
Hey Mike ... I am sorry to bother you but you seemed to be
pretty good with rules and i just could not think of anyone else to ask
abt it ... I am sorry if i am taking much of your time .. Here is my
problem if you can have a quick look ..
Look at this code once .. its very easy but it involves tons of
if else blocks conditions ..
if( newItem.getItemStatusCode() == null){
//do something
}
else{
if(
!valDao.isValidItemStatus(newItem.getItemStatusCode(),user) ){
//do something
}
if(
newItem.getItemStatusCode().equals(ItemVo.DELETED)||getItemStatusCode().
equals(ItemVo.INACTIVE) ){
if(
valDao.isCrossReferencePrime(newItem.getItemNbr(),user)){
//do something
}
else if(
valDao.isFutrCrossReferencePrimeOrSecond(newItem.getItemNbr(),user) ){
//do something
}
else if(
valDao.isComponentLink(newItem.getItemNbr(),user)){
//do something
}
else if(
valDao.hasWhseOnHandsOrOnOrders(newItem.getItemNbr(),user)&&CountryCode(
).equals("CA") ){
//do something
}
}
else{
if(
valDao.isUnlikeAsstParentWithNonActiveChildren(newItemNbr,user) ){
//do something;
}else if
(isLikeAssortmentBaby(newItemNbr,user)&&!alDao.isLikeAsstParentActive(ne
wItemNbr, user)){
//do something
}else{
//do something
}
}
}
}
What i am trying to understand is the right way of putting it in
drl files ..
1.What are the options for putting if else conditions ? Will i
have to write all the rules anyway and they will be called as well all
the time depending on the criteria ... or is there a way where when my
first if check which was if item number is null failed i should not go
for any other rules .. Is there a way where we could have like "when"
inside "when" .. kinda looping of conditions so if one does not meet you
dont go to the next .. jsut like in above blocks ? Whats the good way of
doing it ?
2.Is it possible to make database calls like from my dao
instance in LHS (condition) .. i know we can do it in RHS and i have
tested that as well but can we do it in LHS as sometimes we need to do
that ..like with null checks for the item status code we also want to
check something from the database like a boolean value and if that meets
the criteria we will run the rules ..as u can see above we have basic
state check with nulls etc plus we have some dao calls as well in the
condition part and then we //do something
3.Can i call rules within other rules .. so something like in
rule1 i want to call rule2 .. is that possible ?
Can you suggest a decent way of doing these if else blocks ..
this is the core stuff which we do for our rules here .. if i can handle
this kind of conditions i guess i can handle anything out here ...
Thanks for all the help ..
Sanjay
________________________________
*******************************************************************
*** This email and any files transmitted with it are
confidential
and intended solely for the individual or entity to whom they
are
addressed. If you have received this email in error destroy it
immediately.
******************************************************
**************** Wal-Mart Confidential
****************************
******************************************
17 years, 8 months
RE: [rules-users]The Rule is not working with milestone
by Sikkandar Nawabjan
Hi,
The below rule for dublicate checking is working fine with 3.0.5 but not with milestone version? Is that a problem with milesone?
rule "rule01"
when
$provAddress:ProviderAddress( $addType : addressTypeCode, $pPI : primaryPracticeIndicator )
$provAdd:ProviderAddress( addressTypeCode == $addType, $pp:primaryPracticeIndicator == $pPI )
then
System.out.println("Hi"+$addType+" "+$pPI+"::"+$pp);
retract($provAddress);
end
Basha
17 years, 8 months
new bee writing rules
by temp temp
I have a n object which has a method which returns java.util.Map .
Is it easy to implement a rule which calls the gettter method on this object for the map and get the value for a specified key and check condition on that value ?
Example
class MyObject {
private Map properties;
public Map getProperties(){
return properties;
}
public void setProperties(Map aMap){
this.properties=aMap;
}
Now the rule I need is
MyObject aObject= new MyObject();
return ( aObject.getPorperties().get("price").toString.equals("aproperty"))
}
Is this possible to write in a drl file and is this a good approach also is using eval in a drl file is not a good solution ie it has any problems ?
Thanks
Miro
---------------------------------
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
17 years, 8 months