It's also possible to create "relation" objects in addition to the data objects<br>and insert these. In this situation, it might be a quadruple of Manufaturer,<br>Brand, Model and Part. These facts can be used in a number of ways, e.g.,<br>
for obtaining all Models of a Brand, all Parts of a Model, all Models where a<br>Part is used, etc.<br><br>-W<br><br><br><div class="gmail_quote">On 4 May 2012 16:42, James K <span dir="ltr"><<a href="mailto:james_kosa@verizon.net" target="_blank">james_kosa@verizon.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Thank you laune and manstis for the excellent / relevant information! I have<br>
a follow on question based on my findings the last couple of days using the<br>
information you have provided. I am using Drools Flow, firing the following<br>
</div>rule in a Rules Task in my flow. Initially, I am only inserting a populated<br>
AutoManufacturer into the flow as my transport object. In the flow, I am<br>
<div><div class="h5">able to access the sub-objects / collections on the parent to control flow.<br>
I prefer to keep it this way.<br>
<br>
However, it does not appear the sub-objects on the parent object are<br>
available for LHS evaluation in the rule. So, I am creating a memory entry<br>
for the automanufacturer objects and then iterating collections on the<br>
object / sub-objects to insert them as facts. This is working, however, is<br>
there not a way to do some sort of introspect on collections on the parent<br>
object instead of inserting all of the additional facts and joining them<br>
back together? Is there a better way to be doing this? Another perspective<br>
to approach this?<br>
<br>
<br>
Rule Code<br>
--------------------------------------------------------------<br>
package com.nabble.demo<br>
<br>
import com.nabble.demo.model.Part;<br>
import com.nabble.demo.model.Brand;<br>
import com.nabble.demo.model.Model;<br>
import com.nabble.demo.model.AutoManufacturer;<br>
<br>
rule "Insert additional facts from AutoManufacturer Base Class"<br>
ruleflow-group "determineVendors"<br>
when<br>
$autoMfg : AutoManufacturer()<br>
then<br>
<br>
for(Brand brand : $autoMfg.getBrandsCollection()){<br>
System.out.println ("Adding Brand Fact: " + brand.getBrandName());<br>
insert(brand);<br>
for (Model model : brand.getBrandModels())<br>
{<br>
System.out.println ("Adding Model as Fact: " +<br>
model.getModelName());<br>
insert(model);<br>
for (Part part : model.getPartsList())<br>
{<br>
System.out.println ("Adding Part as Fact: " +<br>
part.getPartsName());<br>
insert(part);<br>
}<br>
}<br>
}<br>
end<br>
<br>
rule "Part Vendor = PV999999"<br>
ruleflow-group "determineVendors"<br>
when<br>
$p: Part( partVendor == "PV999999" )<br>
$m: Model( partsList contains $p )<br>
$b: Brand( brandModels contains $m)<br>
$a : AutoManufacturer( brandsCollection contains $b )<br>
<br>
then<br>
System.out.println( "Manf: " +$a.getManufacturerName() + " , Brand<br>
Name: " + $b.getBrandName() + " , Brand ID: " + $b.getBrandId() + " , Model<br>
Name: " + $m.getModelName() + " , Part ID: " + $p.getPartsId()+ " , Part<br>
Name: " + $p.getPartsName());<br>
end<br>
<br>
--<br>
</div></div>View this message in context: <a href="http://drools.46999.n3.nabble.com/Accessing-properties-of-an-object-within-a-Nested-Collection-of-a-Nested-Collection-tp3955591p3962570.html" target="_blank">http://drools.46999.n3.nabble.com/Accessing-properties-of-an-object-within-a-Nested-Collection-of-a-Nested-Collection-tp3955591p3962570.html</a><br>
<div class="HOEnZb"><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>