BEA Logo BEA WLCS Release 3.1.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

 

   WLCS Doc Home   |   Personalization Server User's Guide   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Creating and Managing Rules

 

Rules Management forms a key part of the personalization process by prescribing custom content to fit individual user profiles. The business logic encompassed by these rules allows robust delivery of personalized content marketed specifically to each end-user type.

This topic includes the following sections:

 


What Is the Rules Manager?

WebLogic Personalization Server offers a robust personalization solution through a set of components that provide edit-time and run-time services for delivering personalized content to end-users while browsing a Web site. These personalization components use business rules to match users and groups with appropriate content. The logic encompassed by the rules forms a critical piece of the personalization process.

The Rules Management component of WebLogic Personalization Server provides editing, deploying, and run-time capabilities for providing personalized content based on externalized rules. This component includes two major parts: an edit-time tool with a graphical user interface (GUI) that allows developers to define classification and content selection rules, and a run-time service that matches users with content based on these rules.

Well-known Objects

The Rules Management component uses several well-known objects:

How the Rules Engine Works

The Rules Engine functions with a set of rules operating on objects in working memory. This working memory is first populated with input from the calling objects, and contains the cached user profile bean, among other things. A representation of the user's profile exists in working memory before any rules are actually fired.

Rules can be executed only within a context. The context associates a rule set with a working memory. The context provides an interface to the Rules Engine that controls the relationship between the rule part of the application and the working memory.

This working memory is operated on by the production rules, which are contained in rule sets. The left-hand sides (LHS) of these rules are evaluated against the objects in the working memory. If the patterns on the LHS are matched, then the actions contained in the right-hand side (RHS) of the rules are performed. Some of these actions may assert new objects into the working memory. For example, if our Classifier rule tests for USER.age > 45, then we might assert a new Classifier object into working memory.

The production system is executed by performing the following operations:

  1. Match: Evaluates the LHSs of the rules to determine which are satisfied given the current contents of working memory.

  2. Conflict resoultion: Selects one rule with a satisfied LHS. If no rules have satisfied the LHSs, halts the interpreter.

  3. Act: Performs the actions in the RHS of the selected rule.

  4. Go to step 1.

Rules will continue to operate on the working memory until the conflict resolution set is zero (that is, no more rules can fire).

After the Rules Engine has halted, the rules service component returns a list of objects remaining in working memory. A likely scenario will have an object remaining of the type "Classification" or "ContentQuery."

The RulesServiceBean will then iterate over these remaining objects and filter first with the input object types (there are "Classifier" and "ContentQuery") and then optionally with the name of the rule that was requested to fire in the first place.

The resultant objects, if any, are then returned to the Advisor. As the Advisor expects to return a Boolean to the calling agent, the existence of an object determines the result of the advislet's request.

What Are Rule Sets?

The BEA WebLogic Personalization Server provides rule sets that comprise a set of classifier and content selector rules. These rule sets act as containers for rules that match personalized content with users.

A saved rule set generally contains a set of related rules. Rules within a rule set may refer to any properties. In general, you should not change or delete properties if a rule refers to it. Adding properties does not affect existing rules.

Note: In some cases, the Rules Engine will need to evaluate each rule in a rule set, so for the sake of performance, it is a good idea to keep each rule set small.

Classifier Rules

Classifier rules dynamically categorize users into groups (user segments) using simple boolean logic. A classifier rule determines if a user profile meets a set of conditions and places the user in a category based upon the result. Essentially, if the user profile meets the conditions, it is classified according to the classifier rule; if it does not meet the classification conditions, the user profile is not included in the classification group.

The following examples illustrate the logic involved in processing a classifier rule (note the implicit and between the rule phrases):

Classifier MiddleAgeMan
If User has the following characteristics:
User.age > 35
and User.age < 65
and User.gender == "M" OR "male"

Classifier HighEarner
If User has the following characteristics:
User.income > 100000

Classifier rules are the building blocks of more complicated rules. Content selector rules can use classifier rules as they select personalized content to match a user or group profile. (For more information, see Content Selector Rules.)

