<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2>Thanks Steve,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2>This fixed the problem!</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2>For Cheng Wei Lee's benefit this is the complete solution
(I had to fix another part):-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face="Courier New"
color=#0000ff size=2>public class DBUtils {</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face="Courier New"
color=#0000ff size=2> public Collection getNumbers()
{</FONT></SPAN></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face="Courier New"
color=#0000ff size=2> Integer[]
numbers = new Integer[10];<BR> for
(int i = 0; i < numbers.length; i++)
{<BR>
numbers[i] = (int)Math.random() *
100;<BR>
}<BR> return
Arrays.asList(numbers);<BR> }<BR>}</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2>rule "a1"<BR><SPAN
class=362182308-23042008> </SPAN>when<BR><SPAN
class=362182308-23042008> </SPAN>$max
: <SPAN class=362182308-23042008><FONT color=#008000>Number</FONT></SPAN>()
from accumulate( <SPAN class=362182308-23042008><FONT
color=#008000>Number</FONT></SPAN>( $v : intValue ) from dbutils.getNumbers(),
max($v) )<BR><SPAN class=362182308-23042008>
</SPAN>then<BR></FONT><FONT><FONT face="Courier New"><FONT color=#0000ff><FONT
size=2><SPAN class=362182308-23042008>
S</SPAN>ystem.out.println($max.<SPAN
class=362182308-23042008>intValue</SPAN>());<BR><SPAN
class=362182308-23042008>
</SPAN>end </FONT></FONT></FONT></FONT></DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008></SPAN><SPAN
class=362182308-23042008></SPAN><SPAN class=362182308-23042008><FONT
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2>With kind regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=362182308-23042008><FONT face=Arial
color=#0000ff size=2>Mike</FONT></SPAN></DIV><FONT color=#0000ff
size=2></FONT><BR>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> rules-users-bounces@lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] <B>On Behalf Of </B>Steven
Williams<BR><B>Sent:</B> 23 April 2008 09:07<BR><B>To:</B> Rules Users
List<BR><B>Subject:</B> Re: [rules-users] Re: Is this scenario suitable for
using Drools?<BR></FONT><BR></DIV>
<DIV></DIV>change DBUtils to return a Collection and it should work I
think.<BR><BR>
<DIV class=gmail_quote>On Wed, Apr 23, 2008 at 5:50 PM, Anstis, Michael (M.)
<<A href="mailto:manstis1@ford.com">manstis1@ford.com</A>> wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff size=2>So, in
my usual helpful manner I thought Drools would be a perfect match and put
together what I thought would be a simple
example:-</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>package com.sample</FONT></SPAN></DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2></FONT> </DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>global com.sample.DBUtils dbutils;<BR></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN></SPAN><SPAN><FONT face="Courier New"
color=#0000ff size=2>rule "a1"<BR>
when</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2> $max : Integer() from
accumulate( Integer( $v : intValue ) from dbutils.getNumbers(), max($v)
)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2> then<BR></FONT></SPAN><SPAN><FONT
face="Courier New" color=#0000ff
size=2>
System.out.println($max);</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN><FONT face="Courier New" color=#0000ff
size=2>end </FONT></SPAN></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT><FONT face=Arial
color=#0000ff size=2></FONT><FONT face="Courier New" color=#0000ff
size=2></FONT> </DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2>public class DBUtils
{</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face="Courier New" color=#0000ff size=2> public
Integer[] getNumbers() {</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><FONT face="Courier New" color=#0000ff
size=2> Integer[] numbers = new
Integer[10];<BR> for (int i = 0; i
< numbers.length; i++)
{<BR>
numbers[i] = (int) <SPAN>(</SPAN>Math.random() *
100<SPAN>)</SPAN>;<BR>
}<BR> return
numbers;<BR> }<BR>}</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT> </DIV>
<DIV><SPAN></SPAN><FONT face=Arial><FONT color=#0000ff><FONT
size=2>H<SPAN>owever this led to some
errors:-</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN></SPAN></FONT></FONT></FONT> </DIV>
<DIV><FONT size=+0><FONT color=#0000ff><FONT face="Courier New"
size=2><SPAN>org.drools.RuntimeDroolsException:
java.lang.ClassCastException: [Ljava.lang.Integer; incompatible with
java.lang.Integer<BR> at
org.drools.rule.Accumulate.accumulate(Accumulate.java:131)<BR> at
org.drools.reteoo.AccumulateNode.assertTuple(AccumulateNode.java:127)<BR> at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(CompositeTupleSinkAdapter.java:73)<BR> at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)<BR> at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)<BR> at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)<BR> at
org.drools.reteoo.Rete.assertObject(Rete.java:177)<BR> at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)<BR> at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:179)<BR> at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1292)<BR> at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:891)<BR> at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:858)<BR> at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:659)<BR> at
com.sample.DroolsTest.main(DroolsTest.java:36)<BR>Caused by:
java.lang.ClassCastException: [Ljava.lang.Integer; incompatible with
java.lang.Integer<BR> at
org.drools.base.java.lang.Integer968047027$intValue.getIntValue(Unknown
Source)<BR> at
org.drools.base.ClassFieldExtractor.getIntValue(ClassFieldExtractor.java:197)<BR> at
org.drools.rule.Declaration.getIntValue(Declaration.java:230)<BR> at
com.sample.Rule_a1_0AccumulateExpression0Invoker.evaluate(Rule_a1_0AccumulateExpression0Invoker.java:16)<BR> at
org.drools.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(JavaAccumulatorFunctionExecutor.java:74)<BR> at
org.drools.rule.Accumulate.accumulate(Accumulate.java:123)<BR> ... 13
more<BR></SPAN></FONT></FONT></FONT></DIV>
<DIV><SPAN></SPAN><FONT face=Arial><FONT color=#0000ff><FONT
size=2>H<SPAN>ave I done something really stupid and is Drools a
fit?</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN></SPAN></FONT></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN>Cheers,</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN></SPAN></FONT></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT color=#0000ff><FONT
size=2><SPAN>Mike</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=Arial color=#0000ff size=2></FONT><FONT face=Arial
color=#0000ff size=2></FONT><FONT face=Arial color=#0000ff
size=2></FONT><BR></DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV lang=en-us dir=ltr align=left>
<HR>
<FONT face=Tahoma size=2><B>From:</B> <A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A> [mailto:<A
href="mailto:rules-users-bounces@lists.jboss.org"
target=_blank>rules-users-bounces@lists.jboss.org</A>] <B>On Behalf Of
</B>Cheng Wei Lee<BR><B>Sent:</B> 22 April 2008 17:27<BR><B>To:</B> <A
href="mailto:rules-users@lists.jboss.org"
target=_blank>rules-users@lists.jboss.org</A><BR><B>Subject:</B>
[rules-users] Re: Is this scenario suitable for using
Drools?<BR></FONT><BR></DIV>
<DIV>
<DIV></DIV>
<DIV class=Wj3C7c>
<DIV></DIV>I've 2 algorithms to calculate the cost of a product. At any
one time, there is only 1 algorithm in use. Initially algorithm 1 will be
the default. Subsequently, the decision to use which algorithm will depend
on customers feedback. The algorithms are:<BR><BR>Algorithm 1:<BR>Cost =
MAX(P1, T1, P2, T2, P3, T3, ...)<BR><BR>Algorithm 2:<BR>Cost = MIN(P1, P2,
P3, ...) + MIN(T1, T2, T3, ...)<BR><BR>The values of P1, P2, ... are
stored within a database. The number of Ps & Ts are unknown but can be
determined by querying the database, Would drools be a good option to use
to store the algorithms? If so, how could I be able to retrieve the values
of P1, P2, etc from the database from within
drools?<BR><BR>Thanks!<BR><BR></DIV></DIV></BLOCKQUOTE></DIV><BR>_______________________________________________<BR>rules-users
mailing list<BR><A
href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A><BR><A
href="https://lists.jboss.org/mailman/listinfo/rules-users"
target=_blank>https://lists.jboss.org/mailman/listinfo/rules-users</A><BR><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR>-- <BR>Steven Williams<BR><BR>Supervising
Consultant<BR><BR>Object Consulting<BR>Office: 8615 4500 Mob: 0439 898 668
Fax: 8615 4501<BR><A
href="mailto:steven.williams@objectconsulting.com.au">steven.williams@objectconsulting.com.au</A><BR><A
href="http://www.objectconsulting.com.au">www.objectconsulting.com.au</A><BR><BR>consulting
| development | training | support<BR>our experience makes the difference
</BLOCKQUOTE></BODY></HTML>