Problem with package names and declare section
by Joaquín Díaz Vélez
Hi guys,
we are currently working with Drools Fusion in order to build a
complex event processing solution. We've modelled our events using and
object (Event) and this object is shared with everyone that needs to
publish and event.
Our scenario goes this way
1) Our shared class, located in *ar.com.fluxit.Event*
2) An example of our cep rules declared in package *rules.flux*
package *rules.flux*
import *ar.com.fluxit.Event;*
declare *Event*
@role (event)
@expires(1m)
end
rule "hello world"
when
$event:Event( eventName == "Hello World") from entry-point "*rules.flux*
"
then
System.out.println("Hello world");
end
3) When we try to insert a *ar.com.fluxit.Event *as a fact in entry point
"rules.flux" Drools Fusion throws a NullPointerException. If you read
Drools Expert documentation (
http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html/...
-
Accessing Declared Types from the Application Code) you find this paragraph:
"The first important thing to realize is that a declared fact will belong
to the package where it was declared. So, for instance, in the example
below, Person will belong to the org.drools.examples package, and so the
fully qualified name of the generated class will be
org.drools.examples.Person."
When we change package declaration to *package ar.com.fluxit *everything
works like a charm. But in our cep scenario we need that our
ar.com.fluxit.Event object to be user by all rules declared in any package.
So, there goes the question. There is a workaround for this? This is a bug?
Any help would be very appreciated
Cheers
--
Joaquín Díaz Vélez
Flux IT SA
Calle 9 N° 865 - Paseo La Panadería - Planta Alta
La Plata - Buenos Aires - Argentina
Teléfono (+54) 221 553 2980 int 306
Móvil (+54) 9221 5863322
www.fluxit.com.ar
14 years, 4 months
Your suggestions for rules for pretty simple problem
by Jason Parekh
I'm new to constraint programming and Drools Planner. I've read through the
docs and built some rules that would probably get me to the right answer,
eventually :)
I was hoping to get your suggestions for better concrete rules.
The problem is I need to order items in a performance with the following
logical rules:
1) All items of the same category must appear together.
2) A performer can be in multiple items, but ideally there'd be at least
three items between any of her two items
The approaches I took are:
- For (1), count the number of transitions from one category to another.
Subtract this to the hard score.
- For (2), three separate rules, each of which assert that an item at
position i does not share performers with an item at position i+1, i+2 and
i+3 (one of these per rule). The number of shared performers would be
subtracted from the hard score.
The scoring and my choice for construction heuristic (FIRST_FIT) are just
naive selections. I haven't gotten to optimizing either of these -- just
wanted to check with you guys to make sure my rules are sane.
Thanks in advance,
jason
14 years, 4 months
5.3.0: combination of KnowledgeAgent and declare broken
by Wolfgang Laun
5.3.0 Final
Using a KnowledgeAgent to build a KnowledgeBase containing a DRL with the
declaration of a new type may result in some rules not firing at all.
The very same code compiled via KnowledgeBuilder API works perfectly
correct.
-W
14 years, 4 months
Truth maintenance and RHS variables
by Juanker Atina
Hi there,
I'm working on a rule that will alert me when there is no events from the
sensors for a while.
So, first idea was to use time window and matches in condition side, to
match all types of sensors, and then to print that something is wrong.
rule "Alert if there is no activity"
when
not StateEvent(itemName matches "door.*|presence.*|luminosity.*") over
window:time( 1m ) from entry-point "EventStream"
then
System.out.println("Alert: one sensor is not working");
end
First change was to add a timer, as truth maintenance will fire this rule
the first time, but not forever. So i add a timer to fire the rule every 20
seconds, for example.
rule "Alert if there is no activity"
timer (cron:0/20 * * * * ?)
when
not StateEvent(itemName matches "door.*|presence.*|luminosity.*") over
window:time( 1m ) from entry-point "EventStream"
then
System.out.println("Alert: one sensor is not working");
end
The second thing i want to achieve is to print what specific sensor is not
working, but i understand that as there is no StateEvent, i can't declare a
variable, for example.
rule "Alert if there is no activity"
timer (cron:0/20 * * * * ?)
when
not $event: StateEvent(itemName matches
"door.*|presence.*|luminosity.*") over window:time( 1m ) from entry-point
"EventStream"
then
System.out.println("Alert: one sensor is not working: " +
$event.getItemName());
So, do you know how can i know which sensor is not working? must i rewrite
the rule to achieve this? is this possible?
Thanks for your help.
end
14 years, 4 months
problem binding variable to map value
by Ming Fang
Below is a very simple rule that binds a variable to a map value...
rule "how many times is map.get() called?"
when
p:Parameter(
$value:tags[1]==1,
$value == 1,
$value != 2,
$value != null,
$value in ("1","2")
)
then
System.out.println("value=" + $value);
end
The problem is map.get() is called 6 times when executing this rule using a Stateless session.
To test this I implement a mock Map that the get(key) simply returns the key.
So in this example tags[1] return 1.
And in the get() I simply print a test message to see how many times it's been called.
Here is the sequence...
1x = tags[1]
2x = tags[1] == 1
3x = $value == 1
4x = $value != 2
5x = $value != null
and most surprisingly none for $value in ("1","2")
but
6x == System.out.println("value="+$value)
Is this a bug?
It's a huge problem for my application since the call to get() is expensive for my map implementation.
Thanks
--ming
14 years, 4 months
GUVNOR
by Olfa h
HI ,
how to install DROOLS Guvnor ?
14 years, 4 months
Ruleflow: two flow exits (or equivalent?) from reusable sub-process?
by George Georgovassilis
Hello list,
I modeled (v5.3) a reusable sub-process which can either finish in a
desired state (i.e. validations ok) or an undesired state (some validations
failed and I need to route to a different flow). Ideally the sub-process
would allow for two outgoing connections, but as far as I see that is
currently not possible. Can anybody advise on how to achieve a similar
functionality?
Is there a chance I could build a workitem that extends the reusable
sub-process but allows for two exit connections, and if yes, how?
Can signals or fault nodes achieve a similar effect and if yes, then how?
Thanks in advance,
G.
14 years, 4 months
Low Date question in drools
by Nancy Henggeler
I have a simple rule where I want to bypass elements that have a low date but
drools seems to be interpreting the date different then I am expecting.
Drools statement and error follows:
ClientSupplement ( dateOfBirth : dateOfBirth != null && != 0001-01-01)
throws error -- Error: [Error: badly formatted number: For input string:
"001-01-01"] [Near : {... 0001-01-01 ....}] ^ [Line: 1, Column: 1]
How do I get drools to understand this low date? I have tried single,
double, and no quotes around the low date and all result in a similiar error
message. Please Help!
--
View this message in context: http://drools.46999.n3.nabble.com/Low-Date-question-in-drools-tp3729940p3...
Sent from the Drools: User forum mailing list archive at Nabble.com.
14 years, 4 months