Wild card characters in .drl file
by hanumesh.m
Hi,
I need to use wild card chars matching in .drl file.
(Assume field filename has data as "XYZ-888-10022008")
If the filename contains string "888" in it
then target Queue will be "jms://INBOUND.888.EDI"
I am writing a rule as follows:
rule "Test 888"
no-loop
when
m: Message( fileName matches "*888*", message : message )
then
System.out.println( "In EATech.drl File" );
m.setTargetEdiQ("jms://INBOUND.888.EDI");
update( m );
end
But its not working. Error is "Dangling meta character '*' near index 0
*888*"
If anyone has used wild card chars in .drl file please respond
--
View this message in context: http://www.nabble.com/Wild-card-characters-in-.drl-file-tp15306359p153063...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 10 months
myemail
by Hanumesh Mekala
hanumesh.m(a)gmail.com
16 years, 10 months
Modify a global variable with mvel dialect
by Joshua Jackson
Dear all,
How do we modify a global variable with mvel dialect inside rules file
without getting
java.lang.UnsupportedOperationException: External Variable
identifer='allowance' type='class java.lang.Double' is final, it
cannot be set
[testng] at org.drools.base.mvel.DroolsMVELGlobalVariable.setValue(DroolsMVELGlobalVariable.java:37)
[testng] at
org.drools.base.mvel.DroolsMVELFactory.createVariable(DroolsMVELFactory.java:199)
[testng] at
org.mvel.ast.AssignmentNode.getReducedValueAccelerated(AssignmentNode.java:80)
[testng] at org.mvel.MVELRuntime.execute(MVELRuntime.java:88)
[testng] at
org.mvel.CompiledExpression.getValue(CompiledExpression.java:108)
[testng] at org.mvel.MVEL.executeExpression(MVEL.java:230)
[testng] at
org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:47)
[testng] at
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:550)
[testng] at
org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:514)
[testng] at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:462)
[testng] at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:424)
This is how I did it:
Java file:
public void run(){
Double allowance = new Double(0);
workingMemory.setGlobal("allowance", allowance);
workingMemory.fireAllRules();
}
Rules:
global Double allowance
dialect "mvel"
rule "Has Wife"
no-loop
salience 20
when
e: Employee()
income:Income()
eval( e.isWife() )
then
System.out.println("Has Wife");
allowance = allowance + 5000;
end
This works if I use java as the dialect.
Have I missed something?
Thanks in advance,
--
It's not going to be like this forever
Blog: http://joshuajava.wordpress.com/
16 years, 10 months
Using the drools as the backend engine for a service
by Jai Vasanth
Hi,
I am planning on using Drools as the rules engine for a service that I am
building. I am considering instantiating a stateful session for every
request to the service. The RuleBase would be created when the service
starts. Is this the correct way to go about incorporating Drools in a
service ? Is session creation an expensive process and if so are there other
efficient ways of doing so ?
Thanks
Jai
16 years, 10 months
Facing Problem with Working Memory Serialization/DeSerialization
by siddhartha banik
Hi,
I am serializing working memory(WM). But after deserializing that, if I try
to modify the corresponding RuleBase that is not getting reflected.
I mean, after loading the serialized WM even I add a package to the
corresponding RuleBase, new Rules are not getting fired for newly added
facts. Or I remove a package from the corresponding RuleBase, even removed
Rules are getting fired for newly added facts.
So, Once WM is deserialized any chage to the corresponding RuleBase is
failing.
I have attached the test program & test rules.
Thanks
Siddhartha
16 years, 10 months
RuleBase was not updated correctly when use RuleAgent
by Cheng, Ping
Hi,
I am using RuleAgent to load rules from pkg files generated by BRMS.
I have "newInstance=false" in my property file and expect the new rules
will be picked/updated when the pkg files was updated.
I added a new rule in BRMS and I can see RuleAgent picked the updated
pkg file from log. The new rule I just added works fine, but the old
rule looks get screwed.
All rules work fine if I restart my program.
Seems that the RuleAgent did not update all rules correctly, I wonder if
anyone has solution for this?
Thanks.
-Ping
-----------------------------------------
The information contained in this transmission may be privileged and
confidential and is intended only for the use of the person(s) named
above. If you are not the intended recipient, or an employee or agent responsible
for delivering this message to the intended recipient, any review, dissemination,
distribution or duplication of this communication is strictly prohibited. If you are
not the intended recipient, please contact the sender immediately by reply e-mail
and destroy all copies of the original message. Please note that we do not accept
account orders and/or instructions by e-mail, and therefore will not be responsible
for carrying out such orders and/or instructions. If you, as the intended recipient
of this message, the purpose of which is to inform and update our clients, prospects
and consultants of developments relating to our services and products, would not
like to receive further e-mail correspondence from the sender, please "reply" to the
sender indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New York,
NY 10105.
16 years, 10 months
OR
by Markus Helbig
This is from Drools documentation
Example 6.36. or with binding
pensioner : (or Person( sex == "f", age > 60 )
Person( sex == "m", age > 65 ) )
Explicit binding on each Pattern is also allowed.
(or pensioner : Person( sex == "f", age > 60 )
pensioner : Person( sex == "m", age > 65 ) )
but trying to get this to work resolves in:
[60,8]: unknown:60:8 Unexpected token 'or'[62,8]: unknown:62:8
mismatched token: [@639,2279:2291='Person',<7>,62:8]; expecting type
RIGHT_PAREN[62,81]: unknown:62:81 mismatched token:
[@656,2352:2352=')',<12>,62:81]; expecting type THEN
Any ideas (using Drools 4.0.4)?
Cheers
Markus
16 years, 10 months
Re: [rules-users] Dynamic Rules will not be executed
by Edson Tirelli
Since you are (re)using a stateful session, rules that fired before will
not fire again just because you changed the rulebase.
This is expected behavior.
[]s
Edson
2008/2/5, Michael Katai <mk.others(a)gmx.at>:
>
> Hello!
>
> I've googeled and searched the mailing list archive, but i couldn't solve
> my
> current problem:
> Every time i create a new rule (while runtime) i use:
>
> PackageBuilder builder = new PackageBuilder();
> builder.addPackageFromDrl(source);
> if(builder.hasErrors())
> ...
> Package pkg = builder.getPackage();
> ruleBase.addPackage(pkg);
> session.fireAllRules();
>
> Every time, fireAllRules is executed, only the last, newest rule will
> fired.
> Where is my mistake?
>
> ruleBase (and factspace) is created as
> session = ruleBase.newStatefulSession();
> factspace = new FactSpace(session);
>
> thanks in advance,
> michael
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Edson Tirelli
JBoss Drools Core Development
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com
16 years, 10 months
Dynamic Rules will not be executed
by Michael Katai
Hello!
I've googeled and searched the mailing list archive, but i couldn't solve my
current problem:
Every time i create a new rule (while runtime) i use:
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl(source);
if(builder.hasErrors())
...
Package pkg = builder.getPackage();
ruleBase.addPackage(pkg);
session.fireAllRules();
Every time, fireAllRules is executed, only the last, newest rule will fired.
Where is my mistake?
ruleBase (and factspace) is created as
session = ruleBase.newStatefulSession();
factspace = new FactSpace(session);
thanks in advance,
michael
16 years, 10 months
xslt for converting rule XML from drools 2 to jboss rule 4
by arina he
I was scraping internet for one xslt when I was converting drools 2 to jboss
rule 4, but couldn't find one,
so I rolled up sleeves and created one by myself, put up here in case anyone
need it too.
welcome comments.
Arina.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:fn="
http://www.w3.org/2005/xpath-functions" xmlns:java="
http://drools.org/semantics/java" >
<xsl:output method="xml" version="1.0" indent="yes" omit-xml-declaration=
"yes"/>
<xsl:template match="/">
<package name="com.sample">
<global identifier="doc" type="Document" />
<xsl:apply-templates />
</package>
</xsl:template>
<xsl:template name="javaimport" match="java:import">
<import name="{.}" />
</xsl:template>
<xsl:template name="javaFunction" match="java:functions">
<xsl:if test="contains(.,'public')">
<xsl:call-template name="separate">
<xsl:with-param name="str" select="substring-after(.,'public ')" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="separate">
<xsl:param name="str" />
<xsl:choose>
<xsl:when test="contains($str,'public')">
<xsl:call-template name="drlFn">
<xsl:with-param name="fnBody" select="substring-before($str,'public')" />
</xsl:call-template>
<xsl:call-template name="separate">
<xsl:with-param name="str" select="substring-after($str,'public ')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="drlFn">
<xsl:with-param name="fnBody" select="$str" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="drlFn">
<xsl:param name="fnBody" />
<function name="{substring-before(substring-after($fnBody,' '),'(')}"
return-type="{substring-before($fnBody,' ')}"> <xsl:if
test="normalize-space(substring-before(substring-after($fnBody,'('
),')' ))!=''">
<xsl:call-template name="params">
<xsl:with-param name="paramStr"
select="normalize-space(substring-before(substring-after($fnBody,'('
),')' ))" />
</xsl:call-template>
</xsl:if>
<body>
<xsl:call-template name="bdy">
<xsl:with-param name="bdyStr" select="substring-after($fnBody,'{' )" />
</xsl:call-template>
</body>
</function>
</xsl:template>
<xsl:template name="bdy">
<xsl:param name="bdyStr"/>
<xsl:value-of select="substring-before($bdyStr,'}')" />
<xsl:if test="contains(substring-after($bdyStr,'}'),'}')">
}
<xsl:call-template name="bdy">
<xsl:with-param name="bdyStr" select="substring-after($bdyStr,'}')" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template name="params">
<xsl:param name="paramStr"/>
<xsl:choose>
<xsl:when test="contains($paramStr,',')">
<xsl:call-template name="buildIdentifier">
<xsl:with-param name="tpy" select="substring-before($paramStr,' ')" />
<xsl:with-param name="idt"
select="substring-after(substring-before($paramStr,','),'
')" />
</xsl:call-template>
<xsl:call-template name="params">
<xsl:with-param name="paramStr" select=
"normalize-space(substring-after($paramStr,','))"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="buildIdentifier">
<xsl:with-param name="tpy" select="substring-before($paramStr,' ')" />
<xsl:with-param name="idt" select="substring-after($paramStr,' ')" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="buildIdentifier">
<xsl:param name="tpy" />
<xsl:param name="idt" />
<parameter identifier="{$idt}" type="{$tpy}" />
</xsl:template>
<xsl:template name="rules" match="rule" >
<rule name="{@name}">
<xsl:if test="java:condition">
<lhs>
<and-constraint-connective>
<xsl:for-each select="java:condition">
<eval><xsl:value-of select="normalize-space(.)" disable-output-escaping="no"
/></eval>
</xsl:for-each>
</and-constraint-connective>
</lhs>
</xsl:if>
<xsl:for-each select="java:consequence">
<rhs>
<xsl:value-of select="." />
</rhs>
</xsl:for-each>
</rule>
</xsl:template>
</xsl:stylesheet>
16 years, 10 months