[rules-users] working with deep object graph

Chris Mathrusse christopher.mathrusse at sybase.com
Wed Jun 6 19:36:41 EDT 2007


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.




More information about the rules-users mailing list