Chapter 2. A Guided Tour of JBoss jBPM GPD

2.1. Creating a jBPM Project

We have included a wizard in the GPD plugin to create a jBPM project. We have opted to create a project containing based on a template already containing a number of advanced artifacts that we will ignore for this section. In the future we will elaborate this wizard and offer the possibility to create an empty jBPM project as well as projects based on templates taken from the jBPM tutorial.

The jBPM projects in Eclipse are in fact Java projects with a number of additional settings, so we switch to the Eclipse Java perspective. To create a new jBPM project using the project creation wizard, we select 'New->Project...' and in the New Project dialog, we select 'JBoss jBPM -> Process Project' (Figure 2.1, “New Project Dialog ”). Clicking 'Next' brings us to the wizard page where we have to specify the name and location for the project. We choose for example 'Hello jBPM' as the name and accept the default location (Figure 2.2, “Process Name and Location ”).

New Project Dialog

Figure 2.1. New Project Dialog

Process Name and Location

Figure 2.2. Process Name and Location

Clicking on Finish results in the project being created. The wizard creates four source folders : one for the processes ('src/process'), one for the java sources ('src/java'), one for the unit tests ('test/java') and one for the resources such as the and the files ('src/resources'). In addition a classpath container with all the core jBPM libraries is added to the project (Figure 2.3, “Layout of the Process Project ”

Layout of the Process Project

Figure 2.3. Layout of the Process Project

Looking inside the different source folders will reveal a number of other artifacts that were generated, but we will leave these untouched for the moment. Instead, we will look at another wizard that enables us to create an empty process definition.

2.2. Creating an Empty Process Definition

When the project is set up, we can use a creation wizard to create an empty process definition. Bring up the 'New' wizard by clicking the 'File->New->Other...' menu item. The wizard opens on the 'Select Wizard' page (Figure 2.4, “The Select Wizard Page ”).

The Select Wizard Page

Figure 2.4. The Select Wizard Page

The Create New Process Definion Page

Figure 2.5. The Create New Process Definion Page

Selecting the 'JBoss jBPM' category, then the 'Process Definition' item and clicking on the 'Next' button brings us to the 'Create Process Definition' page (Figure 2.5, “The Create New Process Definion Page ”). We choose 'hello' as the name of the process archive file. Click on the 'Finish' button to end the wizard and open the process definition editor (Figure 2.6, “The Process Definition Editor ”). As you can see in the package explorer, creating a process definition involves creating a folder with the name of the process definition and a '.par' extension and populating this folder with two .xml files : gpd.xml and processdefinition.xml. The first of these two contains the graphical information used by the process definition editor. Though you can view the contents with an ordinary xml editor, the default editor opening this file will be the process definition editor. The processdefinition.xml file contains the actual process definition info without the graphical rendering info. At present, the GPD assumes that these two files are siblings. More sophisticated configuration will be supported later.

The Process Definition Editor

Figure 2.6. The Process Definition Editor

2.3. A Minimal Process Definition

We will create a very simple process definition, consisting of a begin state, an intermediate state and an end state.

2.3.1. Adding the Nodes

Select respectively 'Start', 'State' and 'End' on the tools palette and click on the canvas to add these nodes to the process definition. The result should look similar to Figure 2.7, “A Simple Process With Three Nodes ”

A Simple Process With Three Nodes

Figure 2.7. A Simple Process With Three Nodes

2.3.2. Adding Transitions

We will connect the nodes with transitions. Select the 'Transition' tool in the tools palette and click on the 'Start' node, then move to the 'State' node and click again to see the transition being drawn. Perform the same steps to create a transition from the 'State' node to the 'End' node. The result looks like Figure 2.8, “A Simple Process With Transitions ”.

A Simple Process With Transitions

Figure 2.8. A Simple Process With Transitions

2.4. The Outline View

You can see an outline of the process being drawn in the Eclipse outline view if it is visible. The process outline comes in two different flavours. One of them is the classical treeview. You can see the expanded tree outline view of our minimal process in Figure 2.8, “A Simple Process With Transitions ”. The other possibility is to view the outline as a scrollable thumbnail. This possibility is illustrated in Figure 2.9, “The Outline as Thumbnail ”. Because the process definition is still fairly simple with as little as three nodes, this thumbnail is at the moment bigger than the actual graph, but for complex graphs this feature is particularly interesting.

The Outline as Thumbnail

Figure 2.9. The Outline as Thumbnail

You are able to toggle between these two outline views using the outline toolbar buttons.

2.5. The Properties View

If the Eclipse Properties view is visible, the relevant properties of the selected item are shown. Some of these properties may be directly editable in the properties view. An example of a directly editable property is the name property of the process definition. As you can see in Figure 2.10, “The Properties of a Process Definition ”, the name property of the process definition can be changed to 'jbay'.

The Properties of a Process Definition

Figure 2.10. The Properties of a Process Definition

When we select the first transition, either by clicking on it on the canvas or by clicking on its node in the tree outline view, we see the properties of this transition in the properties view (Figure 2.11, “The Properties of a Transition ”). We are able to edit the name of the transition, but the 'Source' and 'Target' properties are read-only. We change the name of the first transition to 'to_auction'. We repeat this name change for the second transition and name it 'to_end'.

The Properties of a Transition

Figure 2.11. The Properties of a Transition

2.6. Direct Editing

Some properties can be directly edited in the graphical editor. One example of this is the 'Name' property of nodes. You can edit this directly by selecting the node of wich you want to change the name and then click once inside this node. This enables an editor in the node as shown in Figure 2.12, “Directly Editing the Node Name ”. We change the name of the node to 'auction'.

Directly Editing the Node Name

Figure 2.12. Directly Editing the Node Name

2.7. The Source View

Now that we have defined a simple process definition, we can have a look at the xml that is being generated under the covers. To see this xml, click on the source tab of the process definition editor. (Figure 2.13, “The Source View ”).

The Source View

Figure 2.13. The Source View

This source tab is editable, so if you know your way around in jpdl, you can create or tweak your process definitions directly in the xml source. But if you want to do this, note that at this moment the layout of the drawing may get messy. Intelligent layout algorithms will probably be added in a later stage. Also, the validity of the xml is not yet enforced. This is on the todo list and will be added in the near future.