Problem with updated facts
by thomas moncieu
Hi,
I have a problem when updating fields in rules :
Here's the rule :
when
t : Bill($amount : totalAmount, totalAmount > (new
Double(150.0).doubleValue()));
then
System.out.println("tot : " + $tot);
end
The original totalAmount is 200.
A fact update sets the totalAmount at 100 (with an update of the facthandle
that I can see in the debugger of the working memory) so the condition of
the rule does not be true.
Nevertheless, the System.out is made and prints 100.
I use Statefull session and set shadow facts to true.
Thanks for helping me !
15 years, 8 months
Drools 5.0.0 CR1 : multibyte characters in dsl fails with "no viable alternative at character"
by Yusuke Yamamoto
Hi,
I found that Drools 5.0.0 CR1 is unable to compile DSLs including
multibyte characters in them.
For example, mydsl.dsl as following:
---------
[consequence]print:"{value}" = System.out.println("{value}");
[consequence]出力:"{value}" = System.out.println("{value}");
---------
Fails to be compiled with
---------
line 3:13 no viable alternative at character '出'
line 3:14 no viable alternative at character '力'
---------
"出力" means "print" in Japanese.
It used to be work with Drools 4.0.7.
I couldn't found any related issues on Jira. But is it a known issue?
Best regards,
Yusuke
15 years, 8 months
application for creating rules
by Stjepan Cvitanović
Greetings
After many months of inactivity we have finally released a final version of
MSM Drools Rule Editor.
This version differs from the previous versions in many aspects, most
notable of which are:
- workspace integration
- full separation of data model and logic model
The old features have remained:
- Full graphical rule representation
- Parser for drools and HQL/SQL
- Fast rule testing using HQL/SQL
- Replay of rule fireing (for drools only)
- replay save/load capabilities
New features added:
- plugin support
- docking visual interface (multiple views)
- workspaces
- rules history with SVN
- import from CSV for rule testing
and more...
Java 1.5 required, java 1.6 recommended
Download it from http://www.sourceforge.net/projects/droolsruleedit and tell
us what you think of it
Any feedback is welcome.
MSM Team
15 years, 8 months
Internal type used together with function throws ClassCastException
by Michal Bali
Hi,
Internal type together with a function in one drl file cause
ClassCastException when setting properties of a new instance of this type.
java.lang.ClassCastException: org.drools.generatedbeans.Cheese cannot be
cast to org.drools.generatedbeans.Cheese
at
org.drools.base.org.drools.generatedbeans.Cheese6778431$setType.setValue(Unknown
Source)
at org.drools.base.ClassFieldWriter.setValue(ClassFieldWriter.java:195)
at
org.drools.base.ClassFieldAccessor.setValue(ClassFieldAccessor.java:319)
at org.drools.factmodel.ClassDefinition.set(ClassDefinition.java:207)
at
org.drools.integrationtests.MiscTest.testGeneratedBeansWithFunction(MiscTest.java:1072)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
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)
Test case to reproduce:
test_GeneratedBeansWithFunction.drl:
-------------------------------
package org.drools.generatedbeans;
function void someFunction(String arg) {
System.out.println("hello");
}
declare Cheese
type: String
end
-------------------------------
test method:
public void testGeneratedBeansWithFunction() throws Exception {
final KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newInputStreamResource(
getClass().getResourceAsStream( "test_GeneratedBeansWithFunction.drl" ) ),
ResourceType.DRL );
assertFalse( kbuilder.getErrors().toString(),
kbuilder.hasErrors() );
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
// Retrieve the generated fact type
FactType cheeseFact = kbase.getFactType(
"org.drools.generatedbeans",
"Cheese" );
// Create a new Fact instance
Object cheese = cheeseFact.newInstance();
cheeseFact.set( cheese,
"type",
"stilton" );
}
The last line throws the ClassCastException. If we remove the function from
the drl file all works fine.
Best Regards,
Michal
15 years, 8 months
single binding for or CE flagged by compiler
by Wolfgang Laun
As far as I know, this should work:
package orel;
import orel.Main.Trigger;
rule ror1
when
$t : (or Trigger(fa == 1)
Trigger(fa == 2))
then
System.out.println( "fired " + $t.getName() );
end
This is what Drools-5.0.0 kbuilder.getErrors().toString() returns:
[5,11]: [ERR 102] Line 5:11 mismatched input 'Trigger' expecting '(' in rule
ror1 in pattern or[6,14]: [ERR 102] Line 6:14 mismatched input 'Trigger'
expecting ')' in rule ror1[6,30]: [ERR 102] Line 6:30 mismatched input ')'
expecting 'then' in rule ror1
Shouldn't toString() insert line ends? As it is, the result is pretty much
useless.
This works:
rule ror1
when
(or $t : Trigger(fa == 1)
$t : Trigger(fa == 2))
then
System.out.println( "fired " + $t.getName() );
end
-W
15 years, 8 months
Missing libs for persistence in 5.0.0CR1
by Petersen, Jan (CH Ext)
Hi
I have been trying to get persistence to work in 5.0.0CR1, but I have
noticed that many of libs decribed in the documentation (chapter 5.1.3)
are missing ....
As they were present in M5 I'm just wondering why this is the case?
Best regards
Jan Petersen
15 years, 8 months
using BigDecimal in rules
by Marina
Hi,
I'm getting unexpected results when when using BigDecimal objects for matching in rules.
I'm generating DRL in my code, using freemaker.
I have a RuleEngineNumericFact object which has two attributes:
String propertyName
BigDecimal propertyValue
Below is an example of a rule where I try to match a RuleEngineNumericFact object based on the two attributes:
rule "aaa"
agenda-group "r1"
dialect "java"
when
(RuleEngineNumericFact( propertyName == "somename" , propertyValue == 10.8 ))
then
String ruleId = drools.getRule().getName();
firedRuleIDs.add(ruleId);
end
Then I create a new RuleEngineNumericFact object and set its propertyValue as following:
String stringValue = "10.8";
BigDecimal propertyValue = new BigDecimal(stringValue, new MathContext(10));
(I also tried to use default precision settings by creating the BigDecimal value as:
BigDecimal propertyValue = new BigDecimal(stringValue);
)
When I insert this fact into the rule engine - the rule does not get fired, so the fact does not match.
One note: if the values are integeres (like, propertyValue == 100) - the rule gets fired. So, it is only the floating point numbers that do not match.
I generate the DRL in my Java code, using freemaker, and I specify the
value that will be used in the rule for matching by calling toString()
method on a BigDecimal object that I get from my business code. The toString() representation ends up to be the "10.8" value (for example).
According to the BigDecimal documentation, marshalling from/to the same string representation shoudl still produce BigDecimal objects that will return TRUE from the equals() method when compared.
any ideas why this is not working here?
How does Drools compare values of objects like BigDecimal?
thanks,
Marina
15 years, 8 months
Drools Boot Camp and San Francisco
by Mark Proctor
I'm still trying to get budget approval. We are looking at the Hilton at
the moment as expedia have rooms at $103 per day, which is very good
value. I can get travel and room budget for my team, but not meeting
room budget. The meeting room is $400 per day, I might be able to
negotiate a little off that, and we will need "sponsors" to cover the
price of the meeting room for the week, if this is to go ahead.
We are looking at a date range of:
arriving - 31 of May
departure - 8th of June
So we'll need a room from the 1st to the 7th, inclusive. If you are able
to sponsor the meeting room for a day or two, or more :), please do let
me know as soon as possible.
Thanks
Mark
15 years, 8 months