Re: [rules-users] Example of contains operator...
That worked just fine - thanks very much for clarification - I'm starting to understand how that works now... example is worth a thousand lines of documentation text... :) Marcus Ilgner wrote: > > You could write an accessor in your model called getPartnerListKeys() > which returns getPartnerList().keySet() and then use (partnerListKeys > contains "2900") in your rule. > -- View this message in context: http://www.nabble.com/Example-of-contains-operator...-tf3202978.html#a8947081 Sent from the drools - user 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] Example of contains operator...
On 2/13/07, jdepaul <[EMAIL PROTECTED]> wrote: Ok thanks - that worked when partnerList was an ArrayList, how would I code my "contains" condition if the parternList was a HashMap!? You could write an accessor in your model called getPartnerListKeys() which returns getPartnerList().keySet() and then use (partnerListKeys contains "2900") in your rule. I'm not 100% sure (started with JBoss Rules only a couple of days ago), but I'm pretty confident that this should work. hth Marcus Michael Neale wrote: > > contains works on the Collection interface. So if parnerList is a > ArrayList > of String, then you could do: parnerList contains "2900" > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Example of contains operator...
Ok thanks - that worked when partnerList was an ArrayList, how would I code my "contains" condition if the parternList was a HashMap!? Michael Neale wrote: > > contains works on the Collection interface. So if parnerList is a > ArrayList > of String, then you could do: parnerList contains "2900" > -- View this message in context: http://www.nabble.com/Example-of-contains-operator...-tf3202978.html#a8944919 Sent from the drools - user 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] Example of contains operator...
contains works on the Collection interface. So if parnerList is a ArrayList of String, then you could do: parnerList contains "2900" On 2/13/07, jdepaul <[EMAIL PROTECTED]> wrote: Still having trouble with the contains operator... I have the following rule in place: rule "Shipper List Match" when $shipperGO : GateOut ( customerId == "Walmart", partnerList contains ("2900") ) then myService.sendNotification($shipperGO, Constants.SHIPPER_MATCH); end -- and the folllowing code that builds the partnerList collection object: GateOut walmartGO = new GateOut(); walmartGO.setCustomerId("Walmart"); walmartGO.setContainerId("2939392"); walmartGO.setMatched(false); walmartGO.setSourceLocation("SHGH"); walmartGO.setDestLocation("SFCO"); Partner shipper = new Partner(); shipper.setPartnerId("2900"); shipper.setPartnerName("Yellow Freight"); shipper.setPurpose(Partner.FORWARDER); HashMap hm = new HashMap(); hm.put(shipper.getPartnerId(), shipper); walmartGO.setPartnerList(hm); --- At runtime, I get the ClassCastException: at com.maersk.nam.gems.gatein.walmart.GateOutWalmartExample.main( GateOutWalmartExample.java:62) Caused by: java.lang.ClassCastException: java.util.HashMap Can someone help with the proper expression? James -- View this message in context: http://www.nabble.com/Example-of-contains-operator...-tf3202978.html#a8935042 Sent from the drools - user 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
Re: [rules-users] Example of contains operator...
Still having trouble with the contains operator... I have the following rule in place: rule "Shipper List Match" when $shipperGO : GateOut ( customerId == "Walmart", partnerList contains ("2900") ) then myService.sendNotification($shipperGO, Constants.SHIPPER_MATCH); end -- and the folllowing code that builds the partnerList collection object: GateOut walmartGO = new GateOut(); walmartGO.setCustomerId("Walmart"); walmartGO.setContainerId("2939392"); walmartGO.setMatched(false); walmartGO.setSourceLocation("SHGH"); walmartGO.setDestLocation("SFCO"); Partner shipper = new Partner(); shipper.setPartnerId("2900"); shipper.setPartnerName("Yellow Freight"); shipper.setPurpose(Partner.FORWARDER); HashMap hm = new HashMap(); hm.put(shipper.getPartnerId(), shipper); walmartGO.setPartnerList(hm); --- At runtime, I get the ClassCastException: at com.maersk.nam.gems.gatein.walmart.GateOutWalmartExample.main(GateOutWalmartExample.java:62) Caused by: java.lang.ClassCastException: java.util.HashMap Can someone help with the proper expression? James -- View this message in context: http://www.nabble.com/Example-of-contains-operator...-tf3202978.html#a8935042 Sent from the drools - user 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] Example of contains operator...
Could someone post an example or a link that shows how to use the "contains" operator...HEre's the scenario: I've got the following class that has partnerList collection of Partner objects - the partnerList is a HashMap keyed by partnerID: public class GateOut { private String portID; private Map partnerList; <-- Collection... .. } public class Partner { private String partnerId; private String partnerName; private intpurpose; .. } Need to write a rule that will determine if a specific PartnerID exists in the partnerList HashMap. Could you please point me to an example? The documentation example listed is unclear to me... thanks - james -- View this message in context: http://www.nabble.com/Example-of-contains-operator...-tf3202978.html#a8894103 Sent from the drools - user mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users