Basic Rule Wizard

This topic has the following sections:

Overview

Basic Rules create and invoke 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 Navigator. The Basic Rule Wizard presents the complete rule contents, 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 scripting language, you can still use the wizard.

Even if you intend to implement more complex rules, you can use the wizard to become familiar with rule logic and the add-in environment.

Basic_Rule_Wizard.png

Why to use the Basic Rule Wizard

Within Archibus, Java is the native server-side scripting language for any logic or automation. Whether you automate user interfaces, or script program logic, eventually the task involves execution of Java commands.

A number of use cases exist where you need to add logic, but but may not want to use a full-featured extension environment like Eclipse:

  • Business process owners or business analysts who want to performing repetitive calculations or roll ups.
  • Database Managers who want to script simple server-dependent or data-dependent logic.
  • System Administrators who want to issue update scripts that the customer site can simply copy and execute.
  • Logic Add-In Managers who want to learn the larger extension environment, but who need an “on ramp” that develops the skills step-by-step..

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 workflow rules within the Web Central environment that you can invoke from form actions, or from the Navigator as a regular Workflow Rule. You can also copy the rule file to deploy it as a script, or define new rules with no knowledge of Java. You only need familiarity with some form of scripting.

Advanced Features for Extension Managers

Basic rules may not handle complex use cases, or cases where partners or customer sites wish to alter the deeper logic of off-the-shelf applications. To do so, launch Eclipse; this is the same integrated development environment that we use to develop extensions. Here you can reuse basic rules, rely on a complete toolset for scripting logic, and accomplish these aims:

  • Add your own personalized handlers for user-interface events.
  • Use your own set of nested routines or classes or use third-party classes.
  • Alter the deeper logic for existing Archibus applications.
  • Write high-performance actions that do not need repeat compilation.
  • Use an IDE for logic development.

How to use the Basic Rule Wizard

To access the Basic Rule Wizard, use the Technologies / Business Logic Add-Ins / Workflow / Basic Rule Wizard task. The wizard leads you through several steps.

Step one: Select New or Existing Rule tab

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

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

Step two: Select Rule Template

For new rules, supply a rule name, such as MyRule . Optionally, add a template that inserts boiler plate for typical actions, such as executing a field formula or an SQL query.

Step three: Configure Script tab

Configure Script tab has two panels. The upper panel cointains your script, to modify as you like. For instance, if you add a template to execute an SQL query, you can alter the SQL statement as required. If you invoke a Field Formula, you can change both the calculation and the field that holds the result.

Click Test to compile and run your script. Errors, if any, appear in a pop-up dialog.

Click Save and Next to save the script to the basic-rules folder as a Java file, such as BasicRules_MyRule.java .

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

Step four: Add Rule to Process Navigator tab

Open the Process Navigator tab to add the rule to the Navigator as a task. The rule appears as a workflow rule or job, with a Start button.

Configuring Scripts

Configure scripts with messages that log progress and show job status.

Logging Progress

Use log.debug() to insert progress messages in your script. These messages appear in the logging panel at the bottom of the Configure Script tab. For example:

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 Navigator or a form interface, no debug messages appear. If a job requires 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.

Note: Progress bar appears when you run the rule from the Navigator, but not when you run the rule in the Configure Scripts tab.

Basic_Rule_Wizard_Progress_Bar.png

Code below contains sample statements that update the status bar:

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);

Comments

You can use Java comments in basic rule scripts. Do not use the "class" keyword in comments.

Invoking Basic Rules

You can invoke Basic Rules from a web page.

Executing Basic Rules from the URL

To execute Basic Rules manually, copy a .java file that contains the rule to the schema\ab-site\common\resources\basic-rules folder. Then invoke the rule from the URL. For instance, if the .java file were named BasicRules_myRule.java , invoke the rule from the URL as follows:

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

The single-job view loads, then invokes the rule specified after ruleId when you click Start Job .

Adding Basic Rules to the Navigator

To add Basic Rules to the Navigator, create a Process Tasks table (afm_ptasks) record, then enter a URL like that immediately above as the Task File parameter.

Executing Basic Rules from a Form

To invoke a Basic Rule as a form action, include the ruleId in an <action /> tag in the relevant form. Add-in managers need not never need to worry about compiling Basic Rules, since the program compiles them automatically at each invocation.

Securing Basic Rules

If security requires, you can restrict which users create and invoke Basic Rules. To do so, change the Security Group of the BasicRuleWizService in the Workflow Rules table. To disable the security feature altogether, remove the Security Group record from the Workflow Rules table.

Next Steps

If you inspect the file produced by the Basic Rule Wizard, you see it is a standard Java file. You can modify it at any point with the Basic Rule Wizard. You can also edit the file as needed in the Eclipse IDE.

You need not limit yourself to techniques presented in the templates. Use any of the skills covered in Add-In Manager > Business Logic Extensions > Skills in System Management help. If you know Windows BasicScript, refer to Porting Basic Script To Java for information about techniques to implement typical operations in Windows BasicScript files.

To use the full Eclipse IDE, refer to Installing Application Extension Environment .