Re: [rules-users] Custom Operator - 5.4.0 works but nor not in 5.6.0.

2014-02-14 Thread Wolfgang Laun
What you write about the error message is not consistent. A "casr to
String" cannot produce an error message "cannot cast primarySite to a
FactHnadle".

-W


On 14/02/2014, mattmadhavan  wrote:
> Hello,
> I have written a drools custom operator called inlist. It takes two strings
> are parameters and works great in 5.4.0.
>
> I can do some thing like this.
>
> rule inList_1
>   dialect "mvel"  
> when
> $cp3rRecord  : Cp3rRecord (*primarySite*e inlist ("C500-C505") )
> then
>  System.out.println  ("Fired inList_1");
> end
>
> where primary site is a filed of the type Cp3rRecord and it works great in
> 5.4.0
>
> There is a change in the API from 5.4.0 to 5.6.0
>
> The Old evaluator is:
>
>
> /The new one (Per 5.6.0) is/
>
>
> Note the third parameter! its is changed from Object to a Fact handle
> (*Please see lines 1) and 2)* )
>
> When I extract the Object its returning me the FACT again and it blows off
> when I cast it to String. Any ideas please> I have been stuck on this for a
> day!
>
> I am getting the exception *cannot cast primarySite to a FactHnadle
> *
>
> Can some one throw some light on this one please?
>
> Thanks in advance!
>
> Matt'M
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Custom-Operator-5-4-0-works-but-nor-not-in-5-6-0-tp4028126.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Help with event not found over window query

2014-02-14 Thread daveor
Hi there, 

I'm a drools newbie and I wonder if someone could help me. I'm using drools
6.0.1 and I'm trying to write a rule that fires when:

1) a certain event is seen and 
2) a second event is not seen within a certain period of time (1 minute in
the examples below) after the first event is seen

I have tried the following LHS patterns:

rule "Something" dialect "mvel"
when
$e1: Event($location: properties["location"] && ...)
not Event(, this after $e1)
then
//do stuff
end

rule "Something" dialect "mvel"
when
$e1: Event($location: properties["location"] && ...)
not Event(, this after[0, 1m] $e1)
then
//do stuff
end

rule "Something" dialect "mvel"
when
$e1: Event($location: properties["location"] && ...)
List (size == 0) from collect (Event(..., this after $e1) over
window:time(1m))
then
//do stuff
end


rule "Something" dialect "mvel"
when
$e1: Event($location: properties["location"] && ...)
List (size == 0) from collect (Event(...) over window:time(1m))
then
//do stuff
end

The unwanted behaviours are as follows:

In the first case, the rule fires immediately after the first event is
inserted. 
In the second case, the rule fails to fire if the second event is seen (as
expected) but the rule does not fire if the second event is not seen within
1 minute.
In the third and fourth cases, the rule fires immediately after the first
event is inserted.

Event is a java class with a hash map of properties, defined with the
following metadata:

declare Event
@role(event)
end

I would really appreciate if someone could help me out here. 

Thanks and let me know if you need any more info.

Dave




--
View this message in context: 
http://drools.46999.n3.nabble.com/Help-with-event-not-found-over-window-query-tp4028129.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] ArrayIndexOutOfBoundsException under high events load in drools CEP

2014-02-14 Thread Mario Fusco
Hi,

I suggest to use a persisted session instead of doing the marshalling on
your own. Find documentation about it here:
http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/#d0e3961

Note that it is strongly discouraged (and in the next releases will be
totally disallowed) to use persisted sessions with firUntilHalt. What you
could do to workaround this further limitation is keeping the
WorkingMemoryEventListener and invoke fireAllRules in its callbacks.

I hope this helps,
Mario



--
View this message in context: 
http://drools.46999.n3.nabble.com/ArrayIndexOutOfBoundsException-under-high-events-load-in-drools-CEP-tp4028071p4028128.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] java.lang.NullPointerException when using a custom operator

2014-02-14 Thread mattmadhavan
Hi Davide,
The problem occurs here at my evaluator!



Please note lines 1 and 2 and the third parameter to the evaluate function!
It has changed from *'Object' *to *'FactHandle' *from 5.4.0 to 5.6.0.

The first step return back the same factHandle object so the Casting fails
on step 2). Please note that this works just fine in 5.4.0.

The error is:


Any help on this issue is greatly appreciated!

Thanks in advance!
Matt'M


So the second step fails w




--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-java-lang-NullPointerException-when-using-a-custom-operator-tp4025287p4028127.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Custom Operator - 5.4.0 works but nor not in 5.6.0.

2014-02-14 Thread mattmadhavan
Hello,
I have written a drools custom operator called inlist. It takes two strings
are parameters and works great in 5.4.0.

I can do some thing like this.

rule inList_1
dialect "mvel"  
when
$cp3rRecord  : Cp3rRecord (*primarySite*e inlist ("C500-C505") )
then
 System.out.println  ("Fired inList_1");
end 

where primary site is a filed of the type Cp3rRecord and it works great in
5.4.0

