Put this code into method of Policy with the signature
List<Vehicle> getValidAB()
where the returned List either contains the element you want or is
empty. Then you can write
rule "find first 'car'"
when
$p1:Policy()
$carList: List( size > 0 )
from collect ( Vehicle( name == "car" )
from $p1.getValidAB() )
$first: Vehicle( ) from $carList.get( 0 )
then
System.out.println( $first );
end
-W
On 26/08/2012, Wolfgang Laun <wolfgang.laun(a)gmail.com> wrote:
On 26 August 2012 21:00, salt <writemesaltworth(a)gmail.com>
wrote:
> Hi Laune,
>
> Please find the java method below..
>
> Apart from such trivial omissions as method name, parameter list and
result type...
-W
> int statusApass=0;
> int statusBpass=0;
>
> for(int i = 0;i<policy.getList().size();i++)
> {
>
>
>
if(policy.getList().get(i).getChar().equals("A")||policy.getList().get(i).getChar().equals("B"))
> {
>
> System.out.println("STEP`1"+policy.getList().get(i).getChar());
>
> if(policy.getList().get(i).getChar().equals("A"))
> {
> statusApass =1;
> for(int j=0;j<=i;j++)
> {
>
> if(policy.getList().get(j).getChar().equals("AA"))
> {
> statusApass=0;
> }
> }
> }
> else
> if(policy.getList().get(i).getChar().equals("B"))
> {
> statusBpass=1;
> for(int z=0;z<=i;z++)
> {
>
> if(policy.getList().get(z).getChar().equals("BB"))
> {
> statusBpass=0;
> }
> }
> }
>
> }
>
> if(statusApass==1||statusBpass==1)
> {
>
>
>
System.out.println("policy"+policy.getList().get(i).getQty()+","+"policy"+policy.getList().get(i).getChar());
> break;
> }
> }
>
>
> Thanks
> Salt
>
>
>
> --
> View this message in context:
>
http://drools.46999.n3.nabble.com/Getting-Latest-Matching-Fact-tp4019345p...
> Sent from the Drools: User forum mailing list archive at
Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>