Nested Rules
by Vishal Deshmukh
Hi
I am using Drools 4.0.4 with Eclipse 3.2. I m much happy with the results. But now my application needs nested loops..
Can i write nested rules like
rule "rule 1 " // if condition of rule 1 is true then only execute rule 2 other wise skip it
when
condition is true
then
execute rule2
rule "rule 2 "
when
condition is true
then
action
rule "rule 3"
when
condition is true
then
action
Thanks and Rgards
Vishal
16 years
Unable to load dialect java from Ant task
by Soterro
Hi all,
I have a perfectly running Eclipse 3.3 with DRools 4.0.4 and JDK 1.5.14.
The rules are compiled with a post build Ant task which uses Janino (need it for Tomcat compatibility).
Now OUTSIDE Eclipse it seems I cannot use that Ant task to save my life :(
I tried switching from Janino to the default compiler, same thing. I always get this infamous error:
BUILD FAILED
E:\buildRules-hudson.xml:30: RuleBaseTask failed: Unable to load dialect
'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java'
at com.csc.ezbook.eztarif.rules.DroolsCompilerAntTaskStandalone.execute
(DroolsCompilerAntTaskStandalone.java:163)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
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.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java
:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
[...]
Caused by: 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 com.my.app.rules.DroolsCompilerAntTaskStandalone.getPackageBuilder(
DroolsCompilerAntTaskStandalone.java:257)
at com.my.app.rules.DroolsCompilerAntTaskStandalone.execute(
DroolsCompilerAntTaskStandalone.java:136)
That "DroolsCompilerAntTaskStandalone" is my task using the default compiler like this:
PackageBuilderConfiguration conf = new PackageBuilderConfiguration();
conf.setClassLoader( loader );
PackageBuilder builder = new PackageBuilder( conf );
If I use Janino like below the error is exactly the same...
PackageBuilderConfiguration pkgBuilderCfg = new
PackageBuilderConfiguration();
pkgBuilderCfg.setClassLoader( loader );
JavaDialectConfiguration javaConf = (JavaDialectConfiguration)
pkgBuilderCfg.getDialectConfiguration( "java" );
javaConf.setCompiler( JavaDialectConfiguration.JANINO );
PackageBuilder builder = new PackageBuilder( pkgBuilderCfg );
Again, in Eclipse all is working fine. I checked Ant's classpath, here it is:
E:\apache-ant-1.7.0\bin\..\lib\ant-launcher.jar
E:\apache-ant-1.7.0\lib\*.jar
C:\Program Files\Java\jdk1.5.0_14\lib\tools.jar
Here is how I provide a classpath:
<taskdef name="rulescompiler" classname="com.my.app.rules.
DroolsCompilerAntTaskStandalone" classpathref="droolsutils.classpath" />
<target depends="newfilesarethere" name="build" unless="rulesCompile.
notRequired">
<rulescompiler srcdir="${THIS_PROJ}/src/com/my/app/rules"
tofile="${THIS_PROJ}/build/classes/com/my/app/rules/
packaged.rules"
classpathref="droolsutils.classpath" >
<include name="*.drl" />
</rulescompiler>
</target>
The classpath I provide contains pretty much all libraries I use normally in the project, but I tried even to add ALL jar's from the Eclipse 3.3 install directory (that would include all DRools 4.0.4 libraries, with antlr and whatnot)
I tried also with DRools 4.0.7, same behaviour...
What does that mean and where is it coming from? Could it have issues with the tools.jar from Java 1.5.0_14?
Thank you for any input,
M
16 years, 1 month
newbie - dynamic rules in java and db design
by techluver
I'm very new to drools world.. so please bear with me my beginner question..
I've following requirements in
*store the rules in database and load them dynamically.
*.provide the editor to the business user where they can add/edt the rules.
I think for this requirement, either i can go with BRMS or implement it my
own.
IF I use BRMS, Then my understanding is that it will have its set of
tables(no explicit db design is required) and we can manage the rules using
web editor.
1. Will it easy for business user to manager rules on their own without
interruption of developers?
2. Can we run BRMS 4.x in tomcat 5.5 version?
If I dont use BRMS, then i have to come up with own way of managing rules.
In this case, I'm planning to store the rules in GUI friendly format (I've
not decided on the format..)in the database(and provide my own GUI to manage
the rules) . Then Application will convert those rules into drools specific
language and load dynamically.
3. Is this right approach? if not, please give your suggestion.
4. I think rules can be written in java or drools native language. In my
case, When I read the rules from db which is in GUI friendly format,Will it
be easy to convert that to java rules or drools native language?
Thanks in advance for your help.
--
View this message in context: http://www.nabble.com/newbie---dynamic-rules-in-java-and-db-design-tp1974...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 1 month
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
Compatibility of Rule Flows from 4.0.7 to 5.0.0
by Vikrant Yagnick
Hi All,
I wanted to know if RuleFlows made using the Eclipse 4.0.7 RuleFlow Builder will work with 5.0.0. When, I try to upload a 4.0.7 ruleflow into Guvnor, I get a NullPointerException and before that the following:
Cannot find the declaration of element 'org.drools.ruleflow.core.impl.RuleFlowProcessImpl'.
I checked the 5.0.0M1 jars for drools-core, and this class seems to have been removed from there. Also, after installing the 5.0.0 plug-in into Eclipse, my rule-flow nodes have all gone.
Also, this may be a minor bug but it says(both in the docs and the BRMS Guvnor M1 Release):
"Ruleflows allow flow control between rules. The eclipse plugin provides a graphical editor. Upload ruleflow .rf files for inclusion in this package.":
Should the .rf say .rfm ?
Cheers,
Vikrant
MASTEK LTD.
Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 years, 1 month
Sort different records
by Delaunay Gaetan
Hi,
I've got this following rule :
when
$p1 : PricingField(v1 : name == "startdate")
$p2 : PricingField(this != $p1, name =="startdate", dateValue == v1)
then
....
This rule doesn't work and i can't figure out why. Does anyone have an idea?
Gaet
16 years, 1 month
Working with collections
by Marcin Krol
Hello everyone,
I'm a beginner in Drools, so please account for that. :-)
How do I use memberOf operator when working with collections? Depending
on a day of week, I want to check if a day is a working day or weekend day.
I tried this:
package com.sample
dialect "mvel"
import com.sample.ThermostatTimeData;
import com.sample.Thermostat.WorkDay;
import com.sample.Thermostat.WorkDays;
rule "Rule 1"
when
$wd : WorkDays()
$ttd : ThermostatTimeData( day memberOf $wd.daylist )
//$ttd: ThermostatTimeData ( day == "Monday" || day == "Tuesday" || day
== "Wednesday" || day == "Thursday" || day == "Friday" )
then
insert( new WorkDay() );
System.out.println("inserting new workday");
end
with this in my Thermostat class:
public static class WorkDays {
private String[] dl = {"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday"};
public WorkDays() {
}
public String[] getDaylist() {
return this.dl;
}
}
Now the above rule works fine when I select days using the regular fact
field selection in Drools:
$ttd: ThermostatTimeData ( day == "Monday" || day == "Tuesday" || day ==
"Wednesday" || day == "Thursday" || day == "Friday"
However, when I try to access WorkDays.dl or WorkDays.daylist(), the
rule doesn't fire (the program output is empty).
Regards,
MK
16 years, 1 month
to have some hierarchical control over rules in the same package
by hongyu lu
Hi,
I have a use case where I would like to group rules by package(each package would be one experiment in my app). There are a couple attributes at the package level, which will enable/disable all rules of that package(not being fired). What would be the best way to achieve this? I am new to Drools and it looks like the rule definition is kinda flat. I would like to avoid defining package level conditions within each rule.
thanks
Jeff
16 years, 1 month
Programmatically adding rules do BRMS
by Leonardo Figueiredo
Hello,
I am using Drools 5 M1 and i need to programmatically add DRL rules to an
existing BRMS package. Is there an api for doing it? Does anyone knows if
there is a planning to have something like that?
Thanks,
Leo
16 years, 1 month