It looks like you want to use null safe bean navigation in mvel 2: http://mvel.codehaus.org/MVEL+2.0+Property+Navigation
try this: $f : Fact(details.?END_MATCH == true, details.?WINNER == "AWAY") I have no idea if it will work, as the null safe ? example is for accessing bean properties, but it's worth a try. It's also MVEL 2.0, so will only work with drools 5. --- On Thu, 2/26/09, Zevenbergen, Alex <[email protected]> wrote: > From: Zevenbergen, Alex <[email protected]> > Subject: RE: [rules-users] Rules syntax question using hashmap > To: [email protected] > Date: Thursday, February 26, 2009, 11:30 AM > So that doesn't solve the problem of null params in the > hashmap? > > Do you know if it is possible? > > Also is there a good place for rules documentation and > examples as all > the examples I can find are fairly simply and > one-dimensional > > -----Original Message----- > From: Greg Barton [mailto:[email protected]] > Sent: 26 February 2009 17:26 > To: Zevenbergen, Alex > Subject: RE: [rules-users] Rules syntax question using > hashmap > > Ah. That's because drools is expecting > "details" to be an object type. > Rule conditions take the following form: > > ObjectType(property == value, anotherProperty > > anotherValue, ...) > > So, for a condition like this... > > details(fact == $f, name == "END_MATCH", value == > true) > > ...you would need a class definition like this: > > class details { > Fact fact; > String name; > boolean value; > } > > And an object of type "details" would need to be > inserted into working > memory for the condition to possibly match. > > --- On Thu, 2/26/09, Zevenbergen, Alex > <[email protected]> > wrote: > > > From: Zevenbergen, Alex > <[email protected]> > > Subject: RE: [rules-users] Rules syntax question using > hashmap > > To: [email protected], "Rules Users > List" > <[email protected]> > > Date: Thursday, February 26, 2009, 11:14 AM > > Hi, > > I get the following error: Unable to resolve > ObjectType > > 'details' > > > > I've tried different variations (getDetails etc) > but > > 'details is my > > attribute name and doesn't seem to be picked up! > > > > alex > > -----Original Message----- > > From: [email protected] > > [mailto:[email protected]] On Behalf > Of > > Greg Barton > > Sent: 26 February 2009 17:04 > > To: Rules Users List > > Subject: Re: [rules-users] Rules syntax question using > > hashmap > > > > Can you provide any info on why the third option > > doesn't work? > > > > --- On Thu, 2/26/09, Zevenbergen, Alex > > <[email protected]> > > wrote: > > > > > From: Zevenbergen, Alex > > <[email protected]> > > > Subject: [rules-users] Rules syntax question > using > > hashmap > > > To: [email protected] > > > Date: Thursday, February 26, 2009, 10:45 AM > > > Hi all, > > > > > > > > > > > > Im using an object called 'Fact' this > object > > has > > > one attribute that is a > > > hashmap 'details' > > > > > > > > > > > > I know there are several ways to access the > parameters > > in > > > the hashmap > > > > > > > > > > > > $f : Fact() > > > > > > eval > > ($f.getDetails().get("END_MATCH").toString() > > > == "true" && > > > > $f.getDetails().get("WINNER").toString() == > > > "HOME") > > > > > > > > > > > > $f : Fact(details.END_MATCH == > true,details.WINNER == > > > "AWAY") > > > > > > > > > > > > $f : Fact() > > > > > > details(fact == $f, name == > "END_MATCH", > > value == > > > true) > > > > > > > > > > > > > > > > > > I was told the third option works but it > doesn't > > for > > > me! > > > > > > > > > > > > Anyway my question is: Is there anyway for these > sort > > of > > > rules to not > > > through an exception if any of the named > parameters > > > aren't on the > > > hashmap 'details'? > > > > > > > > > > > > Ideally the rule would simply not fire if it > looked > > for a > > > key that > > > wasn't there! > > > > > > > > > > > > Any info much appreciated > > > > > > > > > > > > Alex > > > > > > > > > > > > > > > > > > ________________________________________________________________________ > > > Privileged, confidential and/or copyright > information > > may > > > be contained in this communication. This e-mail > and > > any > > > files transmitted with it are confidential and > > intended > > > solely for the use of the individual or entity to > whom > > they > > > are addressed. If you are not the intended > addressee, > > you > > > may not copy, forward, disclose or otherwise use > this > > e-mail > > > or any part of it in any way whatsoever. To do so > is > > > prohibited and may be unlawful. If you have > received > > this > > > email in error > > > please notify the sender immediately. > > > > > > Paddy Power PLC may monitor the content of e-mail > sent > > and > > > received for the purpose of ensuring compliance > with > > its > > > policies and procedures. > > > > > > Paddy Power plc, Airton House, Airton Road, > Tallaght, > > > Dublin 24 Registered in Ireland: 16956 > > > > > > ________________________________________________________________________ > > _______________________________________________ > > > rules-users mailing list > > > [email protected] > > > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > > > _______________________________________________ > > rules-users mailing list > > [email protected] > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > ________________________________________________________________________ > > Privileged, confidential and/or copyright information > may > > be contained in this communication. This e-mail and > any > > files transmitted with it are confidential and > intended > > solely for the use of the individual or entity to whom > they > > are addressed. If you are not the intended addressee, > you > > may not copy, forward, disclose or otherwise use this > e-mail > > or any part of it in any way whatsoever. To do so is > > prohibited and may be unlawful. If you have received > this > > email in error > > please notify the sender immediately. > > > > Paddy Power PLC may monitor the content of e-mail sent > and > > received for the purpose of ensuring compliance with > its > > policies and procedures. > > > > Paddy Power plc, Airton House, Airton Road, Tallaght, > > Dublin 24 Registered in Ireland: 16956 > > > ________________________________________________________________________ > > > > > ________________________________________________________________________ > Privileged, confidential and/or copyright information may > be contained in this communication. This e-mail and any > files transmitted with it are confidential and intended > solely for the use of the individual or entity to whom they > are addressed. If you are not the intended addressee, you > may not copy, forward, disclose or otherwise use this e-mail > or any part of it in any way whatsoever. To do so is > prohibited and may be unlawful. If you have received this > email in error > please notify the sender immediately. > > Paddy Power PLC may monitor the content of e-mail sent and > received for the purpose of ensuring compliance with its > policies and procedures. > > Paddy Power plc, Airton House, Airton Road, Tallaght, > Dublin 24 Registered in Ireland: 16956 > ________________________________________________________________________ _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
