Lists with from clause in 3.1M1
by kchantzara@costamare.com
Hello,
I have asserted one ArrayList<Cylinder> into my working memory
and I am using the 'from' clause to iterate over the items of the list and
fire the rule accordingly.
i.e.:
rule "Firing Pressure Less Than Min"
agenda-group "cylinder"
salience 22
when
$cylinders: ArrayList()
$cylinder : Cylinder(pressureValue < Pressure.MIN_VALUE) from $cylinders
then
System.out.println("The FP of Cyl xxx is Lower than Min Possible.");
end
I would like to make the following questions:
a) Is it possible to get the index of the item in the list for which the rule fired;
Lets say that I would like to do that without adding extra fields in the Cylinder class.
b) If i had a second ArrayList<Cylinder> in my working memory would I be able to iterate over
the two lists simultaneously and compare values for corresponding items in the LHS;
c) Can I use the 'from accumulate' clause over an ArrayList instead of individual objects
asserted into the working memory;
My apologies for the multiple questions in one mail.
Thank you in advance for any help,
Katerina
17 years, 8 months
removing rules contained in drl files
by Justine Hlista
Hello,
We are managing sets of related rules in drl files. There may be multiple
drl files that define a package.
It would be really nice if we could easily remove the set of related rules
in a given drl file from a package.
For example:
RuleBase.removeDrlRules(pkg, "path/to/drl/file");
Is there any easy way to do this without having to maintain the list of
rules that exist within each drl file?
I am still on 3.0.x, but will be moving to 3.1 shortly.
Thanks,
Justine
17 years, 8 months
Rule simplification
by Sikkandar Nawabjan
Hi,
I have a object having 10 properties. i want to do null check for all those properties.
i want to write a single rule to do and i don't want to write java functions in drl.i don't want to write 10 individual rules as the action are same for all the property null check.
am using 3.0.6. how can do that in a single rule.syntax please
Thanks and Regs,
Basha
17 years, 8 months
ok - index problems - got a real simple test to try !
by Michael Neale
Really truly ;) , try this with junit, and JR 1.2.2 (1.3 also does it):
public void testIt() throws Exception {
Repository repo = new TransientRepository();
Session sess = repo.login(new SimpleCredentials("foo",
"password".toCharArray()));
Node root = sess.getRootNode();
for (int i = 0; i < 10; i++) {
root.addNode( "" + i + System.currentTimeMillis(),
"nt:unstructured" );
sess.save();
}
Query q = sess.getWorkspace().getQueryManager().createQuery( "select
* from nt:unstructured", Query.SQL);
QueryResult qr = q.execute();
NodeIterator ni = qr.getNodes();
//check we get at least something back from the query
assertTrue(ni.hasNext());
assertNotNull(ni.next());
assertNotNull(ni.next());
assertNotNull(ni.next());
}
And start it up, try it about 10 times in a row, at least one time you will
see a failure (ie it won't return anything from the query) - and then a
subsequent time it just wont start, wait a few seconds, and then it will
work again.
Very very wierd, but somewhat relieved its not my own confused code, this is
as simple as I can make it. I can only imagine there is some index sync
issue still at play. Unfortunately, there is no way to wrap this up as a
proper test, as it needs to startup fresh each time to reliably reproduce
this (seperate JVM process each time).
(and this will happen on any OS, I thought it was just linux, but have tried
it on mac, windows etc).
17 years, 8 months
Potential memory problems
by Matthew Shaw
Hi,
I am fronting my rule engine by a stateless session façade bean, running in a weblogic container. The rule bases are loaded only once via a singleton.
I was running a profiler over the app and have noticed a lot of rule engine objects still attached to the tree. My stub which invokes the working memory looks like the following:
try {
handle = wm.assertObject(shift);
wm.assertObject(shiftCalculator);
wm.fireAllRules();
} catch (RuntimeDroolsException e) {
throw new TimesheetServiceUnavailableException(
"Could not add shift to Working Memory", e);
}
wm.clearAgenda();
wm.dispose();
LoggingUtils.logMethodFinish(logger, methodName);
As you can see if an exception occurs then the dispose method is not run. Could this lead to memory leakage?
I have subsequently modified the offending stub to include a finally block
finally {
wm.clearAgenda();
wm.dispose();
LoggingUtils.logMethodFinish(logger, methodName);
}
Matt Shaw
Snr Applications Developer
Service Performance & Management Unit
Phone: 3247 8666. ext. 94666
This correspondence is for the named persons only.
It may contain confidential or privileged information or both.
No confidentiality or privilege is waived or lost by any mis transmission.
If you receive this correspondence in error please delete it from your system immediately and notify the sender.
You must not disclose, copy or relay on any part of this correspondence, if you are not the intended recipient.
Any opinions expressed in this message are those of the individual sender except where the sender expressly,
and with the authority, states them to be the opinions of the Department of Emergency Services, Queensland.
17 years, 8 months
svn
by Mark Proctor
I'm just doing a big refactor, please don't commit anything to trunk.
Thanks
Mark
--
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire,
SI4 1TE, United Kingdom.
Registered in UK and Wales under Company Registration No. 3798903
Directors: Michael Cunningham (USA), Charlie Peters (USA) and David Owens (Ireland)
17 years, 8 months
Pre Compiling
by Márcio Moraes
Hi all,
I've just discovered production machine does not have a compiler, so i
thought pre-compiling my rules.
How can i do that? Is there some ant task?
Thanks,
Márcio Moraes
17 years, 8 months
Help with M1
by s erel
Hello,
When using the following two rules with an empty working memory both rules
get fired:
===================================
rule rule1
when
not Person(gender == Consts.Unknown)
then
System.out.println("rule1");
end
rule rule2
when
exists Person(gender == Consts.Unknown)
then
System.out.println("rule2");
end
===================================
.
Can anyone help me with this?
Thanks
17 years, 8 months
Issue with "contains" keyword
by Bynum, Joe
I'm doing some simple evaluation of jrules and I ran into a problem.
Here's the rule I'm having problems with:
rule "751845 - Check Stages"
when
order : Order( stages excludes 921 )
then
System.out.println( "This order contains " + order.getStages()
);
end
OUTPUT:
This order contains [804, 921]
I'm actually trying to do the opposite using 'stages contains 921'.
stages is defined as follows in the Order object.
private ArrayList<Integer> stages;
I'm using the 3.0.6 binaries on W2K w/Eclipse.
Any ideas what I'm doing wrong here?
17 years, 8 months
Asserting new Facts in RHS...
by jdepaul
I'm trying to assert a new Fact based on a condition, but I dont know how to
assert a new Fact with a specific attribute in it. I'm trying this - why
doesn't this syntax work:
rule "Assert new Target Records"
when
$one : RKEM_TARGET ( EQPNO == "1") &&
$three : RKEM_TARGET ( EQPNO == "3")
then
// Assert the missing Equipment number record
$two : new RKEM_TARGET();
$two.setEQPNO("2"); // Set attribute
assert( $two ); <-- This does NOT work...
end
How do you assert a new Fact with a specific value in the attribute(s)?
THanks,
James
--
View this message in context: http://www.nabble.com/Asserting-new-Facts-in-RHS...-tf3609763.html#a10086922
Sent from the drools - user mailing list archive at Nabble.com.
17 years, 8 months