Thank you Wolfgang, that works brilliantly.
I appreciate your thoughts on Parameters and will be doing something along
that line as that looks cleaner again - I hadn't gotten up to eliminating
magic numbers yet.
Regards,
-Trav
Travis Smith
Analyst Programmer
Development Centre
BNZ
DDI: +644 4746356 (Or Ext 76356)
Wolfgang Laun <wolfgang.laun(a)gmail.com>
Sent by: rules-users-bounces(a)lists.jboss.org
17/02/2011 05:44 a.m.
Please respond to
Rules Users List <rules-users(a)lists.jboss.org>
To
Rules Users List <rules-users(a)lists.jboss.org>
cc
Subject
Re: [rules-users] using "contains" against a List<BigInteger>
It's Java, after all...
The "contains" operator requires a Collection (or array) and an
Object. A plain numeric literal won't result in a BigInteger without
you providing a hint.
You can write
$performance : Performance( calcScore contains
(BigInteger.valueOf(6)) )
or
dialect "mvel"
when
$performance : Performance( calcScore contains (6I) ) # capital
"i"
All of these (and your eval) use magic numbers, so my preferred way of
dealing with this would be s.th. like this, using a singleton
Parameter fact for this and other values:
when
Parameter( $bis: bigIntSix )
$performance : Performance( calcScore contains $bis )
-W
2011/2/16 <Travis_Smith(a)bnz.co.nz>:
Hi,
A newbie question I'm afraid. I've been unsuccessful searching the
mailing-list archive (and google) for this.
I'm trying to simplify rule-writing for Statistical Analysts to be able
to
write rules. I'm hoping to achieve this without resort to DSLR
files and
a
DSL if possible as we currently need them for nothing else
One of the situations I have is the following:
--------------------
when
$performance : Performance(
eval(calcScore.contains(BigInteger.valueOf(6)))
)
then
[...]
--------------------
That works absolutely fine: CustAccPerf being a having several members,
including an ArrayList<BigInteger> called calcScore
Howwever I'd like to rewrite it like:
--------------------
when
$performance : Performance( calcScore contains 6 )
then
[...]
--------------------
Given the support for BigInteger & BigDecimal type comparison, and the
structure of the 'contains' operator, I couldn't see why this wouldn't
work.
If someone could explain this would be excellent - for now I'm gong
ahead
with the eval, but from a non-technical usability POV the latter form
would
be far preferable: I'd prefer that the users don't have to
worry about
eval
or BigInteger, and while I realize it's not possible (currently)
to
eliminate that altogether, I would like to eliminate as many of the (to
quote) "meaningless tech stuff" questions as possible.
Alternately if some kind person wants to tell me a better way of
structuring
that rule so I can use it as a template, then that'd be welcome
also.
Unfortunately we're dealing with a feed from a 3rd party system so
restructuring the data is not a desirable option.
Thank you for your time,
-Trav
Travis Smith
Analyst Programmer
Development Centre
BNZ
CAUTION - This message may contain privileged and confidential
information
intended only for the use of the addressee named above. If you are
not
the
intended recipient of this message you are hereby notified that any
use,
dissemination, distribution or reproduction of this message is
prohibited.
This email was sent by the Bank of New Zealand. You can contact us
on
0800 ASK BNZ (0800 275 269). Any views expressed in this message are
those
of the individual sender and may not necessarily reflect the views of
Bank
of New Zealand.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
CAUTION - This message may contain privileged and confidential information
intended only for the use of the addressee named above. If you are not the
intended recipient of this message you are hereby notified that any use,
dissemination, distribution or reproduction of this message is prohibited.
This email was sent by the Bank of New Zealand. You can contact us on
0800 ASK BNZ (0800 275 269). Any views expressed in this message are those
of the individual sender and may not necessarily reflect the views of Bank
of New Zealand.