Some small improvements for CDM RuleFrame (including code)

After a year full of stuff like Spring, UIX and ADF, JHeadstart, Struts and JSF, XSL-T and the likes, PL/SQL and SQL, I had a bout of nostalgia this week as I participated in a more ‘traditional’ project, although with the very latest versions of the ‘traditional tools’. Designer 10g, WebForms 10g, Headstart 9i-certified-for-10g, Repository Object Browser and CDM RuleFrame. In a way a trip down memory-lane, although I have not done a lot of work with WebForms 10g and I am looking forward to an opportunity to work with JDAPI and WebUtil in practice. And it is nice to have a little family reunion as I still consider both the ROB and CDM RuleFrame as my babies.

There are some things I have always found annoying while working with CDM RuleFrame – apart from the fact that I would like to give the whole framework a major overhaul, see for example my post The future of CDM RuleFrame – the Oracle framework for server-side business rules. I have made some changes to the Utilities underlying CDM RuleFrame to make life more comfortable:

  • Show list of all available parameters – In the PL/SQL Block where I have to actually code the business rule, I would like to see a list of the parameters that RuleFrame will make available to me at runtime – I don’t like checking the list of Arguments, it is far easier to directly see and copy/paste the parameter names
  • Overwrite Business Rule Design Definitions – I do not like the fact that the Business Rule Design Transformer cannot overwrite or replace existing Business Rule Design Definitions, if I were to tell it do do that; now I have to manually remove the Business Rule Design Definition (both Trigger and Trigger Module) before I can run the Business Rule Design Transformer on changed Business Rules.
  • Create Arguments for Primary Key columns – I am most annoyed by the fact that if I want my business rule validation code to make use of the Primary Key of the current record, I have to manually create a Program Argument. Normally, the BRDT takes Function Attribute Usages and creates Arguments from them. However, my Primary Keys are ID columns that I have had the Designer Database Transformer create as Surrogate Primary Keys. Therefore, these columns are not based on Attributes and hence I cannot create Function Attribute usages for them and therefore the BRDT cannot create Arguments

As the CDM RuleFrame utilities are PL/SQL packages, it is fairly simple to inspect them and modify them. If you how to write PL/SQL, know something about the inner workings of the Headstart Utilities as well as the meta-model and API of Oracle Designer, it is really quite straightforward. In this case, I have made some changes in the packages HSU_BRTR and HSU_CRBR.

The effect is the following: I have an existing Business Rule – BR_EMP001_ATT – for which I have run the Business Rule Design Transformer. Now I have made some changes in the Business Rule definition: I have changed the Short Definition and I have added the <PK/> tag to the Function Entity usage of Entity EMP; through this I want to indicate to the BRDT that I would like to have an Argument created for the Primary Key ID that was added as Surrogate Primary Key by the Designer Database Design Transformer.

Some small improvements for CDM RuleFrame (including code) rf pktag

When I run the Business Rule Design Transformer, I want it to overwrite the existing Business Rule Design Definition for BR_EMP001_ATT. I want it to create an Argument for the ID column in the EMPLOYEES table and and I want it to write a line of comment in the PL/SQL block, specifying all parameters available to me when I write the code for this business rule.

Here is the run screen for the Business Rule Design Transformer – notice the new parameter “Overwrite Existing BRDDs” that my code alterations have added:
Some small improvements for CDM RuleFrame (including code) rf runform

After running the Business Rule Design Transformer, the following logging is reported:
Some small improvements for CDM RuleFrame (including code) rf log

The result is, as anticipated, that the existing BR_EMP001_ATT is replaced/overwritten. It has an argument for the EMPLOYEES.ID column and it contains an additional comment-line hinting the available input parameters to the Business Rule programmer:

Input parameters available in the validation code:  p_salary, p_id

In Designer 10g, this looks like this:
Some small improvements for CDM RuleFrame (including code) rf after run

Resources and Downloads

Since I feel these changes are beneficial to RuleFrame designers and developers, I gladly make the code available. You can download a zip-file with the sources for hsu_brtr.pks and hsu_brtr.pkb as well as hsu_crbr.pkb here:CdmRuleFrameChanges_27aug2005.zip.

Installing the scripts is straightforward:
– extract the files to <hsd_home>\ hsu\scripts\pb\AMIS
– start SQL*Plus as Headstart Utilities Owner (often HSU65)
– run the three scripts: hsu_brtr.pks, hsu_brtr.pkb and hsu_crtr.pkb
– execute the following statement:

begin
  hsu_brtr.install;
  commit;
end;

If you now (re)start the Headstart Utilities Start Form, you should benefit from the three functional enhancements described in this post.

Note: these changes are based on the versions of the source files shipped as part of the Headstart 6.5.3.2 Patch; if you have different base versions of these files, you cannot just replace your scripts with the scripts in this zip-file. In that case, you either first need to ugrade to 6.5.3.2 or you have to manually make changes similar to the ones that I have made in the versions of the files that you have in use.