You'll have to roll your own, but it's a small one. Use accumulate steps:<br><br>$maxVa: VendorAddress() from accumulate(<br> $location : VendorAddress () from $step.job.scorableLocations,<br> init( VendorAddress maxVa = null; int maxScore = 0; ),<br>
action( if( $location.getAbcScore() > maxScore ){<br> maxVa = $location;<br> maxScore = $location.getAbcScore(); } ),<br> result( maxVa ) )<br><br>The scope of a binding within accumulate(...) is this parenthesis.<br>
-W<br><br><div class="gmail_quote">On 29 August 2011 22:52, lhorton <span dir="ltr"><<a href="mailto:LHorton@abclegal.com">LHorton@abclegal.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Thank you for the hints. I have implemented a method to hide the instanceof<br>
code, and tried using the accumulate CE. The LHS of my rule is now:<br>
<br>
$step : Step()<br>
$highScore : Number() from accumulate ( $location : VendorAddress () from<br>
$step.job.scorableLocations,<br>
max($location.abcScore) )<br>
<br>
in my RHS I can display the score this way:<br>
<br>
System.out.println(" MAX SCORE IS: " + $highScore );<br>
<br>
and verify that the accumulate is indeed choosing the max score. HOWEVER,<br>
what I really want is not the max score, but the ADDRESS with the max score.<br>
if I try to use $location in my RHS like this:<br>
<div class="im"><br>
System.out.println("high score is: " + $location.getAbcScore());<br>
<br>
</div>I get compile time exception:<br>
[Error: unable to resolve method using strict-mode:<br>
org.drools.spi.KnowledgeHelper.$location()]<br>
<br>
It looks like my $location variable is usable in the LHS but does not get<br>
scope to the RHS.<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Getting-one-type-from-a-collection-of-multiple-types-tp3287877p3293744.html" target="_blank">http://drools.46999.n3.nabble.com/Getting-one-type-from-a-collection-of-multiple-types-tp3287877p3293744.html</a><br>
</font><div><div></div><div class="h5">Sent from the Drools: User forum mailing list archive at Nabble.com.<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>
</div></div></blockquote></div><br>