It's also possible to create "relation" objects in addition to the data objects
and insert these. In this situation, it might be a quadruple of Manufaturer,
Brand, Model and Part. These facts can be used in a number of ways, e.g.,
for obtaining all Models of a Brand, all Parts of a Model, all Models where a
Part is used, etc.
-W
Thank you laune and manstis for the excellent / relevant information! I haverule in a Rules Task in my flow. Initially, I am only inserting a populated
a follow on question based on my findings the last couple of days using the
information you have provided. I am using Drools Flow, firing the following
AutoManufacturer into the flow as my transport object. In the flow, I am
View this message in context: http://drools.46999.n3.nabble.com/Accessing-properties-of-an-object-within-a-Nested-Collection-of-a-Nested-Collection-tp3955591p3962570.htmlable to access the sub-objects / collections on the parent to control flow.
I prefer to keep it this way.
However, it does not appear the sub-objects on the parent object are
available for LHS evaluation in the rule. So, I am creating a memory entry
for the automanufacturer objects and then iterating collections on the
object / sub-objects to insert them as facts. This is working, however, is
there not a way to do some sort of introspect on collections on the parent
object instead of inserting all of the additional facts and joining them
back together? Is there a better way to be doing this? Another perspective
to approach this?
Rule Code
--------------------------------------------------------------
package com.nabble.demo
import com.nabble.demo.model.Part;
import com.nabble.demo.model.Brand;
import com.nabble.demo.model.Model;
import com.nabble.demo.model.AutoManufacturer;
rule "Insert additional facts from AutoManufacturer Base Class"
ruleflow-group "determineVendors"
when
$autoMfg : AutoManufacturer()
then
for(Brand brand : $autoMfg.getBrandsCollection()){
System.out.println ("Adding Brand Fact: " + brand.getBrandName());
insert(brand);
for (Model model : brand.getBrandModels())
{
System.out.println ("Adding Model as Fact: " +
model.getModelName());
insert(model);
for (Part part : model.getPartsList())
{
System.out.println ("Adding Part as Fact: " +
part.getPartsName());
insert(part);
}
}
}
end
rule "Part Vendor = PV999999"
ruleflow-group "determineVendors"
when
$p: Part( partVendor == "PV999999" )
$m: Model( partsList contains $p )
$b: Brand( brandModels contains $m)
$a : AutoManufacturer( brandsCollection contains $b )
then
System.out.println( "Manf: " +$a.getManufacturerName() + " , Brand
Name: " + $b.getBrandName() + " , Brand ID: " + $b.getBrandId() + " , Model
Name: " + $m.getModelName() + " , Part ID: " + $p.getPartsId()+ " , Part
Name: " + $p.getPartsName());
end
--
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users