[rules-users] match longest matching Long in WM

esstrata esstrata at yahoo.es
Thu Jul 21 07:59:39 EDT 2011


Hi,

  I hope you can help me out here with a way to implement this rule:

1) I have String WM
2) I have beans in WM with a property called 'code' 
public class MyBean {
  private String code;
  ...

3) I want a rule of the type "Process MyBean with the longest-matching,
not-null code"

Let explain myself a little further with an example.

I have the following MyBean objects in WM with the given code properties:
MyBean [code = 44]
MyBean [code = 443]
MyBean [code = 4432]
MyBean [code = 36]
MyBean [code = 7]

What I want to get is a rule where the following samples would assign to a
variable the given results shown:
4411111 gives MyBean [code = 44]
4433333 gives MyBean [code = 443]
22222 gives null

I think the rule could start like:
rule "Process MyBean with the longest-matching, not-null code"
        dialect "mvel"	
	when
                $s : String()
		$m : MyBean($s matches /the longest not-null possible MyBean.code/)
	then
 ......

Thank you

--
View this message in context: http://drools.46999.n3.nabble.com/match-longest-matching-Long-in-WM-tp3188343p3188343.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list