[rules-users] Accessing properties of an object within a Nested Collection of a Nested Collection

Michael Anstis michael.anstis at gmail.com
Wed May 2 16:30:56 EDT 2012


Since the auto manufacturers data is reasonably static you could also use a
"bootstrap" rule that inserts all Parts, Models and Brands from the
AutoManufacturer objects inserted by your java code.

I assume your rules will probably look at supply or costing decisions
updating the static reference data less frequent than the decisions you
make based on the reference data - but I could easily be wrong!

sent on the move

On 2 May 2012 20:20, "Wolfgang Laun" <wolfgang.laun at gmail.com> wrote:

> Yes, the idea is to insert Models, Brands, Parts, and possibly additional
> facts.
>
> You might want to keep lists of child objects or used parts in the
> parent objects - see Michael's rule.
>
> Otherwise:
> Relating a Model to a Brand and a Brand to a Manufacturer is simple: a
> "parent" reference is sufficient. For Parts, you might want to
> establish a Gozinto fact, combining a Part and a Model.
>
> rule "whereIsPV999999"
> when
>     $part: Part( partName == "PV999999" )
>     Gozinto( part == $part, $model: model )
>     Model( this == $model, $brand: brand )
>     Brand( this == $brand, $manu: manufacturer )
>     Manufacturer( this == $manu )
> then
>    System.out.println( "PV999999 used in " +  $model + "/" + $brand +
> " by " + $manu );
> end
>
> For deciding between using this or the "contains" search in potential
> parents,
> there are issues w.r.t. the number of objects you have, the rules
> you'd really use, and how frequently what is evaluated, and concerning
> the ease of rule maintenance.
>
> It is indeed possible to extract all from a small set of Manufacturer
> facts, but nested "from" CEs are most likely bad for performance.
>
> -W
>
>
>
> On 02/05/2012, James K <james_kosa at verizon.net> wrote:
> > Luane - Yes, it would be a normalized database, there would be only one
> > entry
> > for a manufacturer with all of the child records related by Foreign Keys
> or
> > relational tables.
> >
> > Excuse my ignorance I am relatively new to Drools, can you please expand
> on
> > the following:
> >
> > "...(...$p.getPartsName()...) "
> >
> > This is where I am having a hard time on how to navigate into the nested
> > collections. Or are you saying to insert the PART, MODEL, BRAND, etc as
> > individual facts?  How would I relate it back Automanufacturer fact?
> >
> >
> > --
> > View this message in context:
> >
> http://drools.46999.n3.nabble.com/Accessing-properties-of-an-object-within-a-Nested-Collection-of-a-Nested-Collection-tp3955591p3956880.html
> > Sent from the Drools: User forum mailing list archive at Nabble.com.
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20120502/f6b64b2d/attachment.html 


More information about the rules-users mailing list