DroolsCompilerAntTask bugs?
by lhorton
I think I have found a couple of bugs in DroolsCompilerAntTask. I am using
it to compile xls decision tables. My config for the compiler is:
<compiler srcdir="${build.web.dir}/packages/venue"
tofile="${build.web.dir}/packages/venue/venue.pkg"
binformat="package" bintype="knowledge" classpathref="model.classpath">
<include name="*.xls" />
</compiler>
I copied the source and added debug log entries. I found two problems:
(1) in the method compileAndAddFiles(KnowledgeBuilder kbuilder), there is a
call to getDroolsPackageFileList(). The call is supposed to return any
package file names in the srcdir, but it is instead it is returning the xls
spreadsheet file names. Then again within compileAndAddFiles, there is a
call to getFileList(), which also returns the xls file names. As a result,
each file gets added to the rule base twice.
(2) in method compileAndAddFile(KnowledgeBuilder kbuilder, String fileName),
the code to compile a spreadsheet (file extension XLSFILEEXTENSION) throws
exception with message "Property storage size inconsistent with block
chain." I changed the source to use a file resource instead of a reader
resource:
kbuilder.add(ResourceFactory.newFileResource(new File(this.srcdir,
fileName)), ResourceType.DTABLE,
dtableconfiguration);
and then the compile works OK.
--
View this message in context: http://drools.46999.n3.nabble.com/DroolsCompilerAntTask-bugs-tp3279120p32...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Drools 5.2 performance building KnowledgeBase
by darktyco
Has anyone out there experienced any slowdowns using Drools 5.2 to build a
knowledge base? I have around 700 drl files (containing anywhere from 1 to
30 rules each) and the time to build a KnowledgeBase with them has increased
from about 10 minutes in Drools 5.1 to 90 minutes in Drools 5.2. I realize I
have a slow computer here, but the time difference between the two versions
is staggering.
I have already been serializing the KnowledgeBase object for performance
reasons and even loading the serialized KnowledgeBase takes about 3-4x
longer in 5.2 than in 5.1. Am I doing something wrong here? Here are some
code snippets of how I am building and loading the kbase:
//////////////////////// Building
final KnowledgeBuilder kBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
final List<File> drlFiles = getAllDrlFiles(directory);
for (final File name : drlFiles) {
kBuilder.add(ResourceFactory.newFileResource(name),
ResourceType.DRL);
}
if (kBuilder.hasErrors()) {
// ....
}
final KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
kBase.addKnowledgePackages(kBuilder.getKnowledgePackages());
ObjectOutputStream oos = null;
try {
oos = new DroolsObjectOutputStream(new FileOutputStream(pkgFile));
oos.writeObject(kBase);
} catch (...) {
// ....
}
//////////////////////// Loading
ois = new DroolsObjectInputStream(new FileInputStream(pkgFile));
final KnowledgeBase kBase = (KnowledgeBase) ois.readObject();
final StatefulKnowledgeSession ksession =
kBase.newStatefulKnowledgeSession();
Thanks!
--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-2-performance-building-Knowled...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
Eclipse reports error when declaring FactType
by FrankVhh
Hi all,
This question might make me look like a bit of a moaner. Then again, you
shouldn't be a member of an internet forum if you'd worry about what other
people think of you. Therefore:
If you declare a type in one of your rule files, and use that type in
another drl file, Eclipse will return an error message claiming that the
type in question does not exist. And actually, he is quite right, as the
type will only start existing when the kbase is created. So, the rules you
created *will* work at runtime (provided you did not commit any other
foolishness).
The thing is, these errors are a bit annoying. Is there any way to
circumvent this, moan-moan ? Or is the only way to get rid of the error
messages to create the objects in java?
Thanks a lot.
Regards,
Frank
--
View this message in context: http://drools.46999.n3.nabble.com/Eclipse-reports-error-when-declaring-Fa...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 8 months
How to pass global variables to a function called in a condition
by Matthew Erler
In Drools 5 I'm passing in two global Date objects and need to find the difference in days between them. I've discovered that the function parameters (fromDate and toDate in my case) are null in the condition when the function is called, but when the function is called in the consequence they have values. I can see that because the output of the following rule is:
fromDate is null
toDate is null
I'm in dateDiff and the date diff is: 14
I'm guessing that Drools doesn't make globals t available at the point that I need them. Can anyone confirm this and offer a solution?
Here is the rule file itself:
import java.util.Date;
import org.joda.time.DateMidnight;
import org.joda.time.Days;
global java.util.Date fromDate;
global java.util.Date toDate;
rule "dateDiff"
dialect "mvel"
when
eval(getDaysBetweenStartAndEndDate(fromDate, toDate) < 10)
then
System.out.println( "I'm in dateDiff and the date diff is: " + getDaysBetweenStartAndEndDate(fromDate, toDate));
end
function int getDaysBetweenStartAndEndDate(Date fromDate, Date toDate) {
if (fromDate==null) System.out.println("fromDate is null");
if (toDate==null) System.out.println("toDate is null");
return Days.daysBetween(new DateMidnight(fromDate), new DateMidnight(toDate)).getDays();
}
14 years, 8 months
Stateless vs Stateful
by Rob Fisher
We have a batch application that will have 50 - 60 rule sets, comprised of 5 - 75 rules each. We'll run a group of individuals through the rules and potentially qualify them for various awards. We'll insert 10 facts, each containing a unique set of attributes which will be used in the rule sets to determine potential qualification. The batch process will insert one individual's data (10 facts) at a time, fire the rules, and return the results. The data on the objects inserted will remain static.
Also, in the future, we'd like to integrate the rule sets with a 'what if' web application, wherein the individual can modify the input data, fire the rules, and see the results.
Given this, can you recommend whether a Stateful or Stateless knowledge session is more appropriate than the other? Is one more appropriate for a batch vs online application?
Thanks
Rob
14 years, 8 months
Options for rule versioning
by Rob Fisher
Looking for best practice recommendations around the versioning of a rule. Our application will have 50-60 rule sets comprised of up to 70 rules each. The activation of many of the rules will be based on a processing date (inserted fact attribute). The application processing date can be prior, equal, or after the system date.
For example, 2 rules, with slightly different logic
Eligibility rule version 1
//to be potentially activated for application processing time period prior to 2011
When
Car(color = "blue")
Then
Terms(eligible = "yes")
Eligibility rule version 2
//to be potentially activated for application processing time period 2011 and forward
When
Car(color = "blue", type="coupe")
Then
Terms(eligible = "yes")
We've come up with a couple of different ways to handle this:
1. Add Date logic to LHS of the rule . i.e add "Control(processingDate < '01/01/2011')" to 1st rule and "Control(processingDate >= '01/01/2011')" to 2nd rule. First rule would activate with processing date = 12/31/2010 and 2nd rule would activate with processing date = 07/31/2011. When originally authored, first rule would be written without date logic. When 2nd rule is authored, data logic will need to get added to both.
2. We explored a way of setting the session clock to the processing date and using the 'date-effective' and 'date-expires' attributes to do the filtering. i.e. 1st rule is effective until 12/31/2010 and 2nd rule is effective from 01/01/2011 to 12/31/9999. However, we could only figure out how to do this with a stateful knowledge session. Is it possible in a Stateless?
3. We added metadata to the rules (@EffectiveDate and @ExpirationDate), and using agendafilter, we compared processing date to the metadata and return true or false dependent on comparison.
What are your opinions on these three methods? What are other options?
Thanks
Rob
14 years, 8 months
Error in Guvnor with Enumerations (5.1.1)
by John Peterson
Reposting since I didn't get any takers. I'm hoping it might have been because I sent it to the list on a Friday afternoon (2 weeks ago).
Hey,
I'm trying to utilize a "load method" for Guvnor, but I can't seem to get it working. His is my DataHelper class (modeling it off the documentation):
package com.enumerations;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class DataHelper {
public List<String> getQuestionNumberList(){
ArrayList returnList = new ArrayList();
Iterator it = com.enumerations.DroolsTest.questionList.iterator();
while (it.hasNext()){
QuestionAndAnswer qAndA = (QuestionAndAnswer)it.next();
if (!returnList.contains(qAndA.getQuestionNumber())){
returnList.add((String)qAndA.getQuestionNumber());
}
}
return (List<String>)returnList;
}
}
I've placed this (both as a .jar and .class file) in my JBoss installation under \jboss-4.2.3.GA\server\default\deploy\drools-guvnor.war\WEB-INF\classes\com\enumerations.
Using this syntax as an enumeration in Guvnor:
'QuestionAndAnswer.questionNumber' : (new com.enumerations.DataHelper()).getQuestionNumberList()
I get the following errors:
[Enumerations] Unable to load enumeration data.
[Enumerations] [Error: failed to access property: getQuestionNumberList(): [Error: unable to invoke method: getQuestionNumberList] [Near : {... Unknown ....}] ^[Line: 1, Column: 0]][Near : {... r()).getQuestionNumberList() ....}] ^ [Line: 1, Column: 0] [Enumerations] Error type: org.mvel2.PropertyAccessException
I am using Drools 5.1.1. Does anyone have any suggestions on what to do to correct this error?
jp
14 years, 8 months
Inconsistent syntax behaviour
by Swindells, Thomas
Continuing trying to upgrade from drools 5.1 I've been finding some strange funnies in rules behavior. Currently I'm using <droolsVersion>5.3.0.Beta1</droolsVersion>
<jbpmVersion>5.1.0.Final</jbpmVersion>
<mvelVersion>2.1.Beta6</mvelVersion>
In our model we've got some lists (Yuck I know) and we want to test whether they are not empty, there are three variations of the rules that we could use
rule "TESTa"
when
t : Title(t.getMyList().isEmpty() == false)
then
logger.debug(drools.getRule().getName() + " " + drools.getTuple());
end
rule "TESTb"
when
t : Title(myList.isEmpty() == false)
then
logger.debug(drools.getRule().getName() + " " + drools.getTuple());
end
rule "TESTc"
when
t : Title(myList.empty == false)
then
logger.debug(drools.getRule().getName() + " " + drools.getTuple());
end
I'd expect all of these formats to work (particularly c) however only TESTa succeeds, the other two FAIL SILENTLY, failing to match anything but not generating any errors or warnings.
Thomas
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster(a)nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
14 years, 8 months