web based rules design

12
Welcome Page Login to http://localhost:8085/drools-guvnor (It shouldn't prompt you any userid and password). The welcome screen looks like below. Before proceeding to create rule, we have to do some pre rule arrangements for which follow these below steps. Creating Category Step 1. Click the Administration button from left pane and you will see bunch of items along with categories when you click plus sign. Now click the Categories icon and click New category button from right

Upload: narasimha

Post on 11-Apr-2015

859 views

Category:

Documents


3 download

DESCRIPTION

Web based rule designer (BRMS) using jboss drools guvnor

TRANSCRIPT

Page 1: Web Based Rules Design

Welcome Page

Login to http://localhost:8085/drools-guvnor (It shouldn't prompt you any userid and password). The welcome screen looks like below.

Before proceeding to create rule, we have to do some pre rule arrangements for which follow these below steps.

Creating Category

Step 1. Click the Administration button from left pane and you will see bunch of items along with categories when you click plus sign. Now click the Categories icon and click New category button from right pane. Key in the category name and click ok on pop screen.

Page 2: Web Based Rules Design

Page

You should able to see the created 'leads' category under Current categories section in same screen. And also you should able to verify the created category under 'Assets view' tab as well by selecting 'By Category' tree. You can also create any number of hierarchical sub categories by selecting the leads category later onwards based on your requirement. Now we are done at the Administration level at this moment. You can revisit the Administration to clear the archived items and other stuff.

Creating Packages

Step2. Now first click on Packages button and then select New Package from Create New combo. For this tutorial check the 'Create new package' radio button and key in package name as 'scoring' and description can be optional. You should able to see created package name under Packages window.

Creating model object

attachment.

Step 3. Copy the above attachment Lead.java to one folder and compile the class file first by running the command "javac -d . *.java". And archive the compiled class file to score.jar with this command "jar cf score.jar im". Now select the "Create New" combo again to select the "Upload now Model jar(fact classes). Key in the package name as score and

Page 3: Web Based Rules Design

Page

select the scoring from drop down and click ok. If you want you can put some optional description in Initial description text area to check out later.

Now click the Browse button and select the score.jar file from your files system. Once you click on the up arrow button to upload the jar file, you will get pop up message saying that "File was uploaded successfully". Click on the "scoring" package you should able to see the im.score.Lead object Imported types in Configuration pane. Click "Save and validate configuration" button to make sure imported object is properly mapped to the scoring package. Now we can move on to next step.

Page 4: Web Based Rules Design

Page

Creating Rule (Decision Table)

Step 4. Again select the "Create New" combo and click on "New Rule" and key in leadscore as rule name, select category as leads, Type (format of rule) as "Decision table (web-guided editor), Package as scoring and Initial description can optional. Click ok now. Now we are done with all the pre setup to create the rules and good to go.

Page 5: Web Based Rules Design

Page

a. Creating Condition Columns

Now we will have to create the columns for the decision table. To configure the columns, click on the down arrow mark. You should able to see the output window something like this. For this tutorial what we care about is Condition columns and Action columns. As a initial step click on the green plus sign button on Condition columns, you will get popup screen to configure the first column. Click on the pensile icon on Pattern .

You will get below pop up window. Key in the name as lead and click ok. Leave it as it is the default value of Literal Value radio button.

Page 6: Web Based Rules Design

Page

Now select the pencil icon of Field and again you will get pop up window which contains combo with all the properties from the object Lead.

Select the title and click ok. For Operator value would be "is equal to" and even though value list is optional key in values as "CEO,CTO,VP,DIRECTOR". Key in the column name as Title.

Repeat this step for rest of the fields size,quantity,timeFrame.

b. Creating Action Columns

Now click on the green plus icon in Action columns and choose field value as lead and select then score. Key in the default values as you wish ex,10,20,30,40 etc.

Now you should able to see all the created columns in next half of the pane. Now it's time to create the rules in different rows.

c. Creating Rule Table

To start creating rules select the Add row... from Modify... combo. Now you should able to see the newly created empty row under columns. So start fill the data with different scenarios as specified below.

Page 7: Web Based Rules Design

Page

We are done with sample rules creation. Save the changes by clicking the button "Save changes" which you can find on top left corner of the current pane.

d. Validating the Rule Table

Validate the created rules by clicking "Validate" button which you can find down side left corner of the current pane window. If everything perfect you should able to get Validation results popup window saying that Item validated.

e. Verifying generated Business Rule

If you click on view source you should able to see all the generated rule in text window.

Now we are ready to test the generated rules by creating different test scenarios.

Page 8: Web Based Rules Design

Page

Creating Test Scenarios

Click the Create new combo again and select the "New Test Scenario". Key in the "Scenario1" as Name and leave the package:scoring as it is and click ok. The output window should be like this.

Click on the green plus icon which is adjacent to Given. In the popup window key in the Fact name as 'lead' and click Add.

If you click on Add a field button you can choose the title from the combo in the pop up window. (you can achieve same by clicking on small green arrow.) Repeat the same step for size,quantity,timeFrame. Don't repeat this step for score here.

Page 9: Web Based Rules Design

Page

Once added all the fields key in the values as shown below.

Now click on the green plus icon which is very adjacent to EXPECT.

click Add button to select the Fact value to find the what could be the score after the rule got fired.

Once you click add it will return you to parent screen. Now click on small green arrow as shown above and choose the score from the combo in pop up window.

Page 10: Web Based Rules Design

Page

Key in the 50 in text box which is after score: equals. Now save the scenario by clicking the Save changes button and click on Run Scenario button which is right under Save changes button. If the test scenario successful you will see the window like this. You can create some more test scenarios to cover the rest of the rules by clicking by More button and run the all different test scenarios in shot by clicking Run

scenario button. If the scenario is successful you should get small icon in expect part of the field.