Use the <pz:div> JSP tag to include a classifier rule in a JSP page. (For more information, see <pz:div> in the chapter "JSP Tag Library Reference" in the WebLogic Personalization Server Developer's Guide.

Adding "and" conditions to a classifier rule

To add "and" conditions to a classifier rule:

  1. From the Administration Tools Home page, click the Rules Management icon.

  2. Click the name of the ruleset that contains the rule.

  3. Click the name of the rule to which you want to add a phrase. (This rule already has at least one phrase.)

  4. Click Phrase to launch the Create If Phrase Wizard.

  5. Select the Single-Value With Constant radiobutton, then click Next.

  6. From the Properties list, select a property used for the rule, then click Next.

  7. Select a comparator and enter a value to compare against the selected property.

  8. Click Or if you want other conditions to evaluate against the same property, then click Save.

  9. The Edit Rule page appears, with the rule displayed as a link below the first rule, joined by an "and."

Example:

The following example produces a rule that says:
"If the customer is a rock climber and lives in Denver, then show message about a sale at Mountain Sports."

The classifier rule would look like this:

USER.Customer Properties.CustomerType==Climber
and USER.Customer Properties.ContactAddressCity==Denver

The jsp page would look something like this:

<pz:div

ruleSet="jdbc://com.beasys.commerce.axiom.reasoning.rules.RuleSheetDefinitionHome/ShopperRules"
rule="DenverClimber"
id="classifier">

    There's a sale going on at Mountain Sports this weekend!<br>

</pz:div>

Creating Classifier Rules Based on Request Properties

To create classifier rules based on request properties:

First, use the Administation Tool to create the request property.

  1. Click the Property Set Management icon. The Property Set view page appears.

  2. Create a request property set

    or

    Select an existing request property set to which you would like to add a property.

  3. To create the property, click Create, then complete the form. (In the example to follow, we will create a propery called age.)

  4. You can now set the default value for the property, or you can set the value within the HTTP request using JSP.

Next, create the rule that uses the request property

Follow the same steps for creating a classifier rule, but select the desired request property from the drop down list in step 2 of the wizard.

Example

The following example produces a rule that says, "If this person is middle-aged, display `Every vote counts. Get out and vote!'"

The rule: (Ruleset is called RequestAge, and rule is called middleage)
REQUEST.requestPropertySet.userAge>40
and REQUEST.requestPropertySet.userAge<70

The jsp page:
<%@ taglib uri="pz.tld" prefix="pz" %>

<%-- Request properties should be set/get with
HttpRequest.setAttribute()and HttpRequest.getAttribute() --%>

<% Long age = new Long(52);
request.setAttribute("age", age);%>

<pz:div
ruleset="jdbc://com.beasys.commerce.axiom.reasoning.rules.
RuleSheetDefinitionHome/RequestAge"
rule="middleage" >

        Every vote counts. Get out and vote!<br>
</pz:div>

     <%

    // Clean up the session in case you are testing this over and over request.removeAttribute("age");
%>

Content Selector Rules

Content selector rules construct queries on the fly and return content based on the user profile. This type of rule adds time and content components to the basic classifier rule and may use references to classifier rules to define it. It also produces dynamic queries at runtime to select content from a document collection.

The power of producing dynamic queries that match content with user profiles allows content selectors to deliver highly customized content to end-users. Since content selector rules can use queries to select content based on run-time parameters, they allow the system to match personalized content to user profiles.

Note: Although a profile may meet the criteria of a content selector rule, the rule may not return any content objects. Why? If no content matches the query's criteria, the query cannot return a content object.

Content selector rules contain three parts. Each part contains zero to many phrases. The generic description of each rule part includes:

Example:

In this example, we are creating a rule that says:
"If the user is a high income middle aged man with a net worth over a million (dollars), then show him all HTML documents that are less than 20,000 (characters) with an investment_ type that matches the user's investment type and investment_qualities that match the user's risk preference." (This requires that "investment_type" and "investment_qualities" are fields in the content metadata.)

The following example demonstrates the prototype for a content selector rule:

ContentSelector JanuaryStockQuotes (type: StockQuote)
If user has the following characteristics:
Classifier MiddleAgeMan
and Classifier HighEarner
and User.net_worth > 1000000

And when:
Now >= "Jan 01, 2001, 00:00:00 MST"
and Now < " Feb 01, 2001, 00:00:00 MST"

Then select Content where:
Content.size < 20000
and Content.MIMEType LIKE "*html*"
and Content.investment_type == User.investor_type;
and ANY Content.investment_qualities == User.risk_preference
and Content.creation_date > Now

Example:

The following example shows how to implement a content selector rule. We are creating a rule that says:
"Show rock climbers the climbing gear that corresponds to their climbing ability."

First, create the property set and the properties that the rule uses. The following table provides an example of the User Property Set "Climbers".

Property

Value

name

Cindy Climber

climber

true

ability

moderate

Next, create the rule set and rule for "Climbers". In this example, the rule set is "ClimberRules" and the rule name is "GearDisplay".

If User.Climbers.climber == true
Then select Content where:
Content.climberClassification == User.ability

Finally, we use the rule with JSP tags in the *.jsp page:

<%-- Info only -- %>
<um:getProperty propertySet="Climbers" propertyName="ability"
id="climberAbility" />
<um:getProperty propertySet="Climbers" propertyName="name"
id="climberName" />
<p> Climber <%=climberName%> climbs at a <%=climberAbility%> level.

<%-- Now display content geared towards their climbing ability --%>
<pz:contentselector id="stuff"
ruleset="jdbc://com.beasys.commerce.axiom.reasoning.rules.
RuleSheetDefinitionHome/ClimberRules"
rule="GearDisplay"
contenthome="com.beasys.commerce.axiom.document.DocumentManager"
max="-1" />

<es:forEachInArray id="product" array="<%=stuff%>"
type="com.beasys.commerce.axiom.content.Content">
<p>
<ul>
<li><cm:printProperty id="product" name="productName"
encode="html"
/>
<li><cm:printProperty id="category" name="productCategory"
encode="html" />
</ul>
</es:forEachInArray>

Note: Once you define a content selector rule and the content type it uses, you cannot change the content type.

Note: Use the <pz:contentSelector> JSP tag to include content selector rules in JSP pages. (See <pz:contentSelector> in the chapter "JSP Tag Library Reference" in the WebLogic Personalization Server Developer's Guide.)

Debugging Rule Sets

You might notice that a rule set you have used in the past begins functioning icorrectly. This behavior is probably due to a change in the property set with which the rule set has a relationship.

What Is the Relationship Between Property Sets and Rules?

Rules rely on property sets to provide the properties they use to evaluate user and group profiles. If a property is modified after a rule that uses it has been created, rules may contain dangling references to properties that no longer exist or that have been changed.

As much as possible, you should avoid modifying properties after defining rules that rely upon them. Since the property set defines the schema for the properties the rules act upon, any change to the properties the rules use will affect the schema and may alter the validity of the rules. In general, be careful when modifying or deleting existing properties.

Note: You can add properties without affecting existing rules.

Content Type and Content Selector Rules

Another problem can occur when you change a content's metadata types after creating a content selector rule based on that content type's metadata. Remember that the content selector rule relies upon metadata to locate content. If you change content metadata and a content selector rule references the previous metadata, the rule will not work correctly.

 


Using the Rules Management Administration Tool

The Rules Management Administration Tool is an edit-time tool that provides an HTML-based GUI for creating, editing, and deleting rule sets.

The run-time rules service uses rule sets to create personalized content for end-users. The rule sets created via the Rules Management Administration Tools interface produce output that is stored in the database and evaluated at runtime.

Note: You should already have defined at least one property set before creating rule sets. Property sets provide the template that defines the parameters that rules act upon at runtime.

Creating a Rule Set

To create a rule set:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. On the Rules Management Home page, click Create. The Create a Rule Set edit page appears.

  3. Enter a name for the rule set in the Name field.

    Note: You must populate all fields that have a red star to their right before you can create the rule set.

  4. Enter a description for the rule set in the Description field.

  5. Click Create to save the rule set with the parameters you have selected. WebLogic Personalization Server saves the new rule set and returns to the Rules Management Home page.

    Note: Clicking Back cancels the operation and returns you to the Rules Management Home page without creating a new rule set.

Opening a Rule Set

To open a rule set:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. On the Rules Management Home page, click the name of the rule set to open. The Rule Set view page appears, displaying rule set information and a list of the classifier and content selector rules included in the rule set.

Editing Rule Set Properties

To edit rule set properties:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set you want to edit.

  3. On the Rule Set view page, click Edit in the Definition bar. The Edit Rule Set edit page appears.

  4. Enter a new name and description.

  5. Click Save to commit the changes or Back to cancel the changes. If you save the changes, the Rule Set view page appears with the new information displayed.

Saving a Rule Set

To save a rule set:

  1. On the Rule Set view page, click Finished. The rule set is saved with the changes you made and WebLogic Personalization Server returns to the Rules Management Home page.

    Note: This is the only time the rule set is saved, so ensure you click Finished before closing the rule set.

Deleting a Rule Set

To delete a rule set:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. On the Rules Management Home page, click Delete.

  3. Select the name of the rule set to delete from the Rule Set Name drop-down list box.

  4. Click Delete to permanently delete the rule set or click Back to cancel the delete operation. The Rules Management Home page appears after the delete operation completes.

    Note: You must click OK in the dialog box that appears to confirm the delete operation.

Navigating Between Rule Types

To navigate between rule types:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open a rule set. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. In the rules list, click To Content Selectors or To Classifiers to navigate to the top of the rule type sections.

Finding a Rule

To find a rule:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set which contains the rule you want to locate. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Locate the top of the rule type list-classifier or content selector type. (For the procedure to navigate between rule types, see Navigating Between Rule Types.)

  4. Click the letter in the alphabet bar that matches the first letter of the rule you want to find. An underlined letter indicates that a rule name begins with that letter. The browser displays the rule names beginning with the letter you selected at the top of the browser.

    Note: You can also scroll to the rule using the browser's scroll bar.

  5. Locate the rule you need. (For information about making changes to the rule, see Editing a Rule.)

Creating a Classifier Rule

To create a classifier rule:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set in which you want to create the rule by clicking the rule set name. (For instructions on creating a rule set, see Creating a Rule Set). The Rule Set view page appears.

  3. Click Create in the Classifiers bar of the Rules list. The Create a Classifier Rule edit page appears.

  4. Enter the rule's name into the Rule Name field.

    Note: Rule names cannot include spaces and punctuation.

  5. Enter a description of the rule into the Description field.

  6. Click Create to save the rule in the current rule set. The Create a Classifier Rule edit page refreshes and displays a message about the rule creation's success or failure.

  7. Create as many more rules as you need. Click Back to return to the Rule Set view page. The Rule Set view page appears with the new rule(s) you created displayed in the alphabetical rule list.

Editing a Rule

To edit a rule:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set that contains the rule by clicking the rule set name. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Locate the rule you want to edit. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. Edit the rule using the instructions included in this documentation.

Editing Rule Properties

To edit rule properties:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set containing the rule you want to edit. (For more information, see Opening a Rule Set.) The Rule Set view page appears.

  3. Find the appropriate rule to edit. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. Click Edit in the Definition bar. The Edit Rule Definition edit page appears.

  6. Enter a new name and description.

  7. Click Save to commit the changes or Back to cancel the changes. The Rule view page appears with the new information displayed.

Adding an If User Phrase to a Rule

To add an If user phrase to a rule:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set that contains the rule to which you want to add a phrase. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Find the rule you want to modify. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. Click Phrase to add a phrase to the rule. Step 1 of the Create If Phrase Wizard appears.

  6. Select the Single-Value with Constant template to define the phrase and click Next. Step 2 of the Create If Phrase Wizard appears.

    Note: Click Back in any wizard page to return to the preceding page in the Rules Management interface.

    Select the property to use to define the left operand of the rule phrase and click Next. Step 3 of the Create If Phrase Wizard appears.

  7. Select a comparator from the Comparator drop-down list box.

    The following table shows the possible comparators for each property type:

    String

    Boolean

    Integer

    Float

    Set

    ==

    ==

    ==

    ==

    contains

    !=

    !=

    !=

    !=


    >


    >

    >


    >=


    >=

    >=


    <


    <

    <


    <=


    <=

    <=


    Note: You can use "and" or "or" to connect expressions that contain comparators. These are the only conjunctions or disjunctions that are allowed in expressions that contain comparators.

  8. Enter a value into the Constant field.

  9. To add an "or" condition to the phrase, click the icon. The wizard page adds another Comparator drop-down list box and Constant field to the phrase below the current Comparator drop-down list box and Constant field.

  10. Select a comparator and enter a value into the new Constant field. Click the icon again to add any number of conditions to the phrase.

  11. When you have completed construction of the phrase, click Save to add the phrase to the rule or Back to return to the previous step of the Create If Phrase Wizard.

    Note: You can create "and" conditions by creating multiple phrases for the same rule.

Editing an If User Phrase

To edit an If user phrase:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set which contains the rule you want to edit. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Find the rule to edit. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. Click one of the phrases listed below the If the user has the following characteristics bar. Step 3 of the Create If Phrase Wizard appears.

  6. Select a comparator from the Comparator drop-down list box and enter a value into the Constant field.

  7. Click Save to commit the changes or Back to cancel the changes. The Rule view page appears with the changes you made to the phrase displayed.

Deleting a Rule Phrase

To delete a rule phrase:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set which contains the rule to which you want to add a phrase. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Find the rule which contains the rule phrase to delete. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. To delete a phrase, click the icon next to the phrase name. After you confirm the delete process, the page refreshes and the new page does not show the phrase you deleted.

Creating a Content Selector Rule

To create a content selector rule:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set in which you want to create the rule by clicking the rule set name. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Click Create in the Content Selectors bar of the Rules list. The Create a Content Selector Rule edit page appears.

  4. Select the content type from the Content Type drop-down list box.

  5. Enter the rule's name into the Rule Name field.

    Note: Rule names cannot include spaces and punctuation.

  6. Enter a description of the rule into the Description field.

  7. Click Create to save the rule in the current rule set. The Create a Content Selector Rule edit page refreshes and displays a message about the rule creation's success or failure.

  8. Create as many rules as you need. Click Back to return to the Rule Set view page. The Rule Set view page appears with the newly created rule(s) displayed in the alphabetical rule list.

Adding an If User Classifier to a Content Selector Rule Phrase

To add an If user classifier to a Content selector rule phase:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set which contains the rule you want to edit. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Find the rule to edit. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. Click Classifier in the If the user has the following characteristics bar. The Rule search page appears.

  6. Enter the name of the rule in the Classifier Name field and click Search to find a rule or click a letter to view all classifier rules that begin with the letter you click. Rules matching the search criteria populate the page when the search completes.

    Note: The * character allows you to perform a wildcard search. Using the * character alone returns a list of all classifier rules.

  7. Check the boxes next to the classifier you want to add to the rule.

  8. Click Save to commit the changes. The Rule search page refreshes and displays a message about the process's success or failure.

  9. Add as many classifier rules as you need. When you finish, click Back to return to the Rule view page. The Rule view page appears with the new classifier(s) displayed beneath the If the user has the following characteristics bar.

Adding an And When Phrase to a Content Selector Rule

To add an And When phrase to a Content selector rule:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set which contains the rule you want to edit. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Find the rule to edit. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. Click Phrase in the And when bar. The Edit And When Phrase edit page appears.

  6. Select a comparator from the Comparator drop-down list box.

  7. Click the icon to display the calendar, then select a date and time to compare. Click Save within the calendar window.

    Note: You cannot enter a date by typing into the date field. The field only accepts the date string in `MM/dd/yyyy HH:mm:ss z' format.

  8. Click Save to add the phrase to the rule or click Back to cancel the phrase creation and leave the rule as it was before. The Rule view page appears and displays the new phrase.

Adding a Then Display Content Phrase to a Content Selector Rule

To add a Then Display Content phrase to a Content selector rule:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set which contains the rule you want to edit. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Find the rule to edit. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. Click Phrase in the Then display content based on bar. Step 1 of the Create Then Phrase Wizard appears.

  6. Select a template to use to define the content query and click Next. Step 2 of the Create Then Phrase Wizard appears.

  7. Select a property from the Property list and click Next. Step 3 of the Create Then Phrase Wizard appears.

    Note: The list receives its data from the metadata stored in the document management system.

  8. Select a comparator and one of the following, depending on the template:

Editing a Then Display Content Phrase

To edt a Then Display Content phrase:

  1. From the Administration Tools Home page, click the Rules Management icon. The Rules Management Home page appears.

  2. Open the rule set which contains the rule you want to edit. (For instructions on creating a rule set, see Creating a Rule Set.) The Rule Set view page appears.

  3. Find the rule to edit. (For information on locating a rule, see Finding a Rule.)

  4. Click the name of the rule. The Rule view page appears.

  5. Click one of the phrases listed below the phrase bar. Step 3 of the Create Then Phrase Wizard appears.

  6. Select a comparator from the Comparator drop-down list. If the content selector template is "Value with Constant," enter a value into the Constant field.

  7. Click Save to commit the changes or Back to cancel the changes. The Rule view page appears with the changes you made to the phrase displayed.