For question 1, if your asking can a object matched be automatically set to a variable that you can later reference?  No.  You have to provide the binding else how would you know how to reference it.

For question 2, the or part is tricky from the UI as you have to do the and first then or embedded in the and.  You accomplish that via Multiple field constraints.  So I guess you always want to start on the outter condition and work your way in due to the quirkiness of the UI.



HTH
Minh

On 10/8/2010 5:11 AM, Dean Whisnant wrote:

Minh,

 

Thank you!  The binding to a variable is the part I was missing in order to accomplish 2 & 3 and #1 was as simple as using the formula to say null.

 

Last night I worked through this and some matching Regex issues I had.

 

I do have two follow on questions if you don’t mind:

 

1)      Can the binding be done in another way where you don’t have to set it up on each rule?

2)      How does one go about creating an “or” condition here in guvnor?

a.       If ((string1 != null ||  string2 != “AB”)  && string1 != string2) then

b.      If (string1 == “ABC” || string1 ==”XYZ” | string1==”QWERTY”) then

 

These scenarios all seem so simple to me from a DRL hand coding, so I know they must be able to be handled in guvnor and I’m just missing some subtle nuance.

 

I appreciate the help…

 

Dean

 

From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Minh Huon
Sent: Thursday, October 07, 2010 8:31 PM
To: Rules Users List
Subject: Re: [rules-users] Guvnor LHS and RHS questions

 

Look at screen shot for questions 1 and 2




UI is a little screwy but you can check for null.

As for question 3, if you look at the source of your drl, you'll see if you have a named reference to your object if not, you cannot use it on the right hand side.  If you look at my rule, I'm setting the contents of override to resultNumberToPick which is what I think your trying to accomplish.

hth

Minh


On 10/7/2010 2:15 PM, Dean Whisnant wrote:

Hello,

 

I’ve only been working with Drools for a little over a month or so now and I’ve begun integrating it into my application via Eclipse and creating DRL files.  The nature of this application is to take a data record from one file and create a new data record in another file.  This is done in a batch of any number of records, depending on the number of records sent to us in the first file. To accomplish this I have two classes, one representing each file, and I create and object for each of them, inserting them into the knowledge session and then fire the rule. 

 

                ksession.insert(myObjectIn);

                ksession.insert(myObjectOut);

                ksession.fireAllRules();

 

The first object has around 1,000 fields and the second has 250, so my class structure is quite broad.

 

In a DRL file I have created the following rule:

 

rule "Primary Diagnosis Code"

     when

           $ccl : anObjectIn(IncomingDiag1 != null)

           $cdl  : anObjectOut()

     then

           $cdl.PrimaryDiag = $ccl.IncomingDiag1;

end

 

This rule fires great and the PrimaryDiag field in myObjectOut is updated with what iss in myObjectIn.IncomingDiag.  I can then write the object back out the the database fine.

 

A requirement of my project is that I allow users (analysts) to create their own rules that are above and beyond those I might create in a .drl file. To do so we are looking to deploy Guvnor and let them use the Guided editor to create rules.  I’ve already loaded my fact models into Guvnor and have them available in the drop down conditions.

 

The questions that are hitting me now are:

 

On the LHS when I’ve chosen the fiels IncomingDiag the only options I have for conditions are “equal to”, “not equal to”, “matches”, and “sounds like”. I don’t see an option for null or notnull. If I were to choose “not equal to” I then have the options for Literal Values, New Formulas, or Expression Editor (which has none by default).  I haven’t seen any examples where someone is evaluating a field in Guvnor for being either “” or null.  How would one accomplish this?  The literal value does not allow you to leave it blank as in “” and if you type “” in it, the source shows “”””.

On the LHS, if I were to want to evaluate IncomingDiag1 == IncomingDiag2 I don’t see a method except if I were to choose New Formula and type in the field name Incoming Diag2.  Is there another way that they could be prompted for the field choises again?

On the RHS, when I go to add a new then, I’m prompted to choose only to either “insert fact anObjectIn” or to “logically insert fact anObjectIn” or to manually enter DRL logic.  Both of the inserts appear to create logic that would create a new object with the data in it:

 

anObjectIn fact0 = new anObjectIn ();

fact0. IncomingDiag1 ( 11 );

insertLogical(fact0 );

       

        But what I really want is something similar to my DRL from above.  Am I missing something?  Or would this have to be a case where they would manually enter the DRL statement?

 

Thank you!

 

Dean Whisnant

Senior Software Developer

basys, inc.

 
 
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users