Use of Drools for a product catalog retrieval in a best effort fashon
by Alessandro Terrinoni
Hello.
I'm working on a project about a product catalog, which involves the use of Drools for fetching from the database layer a set of products that support a list of characteristics in a best-effort fashon
In detail the database is constructed with the use of dynamic characteristics, i.e. all attributes, like dimensions or weight, are not included as fields in the table cointaining the definition of the product but they are stored in a different table; then the linkage product-characteristic is stored in a third table cointaning the product id, the characteristic id and the value associated and other necessary fields.
Now i would use drools for getting a limited number (let's say fixed - i.e. everytime max 10) products which has a variable number of characteristic (supplied by the user) in a best-effort style. For example if i search a router with 5 ports i could retrieve also routers with 6 or 4 ports if no router with 10 ports are in the database or there are less then 10, and so on until i get 10 (or until there are no more routers - obviusly i cant get 10 if in the db there are just 7). Now this is a really simple scenario, but you can imagine one user specifing several desired characteristics.
I tought about recursive use of business rules, i mean i look first for routers with X ports, then X+1 or X-1 ports, then X-2 or X+2 ports etc. but this would lead to a monster number of business rules, since the characteristics are many. Moreover, this works fine with characteristics that takes on numeric values, but what about those which takes on Strings? I.E. encription support can be AES, DES, 3DES etc. In this case I should specify one rule for each desired request and for each step, i.e. if the user wants AES support then look for AES first, then 3DES, then DES etc. OR if he wants 3DES then 3DES first, then AES etc. (just a dumb example but i hope you get the point).
I see this is quite a lot of rules handling.. maybe someone has a suggestion for another approach which would simplify the process? Or maybe someone had to solve something similar and would share some knowledge with me?
Thanks for the attention :)
Cheers
Alessandro Terrinoni
_________________________________________________________________
Scopri le keyword più cercate della settimana!
http://clk.atdmt.com/GBL/go/136430524/direct/01/
15 years, 8 months
Error running DroolsCompilerAntTask in CR1
by Jeff Davis
Hi,
I upgraded everything from M5 to CR1 last night, but noticed that my ant
task no longer worked and was returning an error (it had worked previously
under M5, and I confirmed by switching everything back to test). The error I
now receive is:
[compiler] java.util.zip.ZipException: error in opening zip file
[compiler] at java.util.zip.ZipFile.open(Native Method)
[compiler] at java.util.zip.ZipFile.<init>(ZipFile.java:203)
[compiler] at java.util.zip.ZipFile.<init>(ZipFile.java:234)
[compiler] at
org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1028)
[compiler] at
org.apache.tools.ant.AntClassLoader$ResourceEnumeration.findNextResource(AntClassLoader.java:147)
[compiler] at
org.apache.tools.ant.AntClassLoader$ResourceEnumeration.nextElement(AntClassLoader.java:130)
[compiler] at
org.apache.tools.ant.util.CollectionUtils$CompoundEnumeration.nextElement(CollectionUtils.java:198)
[compiler] at
sun.misc.CompoundEnumeration.nextElement(CompoundEnumeration.java:43)
[compiler] at
org.drools.util.ChainedProperties.loadProperties(ChainedProperties.java:233)
[compiler] at
org.drools.util.ChainedProperties.<init>(ChainedProperties.java:119)
[compiler] at
org.drools.util.ChainedProperties.<init>(ChainedProperties.java:41)
[compiler] at
org.drools.util.ChainedProperties.<init>(ChainedProperties.java:35)
[compiler] at
org.drools.RuleBaseConfiguration.init(RuleBaseConfiguration.java:376)
[compiler] at
org.drools.RuleBaseConfiguration.<init>(RuleBaseConfiguration.java:234)
[compiler] at
org.drools.common.AbstractRuleBase.<init>(AbstractRuleBase.java:149)
[compiler] at
org.drools.reteoo.ReteooRuleBase.<init>(ReteooRuleBase.java:144)
[compiler] at
org.drools.reteoo.ReteooRuleBase.<init>(ReteooRuleBase.java:121)
[compiler] at
org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:58)
[compiler] at
org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:38)
[compiler] at
org.drools.contrib.DroolsCompilerAntTask.createWithPackageBuilder(DroolsCompilerAntTask.java:241)
[compiler] at
org.drools.contrib.DroolsCompilerAntTask.execute(DroolsCompilerAntTask.java:170)
[compiler] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[compiler] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[compiler] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[compiler] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[compiler] at java.lang.reflect.Method.invoke(Method.java:585)
[compiler] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[compiler] at org.apache.tools.ant.Task.perform(Task.java:348)
[compiler] at org.apache.tools.ant.Target.execute(Target.java:357)
[compiler] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[compiler] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
[compiler] at
org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[compiler] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[compiler] at
org.apache.tools.ant.Project.executeTargets(Project.java:1189)
[compiler] at org.apache.tools.ant.Main.runBuild(Main.java:758)
[compiler] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[compiler] at
org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[compiler] at
org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
My build.xml is:
<project name="test" default="compile">
<path id="drools.path.task">
<fileset dir="C:\Apps\drools-5.0.0.CR1-bin">
<include name="drools-compiler-5.0.0.CR1.jar"/>
<include name="drools-ant-5.0.0.CR1.jar"/>
<include name="drools-core-5.0.0.CR1.jar"/>
<include name="drools-decisiontables-5.0.0.CR1.jar"/>
<include name="drools-api-5.0.0.CR1.jar"/>
</fileset>
<fileset dir="C:\Apps\drools-5.0.0.CR1-bin\lib">
<include name="*.jar"/>
</fileset>
</path>
<path id="drools.path">
<pathelement path="target\classes"/>
<fileset dir="C:\Apps\drools-5.0.0.CR1-bin">
<include name="drools-ant-5.0.0.CR1.jar"/>
<include name="drools-decisiontables-5.0.0.CR1.jar"/>
<include name="drools-api-5.0.0.CR1.jar"/>
</fileset>
</path>
<taskdef name="compiler"
classname="org.drools.contrib.DroolsCompilerAntTask"
classpathref="drools.path.task" />
<target name="create.rules.package" >
<compiler
srcdir="src\main\rules"
tofile="target\package\packge.pkg"
classpathref="drools.path">
<include name="Sample.drl" />
</compiler>
</target>
<target name="clean">
<delete includeemptydirs="true">
<fileset dir="target"/>
</delete>
</target>
<target name="compile" depends="clean">
<mkdir dir="target/classes"/>
<mkdir dir="logs"/>
<javac destdir="target/classes" debug="on" source="1.5" target="1.5">
<src path="src\main\java"/>
<classpath refid="drools.path.task"/>
</javac>
</target>
<target name="init">
<mkdir dir="target/classes"/>
<mkdir dir="target"/>
<mkdir dir="target/wsdl2javasource"/>
</target>
</project>
If anyone has any ideas, they would be much appreciated!
Thanks!
jeff
15 years, 8 months
Persistence and drools-process-enterprise.jar
by Umesh Wankhede
The persistence chapter talks about dependency on
drools-process-enterprise.jar. But 5.0CR1 distribution doesn't seem to
have this jar whereas 5.0M5 contains the same. Any reason for removing
the jar and which jar replaces this one in 5.0CR1?
Legal Notice: This transmission, including any attachments, is confidential, proprietary, and may be privileged. It is intended solely for
the intended recipient. If you are not the intended recipient, you have received this transmission in error and you are hereby advised that any
review, disclosure, copying, distribution, or use of this transmission, or any of the information included therein, is unauthorized and strictly
prohibited. If you have received this transmission in error, please immediately notify the sender by reply and permanently delete all copies of
this transmission and its attachments
15 years, 8 months
Re: Mixing dsl language and regular rule syntax in a rule file
by Matt Geis
>> Is it possible to mix dsl language and regular rule syntax in a rule
file?
Absolutely. Last I checked, it was not documented, but you can see it in the samples that ship with Drools. Your dslr file below has been rewritten to support what you want to do. (The '>' character tells the parser to not perform DSL expansion on a given line)
animal.dslr file
#created on: Mar 12, 2009
package com.fedex.cc.expertsystem.test
import com.fedex.cc.expertsystem.fact.*
expander animal.dsl
rule "Set dog's ownership"
no-loop
when
There is an animal lover and dog in the system
then
The person owns the dog
end
rule "Tell us person doesnt like dogs"
when
> person : Person(animalLover == false)
then
> System.out.println("Person does not like dog");
end
15 years, 8 months
forall over a collection
by howard goldberg
Trying to check whether a patient has a particular problem on their problem
list:
when
$patient : Patient()
forall ( Problem( code != "195967001") from $patient.problemList)
but I get the following parsing error--
[29,41]: [ERR 101] Line 29:41 mismatched input 'FROM' expecting ')' in rule
"Dumb no asthma Rule"
[29,66]: [ERR 101] Line 29:66 mismatched input ')' expecting '(' in rule
"Dumb no asthma Rule" in pattern $patient.problemList
What is the correct way to check for this condition?
Thanks,
Howard
15 years, 8 months
Inserting a JRuby object via Spring JRubyScriptFactory in Drools
by Premkumar Stephen
Hello Folks,
I have been looking at options of using ruby objects as fact objects in
Drool's working memory.
One obvious way is using services.
Another path that I have been researching about is to use Spring as outlined
here http://www.jroller.com/habuma/entry/spring_meet_ruby
Now, in this example, if the Lime ruby object were like a POJO, (contains
fields), will I be able to insert this object into the workingMemory? My
Lime interface would have getters and setters. Will the engine look for the
fields themselves in an object or can it work with just getters and setters
( as would be declared in the Lime.java interface and defined in the Lime.rb
ruby class?
Are there any drawbacks in doing it this way?
Any comments/pointers will be appreciated.
Thanks!!
15 years, 8 months
running a small set of rules from a drl file.
by Lucas de Oliveira
Hi,
I was wondering if it's possible to pick up just a few rules from a drl file
to create the RuleExecutionSet. Something like:
rules.drl ===>
...
rule "r1"
...
end
rule "r2"
...
end
...
=============
RunRules.java ===>
...
List<String> rulesToRun = new ArrayList<String>();
rulesToTun.add("r1");
RuleExecutionSet ruleExecutionSet =
ruleSetProvider.createRuleExecutionSet(ruleFileName, null, rulesToRun);
ruleAdministrator.registerRuleExecutionSet("test.drl", ruleExecutionSet,
null);
...
=============
I haven't found anything like that in the documentation. I'd really like
that otherwsie I'll have to split the rules through many different files,
which will be a bit of a havoc to unit test...
thanks in advance!
best regards,
--
Lucas de Oliveira Arantes
15 years, 8 months