Globals in LHS
by thomas kukofka
Hello,
Is it possible to evaluate a global on the LHS of rule?
Like:
global SomeGlobal someGlobal
rule "xy"
when
someGlobal.getValue() <= 3
then
....
end
Kind Regards
Thomas
18 years
QueryResult.getFactHandles bug?
by Fenderbosch, Eric
I didn't find a JIRA for this and I'm pretty sure my test is valid.
QueryResult.getFactHandles() seems to be only returning [fid:-1:X:null]
I'm using 4.0.7.
Here's my test case:
public void testQueryResults() throws Exception {
StatefulSession workingMemory = DroolsUtil.getWorkingMemory();
TestFact testFact = new TestFact();
String id = "1234";
testFact.setId(id);
FactHandle testHandle = workingMemory.insert(testFact);
System.out.println(testHandle);
Object[] args = {id};
int resultCount = 0;
int factCount = 0;
int handleCount = 0;
Object fact = null;
FactHandle handle = null;
// query getTestFact(String _id)
// TestFact(id == _id)
// end
QueryResults queryResults =
workingMemory.getQueryResults("getTestFact", args);
Iterator<QueryResult> iterator = queryResults.iterator();
while (iterator.hasNext()) {
resultCount++;
QueryResult result = iterator.next();
FactHandle[] handles = result.getFactHandles();
for (FactHandle h : handles) {
handleCount++;
handle = h;
}
for (int i = 0; i < result.size(); i++) {
factCount++;
fact = result.get(i);
}
}
System.out.println(handle);
assertTrue(resultCount == 1);
assertTrue(factCount == 1);
assertTrue(testFact == fact);
assertTrue(handleCount == 1);
// this fails
assertTrue(testHandle == handle);
}
TestFact is very simple, using id in hashCode and equals.
Am I using getFactHandles correctly?
Thanks.
18 years
Package parameters
by Yoni Mazar
Hi all,
We are at the begining of a new clinical decision-support project. We are
considering using a BRMS to manage and execute our business logic. As part
of our research, we evaluated JRules and Drools. JRules has a nice feature
that we could not find in Drools. We'd like to know if we are
misunderstanding something, or maybe this feature is missing.
In JRules, one can define a ruleset (corresponds to a package) with
parameters. Each parameter has a datatype (a class), a direction
(in/out/inout), and an alias. Then, within the rules, the user can refer to
the parameter alias. For example, a user can define a ruleset with the
following parameters:
*class=LabResult, direction=in, alias=hemoglobin
*class=LabResult, direction=in, alias=creatinin
Then, within a rule, one can write:
when hemoglobin.value<10 and creatinin.value>34
then...
Now, the application retrieves the patient data accordingle (hemoglobin and
creatinine data separetly) and sets the ruleset parameters:
ruleset.parameters.add("hemoglobin",hemoglobinFact)
ruleset.parameters.add("creatinin",creatininFact)
This approach simplifies the rule authoring process significantly!
Writing this logic in Drools will be:
package cdss
import LabResult;
rule
when
LabResult(type=hemoglobin && value <10)
LabResult(type=creatinin&& value <34)
then...
workingMemory.Assert(hemoglobinFact);
workingMemory.Assert(creatininFact);
Does someone has an idea how to bridge this gap using Drools?
Im not sure if using parameters JRule complies with JSR94 specification.
Thanks,
Yoni
--
View this message in context: http://www.nabble.com/Package-parameters-tp17979190p17979190.html
Sent from the drools - user mailing list archive at Nabble.com.
18 years
Eclipse plugin error: DRL-files in multiple folders?
by Tobias Abstreiter
Hi!
I have a problem using the drools Eclipse plugin 4.0.7 (with Drools 4.0.7).
In our project rules are located in different folders. One of it is called "global" (containing many functions, imports, ...) whereon most of the rules in the other folders depend. The package name is identical.
Running the application works fine but the Eclipse plugin reports many "... cannot be resolved"-errors when I convert the Eclipse Java project into a Drools project. I believe that the plugin has problems to find all rule files. Is that possible?
Is there a way to tell the plugin to look in multiple rule-folders?
Thanks in advance,
Tobias
__________________________________________________________________
MicroNova electronic GmbH
Tobias Abstreiter
Telekommunikation & Netzmanagment
Unterfeldring 17
D-85256 Vierkirchen
Tel.: +49 (08139) 93 00-42
Fax.: +49 (08139) 93 00-80
eMail: Tobias.Abstreiter(a)micronova.de
Web: http://www.micronova.de
Geschäftsführer: Josef W. Karl - Sitz der Gesellschaft: Jetzendorf
Registergericht: Ingolstadt - HRB-Nr.: 181 373
__________________________________________________________________
18 years
DSL debugging?
by Barry Kaplan
I have a very simple DSL snippet:
PPositionQuantityAllocatedToLegs {position} {rulePriority}=
Integer(intValue < {position}.quantity) from accumulate(
StrategyLeg(priority > {rulePriority}, instrument == {position}.instrument,
longShort == {position}.longShort, legQuantity : quantity)
legsQuantity(legQuantity) )
In the IDE it seems to expand correctly without errors. However, at runtime
I get the below error. How does one decipher such a message?
Caused by: org.drools.rule.InvalidRulePackage: [20,0]: unknown:20:0
mismatched token: [@148,506:513='expander',<7>,20:0];
at org.drools.rule.Package.checkValidity(Package.java:424)
at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:394)
at
com.sig.buyingpower.DroolsOptionStrategyBuyingPowerPositionAggregator.loadRules(DroolsOptionStrategyBuyingPowerPositionAggregator.java:91)
at
com.sig.buyingpower.DroolsOptionStrategyBuyingPowerPositionAggregator.<clinit>(DroolsOptionStrategyBuyingPowerPositionAggregator.java:117)
--
View this message in context: http://www.nabble.com/DSL-debugging--tp18095970p18095970.html
Sent from the drools - user mailing list archive at Nabble.com.
18 years
Problems with drools-4.0.7 examples
by Stephen Schaub
I am new to Drools.
I downloaded the drools-4.0.7 examples from
http://download.jboss.org/drools/release/4.0.7.19894.GA/drools-4.0.7-exam...
I have Eclipse 3.3 with the GEF dependency, and installed the Drools
plugins. I then imported the drools examples into a clean Eclipse
workspace. I'm getting many errors reported in the Eclipse Problems
view on the .drl files.
I attempted to run the HelloWorldExample, and got a runtime error. I
checked the build path of the project, and it references
drools-compiler and drools-core projects, neither of which are in my
workspace. I manually removed these, and added the dependencies
mentioned in the Drools README_DEPENDENCIES.txt.
I looked around for info on setting up the drools examples, and didn't
find any. I would appreciate a pointer...
--
Stephen Schaub
18 years
Rule syntax question
by Joe12345678990000 Amazander
Greetings,
I have two questions regarding Drools' capability:
1. Does Drools support mathematic operations in the "If" part?
If I use MVEL, can I write something like this:
$h: Holder($h.account.balance - 1000 > 25)
I know this can be replaced as
$h: Holder($h.account.balance >1025)
But I need to know if the first expression is valid. I tested and it did not
work for me - am I doing something wrong?
2. Does Drools support function call with parameters?
If I use MVEL, can I write something like this:
...
import com.mytest.util.CommonFunction.myTest;
...
dialect "mvel"
salience 2
when
$h: Holder(eval(myTest($h.account.balance) >= 0))
then
$r.account.label = 17;
update($r);
end
myTest is a static method of CommonFunction.
>From what I read in the doc, "function" is most useful in the then part -
but can I use it in the "if" part? This does not work for me in my test -
did I do anything wrong?
Any help will be appreciated.
Thanks,
Joe
18 years
Drools infixOr with a from Collection Not Working???
by Carlsen, Len
Hi,
I have a rule with an infixOr and an infixAnd that test for objects in a
collection which doesn't execute even though it should.
# This rule will not execute even though it should
rule "FAIL_AorBandC"
when
test : TestClass( string=="TEST" )
( TestClass( string == "A" ) from test.list
or
TestClass( string == "B" ) from test.list )
and
TestClass( string == "C" ) from test.list
then
System.out.println( "FAIL_AorBandC: " + test.getString() );
end
All other combinations of ANDs and ORs such as (A and B) or C, (A or B),
(A or B) or C will work except the one above if a from collection is
used.
(A or B) and C will work if a from collection is not used.
Has anyone come across this? Is this a bug?
Thanks,
Len
18 years
Business rule name weirdness
by Keith Bennett
Does anyone have any idea why drools.getRule().getName() inside of the
rule consequence would be returning the old business rule name? I
renamed the business rule, and I am seeing through testing that the
old name is being resolved by Drools at runtime, not the new one.
What the heck is going on? I am using the Drools 4.0.7 libraries.
Keith
18 years