There is a change in the API from 5.4.0 to 5.6.0

The Old evaluator is:


/The new one (Per 5.6.0) is/


Note the third parameter! its is changed from Object to a Fact handle
(*Please see lines 1) and 2)* )

When I extract the Object its returning me the FACT again and it blows off
when I cast it to String. Any ideas please> I have been stuck on this for a
day!

I am getting the exception *cannot cast primarySite to a FactHnadle
*

Can some one throw some light on this one please?

Thanks in advance!

Matt'M




--
View this message in context: 
http://drools.46999.n3.nabble.com/Custom-Operator-5-4-0-works-but-nor-not-in-5-6-0-tp4028126.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] real world examples wanted

2014-02-14 Thread Stephen Masters
What sort of thing are you looking for? Open source demos with source code? 
Proprietary applications?

I have a few trivial examples of web applications with REST services in GitHub. 
Also, I have a few works in progress in private repos built around v6. Due to 
be de-privatised when I get them to a point where they hang together somewhat 
better than they do right now.

Not so sure about real-world proprietary stuff though. I have a client who use 
something I built as part of their sales pitch to potential clients, so they 
may be up for a few anonymised screenshots to be part of a presentation. That’s 
using 5.3 though.

Steve


On 14 Feb 2014, at 15:18, Mark Proctor  wrote:

> Real wold examples wanted. If you can help, please let us know.
> 
> We have a large user base now, and over the years a number of people have 
> said they would help with contributing real world examples. Alas after 10 
> years, except for the small banking example, we are still waiting for a 
> single user example contribution.
> 
> Mark
> 
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] real world examples wanted

2014-02-14 Thread Mark Proctor
Real wold examples wanted. If you can help, please let us know.

We have a large user base now, and over the years a number of people have said 
they would help with contributing real world examples. Alas after 10 years, 
except for the small banking example, we are still waiting for a single user 
example contribution.

Mark


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] java.lang.NullPointerException when using a custom operator

2014-02-14 Thread Davide Sottara
Could you please show the stack trace of the exception and the rule that
causes it?
Thanks
Davide

On 02/14/2014 02:38 AM, mattmadhavan wrote:
> Hello, 
> I am having a hard time with a custom operator. It works great  in 5.2 but
> not in 5.6. Do you mind sharing your email ample for 5.6 please? I  spent 
> the whole day  today on this issue. 
> There are Any differences between a 5.2 5.6 and 6.0.x.
>
> Your example works great for 6.0.x btw. 
>
> Thanks in advance.! 
>
> Matt 
>
>
>
> --
> View this message in context: 
> http://drools.46999.n3.nabble.com/rules-users-java-lang-NullPointerException-when-using-a-custom-operator-tp4025287p4028110.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread Avin
Hi,
am sorry i wasnt able to understand your solution. will you be able to
simply it ?
What if i push my maps as facts?
Will it be too heavy ?

1 more thing. if I have 2 maps of different types in facts then how can i
access the object from a particular map.
I mean say i have 2 maps says map_1 holding objects of obj_1 and map_2
holding objects of obj_2 
and i insert fact of type factObject. Then how can i get objects from obj_1
using a property of factObject
then compare it and if it is true then i try to get object from map_2 using
factObject





--
View this message in context: 
http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028122.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread rjr201
Ok, I think I'm starting to understand. Could you create another fact object
that is a pair of encapsulating objects, one that is inserted, and another
that you retrieve from your global?

It would look something like: 

public class EncapsulatingObjectPair {
   EncapsulatingObject a;
   EncapsulatingObject b;

//getters setters etc..

}

And then you'd have a rule that looks like this: 

WHEN 
   $object : EncapsulatingObject($key : id)
THEN
   insert new EncapsulatingObjectPair($object,
encapsulationMap.get($key+""));
END

And a second rule that looks something like:

WHEN 
   EncapsulatingObjectPair(secondEncapsulatingMap != null)
THEN
   do something.. 
END

I haven't tried to compile this.. but the general idea is there.



--
View this message in context: 
http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028121.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread rjr201
Yeah, sorry I'm too used to having drools.removeIdentities set to true.
Otherwise yes, you'd need to put a check in to ensure it's not the same
fact. 



--
View this message in context: 
http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028120.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread Avin
Hi,
I cannot do that. This map is not a normal *hashmap is  gemfire region *as i
have mentioned. It is used to commnunicate with gemfire. So when i say i
have fact and when I say map.get(fact). its gemfire hitting its region. It
gets object for me from gemfire. *Gemfire is a database engine*.

so when i say EncapsulatingObject($key : id) it is going to assign value of
id to $key. It is from fact.

using this value as key i fetch it from map which is my gemfire region. *For
time being since i am exprementing i am converting this $key as string to
fetch it from map */else in real map all the values will be of type 
EncapsulatingObject and all of its keys will also be of type
EncapsulatingObject/
After i obtain my object from gemfire i will use its properties to match my
condition.

*This region actually holds millions of data* so i cannot copy this data to
my jvm and use it
I am trying to simulate some things for its possibility before i use it in
my development code.






