Re: [rules-users] Do really support the containsKey() function on maps?

2011-08-20 Thread Edson Tirelli
   I think your data is somehow not matching, but you can try to simplify
your rule like this (assuming Drools 5.2):

rule transport
   when
   $pfMapType : MapType( name  ==  transport )
   $inputKey : InputKey( email == true )
   $ldapResponseMap : Map( this[zimbraMailDeliveryAddress]
== $inputKey ||
   this[zimbraDomainName] ==
$inputKey )
   then
   $pfMapType.setQueryFilterCheck(true);
end

   Edson


2011/8/20 dvsnmurty murty.devarako...@teamaol.com

 Hello Wolfgang,
 Thanks for the quick reply.  So if equals($inputKey) is the culprit, how
 can
 I modify the rule to make it work?  My best guess is to do something like
 this:

 rule transport
when
$pfMapType : MapType( name  ==  transport )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
 then
updateTransportMap($pfMapType, $inputKey, $ldapResponseMap)
 end

 And then add the function updateTransportMap() to do the required checks
 that I am doing in the eval above.  Do you think of any other way?

 Regards,
 Murty.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Do-really-support-the-containsKey-function-on-maps-tp3269570p3270684.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




-- 
  Edson Tirelli
  JBoss Drools Core Development
  JBoss by Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Do really support the containsKey() function on maps?

2011-08-20 Thread dvsnmurty
Hello Edson/Wolfgang,
Thanks for the reply.  I am stuck with 5.0.1 in our company.  Would the map
expression that you gave work with 5.0.1?  I tried to reason it out if there
is anything wrong with my logic itself, but can think of any.  Essentially,
I have a map of Maplt;String, Stringgt; type, where I want to see if a key
is present and if so, compare the value of that key to an expected string. 
For me it sounds like a simple logic, but please correct me if I am wrong
here.  May be my logic is not correct in drools semantics

Here is what I want to do in Java terms:

if( ldapResponseMap.get(zimbraMailDeliveryAddress).equals(abc) ) {
pfMapType.setQueryFilterCheck(true);
}  else {
if( ldapResponseMap.containsKey(zimbraDomainName) ) {
if(ldapResponseMap.get(zimbraDomainName).equals(abc) {
pfMapType.setQueryFilterCheck(true);
}
}
}

Regards,
Murty.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Do-really-support-the-containsKey-function-on-maps-tp3269570p3270932.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] Do really support the containsKey() function on maps?

2011-08-20 Thread Wolfgang Laun
What is the class of $ldapResponseMap.get(zimbraDomainName)? Is it really
an InputKey? And if so, how is equals() defined in this class? Does it
return true for two different objects, one inserted in Working Memory and
another one in the Map()?

Did you explore the truth of the eval expression components?

-W


On 20 August 2011 18:55, dvsnmurty murty.devarako...@teamaol.com wrote:

 Hello Edson/Wolfgang,
 Thanks for the reply.  I am stuck with 5.0.1 in our company.  Would the map
 expression that you gave work with 5.0.1?  I tried to reason it out if
 there
 is anything wrong with my logic itself, but can think of any.  Essentially,
 I have a map of Maplt;String, Stringgt; type, where I want to see if a
 key
 is present and if so, compare the value of that key to an expected string.
 For me it sounds like a simple logic, but please correct me if I am wrong
 here.  May be my logic is not correct in drools semantics

 Here is what I want to do in Java terms:

 if( ldapResponseMap.get(zimbraMailDeliveryAddress).equals(abc) ) {
pfMapType.setQueryFilterCheck(true);
 }  else {
if( ldapResponseMap.containsKey(zimbraDomainName) ) {
if(ldapResponseMap.get(zimbraDomainName).equals(abc) {
pfMapType.setQueryFilterCheck(true);
}
}
 }

 Regards,
 Murty.

 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Do-really-support-the-containsKey-function-on-maps-tp3269570p3270932.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] Do really support the containsKey() function on maps?

2011-08-19 Thread dvsnmurty
Hello all,
I am having trouble with the following drools file:
===
rule vam
when
$pfMapType : MapType( name  ==  vam )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
then
$pfMapType.setQueryFilterCheck(true);
end

rule transport
when
$pfMapType : MapType( name  ==  transport )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
eval(
($ldapResponseMap.get(zimbraMailDeliveryAddress).equals($inputKey)) ||
(($ldapResponseMap.containsKey(zimbraDomainName) == true)
 ($ldapResponseMap.get(zimbraDomainName).equals($inputKey))) )
then
$pfMapType.setQueryFilterCheck(true);
end
===
In the above, the rule vam works fine.  But the rule transport never
works.  Could it be because of the use of containsKey() function? 
Alternatively, I tries replacing the rule transport with the following
with no luck still:

===

rule transport
when
$pfMapType : MapType( name  ==  transport )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
eval(
($ldapResponseMap.get(zimbraMailDeliveryAddress).equals($inputKey)) ||
(($ldapResponseMap.keySet().contains(zimbraDomainName)) 
($ldapResponseMap.get(zimbraDomainName).equals($inputKey))) )
then
$pfMapType.setQueryFilterCheck(true);
end

===


Appreciate your kind attention on this.

Regards,
Murty.



--
View this message in context: 
http://drools.46999.n3.nabble.com/Do-really-support-the-containsKey-function-on-maps-tp3269570p3269570.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] Do really support the containsKey() function on maps?

2011-08-19 Thread dvsnmurty
Forgot to tell you.  There is no exception on the logs.  Just the rule is not
setting the flag in the THEN portion of the rule.

--
View this message in context: 
http://drools.46999.n3.nabble.com/Do-really-support-the-containsKey-function-on-maps-tp3269570p3269594.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] Do really support the containsKey() function on maps?

2011-08-19 Thread Wolfgang Laun
Try rule transport without the eval and print all components of the
boolean expression in the consequence. This will show you where it fails.
(My money would be on the equals($inputKey) comparisons.)
-W


On 20 August 2011 01:36, dvsnmurty murty.devarako...@teamaol.com wrote:

 Hello all,
 I am having trouble with the following drools file:
 ===
 rule vam
when
$pfMapType : MapType( name  ==  vam )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
then
$pfMapType.setQueryFilterCheck(true);
 end

 rule transport
when
$pfMapType : MapType( name  ==  transport )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
eval(
 ($ldapResponseMap.get(zimbraMailDeliveryAddress).equals($inputKey)) ||
(($ldapResponseMap.containsKey(zimbraDomainName) == true)
  ($ldapResponseMap.get(zimbraDomainName).equals($inputKey))) )
then
$pfMapType.setQueryFilterCheck(true);
 end
 ===
 In the above, the rule vam works fine.  But the rule transport never
 works.  Could it be because of the use of containsKey() function?
 Alternatively, I tries replacing the rule transport with the following
 with no luck still:

 ===

 rule transport
when
$pfMapType : MapType( name  ==  transport )
$inputKey : InputKey( email == true )
$ldapResponseMap : Map()
eval(
 ($ldapResponseMap.get(zimbraMailDeliveryAddress).equals($inputKey)) ||
(($ldapResponseMap.keySet().contains(zimbraDomainName)) 
 ($ldapResponseMap.get(zimbraDomainName).equals($inputKey))) )
then
$pfMapType.setQueryFilterCheck(true);
 end

 ===


 Appreciate your kind attention on this.

 Regards,
 Murty.



 --
 View this message in context:
 http://drools.46999.n3.nabble.com/Do-really-support-the-containsKey-function-on-maps-tp3269570p3269570.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