mvel regex not working???
by Carlsen, Len
Hi,
I have an email validation regex where the mvel matches doesn't seem to
work. I have created 2 rules where test1 uses the Java String matches
and test2 uses the mvel matches. Test1 works but test2 doesn't. I am
using Drools 4.0.3 and JDK 1.6.0_02.
rule "Test1"
when
// This works
email : String()
eval( !email.matches(
"^[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+(
\\.[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+
)*(a)[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9
-]{0,61}[a-zA-Z0-9])?)*\\.[a-zA-Z]{2,6}$" ) )
then
System.out.println( "1-Invalid Email Address: " + email );
end
rule "Test2"
when
// This doesn't work
email : String( toString not matches
"^[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+(
\\.[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~]+
)*(a)[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9
-]{0,61}[a-zA-Z0-9])?)*\\.[a-zA-Z]{2,6}$" )
then
System.out.println( "2-Invalid Email Address: " + email );
end
Here's the output using email addresses x.x(a)x.com (valid) and x.xx.com
(invalid):
test1-Invalid Email Address: x.xx.com
test2-Invalid Email Address: x.x(a)x.com
test2-Invalid Email Address: x.xx.com
The regex expressions are exactly the same. Am I doing something wrong
here?
Thanks,
Len
17 years, 1 month
Fire Rules in DT based on a rule in DT
by Arjun Dhar
Hi,
I have the following scenario.
SCENARIO (simplified for discussion from actual blown up scenario)
---------
1. A decision table (DT) with rules for "all types of employees" - Call
it "Common DT"
2. The DT mentioned in Point 1 has a condition that fetched data depending
on "Type Of Employee"
3. There are other decision tables that would like to use the the rules
from "Common DT", but here are the challenges:
Challenges
----------
1. Decision does not support Agenda Groups
2. Using a fact; to hold the evaluated result from a DT can pass it from a
child to a parent; but it requires an "update()"; which can cause infinite
recursion if i dont have a "Execute ONE Rule Only from Table" decision variable.
(Parent) DT - Condition 1, condition 2, Condition 3 (Actually result of Child
DT)
(Child DT)
... The relation is maintained using decision variables.
This relation works perfenctly good (been working for 3 months now), but issue
is it creates a Sort of a Tree (with each node a DT); in shich I cannot fire a
common set of rules from Any Node.
As an alternative; I'm suggesting to the client to write replicated DT's for
each type of employee instead of 1 generic DT.
Can anyone help?
I've been begging for agenda Groups in decision tables but I guess you guys are
tied up. So at a design level can you suggest a work around?
Thanks,
Arjun
17 years, 1 month
Defining the Object Model in Drools IDE 4.0.3...HOWTO????
by mmquelo massi
Hi everybody,
I am starting to define my little Drools Project.
I am using DROOLS IDE 4.0.3 for Eclipse 3.2 .
I already have some underlying Java classes and want to build my rules
over those classes.
In other words I need to define the Object Model to execute the rules
against it.
I added all the Object Model classes in the same Rule workspace, but
once I started
te "Guided Rule Editor" to define the rules, I did not see any "fact"
coming out from the
"Fact" list.
So what should I do in order to get a "Nice and Cool" ( :D ) list
with all the classes
I put within the Eclipse Workspace.
Thank You everybody.
I hope u can help me to work it out.
Massi
17 years, 1 month
Classloader issues with webapp : No ClassLoaders found, Circular dependencies...
by Julien Cassignol
Hello,
Following Mark's advice, I decided to mail about a problem I experienced
and managed to fix, with Mark's and Edson Tirelli's help.
I was trying to build a RuleBase with the following code :
final SpreadsheetCompiler converter = new SpreadsheetCompiler();
FileInputStream file = new FileInputStream(decTable);
final String drl = converter.compile(file, InputType.XLS);
System.out.println(drl);
Properties properties = new Properties();
properties.setProperty( "drools.dialect.default",
"java" );
properties.setProperty("drools.compiler","JANINO");
PackageBuilderConfiguration conf = new
PackageBuilderConfiguration(properties);
PackageBuilder builder = new PackageBuilder( conf );
builder.addPackageFromDrl(new StringReader(drl));
Package pkg = builder.getPackage();
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
Nothing difficult, but it was failing on the construction of
PackageBuilderConfiguration :
No ClassLoaders found for:
org.drools.rule.builder.dialect.java.JavaDialect
Followed by an unhelpful stack.
Debugging my webapp (which sources I didn't have), I noticed that my
class ClassLoader was different from the thread one. The thread
classloader was the JBoss ClassLoader, and my class classloader was the
one of the webapp.
Setting the classloader of the thread manually to the classloader of my
webapp failed to cope with the problem, as the drools jars were
installed on Jboss, and drools instantiated object couldn't find core
objects within the classpath with the classloader of the webapp. To fix
the problem, I had to use the following code :
PackageBuilderConfiguration conf = new PackageBuilderConfiguration(
properties);
conf.setClassLoader(MyClass.class.getClassLoader());
RuleBaseConfiguration ruleBaseConf = new RuleBaseConfiguration();
ruleBaseConf.setClassLoader(MyClass.class.getClassLoader());
Setting the classloader property of the drools configuration objects
allowed me to use imports of local classes (I mean local to the webapp)
within rule packages, and solved my problem (or so it seems).
I hope this short explanation will help someone !
17 years, 1 month
RE: Duplicate check using dialect
by Sikkandar Nawabjan
i just use this sort of rule
rule "Hello World"
dialect "mvel"
when
m : Message( $message1 : message )
mdup : Message($message2:message==$message1,eval(this!=m) )
then
System.out.println("Rule Fired1111"+m +"::"+mdup );
System.out.println("Rule Fired"+$message1 +"::"+$message2 );
end
if i put rule parameter dialect "MVEL" the error "this should be used in static context" is gone. But now the rule is firing whatever may be the data
i assert 2 objects with message Hello and Hello11111.
still the rule is firing(2 times).
Thanks and regs,
basha
Message: 1
Date: Wed, 14 Nov 2007 09:48:02 -0200
From: "Edson Tirelli" <tirelli(a)post.com>
Subject: Re: [rules-users] RE: how to find duplicate inlineeval
To: "Rules Users List" <rules-users(a)lists.jboss.org>
Message-ID:
<e6dd5ba30711140348p6da77e64kdac90cd313b5aa80(a)mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Sorry, you lost me. What is the error message?
Can you send us a self contained test showing the problem you are having?
[]s
Edson
2007/11/14, Sikkandar Nawabjan <Sikkandar.Nawabjan(a)ust-global.com>:
>
> Edson,
>
> As you said i used inline eval. But am getting erroe message like this
> can't be used in static context.am using statelesssession to assert my
> objects.
>
> i also put eval(this!=obj1) as follows.
>
> $obj1:Object1($id:id,$name:name)
> $obj2:Object1(id==$id,$name:name==$name, eval( this!=$obj1
> )) eval($obj2!= $obj1)
>
> Though my references are different the rule is not firing
>
>
> Thanks and Regs
>
> Basha
>
> From: rules-users-bounces(a)lists.jboss.org on behalf of Edson Tirelli
> Sent: Tue 11/13/2007 9:35 PM
> To: Rules Users List
> Subject: Re: [rules-users] RE: how to find duplicate
>
>
>
>
> Sikkandar,
>
> The only way to check for identity is to use an inline eval and use
> java code to check that:
>
> when
> $obj1:Object1($id:id,$name:name)
> $obj2:Object1(id==$id,$name:name==$name, eval( this!=$obj1 ))
> then
>
> Another option is to configure your rulebase to not allow the same
> object to be matched by more than one pattern in your rules. To do that you
> can either set a system property:
>
> drools.removeIdentities = true
>
> Or you can use drools API:
>
> RuleBaseConfiguration conf = new RuleBaseConfiguration();
> conf.setRemoveIdentities( true );
> RuleBase rulebase = RuleBaseFactory.newRuleBase( conf );
>
> If you do that, your rule can be written as this:
>
> when
> $obj1:Object1($id:id,$name:name)
> $obj2:Object1(id==$id,$name:name==$name)
> then
>
> Since the engine will never allow the same fact to simultaneously match
> both patterns.
>
> []s
> Edson
17 years, 1 month
Another rule vendor being acquired
by Paul Haley
I hope it is interesting to the community to consider the second business
rules vendor acquisition within the last 30 days.
Haley Systems (www.haley.com), the company that I founded many years ago
(hopefully, some of you have heard of it!), is in the process of being
acquired by Ruleburst. I am not going with the acquisition but have started
up my own "vendor neutral" business practice in which I anticipate helping
improve and support Drools and the emerging standards in rules and web
semantics.
See
http://www.ad-hoc-news.de/CorporateNews/en/14178920/RuleBurst-Acquires-US-Bu
siness-Rules-Technology-Vendor
Regards,
Paul
17 years, 1 month
create .pkg file with or without BRMS
by Arnaud Bouzinac
Hi,
I'm using BRMS to generate a .pkg for an application
i need to generate the same file without BRMS:
i'm trying to use a drools-ant task, but, pkg file generated with drools-ant
task is not the same !!!
i don't found a specific documentation to do that ?
Somebody can help me please ?
thanks for your help
<project default="rules">
<property name="eclipsepath" value=""/>
<path id="qirules.classpath">
<pathelement location="${eclipsepath}../install/*"/>
</path>
<path id="drools.classpath">
<fileset dir="${eclipsepath}../">
<include name="**/*.jar"/>
</fileset>
<pathelement location="target"/>
</path>
<taskdef name="rulebase" classname="
org.drools.contrib.DroolsCompilerAntTask" classpathref="drools.classpath" />
<target name="rules" >
<rulebase
srcdir="${eclipsepath}../rules/"
tofile="${eclipsepath}../rules/FLIResultsUpdateRules.pkg"
classpathref="qirules.classpath" >
<include name="*.drl" />
</rulebase>
</target>
</project>
17 years, 1 month
Re: howto BRMS - already stuck at fact model
by Chong Minsk Goh
Hi Darren,
Glad I am not alone : )
I am also in the process of using BRMS for our application. Would also
like to seek advice on how to better use the BRMS.
Especially on how the parsing of user inputs to DRL is executed,
specifically which package/api in drools is used.
Cheers!
Chong Minsk
>
> Message: 1
> Date: Wed, 14 Nov 2007 10:06:05 -0500
> From: "Darren Hartford" <dhartford(a)ghsinc.com>
> Subject: [rules-users] howto BRMS - already stuck at fact model
> loading
> To: <rules-users(a)lists.jboss.org>
> Message-ID:
> <214FF1B5E37DC84D9968F0F82FBB112502A010C4(a)AUGEXCH.ghsinc.com>
> Content-Type: text/plain; charset="us-ascii"
>
> Hey all, new to BRMS as trying to learn how this works. My usecase is
> to take an existing, working EJB3 application and migrate some of the
> complex rules over to be managed by BRMS.
>
>
>
> However, initial attempts over the course of a couple of days have
> yielded zero results.
>
>
>
> When trying to follow
> http://downloads.jboss.com/drools/docs/4.0.3.15993.GA/html_single/index.
> html#d0e5301, they want you to load a fact model. I take an existing
> EJB3 entity bean and it loads fine. There doesn't seem anything more
> for me to do, or to verify this is o.k. or not. So, then I move to the
> rule editors, and nothing works - not able to use the guided editor at
> all, and using the DSL text editor with the 'model/entity' from the jar
> isn't recognized.
>
>
>
> Now, I admit ignorance, and I would like some direction as to how to
> best learn to use BRMS.
>
>
>
> There were a couple mentions of a drools-examples-brms, but it just can
> not be found. Following the documentation mentioned above is only
> guidelines without any good examples leaving one easily lost.
>
>
>
> http://www.google.com/search?q=drools-example-brms
>
> http://www.nabble.com/forum/Search.jtp?query=jbrms+example&local=y&forum
> =11822&daterange=0&startdate=&enddate=
>
> http://labs.jboss.com/drools/downloads.html
>
> http://labs.jboss.com/drools/livetrails/index.html
>
>
>
> So - where can one go to learn how to use BRMS to help convert an
> existing EJB3 application to use Drools and BRMS?
>
>
>
> Thanky,
>
> -D
>
17 years, 1 month