This content has been archived.

Table of Contents

Java and Activities Overview

The Activities and Java topic category covers information about three types of rules; activity rules, library rules and function rules.

What are activities?

An activity rule can perform computations, create, update, or delete objects, or support user interactions. Activity rules are most like traditional computer programs, in that they consist of a sequence of steps that are typically performed in order. Each step contains a primitive operation known as a method. For example, an activity can fetch a work item from the database, compute new values for some of the properties in the work item, and save the updated work item back into the database.

Activities are popular with many Process Commander application designers who have previous programming experience. However, activities are only one of dozens of useful rule types. By design, activities have limitations and restrictions that improve maintainability and performance, but are important to understand.

What are libraries and functions?

Process Commander, like Microsoft Excel and many other software products, includes libraries of functions that can be called to perform various useful calculations. For example, the DateTimeDifference( ) function computes the days, hours, minutes and seconds between two moments in time. Functions support a wide variety of processing needs, including date and time calculations, manipulation of text strings, operations with HTML styles, importing data from files, and exporting data to Excel. Each library holds a group of related functions.

No knowledge of Java programming is required to use a function (or to execute an activity). Internally, Process Commander automatically produces Java code from these rules that implements the required function. (To create a custom function — one not found among the hundreds of standard functions provided — does require a developer with Java skills.)

Key features of activities

Activities consist of one or a few dozen numbered steps, that are ordinarily executed in order from the top one listed on the activity rule form to the bottom one. Each step contains an atomic operation known as a method. For example, the Property-Set method sets the value of one or more properties to a literal constant value, or to the value of a different property, or to the result of a computation. (This method is the Process Commander equivalent of an assignment statement such as Area = Width * Height.)

Many methods add, update, or delete values on the clipboard, a private memory area for each user. Other methods save clipboard contents into the PegaRULES database. Other methods send an HTML or XML document to a user's browser.

Most activities contain no more than 20 steps. Within the sequence of steps, processing can jump ahead to a later-numbered step, identified by a label, based on a conditional test. (Jumping back to an earlier step, to cause execution to loop, is not allowed. However, limited "repeat-until" loops are supported. ). The example below has five steps, executed in sequence. Since the Label column is blank, none of these steps is ever reached by a jump.

Activity example

Show Calls displayActivities can call other activities, which can call other activities, and so on. This capability promotes modularity and reuse (sharing of common capabilities) and allows activities that might require many steps to be structured as a set of interrelated but shorter activities. The Show Calls button presents a display of activity calling relationships; an example appears at the right.

Like other rules, activities belong to a RuleSet and version. When activity Alpha calls activity Beta, the system uses rule resolution (in the context of a particular user's RuleSet list) to search for the right Beta activity to run.

Clipboard ViewerMost methods examine, update or create properties on a clipboard page. Each user's clipboard is a private temporary memory area, consisting of a collection of named pages in a tree structure. Each page holds property-value pairs. For example, the Page-New method adds a new page to the clipboard, specifying its name. The new page may initially be empty. The Property-Set method adds or updates the value of a property on a clipboard page. The Clipboard tool, a debugging aid, lets application designers see and interact with a snapshot of their current clipboard.

While activities provide power and flexibility, designers must determine when and how they execute. In contrast, declarative rules execute automatically whenever certain conditions are met, and so are the alternative to activities and the recommended "best practice" in many situations.

Restrictions on the size and power of activity rules do not, in practice, limit what application designers can achieve with activity rules. The restrictions encourage good practices and help prevent difficult-to-analyze issues like infinite loops, deadlocks, and difficult-to-maintain "spaghetti" code.

Important terminology

Function rule — A rule that performs a computation or other useful operation, based on the value of input parameters. Function rules are grouped into libraries. The name of the library is part of the formal name of each member function.

Library — A named collection of function rules, typically all relating to one general theme, such as calendar dates.

Local variables — A named text value, number or date that is used only temporarily during the execution of an activity. When the activity completes, the local variables are no longer defined.

Method — One of about 70 atomic operations that can happen in a single activity step. For example, the Property-Set method updates the value of one or more properties. The Obj-Open method retrieves a single row of a table in the PegaRULES database and converts it to a clipboard page or pages.

Parameter — An input value to a specific execution of an activity that can affect the behavior and operation of the activity. For example, if an activity is designed to change the status of a work item, one of the input parameters is the key of the work item. (Other parameter values can be "return" values, available to a calling activity after the called activity completes.)

Page — A named, structured collection of property name and property value pairs. The clipboard is a collection of named pages, organized into a tree structure.

Primary page — A clipboard page that is the default page for the operations of an activity. While one activity may update multiple pages, if no page is explicitly identified in a step, the method in the step typically operates on the primary page.

Tracer tool — An interactive debugging tool that lets you display each step of activity execution, pause or restart execution, and display clipboard values.

Suggest Edit

100% found this useful

Related Content

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.