There are a couple of ways to do this. I'm sure there's a bit more clean way
than the example I'm providing, but this should get you in the right direction.
It's not 100% rules, because it involves a bit of java collections trickery.
(See attached project,
Another proposal, with perhaps more emphasize on rulishness.
Given
class Item { T1 s1;... Tn sn;... }
let's add
enum Criterium { C1, C2,... Cn; }
class Request { EnumSetCriterium criteria; HashSetItem results; }
To launch a request, insert a Request object with an appropriate setting
On Sat, Nov 7, 2009 at 6:00 PM, Leonardo Gomes
leonardo.f.go...@gmail.comwrote:
Hello,
I'm feeding my working memory with Maps (unfortunately, this is a
requirement and I can't use beans).
Before people start racking their brains to overcome all the resulting
difficulties: Could you please
Hi I am working on a simple drools project.
I have now one rule, but it not works.
This is the drl:
package orvosi;
import orvosi.orvosimeres.Adattipus;
import orvosi.orvosimeres.Mertadat;
rule Your First Rule
when
Adattipus(ertek=heart_rate);
So, Do you mean that for serializing the state of a StatefulKnowledgeSession
we must include our rules into a ruleflow? How do you upgrade your
KnowledgeBase without loosing the WM state?
Please check this issues:
https://jira.jboss.org/jira/browse/JBRULES-1946
Thanks Greg\Barton. I will try it out and get back to you.
Regards,
cabear
2009/11/8 Wolfgang Laun wolfgang.l...@gmail.com
Another proposal, with perhaps more emphasize on rulishness.
Given
class Item { T1 s1;... Tn sn;... }
let's add
enum Criterium { C1, C2,... Cn; }
class
I was just referring to facts that we're being placed into your
statefulknowledgesession. As I mentioned, I use a mechanism with an EJB to
manage my JPA entities before injecting them into the session. I passed on
a blog entry with a ruleflow example as that looks to do a similar thing but
Hi Wolfgang,
Here's the context:
We're replacing a very basic home-made rule engine with drools. Today,
fact data can be added dynamically b/c for all rules our fact is
nothing more than a Map and we can register new fact data through an
UI where you say what's the key and what's the type of the
Ok, without discussing the merits of using (or not) maps, the reason
you are having problems with dates is that the string-based date is syntax
sugar in Drools parser/compiler. Although, when you create expressions using
nested accessors or [] for collection/map element access, drools wraps
For the sake of clarification: Are you saying that there is, or should be,
some magic which would make a constraint like
Map ( this[departureDate] == 07-Jan-2009 )
behave as a comparison between two java.util.Date values if the LHS Object
is of this type? And also if it is a GregorianCalendar
Wolfgang,
As you know, there are a ton of problems when you go down the date
route. Probably the reason java never had a decent built-in date framework
(fingers crossed for JSR-310).
Anyway, back to the point, the syntax sugar for string-based strings is a
really simple way for people
Hi Greg:
I'm trying to understand your first solution.
Ran the project and it works fine. If possible could you explain me little
bit on :
from accumulate( Criteria( this memberOf d, this memberOf q ),
*init*( *int* total = 0; ),
action( total ++; ),
reverse( total --; ),
result( total ) )
In this case the accumulate clause is maintaining a counter (total) that's
incremented whenever a Criteria is detected that is contained in both the Data
and Query object matched in the rule. So:
# Find Criteria that are contained in both the Data and Query
from accumulate( Criteria( this
Why not use count() accumulate function? ;)
from accumulate( Criteria( this memberOf d, this memberOf q ),
count(1) )
Edson
2009/11/8 Greg Barton greg_bar...@yahoo.com
In this case the accumulate clause is maintaining a counter (total) that's
incremented
Yes Edson, I tried with count and sum. Both seems to be working fine.
But with the test case, the Criteria for query also needs to be inserted in
addition to the query and data objects like shown below:
Query query = *new* Query(1);
query.add(*new* Criteria(query, c2, bas));
Hi Wolfgang:
Thanks for your help.
Is it possible to explain little bit more on the Item class and rule C1.
Not able to comprehend the complete solution.
Thanks,
cabear
2009/11/8 Wolfgang Laun wolfgang.l...@gmail.com
Another proposal, with perhaps more emphasize on rulishness.
Given
Also I hope modifying the statement:
*q : Query( size = d.size )*
to
*q : Query( )*
should be fine.
2009/11/8 Greg Barton greg_bar...@yahoo.com
Yep. See attached project. It actually simplifies the java a bit, as now
there doesn't need to be any trickery in the contains method for
Yeah, That condition is just an optimization that prevents comparison of a
Query against a Data that has less Criteria than the Query, which by definition
cannot then be satisfied. It's not logically necessary, but a pretty easy
optimization.
--- On Sun, 11/8/09, Wishing Carebear
Hi,
I have an example of two rules we use in our project.
Rule CheckStationNumber checks if the station number field is null in
BillingRecord Object which is
stored as a list in AssertionObject object.
Rule AssignBAC gets a value from a static map(we dont want to do database
calls eachtime.so
OK, first thing: getBillActCode() creates an empty HashMap that is either not
used or replaced in all cases. In general you should avoid object creation in
functions called in rule conditions, but especially avoid unnecessary object
creation. :)
And now for the rules. I'm not sure I've ever
Hi swapnil thanx for the reply
I think there is no error in url path.for a week i was not active in my
project.
Im sending my sample project
Here is my sample application
-
main java class
21 matches
Mail list logo