[rules-users] Need DRL authoring Help

Anstis, Michael (M.) manstis1 at ford.com
Wed Apr 4 03:48:16 EDT 2007


If you can add the CatalogObject element data to working memory and if
you can add a connective property ("parent" in the rule below) you can
eliminate the use of "eval" (which does not allow the benefits of a RETE
network to be fully realised) I think a rule like the below using 3.1-M1
would provide the same function as that shown by Michael Neale. Lots of
assumptions but performance would be better.
 
        rule "UCCnet_DVE_Depth_All"
 
        when
 
            catalogObject : CatalogObject(  )
 
            elementValue( name = "depth", value == null | == "", parent
== catalogObject )
 
        then
 
            logWriter.logDebug( "Package Depth is Blank"); 
 
            System.out.println( "Package Depth is Blank" );
 
        end 
 
With kind regards,
 
Mike


________________________________

	From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Michael Neale
	Sent: 04 April 2007 05:18
	To: Rules Users List
	Subject: Re: [rules-users] Need DRL authoring Help
	
	
	you are close ;)
	
	Yes, it is a challenge, thats what the examples are for etc.
	
	but try this (FYI I think you mean "or"):
	
	

	rule "UCCnet_DVE_Depth_All"

	      when

	            catalogObject : CatalogObject(  )

	         eval( catalogObject.getElementValue( "depth") == null
|| catalogObject.getElementValue( "depth") == "" )
	

	#           String depth =
CatalogObject.getElementValue("depth")

	#           depth == null 

	#           depth == "" 

	#           catalogObject : CatalogObject( depth == null) 

	#           catalogObject : CatalogObject( depth == "") 

	      then

	           # DON'T do this            logWriter : LogWriter();

	        # BUT you can pass in a logWriter global variable 
	

	            logWriter.logDebug( "Package Depth is Blank"); 

	            System.out.println( "Package Depth is Blank" ); 

	end
	
	
	Hope that helps.
	In the up coming BRMS, there will be a GUI which also has a
secret purpose of "coaching" what DRL looks like, for those who need to
know. 
	
	
	On 4/4/07, John.Tal at gxs.com <John.Tal at gxs.com> wrote: 

		Writing DRL is not easy for people new to drools.   Can
someone please help me understand how to write this simple rule?  You
can see the approaches I have taken.

		 

		In this case I do not have getters and setters for the
attributes I am checking.  I need to pass parameters to the object for
it to get the data.

		 

		I can't get any of the code in the when block to be
syntax proper.  Existing DRL doc is lacking in this area.

		 

		Thanks  John

		 

		 

		rule "UCCnet_DVE_Depth_All" 

		      when

		            catalogObject : CatalogObject(
getElementValue( "depth") == null, getElementValue( "depth") == "") 

		#           String depth =
CatalogObject.getElementValue("depth")

		#           depth == null 

		#           depth == "" 

		#           catalogObject : CatalogObject( depth ==
null) 

		#           catalogObject : CatalogObject( depth == "") 

		      then

		            logWriter : LogWriter(); 

		            logWriter.logDebug( "Package Depth is
Blank"); 

		            System.out.println( "Package Depth is Blank"
); 

		end 


		_______________________________________________
		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/20070404/555dd421/attachment.html 


More information about the rules-users mailing list