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:JUnit testing
by J. Michael Dean
>
Thanks. Sorry for few details as this has been a several message
question. I have created a Drools plugin that contains EITHER the
maximum number of jars and dependencies (i.e. ALL), or the minimum
(i.e. those needed for compiler option only processing DRL files), or
adding the entire Drools distribution to my Java extensions folder in
OS X, and in all instances, I get an error loading dialects. The
enigma for me is that all of these plugin options enable me to make a
stand alone RCP application that works fine.
Here is the test unit code:
@BeforeClass
public static void setUp() throws Exception {
Reader source;
PackageBuilderConfiguration pkgConfig = new
PackageBuilderConfiguration();
JavaDialectConfiguration javaDialectConf =
(JavaDialectConfiguration) pkgConfig.getDialectConfiguration("java");
javaDialectConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
final PackageBuilder builder = new PackageBuilder(pkgConfig);
boolean exists = (new File("rules/GlucoseDroolRules00.drl")).exists();
if (exists) {
builder.addPackageFromDrl(new FileReader(
"rules/GlucoseDroolRules00.drl"));
System.out.println("Found the file!");
} else {
System.out.println("Cannot locate the file - will try as resource");
source = new InputStreamReader(AllDroolsRulesTests.class
.getResourceAsStream("rules/GlucoseDroolRules00.drl"));
builder.addPackageFromDrl(source);
}
if (builder.hasErrors()) {
System.out.println(builder.getErrors().toString());
}
Package pkg = builder.getPackage();
ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);
}
It crashes in the line trying to instantiate the package
configuration. If I eliminate the lines that configure the package,
and invoke the package building without an argument (the default),
then the crash occurs in that line. The crash trace:
org.drools.RuntimeDroolsException: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
at
org
.drools
.compiler
.PackageBuilderConfiguration
.addDialect(PackageBuilderConfiguration.java:152)
at
org
.drools
.compiler
.PackageBuilderConfiguration
.buildDialectConfigurationMap(PackageBuilderConfiguration.java:140)
at
org
.drools
.compiler
.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:117)
at
org
.drools
.compiler
.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:94)
at
droolsRules.tests.AllDroolsRulesTests.setUp(AllDroolsRulesTests.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org
.eclipse
.jdt
.internal
.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at
org
.eclipse
.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org
.eclipse
.jdt
.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460)
at
org
.eclipse
.jdt
.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673)
at
org
.eclipse
.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386)
at
org
.eclipse
.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196)
Caused by: java.lang.NullPointerException
at
org
.drools
.compiler
.PackageBuilderConfiguration
.addDialect(PackageBuilderConfiguration.java:146)
... 18 more
This trace is identical in all instances. I have looked at the source
code and it appears that the Drools code is looking for the drools
configuration file, and I am not sure if this is included in the
classpath when running JUnit. However, the minimal and maximal plugin
configurations make an RCP run perfectly as a standalone application.
This is Eclipse 3.3 fall version, Mac OXX Leopard (but have run on
Tiger and same error, so not a new Apple bug), Drools 4.03, and JUnit 4.
Thanks.
> ------------------------------
>
> Message: 8
> Date: Tue, 4 Dec 2007 06:50:15 -0800 (PST)
> From: "John J. Franey" <jjfraney(a)gmail.com>
> Subject: Re: [rules-users] JUnit testing
> To: rules-users(a)lists.jboss.org
> Message-ID: <14151759.post(a)talk.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
>
>
>
> J Michael Dean wrote:
>>
>> I am having problems figuring out how to do JUnit 4 unit tests with
>> Drools and am wondering what I am missing.
>>
>
> I'm successfully using junit4 to test rules. I build a rules
> package from
> my rules file, create a stateful session, insert facts, fire all
> rules, run
> queries, and finally, perform junit asserts on the results.
>
> I can't tell you what you are missing, unless you say what you have.
>
> Regards,
> John
>
>
> --
> View this message in context: http://www.nabble.com/JUnit-testing-tf4930259.html#a14151759
> Sent from the drools - user mailing list archive at Nabble.com.
>
>
>
> ------------------------------
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> End of rules-users Digest, Vol 13, Issue 6
> ******************************************
16 years, 6 months
Accessing maps (hashmaps) keys and values in rules
by Ryan, Dennis (Dennis)
We are using Maps (HashMaps) in our rules and the only way we have found
to access keys and values in the Map in the "when" clauses is thru use
on eval() which I know is a big no-no by rules purists. Is there a
better way, maybe some shorthand I'm not familiar with to deal with Maps
in the when clause?
Thanks,
Dennis
16 years, 8 months
How do you use Ruleflows with StatelessSession's?
by Shahad Ahmed
Does anyone know if it's possible to use a ruleflow with a StatelessSession?
The current documentation and API seem to show examples with
StatefullSessions i.e.:
statefullSession.startProcess(id);
statefullSession.fireAllRules();
etc...
However, there doesn't seem to be anything equivalent in the API for
StatelessSesssion's. I'd really like to be able to use the new sequential
mode (i.e. with a StatelessSession) and ruleflow.
Regards,
Shahad
16 years, 8 months
BRMS
by Markus Helbig
Hi,
i tryed to deploy the BRMS on a WebSphere Server, but i get
incompatibility errors. It seems BRMS can not be used with JRE 1.4.x,
right? Why? JRE 1.4.x is still very common and often used in
enterprises ...
Cheers
Markus
Stacktrace is:
Could not be defined due to: (org/jboss/seam/servlet/SeamListener) bad
major version at offset=6
This is often caused by having a class defined at multiple
locations within the classloader hierarchy. Other potential causes
include compiling against an older or newer version of the class
that has an incompatible method signature.
Dumping the current context classloader hierarchy:
==> indicates defining classloader
16 years, 9 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, 9 months
Problem with ternary and mvel
by vdelbart
Hi,
I have a problem with this simplified rule (mvel + ternary) :
rule "Your Third Rule"
dialect "mvel"
when
v:Venue()
then
v.activite = (v.um == null ? "it's null" : "it's not null");
end
before the execution I have this fact :
Venue(Type Hosp: null, activite: null, activite Hosp: null, um: null,
SousVenue: null)
when I execute the rule, I have :
Venue(Type Hosp: null, activite: true, activite Hosp: null, um: null,
SousVenue: null)
Of course with dialect = java it works but I need to use mvel dialect for
other reason in all of my rules.
maybe somebody have a workaround for this ?
Thanks,
Vincent
--
View this message in context: http://www.nabble.com/Problem-with-ternary-and-mvel-tp14452888p14452888.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 10 months
How to write constraint about a Map inside a Map?
by Felipe Piccolini
Suppouse I have a Map attribute and one of the values is another
Map...how can I check a member of the inner Map?
class MyFact{
Map map;
public MyFact(){
this.map = new HashMap();
}
....setter and getter...
}
-- test --
MyFact myFact = new MyFact();
Map innerMap = new HashMap();
innerMap.put("innerKey", new String("InnerValue"));
Map map = new HashMap();
map.put("mapKey", innerMap);
myFact.setMap(map);
.... set the RuleBase and insert myFact as a fact for the
WorkingMemory...
-------
Now... how should I write the rule to check the innerKey ??
rule "test InnerMap"
when
$mf: MyFact( map['mapKey']['innerKey'] ==
"InnerValue" ) // doesnt work...
....
$mf: MyFact( map['mapKey'].this['innerKey'] ==
"InnerValue" ) // doesnt work...
$mf: MyFact( map['mapKey'].['innerKey'] == "InnerValue" ) //
doesnt work...
$mf: MyFact( $innerMap: map['mapKey'], $innerMap['innerKey'] ==
"InnerValue" ) // doesnt work...
$mf: MyFact( $innerMap: map['mapKey'] -> ($innerMap
['innerKey'] == "InnerValue" )) // doesnt work...
Thanks.
Felipe Piccolini M.
felipe.piccolini(a)bluesoft.cl
16 years, 10 months
Custom EvaluatorFactory
by Andy Mei
Hi,
Is there a way I could register my own custom EvaluatorFactory?
Drools ships with DateFactory what compares only dates, but no time is
included. I would like to compare time as well.
I see that it would be very helpful to include capability to register
custom EvaluatorFactory.
Thanks.
Andy
16 years, 11 months
JUnit testing problem
by J Michael Dean
Continuing to have problems - can use Drools in RCP but when I try to
JUnit test, I cannot instantiate a PackageBuilder. With the following
code fragment:
@BeforeClass
public static void setUp() throws Exception {
Reader source;
PackageBuilderConfiguration pkgConfig = new
PackageBuilderConfiguration();
JavaDialectConfiguration javaDialectConf =
(JavaDialectConfiguration) pkgConfig.getDialectConfiguration("java");
javaDialectConf.setCompiler(JavaDialectConfiguration.ECLIPSE);
if (pkgConfig == null) {
System.out.println("Error - null package configuration");
} else {
System.out.println("Package configuration is not null"); // NOTE
THAT THIS EXECUTES SO NOT NULL
}
final PackageBuilder builder = new PackageBuilder(pkgConfig); //
CRASH OCCURS IN THIS LINE OF CODE
I get the following trace:
Package configuration is not null
java.lang.NullPointerException
at
org.mvel.optimizers.OptimizerFactory.<clinit>(OptimizerFactory.java:43)
at
org.drools.rule.builder.dialect.mvel.MVELDialect.init(MVELDialect.java:
142)
at org.drools.compiler.DialectRegistry.initAll(DialectRegistry.java:49)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:146)
at org.drools.compiler.PackageBuilder.<init>(PackageBuilder.java:108)
at
droolsRules.tests.AllDroolsRulesTests.setUp(AllDroolsRulesTests.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun
.reflect
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at
org
.junit
.internal
.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at
org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org
.eclipse
.jdt
.internal
.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at
org
.eclipse
.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org
.eclipse
.jdt
.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
460)
at
org
.eclipse
.jdt
.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:
673)
at
org
.eclipse
.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:
386)
at
org
.eclipse
.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:
196)
[MVEL] Notice: Possible incorrect version of ASM present (3.0
required). Disabling JIT compiler. Reflective Optimizer will be used.
I had similar issue a number of weeks ago that never resolved, but
subsequently have upgraded Eclipse to 3.3.2, running on OSX Leopard.
I cannot locate a ASM library and obviously the error message is
hinting at that.
Any assistance will be appreciated. I hate proceeding without JUnit
testing in place.
- Mike
16 years, 11 months