About drools
by kranthikumar dalai
Hi ,
I am new to drools. We are using drools with java in our
project. We are doing leave application system. we created some rules and
they are working undre java. But actually problem is we are facing is, we
developed this ok, if user want to change the rule then where he enter the
new rule and how it works. we have to give user the drl file or any other.
But the user dont know the drl file and he want to change only rules but he
dont know the drl file how can he enter new rules.
Regards:
Kranthi dalai
17 years, 7 months
[rule-users]RunTime polypmorphic support in 3.0.6?
by Sikkandar Nawabjan
Hi,
I have a query. am using Drools 3.0.6.
i have a ObjectA and ObjectB and ObjectC.
ObjectB and OBjectC inherits Object A.
am using seperate drl file for objectA, objectB and objectC.
i need to use the DRL pertain to ObjectA when validate ObjectB and ObjectC.
So when i check the object say ObjectB which i asserted in working memory, can i assume that ObjectA also available implitcitly?
The rules associated with ObjectA will fire when I assert just OBjectB?
Please clarify
Thanks and Regs,
Basha
17 years, 7 months
[rule-users] rule comparison
by Sikkandar Nawabjan
Edson,
am getting the following output
[ b, a ]
[ a, b ]
only the order of the output is different. so if i check a equal to b according to the cross product law the then part execute 2 times?
thats y i check the reference in the then part.
how to use eval to variable comparison of objects in a single line
Thanks and regs,
Basha
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Message: 3
Date: Sat, 19 May 2007 09:53:29 -0300
From: "Edson Tirelli" <tirelli(a)post.com>
Subject: Re: [rules-users] [rule-users]how to create object properties
in single stmnt
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Message-ID:
<e6dd5ba30705190553p1f5f794ct91ad250fb1ad3753(a)mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Sikkandar,
In 3.0.6, if you have 2 strings in the working memory ("a" and "b" ) and
you write:
rule "cross product"
when
$s1: String()
$s2: String()
then
System.out.println("[ "+$s1+", "+$s2+" ]");
end
The result MUST be:
[ a, b ]
[ b, a ]
If it is not that, then we have a bug, but our integration tests that
test this specific situation are working fine. Plz let us know if it is
different for you.
In 4.0, the result must be:
[ a, b ]
[ b, a ]
[ a, a ]
[ b, b ]
So a fact (by default) may match multiple simultaneous patterns.
Regarding your second question, comparing properties of the same object
is also something we added for 4.0. In 3.0.x you need eval() too.
[]s
Edson
2007/5/19, Sikkandar Nawabjan <Sikkandar.Nawabjan(a)ustri.com>:
>
> Hi ,
> The very reason i used to compare two object reference is that i got then
> executed multiple time when i do duplicate check between object properties.
> so i beleive the pattern match happen more than a time
> for example
> when
> $obj1:object($code:code,$stdate:startdate);
> $obj2:object(code==$code,startdate=$stdate);
> then
> if(obj1!=obj2)
> System.out.println("Fired");
>
> My questions are
>
> 1) In 3.0.6 is there any other way to avoid this multiple check other than
> using eval(which affects performance i beleive). i can't use this operator
> in 3.0.6
>
> 2) related to this i have one more query. how to check properties within
> the object itself
>
> for example i want to do
> when
> $obj1:object($code:code,$stdate:startdate,$enddate:enddate > $stdate,
> reasoncode == $code);
> then
> System.out.println("Fired");
> i beleive the above throws error in 3.0.6 (nullpointer related to alpha
> node)
>
> Earlier reply is highly appreciated
>
> Thanks and Regs,
> Bassha
>
>
17 years, 7 months
attribute list
by fakhfakh ismail
hello,
I have an object has an attribut type List of String
I when to verify if a String exist in List how can I do to check it?
rule "machin"
when
$CurrentAct : Nodes(name =="CHECK FUNDS", $List:list)
// how can I know if "admin" exist in list
then
System.out.println("admin exist");
end
thank u for your help
Best regards
Ismail
---------------------------------
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
17 years, 7 months
[rule-users]how to create object properties in single stmnt
by Sikkandar Nawabjan
Hi ,
The very reason i used to compare two object reference is that i got then executed multiple time when i do duplicate check between object properties. so i beleive the pattern match happen more than a time
for example
when
$obj1:object($code:code,$stdate:startdate);
$obj2:object(code==$code,startdate=$stdate);
then
if(obj1!=obj2)
System.out.println("Fired");
My questions are
1) In 3.0.6 is there any other way to avoid this multiple check other than using eval(which affects performance i beleive). i can't use this operator in 3.0.6
2) related to this i have one more query. how to check properties within the object itself
for example i want to do
when
$obj1:object($code:code,$stdate:startdate,$enddate:enddate > $stdate, reasoncode == $code);
then
System.out.println("Fired");
i beleive the above throws error in 3.0.6 (nullpointer related to alpha node)
Earlier reply is highly appreciated
Thanks and Regs,
Bassha
----------------------------------------------------------------------
Message: 1
Date: Fri, 18 May 2007 09:51:34 -0300
From: "Edson Tirelli" <tirelli(a)post.com>
Subject: Re: [rules-users] how to check reference
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Message-ID:
<e6dd5ba30705180551y6562b7f6oe5ea173379ebb4c8(a)mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Yes, in 3.0.6 you will need eval. But also it is important to remember
that by default, in 3.0.6, an object will never match more than one pattern.
So in the given example, ob1 and ob2 will always be different and the check
is not needed.
In 4.0, things are a bit different, as by default a single object may
match more than one pattern at once and we introduced the "this" keyword to
check for object identity.
[]s
Edson
2007/5/18, Chris Woodrow <woodrow.chris(a)gmail.com>:
>
> Hi,
> You can use eval();
>
> when
> $obj1:object();
> $obj2:object();
> eval ($obj1!=$obj2);
> then
> System.out.println("Fired");
>
> Hope this helps
> Chris
17 years, 7 months
dynamically get drl using spring module
by ch4nd4n
Hi,
I am using spring module (with drools) to fire the rules. How can I
setSource at the runtime? I am hard coding a different drl file in
setSource() method yet when the rule is executed it fires the rule based on
.drl set in the applicationContext.xml
My issue is that the drl file name might change frequently and on basis of
that I would like to fire the rules. Is it possible to change the drl name
dynamically at runtime?
Any advice would be great help.
--
Thanks
Ck
http://www.gfour.net
The code is given below
-- code --
public class RuleServiceDrools implements RuleService{
private DefaultRuleSource rs = null;
private Jsr94Template template = null;
public List fireRules(List users) {
final List list = users;
setSource();
// TODO Auto-generated method stub
Object obj = getTemplate().executeStateless("vaccination",null,new
StatelessRuleSessionCallback() {
public Object execute(StatelessRuleSession session) throws
InvalidRuleSessionException, RemoteException {
return session.executeRules(list);
}
});
return (List)obj;
}
public void setSource() {
Resource res = new FileSystemResource("/enfold/rules/vaccination2.drl");
rs = (DefaultRuleSource)getTemplate().getRuleSource();
rs.setSource(res);
}
public DefaultRuleSource getRs() {
return rs;
}
public void setRs(DefaultRuleSource rs) {
rs.setBindUri("what");
this.rs = rs;
}
public Jsr94Template getTemplate() {
return template;
}
public void setTemplate(Jsr94Template template) {
this.template = template;
}
}
-- code end --
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="ruleServiceProvider"
class="org.springmodules.jsr94.factory.DefaultRuleServiceProviderFactoryBean">
<property name="provider">
<value>http://drools.org/</value>
</property>
<property name="providerClass">
<value>org.drools.jsr94.rules.RuleServiceProviderImpl</value>
</property>
</bean>
<bean id="ruleRuntime"
class="org.springmodules.jsr94.factory.RuleRuntimeFactoryBean">
<property name="serviceProvider">
<ref local="ruleServiceProvider" />
</property>
</bean>
<bean id="ruleAdministrator"
class="org.springmodules.jsr94.factory.RuleAdministratorFactoryBean">
<property name="serviceProvider">
<ref local="ruleServiceProvider" />
</property>
</bean>
<bean id="ruleSource"
class="org.springmodules.jsr94.rulesource.DefaultRuleSource">
<property name="ruleRuntime">
<ref local="ruleRuntime" />
</property>
<property name="ruleAdministrator">
<ref local="ruleAdministrator" />
</property>
<property name="source">
<value>/enfold/rules/vaccination2.drl</value>
</property>
<property name="bindUri">
<value>vaccination</value>
</property>
</bean>
<bean id="jsr94Template"
class="org.springmodules.jsr94.core.Jsr94Template">
<property name="ruleSource">
<ref local="ruleSource" />
</property>
</bean>
<bean id="ruleService"
class="enfold.rules.service.impl.RuleServiceDrools">
<property name="template">
<ref local="jsr94Template" />
</property>
</bean>
<bean id="memberDao" class="enfold.dao.dummy.MemberDaoDummy" />
<bean id="ruleObjectbuilder"
class="enfold.rules.RuleObjectBuilderDatabase">
<property name="memberDao">
<ref local="memberDao"/>
</property>
</bean>
<bean id="service" class="enfold.rules.ServiceImpl">
<property name="ruleObjectbuilder">
<ref local="ruleObjectbuilder"/>
</property>
<property name="ruleService">
<ref local="ruleService"/>
</property>
</bean>
</beans>
--
View this message in context: http://www.nabble.com/dynamically-get-drl-using-spring-module-tf3778174.h...
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 7 months
Exception with 4.0.0.MR2
by José Miguel Sánchez
Hi,
I get the next exception with 4.0.0.MR2 that I didn't get with previous
versions with the same DRL:
java.lang.IllegalArgumentException: The rule called regla1_11 is not
valid. Check for compile errors reported.
at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:363)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:263)
at
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:293)
at evendor.mebone.rules.RulesLoader.<init>(RulesLoader.java:217)
at
evendor.mebone.rules.RulesSet.createAgendaAndLoadClass(RulesSet.java:207)
at evendor.mebone.rules.RulesSet.includeAssert(RulesSet.java:291)
at evendor.mebone.core.Map.existsReadCursors(Map.java:3589)
at evendor.mebone.core.Map.existsReadCursors(Map.java:3487)
at evendor.mebone.core.Map.run(Map.java:1545)
The DRL file is the result of compiling a decision table in XLS format
and it has the next aspect:
package demo1;
#generated from Decision Table
import rules.*;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.sql.Timestamp;
#From row number: 11
rule "regla1_11"
salience 65525
when
a: _demo1_RuleEnvelope(s_IMPORTE >= 10000)
then
a.sett_NUEVO_IMPORTE(10500);
a.sett_COPIA_NUM_TARJETA("1234567890");
end
¿What is wrong in this DRL?
Thanks in advance,
José Miguel Sánchez
17 years, 7 months