Re: [rules-users] Condition syntax to access Map

2011-08-02 Thread Wolfgang Laun
2011/7/31 Mark Proctor mproc...@codehaus.org On 31/07/2011 19:39, Wolfgang Laun wrote: 2011/7/31 Mark Proctor mproc...@codehaus.org Implicit mapping I call Managed Object Graphs MOGs. So you can write Person( address.street == my road ) And that internally would get translated too $p

Re: [rules-users] Condition syntax to access Map

2011-08-02 Thread Mark Proctor
On 02/08/2011 07:15, Wolfgang Laun wrote: 2011/7/31 Mark Proctor mproc...@codehaus.org mailto:mproc...@codehaus.org On 31/07/2011 19:39, Wolfgang Laun wrote: 2011/7/31 Mark Proctor mproc...@codehaus.org mailto:mproc...@codehaus.org Implicit mapping I call Managed Object

Re: [rules-users] Condition syntax to access Map

2011-07-31 Thread Mark Proctor
: From: Mark Proctor mproc...@codehaus.org Subject: Re: [rules-users] Condition syntax to access Map To: rules-users@lists.jboss.org Date: Friday, July 29, 2011, 8:52 AM On 29/07/2011 14:28, Edson Tirelli wrote: Yes, that is exactly what I think. Pattern matching

Re: [rules-users] Condition syntax to access Map

2011-07-31 Thread Wolfgang Laun
2011/7/31 Mark Proctor mproc...@codehaus.org Implicit mapping I call Managed Object Graphs MOGs. So you can write Person( address.street == my road ) And that internally would get translated too $p : Person() Address( person == $p, street == my road ) As there is no doubt that the

Re: [rules-users] Condition syntax to access Map

2011-07-31 Thread Mark Proctor
On 31/07/2011 19:39, Wolfgang Laun wrote: 2011/7/31 Mark Proctor mproc...@codehaus.org mailto:mproc...@codehaus.org Implicit mapping I call Managed Object Graphs MOGs. So you can write Person( address.street == my road ) And that internally would get translated too $p :

Re: [rules-users] Condition syntax to access Map

2011-07-29 Thread Wolfgang Laun
Whoa! See below... 2011/7/28 Edson Tirelli ed.tire...@gmail.com I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == value ) In the above case, we are looking for Xs that make that whole

Re: [rules-users] Condition syntax to access Map

2011-07-29 Thread Mark Proctor
Lets forget that these are nested accessors and the problems they bring. Lets look at what they would be if they were real relations: On 29/07/2011 08:55, Wolfgang Laun wrote: Whoa! See below... 2011/7/28 Edson Tirelli ed.tire...@gmail.com mailto:ed.tire...@gmail.com I think we

Re: [rules-users] Condition syntax to access Map

2011-07-29 Thread Edson Tirelli
Yes, that is exactly what I think. Pattern matching constraints are like query parameters. They need to exist and evaluate to true in order to match. So, for this to match: a.b.c == null a needs to exist and be non-null, b needs to exist and be non-null, c needs to exist and be null. So it

Re: [rules-users] Condition syntax to access Map

2011-07-29 Thread Mark Proctor
On 29/07/2011 14:28, Edson Tirelli wrote: Yes, that is exactly what I think. Pattern matching constraints are like query parameters. They need to exist and evaluate to true in order to match. So, for this to match: a.b.c == null a needs to exist and be non-null, b needs to exist and

Re: [rules-users] Condition syntax to access Map

2011-07-29 Thread Greg Barton
Ah, other engines don't do nested accessors because they're wimps.  WIMPS! :) --- On Fri, 7/29/11, Mark Proctor mproc...@codehaus.org wrote: From: Mark Proctor mproc...@codehaus.org Subject: Re: [rules-users] Condition syntax to access Map To: rules-users@lists.jboss.org Date: Friday, July 29

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread bolsover
Mark Thanks for the info - although it was not actually the solution to my problem, it prompted me to look again at my assertion that there were not any null values. In actual fact answerData[0] was null ( I should have been checking for answerData[100]) and this was causing the error. You

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread Mark Proctor
On 28/07/2011 08:26, bolsover wrote: Mark Thanks for the info - although it was not actually the solution to my problem, it prompted me to look again at my assertion that there were not any null values. In actual fact answerData[0] was null ( I should have been checking for answerData[100])

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread bolsover
Thanks for the pointer to the MVEL documents - I can forsee null-safe operator user.?manager.name syntax being most useful. As for making the null test the default action - I'm not sure - I can't say I have ever actually 'wanted' a nullpointer - but there may be some special case. David -- View

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread Wolfgang Laun
Two points to consider: (1) If a programmer writes a.getB().getC() == something and a NPE happens due to a.getB() == null we may distinguish (a) and (b) - see below. (a) The setup is so that this is to be expected but the programmer forgot to take this possibility into account. Then we have:

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread Mark Proctor
On 28/07/2011 13:53, Wolfgang Laun wrote: Two points to consider: (1) If a programmer writes a.getB().getC() == something and a NPE happens due to a.getB() == null we may distinguish (a) and (b) - see below. (a) The setup is so that this is to be expected but the programmer forgot to

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread Vincent LEGENDRE
Hi all, I agree with W. : NPE should be the default, and null cases behaviour should be planned by programmers. But I am not sure about using a new operator in rules (and do the update in Guvnor ...). Why not using some drools annotations on the getter specifying the behaviour of an eval on

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread Edson Tirelli
All, I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == value ) In the above case, we are looking for Xs that make that whole constraint true (i.e. match). If a or b are null, the whole

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread Greg Barton
+1 Naw +billion --- On Thu, 7/28/11, Edson Tirelli ed.tire...@gmail.com wrote: From: Edson Tirelli ed.tire...@gmail.com Subject: Re: [rules-users] Condition syntax to access Map To: Rules Users List rules-users@lists.jboss.org Date: Thursday, July 28, 2011, 1:13 PM    All,    I think we

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread Mark Proctor
Subject: Re: [rules-users] Condition syntax to access Map To: Rules Users List rules-users@lists.jboss.org Date: Thursday, July 28, 2011, 1:13 PM All, I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern

Re: [rules-users] Condition syntax to access Map

2011-07-28 Thread Joe White
convention. Joe From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mark Proctor Sent: Thursday, July 28, 2011 1:35 PM To: rules-users@lists.jboss.org Subject: Re: [rules-users] Condition syntax to access Map if we do implicit .? support people

[rules-users] Condition syntax to access Map

2011-07-27 Thread bolsover
I'm struggling with the syntax to access a mapped object - hoping that someone can help with this.. I have the following condition in a rule: $a : Answer(getAnswerData().get(0).getValue_str() == Valves) Answer is a pojo where answerData is a Maplt;Integer, AnswerDatagt; object. AnswerData is

Re: [rules-users] Condition syntax to access Map

2011-07-27 Thread Mark Proctor
On 27/07/2011 19:45, bolsover wrote: I'm struggling with the syntax to access a mapped object - hoping that someone can help with this.. I have the following condition in a rule: $a : Answer(getAnswerData().get(0).getValue_str() == Valves) try Drools 5.2 and you should be able to do Answer(