Basic Rule Wizard

This topic has the following sections:

Overview

Uses of the Basic Rule Wizard

Using the Basic Rule Wizard

Configuring Scripts

Invoking Basic Rules

Securing Basic Rules

Next Steps

Overview

Basic Rules are an easy way of creating and invoking logic for commonly defined actions – such as calculations or roll up actions. You can use the wizard to create new workflow rules and put them on the Process Navigator. The Basic Rule Wizard presents the complete rule contents for you to modify to suit your circumstances – for instance, you can change the table and field names for a Field Formula or paste in an example from the help. If you have used any scripting language, you will be able to use the wizard.

Basic rules are very similar to the “Basic Script” in the Windows client/server environment. However, the basic rules run on the Web Central server and can be created and deployed over the Web.

Even if you intend to implement more complex rules, you may wish to first use the Basic Rule Wizard to familiarize yourself with the logic add in environment.

Uses of the Basic Rule Wizard

Within ARCHIBUS, Java is the native server-side scripting language for any logic or automation. Whether you are automating user interfaces or scripting logic, eventually the task comes down to executing Java.

There are a number of use cases in which users will want to add logic but do not need to or wish to use a full-featured extension environment like Eclipse:

Basic Rules for Administrators

The Basic Rule Wizard suits these purposes, as it is a step-by-step wizard that lets you define scripted actions. The Basic Rule Wizard creates “basic rules” within the Web Central environment. These are ARCHIBUS workflow rules that:

Advanced Features for Extension Managers

There are always more intensive use cases, or cases where partners or customer sites wish to alter the deeper logic of the off-the-shelf applications. The basic rules cannot handle these cases. However, you can use the same techniques learned using basic rules and you can re-use all of your basic rule scripts in the larger extension environment for ARCHIBUS. This extension environment uses an industry-standard environment, Eclipse, to provide an extremely high-productivity tool set.

You will wish to use the larger extension environment if you wish to:

Using the Basic Rule Wizard

To access the Basic Rule wizard use the Process Navigator: Technologies / Business Logic Add-Ins / Workflow / Basic Rule Wizard task.

The wizard will lead you through several steps.

Select New or Existing Rule tab

If you choose to create a new rule, the program will take you to a new rule dialog.

If you select to alter an existing rule, the program will list all rules currently in the schema\ab-products\common\resources\basic-rules\ folder.

Select Rule Template

For new rules, you supply a rule name, e.g. "MyRule".

You can optionally add a template that will insert boiler plate for typical actions, such as executing a field formula or an SQL query.

Configure Script tab

This tab has two panels. The upper panel is your script which you can modify as you will.  For instance, if you have added a template for executing an SQL query, you can alter the SQL statement to be whatever you like. If you have added a Field Formula invocation, you can change the field holding the result and the calculation to execute to suit.

Pressing the "Test" button compiles and runs your script. If there are any errors, they will appear in a pop-up dialog.

Pressing "Save and Next" saves the script to the basic-rules folder as a Java file (e.g. BasicRules_MyRule.java).

When you save the rule, the program adds the class declaration and the #import statements that you need to run the rule. If you inspect the resulting file, you will see that your script is a standard Java file.

Add to Process Navigator tab

Here you can add your rule to the Process Navigator as a task. The rule will appear as a workflow rule Job form with a Start Button.

Configuring Scripts

Logging Progress

You can insert messages in your script that will show in the logging panel at the bottom of the Configure Script tab using the log.debug() method:

String message = "My first rule called";

log.debug(message);

These messages also appear in the WEB-INF\config\archibus.log file.

Showing Job Status

When you or your users run the rule from the Process Navigator or a form interface, they will not see any debug messages. If a job is going to take more than a few seconds, use the job status object to set the messages and percent complete on the "thermometer-style progress bar that appears when you start the job. (Notice that you will see this progress bar when you run the rule from the Process Navigator, but not when you run the rule in the Configure Scripts tab).

Example statements updating the status bar are below.

status.setResult("Hello World");

status.setTotalNumber(100);

status.setCurrentNumber(0);

status.setMessage("Starting");

// do some operation that takes time

status.setCurrentNumber(50);

status.setMessage("Halfway");

// do another operation that takes time

status.setCurrentNumber(100);

status.setMessage("Finished");

status.setCode(JobStatus.JOB_COMPLETE);

 

Invoking Basic Rules

Executing Basic Rules from the URL

You can execute Basic rules “manually” by copying .java file containing the rule to the schema\ab-site\common\resources\basic-rules folder, and then invoking the rule from the URL. For instance, if the .java file were named “BasicRules_myRule.java”, you would invoke it from the URL like this:

ab-single-job.axvw?ruleId=AbCommonResources-BasicRules_myRule

The single-job view will load and invoke the rule given by the ruleId when the user presses the Start Job button.

Adding Basic Rules to the Process Navigator

You add Basic Rules to the Process Navigator by creating a Process Tasks table (afm_ptasks) record per usual, and then entering a URL like that immediately above as the "Task File" parameter.

Executing Basic Rules from a Form

Add-in managers can also invoke Basic Rules as form actions by including their ruleId in an “<action />” tag in their forms. You never need to worry about compiling Basic Rules, since the program compiles them automatically at each invocation.

Securing Basic Rules

Security-conscious sites can restrict which users can create and invoke Basic Rules by changing the Security Group of the BasicRuleWizService in the Workflow Rules table. You can disable the feature by removing this Workflow Rule record altogether.

Next Steps

If you inspect the file produced by the Basic Rule Wizard, you will see that it is a standard Java file. You can modify it again using the Basic Rule Wizard. You can also continue to edit the file in the Eclipse IDE.

You do not need to limit yourself to the techniques presented in the templates. You can use any of the skills that are discussed anywhere within the Logic Add In topics of the help. In particular, if you are familiar with Windows BasicScript, please refer to this topic for more information to orient you to the techniques for implementing the typical operations you find in Windows BasicScripts files: Porting Windows BasicScript to Java.

If you are interested in using the full Eclipse IDE, refer to this topic: Installing the Application Extension Environment.