You will now create the business process component's
implementation, which is more involved than the human task:
- In the Assembly Diagram editor, double-click the HelloWorldProcess process
component to start work on it. Click Yes in
the Open dialog and OK in the Generate Implementation
dialog. The business process editor opens, as shown here: .
- Your process is going to invoke a human task, which could
take a long time to respond. Hence, you need the process to be defined
as long running. Click somewhere in the white
space of the editor, and go to the Properties view
and select the Details tab. Notice the check
box Process is long running is selected, as
shown here: Note:
The hovering information instructs you to press Alt+Shift+R to refactor
this value, which means changing not only it but all downstream artifacts
impacted by the change. If you did want to change this to a micro-flow
(not long running) then refactoring is encouraged. It is not enough
to just set this flag here as there are qualities of service that
need to be re-configured back in the Assembly Diagram editor when
changing this setting.
- A business process is made of activities, or individual
steps. When a process is initially created for an interface with a
request response operation, it has two activities pre-supplied: Receive for
starting the process via that operation, and Reply for
returning the response to the caller. Your own activities will be
inserted between these two activities. From the palette on the left,
in the Structures category, drag Generalized
Flow and drop it between Receive and Reply, as shown here: Note: some
activities like Generalized Flow are structured, meaning they are
intended to contain other activities. To produce a flow that branches
you must use Parallel Activities, Generalized Flow or Collaboration
Scope.
- From the tray on the right, in the Reference
Partners category, drag and drop HelloWorldTaskPartner into
the GeneralizeFlow structure, and set the name
to InvokeTask as shown here: Note: this creates a configured
Invoke activity that calls this reference, which is wired to the human
task component back in the Assembly Diagram editor. This means at
runtime the activity results in the creation of an instance of your
human task – that is, a todo is created and awaits being claimed by
one of its potential owners. It is not fully configured yet however
– next you will define where to get its input parameter data and store
its output results.
- On the canvas, select the InvokeTask activity,
and go to the Properties view below the editor.
Select the Details tab. In the table, for the
Input(s) click on (none) in the cell of the “gender” row and
of the last column named Read From Variable.
You see a drop-down list showing all variables currently defined in
this process which have a matching type, which at this point consists
only of the process interface's input and output parameters.
Select the gender variable, which is the input
parameter to this process. This selection means, you will pass this
variable's text data as input to the human task.
- Similarly, for the Output(s) click on (none) in
the cell of the “firstName” row and of the last column named Read
From Variable, but this time select New to
create a new variable named firstname. Do the
same for the “lastName” row creating a new variable named lastname.
Note the variables are created with appropriate type for this reference
partner parameter. Your table should look like this:
- At runtime, after InvokeTask returns
you will have variables containing the user's first name and
last name. The hello world part 1 sample service you need to invoke
also requires a “title” like “Mister”, so you need to define a variable
to hold such a value. In the tray area in the Variables category,
click the plus sign as highlighted here: The Add a Variable dialog opens.
- In the Add a variable dialog, in
the Name field type variable name fullname,
and select type FullName which is a business
object created in Hello World Part 1 sample. This is the type of variable
that the service from the first sample requires as input. Your variable
list should now look like this: Note:
this fullname variable has three fields defined in it, all of type
string: title, firstName and lastName.
You will need to set a value for all three fields before you can invoke
the service. This you will do next.
- From the palette on the left, in the Basic Actions category,
drag and drop the Assign activity to the canvas
to the inside of GeneralizedFlow. Set its name
to AssignM.
- While AssignM is selected, go to
the Properties view, and the Details tab.
In the table, in the rightmost Assign To column,
click on Select To. In the dropdown list, expand fullname and
select title under it.
- In the same table, in the leftmost Assign From column,
click on Select From. Select String (enter
a value) from the dropdown list, and type Mr as
shown here:
- Back in the canvas, wire the InvokeTask activity
to the AssignM activity. In the resulting popup,
select Add a Link.
- Once again drag and drop Assign from
the palette to within the GeneralizedFlow structure,
and this time name it AssignF, and configure
it to assign Ms to the title field as shown
here:
- Wire the InvokeTask activity to
the AssignF activity. In the resulting popup,
select Add a Link. Your flow should now look
like this:
- It is time to assign values to the remaining
two fields in fullname: namely firstName and lastName.
You will set these from the values returned from the human task. Drag
and drop Assign again to inside GeneralizedFlow,
and set its name to AssignNames. Configure
it as follows (tip: you will need to use Add):
- Wire both the AssignF and AssignM activities
to this new AssignNames activity, so that GeneralizedFlow looks
like this:
- You need to condition the two links coming from InvokeTask so
there is some criteria about when to follow each link. Select the
blue link that goes into AssignF, and go to
the Details tab of the properties view. For
the Expression Language select XPath 1.0, and click the Edit button.
The XPath Expression Builder opens.
- In the XPath Expression Builder, in the Data
Types Viewer list on the left, double-click on gender,
and in the Operators list double-click on the equals operator (=).
In the XPath Expression entry field, type ‘female' on
the end, so that the expression reads $gender='female' and
then click Finish.
- Select the link that goes into AssignM,
and for its properties set the Expression Language to XPath 1.0 and
the Condition to $gender!='female' as shown
here: Optional: It is possible to give your
links a label by setting the Display Name in
the Description properties tab, and then show
that label via the right-click context menu action Show labels on
links.
- From the tray on the right, drag and drop HelloWorldPartner to
right above the Reply activity and name it InvokeHW1 as
shown here:
- In the Details properties for the InvokeHW1 activity,
bind the input and output parameters to the fullname and result variables
as shown here:
- From the Basic Actions category in the palette, drag Snippet to
be right above Reply. In the properties view,
there is a visual java snippet editor. Double click the Properties tab
to go full screen. Click on Standard… in the
palette. The Add a Standard Visual Snippet dialog appears. Expand utility and
double-click Print to log and then click in
the visual snippet editor canvas. A print to log node appears.
- Drag the result variable from the tray on the right to
the visual snippet editor canvas. Wire from the result node
to the print to log node, so that your snippet
looks like this: Restore
the properties view to its normal size. Note: what
you have done is author Java code visually to emit the contents of
the result variable to system out. Technically, by wiring one node
to another you supply an input parameter to a method.
- You are done authoring the process! Save your process.
It should look like this:
- Optional: Sometimes in your process you want to
know which activities use a particular variable. There is a way to
do that. In the tray, select the fullname variable.
In the lower right of the perspective, give focus to the References view.
There you will see a graph showing as input to the variable, all activities
that set the variable, as shown here:
Congratulations – the authoring steps are done … time to test!