[rules-users] working with deep object graph

Mark Proctor mproctor at codehaus.org
Wed Jun 6 19:59:14 EDT 2007


Express your data relationally and assert individual objects. Using 
'from' to traverse deep object graphs really is for legacy pojo support. 
If you do that you'll have no problem solving problems like this, look 
at Conways Game of Life to see how to exploit this relational approach 
to solving problems.

Later we will alow 'collect' and 'from' to be chained together, which 
will allow this for legacy deep graph pojo support.

Mark
Chris Mathrusse wrote:
> I'm using JBoss Rules 4.0MR2 and I'm just starting out trying to learn the
> concepts and syntax. My challenge is that I am placing into Working Memory a
> List of Message objects. A Message contains an Order, and Order contains a List
> of Line Items, a Line Item contains a Catalog, a Catalog contains a PriceCode,
> and a PriceCode contains a value.
>
> I'm trying to create rules that will identify the negative cases. My rules are
> designed to find Orders, contained within each Message, that should not be
> Released. If any rule finds a match the Order is no longer eligible for Release
> and the Message will be updated appropriately. I've had some success with some
> of the rules I've defined but now I'm getting into the more complex ones and
> they are giving me some challenges when I need to work with Lists. The following
> rule compiles and executes correctly but is not complete.
>
> rule "Is Academic or Not For Resale"
>
> 	when
> 		$msg : Message( state == MessageState.RELEASING )
> 		$order : RequestOrder( requestStatus == RequestStatus.ACCEPT ) from $msg.order
> 		$itemList : List( ) from $order.lineItems
> 	then
> 		System.out.println("Rule Name: " + drools.getRule().getName());
>   
> end
>
>
> So this rule compiles and it does print the message so I know that things are
> working. But now my challenge is to test the PriceCode value contained in each
> LineItems Catalog? 
> Message -> Order -> LineItems -> Catalog -> PriceCode -> value
>
> Should I load all the Order and Line Item objects up into working memory or can
> I express what I want in a rule without having to do that?
>
> Thanks for taking the time to help me with this.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>   




More information about the rules-users mailing list