Dynamic JavaBeans
by Yuri de Wit
I noticed that changes performed on facts asserted dynamically causes
the fact to be modified right away and therefore triggering a RETE
network traversal and rule schedulings.
For apps with a large number of facts this could be a significant
scalability problem. At least in my case, I would like to be able to
use dynamic facts and perform any number of updates and have those
updates commited to working memory only when the rule consequence is
completed.
Looking at the code, it seems that it would not be a major effort to
collect the facts received by the ReteooWorkingMemory.propertyChange
and perform the actual modifyObject() only when the consequence
evaluation is actually completed.
Does that makes sense? Or are there side effects I am not seeing? Is
this a problem that 4.0 already resolves?
thanks in advance,
-- yuri
17 years, 5 months
question about DSL, nested values
by Matt Geis
Hi,
I'm encountering some conceptual issues trying to get something done with JBossRules.
What I'd like to do is to create a DSL that allows our non-technical users to have some very flexible options for accessing nested properties in an object.
Ideally I'd like to allow them to....
1. Access certain cryptically named properties by easy-to-understand aliases.
2. Use boolean operators such as and/or
3. Use comparators such as ==, >, <, etc.
4. Use the above in nested clauses (see below).
For example, take a Person, which has the following properties...
String name
Date birthdate
Address[] addresses
Phone[] phones
Address has the following properties:
String street, city, state, zip;
Phone has...
String areaCode, exchange, line:
Most frequently, the rules will operate to find out if a given object
in a nested collection meets certain property criteria, and if so, to
identify the first object that does and call out that fact in the THEN
clause of the rule.
Here's a sample use case. If the user has one or more phones with an area code of "415", print "San Francisco".
Pseudo-code...
rule
when
There is a person with a phone with area code equals '415'
then
Output "San Francisco"
end
So, "there is a person" clearly equates to something like p:Person()...
but where I'm getting stuck is the rest of it. I dont' want to come up with ALL possible permutations of the object's properties, so having
something like p:Person(phone[0].areaCode == '415') is not an option. Not only does it fail to address ALL the phones, it's hard-coded.
I couldn't find any documentation on using the 'contains' operator for anything other than Collections of Strings ($shop.cheeses contains 'stilton'). I could imagine something like...
in DRL: p:Person(phones contains phone.areaCode == '415') (yes, very pseudocode, I know)
Other thoughts I've had, but I have no experience with them, are whether MVEL projections or accumulator functions would be of use. I could see ways where I could find out if a nested item met certain criteria (project all area codes for phones into a collection, then see if that collection 'contains' the desired value, or use an accumulator function to examine all objects and capture the index of the first one that matches). Although that might work (as I said, not sure here), I'm still not seeing how to do this and still keep the end user flexibility I'm hoping for.
I'd like to have a list of names, like 'area code' maps to 'areaCode' and 'street address' maps to 'street', and the user could plug them in on their own, so they could just as easily also write (with no changes to the DSL)...
There is a person with an address with state equals 'MA'
I've thought about somehow using an eval() call, but I can't capture the entire criteria string and pass it to a function in a global helper (the DSL doesn't expand it, and just sends the String literal "{criteria}"
Even if that did work, I don't like the idea of circumventing the declarative nature of the rules language.
I'd LOVE to be able to express this all in one rule, as it's business users who will be working with the DSL. If it were programmers, I'd probably be ok with asking them to assert the Phone[], and have some other rule act on that, but I don't think that will work for me.
On a side note, is there documentation or examples anywhere for getting nested properties and using MVEL?
Any help and suggestions greatly appreciated.
Thanks,
Matt
____________________________________________________________________________________Ready for the edge of your seat?
Check out tonight's top picks on Yahoo! TV.
http://tv.yahoo.com/
17 years, 5 months
Call functions from other functions?
by Ru
Hello rules-users,
Is it possible to call from functions other (same, if recursive)
functions in jbossrules 3.0.6? in 4.0.0?
Thanks in advance.
Sincerely,
Ru
17 years, 5 months
Logging from rules file
by Rahul Phadnis
Hello,
I am looking for pointers to how I can effectively log
messages during rule executions. Do I need to assert a
logger object for this purpose?
Does anybody have an recommendations for this?
-Rahul
17 years, 5 months
Use FROM-CE in BRMS
by warmonga
Hi list,
does the BRMS support/allow the use of the FROM Conditional Element
and, if so, how do I add such an element to a condition?
Many thanks and best regards!
17 years, 5 months
Dynamic JavaBeans evaluate again, and again...
by Felipe Piccolini
Hi, I dont know if this is reported or maybe its just my mistake... but
when I use dynamic JavaBeans and PropertyListeners the re-evaluation
of the rules
seems to skip the condition evaluation, so they fire again.. and
again, and again..
I have a couple of rules where the conditions are true then I change
the value of an attribute
and the rules re-evaluate again... and so on. I putted a special
constraint in the conditions
of that rule so when it is fired, it modify an atribute of another
fact (tested with the another
attribute of the same fact but it happens anyway), so I try to be
sure that rule will not fire again...
but it does ignoring the constraints... checked with the logger and
the debugger...
Is this a bug or it is supposed to be so, and I need to think another
way to write my rules?...
I want to use the dynamic JavaBeans, so no need to write inserts/
updates... When I set the insert(Object, FALSE)
the problem dissapears.
Thanks.
Felipe Piccolini M.
felipe.piccolini(a)bluesoft.cl
17 years, 5 months