--
View this message in context: 
http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028119.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread Wolfgang Laun
On 14/02/2014, rjr201  wrote:
> I still don't fully understand what you are trying to do, but could you
> maybe
> try inserting each object in your hashmap as a fact rather than having a
> global hashmap. Your rule would then look something like:
>
> WHEN
>EncapsulatingObject($id : id)
>EncapsulatingObject(id == $id)
> THEN
>Do something..
> END
>
> This rule simply checks if there are two encapsulatingObjects with the same
> id.

No, it doesn't - it wlll fire if there's just one EncapsulatingObject,
because that'll have an id equal to its own id. And it'll fire for any
other EncapsulatingObject...#

-W


>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028116.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread Avin
Fact is in real i have multiple rules who share same Maps. hence i have kept
it global. There are multiple maps. I have data as facts. This facts are to
be compared with that of map. this facts are also used as Key in those Maps.
I am not inserting objects in map. My map is not going to be modified. I am
only checking facts with map. If I find value in map (which is also an
object of Encapsulation type) then i check for other properties. If it
matches my condition then i insert it into a list (for now i am only
printing it on console).

/Just adhoc question can i compare values from 2 different properties of
different type of objects ?/

Am i clear ?



--
View this message in context: 
http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028117.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread rjr201
I still don't fully understand what you are trying to do, but could you maybe
try inserting each object in your hashmap as a fact rather than having a
global hashmap. Your rule would then look something like:

WHEN
   EncapsulatingObject($id : id)
   EncapsulatingObject(id == $id)
THEN
   Do something.. 
END

This rule simply checks if there are two encapsulatingObjects with the same
id. 



--
View this message in context: 
http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028116.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread Avin
Thanks for your response. I will try to explain as much as i can if you have
any doubts then let me know
I am actually simulating a live process with gemfire.
So we have Maps( which are nothing but regions of gemfire). I try to
retrieve data from this Map using map.get. This data needs to be compared
with other Maps. I have facts which are used to retrieve data from Map if
they are present. In example that i have given I am hardcoding id == 7 for
testing because i am getting this wierd behaviour. So this facts are used as
keys of maps and data found in other maps.
If it satisfies my condition then i have list in which I insert those fact
objects. 
Also Map objects and fact objects are actually of type EncapsulatingObject .
java version 6
Drools 5.5

public class EncapsulatingObject {
private int id;
 
public int getId() {
return id;
}
 
public void setId(int id) {
this.id = id;
}
public int hashCode_() {

final int prime = 31;
int result = 1;
result = prime * result + id;
 
return result;
}
public boolean equals_(Object obj) {
 
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof EncapsulatingObject))
return false;
EncapsulatingObject other = (EncapsulatingObject) obj;
if (id != other.id)
return false;
return true;
}

}





--
View this message in context: 
http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028115.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread Wolfgang Laun
That's a *very* weird combination of globals and facts.  However, it
could be a bug.

Drools version?

A complete set of Java classes?

-W


On 14/02/2014, rjr201  wrote:
> Hi,
>
> Can you give a bit of a broader explanation of what it is your rule is
> trying to achieve? I suspect there is a simpler, way of doing what you want
> without having to resort to using eval.
>
> For example, EncapsulatingObject(encapsulationMap[$key+""] !=null) is very
> confusing.
>
> Please explain your requirement in detail.
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028113.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] irrational behaviour by drools engine

2014-02-14 Thread rjr201
Hi,

Can you give a bit of a broader explanation of what it is your rule is
trying to achieve? I suspect there is a simpler, way of doing what you want
without having to resort to using eval. 

For example, EncapsulatingObject(encapsulationMap[$key+""] !=null) is very
confusing.

Please explain your requirement in detail. 



--
View this message in context: 
http://drools.46999.n3.nabble.com/irrational-behaviour-by-drools-engine-tp4028104p4028113.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] calling function in When which one is faster

2014-02-14 Thread Wolfgang Laun
NO, I did NOT mistype. But I also wrote "probably".

Your three alternatives aren't even exchangeable. For a serious
discussion, provide a complete code example with true, exchangeable
alternatives and then one might benchmark.

The myth that eval is "the slowest of all possibilities" is due to
imprecise statements from people not taking enough time to write. The
truth is that constraints where indexing is possible are faster than
anything else. Among the runners-up, it depends on the complexity of
the inner workings, which depend on the CE type and may vary between
versions. eval() is just a simple boolean expression, akin to any
regular constraint where indexing does not apply. Whether JITting or
some interpretation applies also depends on the Drools version and
what not, so, once more: only benchmarking tells you hard facts.

-W


On 14/02/2014, wtang  wrote:
> Sorry, just double check to see if you miss typed --
>
> Do you mean eval() is the slowest and has the most overhead?
>
> Your reply seems to say opposite and said that eval() is the faster and
> have
> the least overhead.
>
> You really meant eval() is the slowest and has the most overhead right?
>
> thx!
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/calling-function-in-When-which-one-is-faster-tp4028076p4028111.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users