Joe and Wolfgang,
Thanks for both of the suggestions. I am initially going with the curly brace solution as
I have users entering their rules through Guvnor and changing to from mvel is a bit more
of a pain than teaching them to use the braces.
Not that my application is super-intense, but would I expect better performance from
either method?
Again, Thank you guys for the rapid response and great solution
Dean
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Joe White
Sent: Friday, August 19, 2011 1:54 PM
To: Rules Users List
Subject: Re: [rules-users] String.format question in the RHS
I got it to work in mvel. You need to pass the second argument as an mvel array (note the
curly braces) for it to recognize the method signature.
Here is a rule that works for me:
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
import java.lang.String;
import com.recondotech.droolsTest.TestInput;
import com.recondotech.droolsTest.TestConts;
import com.recondotech.droolsTest.TestMap;
dialect "mvel"
rule "map list test rule"
salience 155
when
TestInput(val : val!=null)
then
String result = String.format("%010d",{val});
System.out.println(result);
end
From:
rules-users-bounces@lists.jboss.org<mailto:rules-users-bounces@lists.jboss.org>
[mailto:rules-users-bounces@lists.jboss.org]<mailto:[mailto:rules-users-bounces@lists.jboss.org]>
On Behalf Of Wolfgang Laun
Sent: Friday, August 19, 2011 9:34 AM
To: Rules Users List
Subject: Re: [rules-users] String.format question in the RHS
Do not use dialect "mvel".
-W
2011/8/19 Dean Whisnant <dean@basys.com<mailto:dean@basys.com>>
Hello,
Can anyone see an issue with the following RHS? The String.format is failing. I've
copied it straight into java to verify my intentions and it works there.
What I'm trying to accomplish is to concatenate the string UH005 with a sequence
number that is a fixed 10 digits, zero filled. So if CurrentClaimSeq_48 is the number
123, then I expect that TRN02_Check... would be populated with UH0050000000123.
Again, this is working fine in straight java, but not in a rule. What am I missing? Is
there a better way to try to accomplish this in a rule?
rule "L1000_TRN02_UHC_BPA"
dialect "mvel"
when
CLM_835_SUPP( seq : currentClaimSeq_48 != ( null ) )
CLM_DET_LOAD( )
trn : x221TransactionHeader_TRN_ReassociationTraceNumber( )
then
trn.setTRN02_CheckOrEftTraceNumber( "UH005" + String.format
("%010d", seq) );
end
Here are the data types of the two fields involved.
private Integer CurrentClaimSeq_48;
public String TRN02_CheckOrEftTraceNumber;
Thank you!
Dean
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users