Samples > Sample stores > Consumer direct sample store > IBM Gift Center for the Consumer direct sample store > IBM Gift Center > Customize the data persistence layer


IBM Gift Center business rules and the GRREGRULE table

The IBM Gift Center contains several business rules that are stored in the GRREGRULE database table. Each rule is simply a value in the database. It is up to the rule implementer to decide how complex to make the rule. All rules are loaded on server startup, so if you apply a manual database update to any rule, then the server must be restarted to take effect.

The GRREGRULE table is defined...

Column Type Column Name
INTEGER GRREGRULE_ID
INTEGER STOREID
INTEGER NAME
VARCHAR DESCRIPTION
VARCHAR EVENTTYPENAME
VARCHAR GRRULEVAL

The business rules data is loaded when you publish the Gift Center store archive. The data is specified in the gift_registry.xml file, within the store archive file.

The following business rules are configured in the GRREGRULE table:

Business rule name Business rule description
1000 The maximum number of registries allowed per registrant should not exceed a preconfigured number. The default is 10 registries per registrant.
1001 The maximum number of registry search results (perfect and similar match) should not exceed a preconfigured number. The default is 200 search results.
1002 When in edit mode, indicates whether the registry event date can be updated to a past date. The default is 1 to indicate that an event date cannot be in the past.
1003 When updating gift items, indicates whether the requested quantity can be less than the purchased quantity. The default is 1 to indicate that the a gift giver cannot purchase a gift (for the registry list) for a registrant, if they have not registered for this item.
1004 Indicates whether gift items with purchase records can be removed by the registrant. The default is 1 to indicate that purchased items cannot be removed from the gift registry list.
1005 For display of purchase records, indicates whether non-requested purchase items should be displayed. The default is 1 to indicate that non-requested items should not be displayed.
2000 The total number of items for a registry should not exceed a preconfigured number. The default is 200 to indicate a registry list should contain no more than 200 items.
2001 The maximum number of the same item added to the registry should not exceed a preconfigured number. The default is 99 to indicate that a registrant can specify a maximum of 99 units of one item.
2002 Registrants become eligible for the store's completion program discount at x days past their event date. The default is 1 to indicate that registrants can purchase items through the completion program one day after the event.
2003 Registrants are no longer eligible for the store's completion program discount at y days past their event date. The default is 365 to indicate that registrants can purchase items through the completion program up to one year after the event.
2004 A registry can be created with a event date of x days in the past. The default is 0 to indicate that registrants can never create registries for a date in the past.
2005 A registry can be created with a event date of y days in the future. When there are no event types specified for this rule, the default is 1824 to indicate that registrants can create registries with event dates up to 1824 days from the creation date (that is, just under 5 years).

You can configure rules on a full store basis, on an event type basis, or by both store and event type. When configuring rules, consider the following guidelines:

For example, to set a rule for all event types and stores, load data similar to the following:

GRREGRULE_ID               10000
STOREID                 -1
NAME                    1000
DESCRIPTION             'Maximum # of registries allowed per registrant'
EVENTTYPENAME           'Default'
GRRULEVAL               '5string5'

For the above code, the system scans through the GRREGRULE table looking for a STOREID that matches getStoreId() and a GRREGRULE.NAME value that matches the constant set. If no rule matches, the system performs another query is to look up a site default meaning to search for storeId with a value of -1 and the constant value passed through. The following example uses the data above:

String sTempRuleResult = 
GiftRegistryRules.getRuleValueAsString(5001, 1000);

The output would yield 5string5 because of an implicit site level rule where storeId=-1 and name=1000 exists.

Ensure that you know what type of value you stored in the GRRULEVAL column. In the code example above, the value stored is a string; hence, the system retrieves a string value. Typically, if a rule is looked up and not found in the database, the system does not validate against it, and ignores the rule instead.


Related tasks

Configure business rules for customization

Related reference

IBM Gift Center business rules

Extend commands for new business rules


+

Search Tips   |   Advanced Search