Map using from constraint

View: New views
3 Messages — Rating Filter:   Alert me  

Map using from constraint

by Paul Ryan-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi all,

 

Is there a way using the ‘from’ constraint to get the values of a map(the implementations of java.lang.Map eg HashMap, TreeMap, etc) into a constraint parameter, and if so can someone please give an example. Below is the way I’ve been trying, without success, to get a value based on a key.

 

import my.package.MyFact

import java.util.Map.Entry

rule “Find with map”

                when

                                $fact : MyFact($paramMap : paramMap)

                                $myValue : Entry(key == “mykey1”) from $paramMap

                Then

// Sudo code…

                                <use $myValue.getValue()>

end

 

Paul Ryan

Software Architect
Product Engineering

InfoTrust Group, Inc.

 

Logo FINAL 1-30-08_scaled

500 Discovery Parkway, Suite 200
Superior, CO 80027
Office (303) 627-6528

Fax (303) 666-6711
Email pryan@...
WEB www.infotrustgroup.com

 

This e-mail and all information included herein do not constitute a legal agreement accorded by INFOTRUST GROUP and its affiliates and subsidiaries.  All legal agreements must be formulated in writing by a legal representative of INFOTRUST GROUP. This email 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 have received this e-mail by mistake, please inform us and destroy this e-mail and any documents it might contain.  Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.  Thank you for your cooperation.

 



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

Re: Map using from constraint

by Mark Proctor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Paul Ryan wrote:

Hi all,

 

Is there a way using the ‘from’ constraint to get the values of a map(the implementations of java.lang.Map eg HashMap, TreeMap, etc) into a constraint parameter, and if so can someone please give an example. Below is the way I’ve been trying, without success, to get a value based on a key.

$m : Map()
MyObject(.....) from $m['key']

We support MVEL notation for the 'from' keyword.

 

import my.package.MyFact

import java.util.Map.Entry

rule “Find with map”

                when

                                $fact : MyFact($paramMap : paramMap)

                                $myValue : Entry(key == “mykey1”) from $paramMap

                Then

// Sudo code…

                                <use $myValue.getValue()>

end

 

Paul Ryan

Software Architect
Product Engineering

InfoTrust Group, Inc.

 

Logo FINAL 1-30-08_scaled

500 Discovery Parkway, Suite 200
Superior, CO 80027
Office (303) 627-6528

Fax (303) 666-6711
Email pryan@...
WEB www.infotrustgroup.com

 

This e-mail and all information included herein do not constitute a legal agreement accorded by INFOTRUST GROUP and its affiliates and subsidiaries.  All legal agreements must be formulated in writing by a legal representative of INFOTRUST GROUP. This email 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 have received this e-mail by mistake, please inform us and destroy this e-mail and any documents it might contain.  Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.  Thank you for your cooperation.

 


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



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

RE: Map using from constraint

by Paul Ryan-7 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Sorry if this is a very basic question but does that mean that I have to set the dialect for the whole rule to MVEL. I ask because using the code below with the dialect left as default fails with an error about the square brackets. However my consequence code doesn’t work with the dialect set as MVEL. All this means for me is that I will probably have to stick with my eval version of key checking but I just wanted to be sure.

 

import my.package.MyFact

import java.util.Map.Entry

rule “Find with map”

                when

                                $fact : MyFact($paramMap : paramMap)

                                $myValue : String() from $paramMap[‘mykey1’]

                then

// Sudo code…

                                <use $myValue >

end

 

 

Thank you Mark for the quick reply,

 

-- Paul Ryan

 

From: rules-users-bounces@... [mailto:rules-users-bounces@...] On Behalf Of Mark Proctor
Sent: Wednesday, July 16, 2008 4:29 PM
To: Rules Users List
Subject: Re: [rules-users] Map using from constraint

 

Paul Ryan wrote:

Hi all,

 

Is there a way using the ‘from’ constraint to get the values of a map(the implementations of java.lang.Map eg HashMap, TreeMap, etc) into a constraint parameter, and if so can someone please give an example. Below is the way I’ve been trying, without success, to get a value based on a key.

$m : Map()
MyObject(.....) from $m['key']

We support MVEL notation for the 'from' keyword.

 

import my.package.MyFact

import java.util.Map.Entry

rule “Find with map”

                when

                                $fact : MyFact($paramMap : paramMap)

                                $myValue : Entry(key == “mykey1”) from $paramMap

                Then

// Sudo code…

                                <use $myValue.getValue()>

end

 

Paul Ryan

Software Architect
Product Engineering

InfoTrust Group, Inc.

 

Logo FINAL 1-30-08_scaled

500 Discovery Parkway, Suite 200
Superior, CO 80027
Office (303) 627-6528

Fax (303) 666-6711
Email pryan@...
WEB www.infotrustgroup.com

 

This e-mail and all information included herein do not constitute a legal agreement accorded by INFOTRUST GROUP and its affiliates and subsidiaries.  All legal agreements must be formulated in writing by a legal representative of INFOTRUST GROUP. This email 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 have received this e-mail by mistake, please inform us and destroy this e-mail and any documents it might contain.  Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.  Thank you for your cooperation.

 

 


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

 



_______________________________________________
rules-users mailing list
rules-users@...
https://lists.jboss.org/mailman/listinfo/rules-users
LightInTheBox - Buy quality products at wholesale price