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 > On 31/07/2011 19:39, Wolfgang Laun wrote: 2011/7/31 Mark Proctor mailto:mproc...@codehaus.org>> Implicit mapping I call Managed Object Graphs MOGs. So you can write

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

2011-08-01 Thread Wolfgang Laun
2011/7/31 Mark Proctor > On 31/07/2011 19:39, Wolfgang Laun wrote: > > 2011/7/31 Mark Proctor > >> >> >> 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(

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 > 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( p

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

2011-07-31 Thread Wolfgang Laun
2011/7/31 Mark Proctor > > > 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 current expli

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

2011-07-31 Thread Mark Proctor
cts another. Mark --- On *Fri, 7/29/11, Mark Proctor //* wrote: From: Mark Proctor 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, th

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 wrote: From: Mark Proctor Subject: Re: [rules-users] Condition syntax to access Map To: rules-users@lists.jboss.org Date: Friday, July 29, 2011, 8:52 AM

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 b

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
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 > I think we need to differentiate p

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

2011-07-29 Thread Wolfgang Laun
Whoa! See below... 2011/7/28 Edson Tirelli > >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 == ) > >In the above case, we are looking for Xs that make that whole constraint > true (i.

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

2011-07-28 Thread Joe White
is an excellent 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 .?

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

2011-07-28 Thread Mark Proctor
if we do implicit .? support people will still be able to do null checks. So it's not one or the other. Mark On 28/07/2011 20:07, Greg Barton wrote: +1 Naw +billion --- On *Thu, 7/28/11, Edson Tirelli //* wrote: From: Edson Tirelli Subject: Re: [rules-users] Condition s

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

2011-07-28 Thread Greg Barton
+1 Naw +billion --- On Thu, 7/28/11, Edson Tirelli wrote: From: Edson Tirelli Subject: Re: [rules-users] Condition syntax to access Map To: "Rules Users List" Date: Thursday, July 28, 2011, 1:13 PM    All,    I think we need to differentiate paradigms here. When using rules

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 == ) 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 expression

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 o

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() == 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 pos

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() == 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: (a1) The

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 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]) and

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 m

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 A

[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 Map object. AnswerData is also