Modeling your business processes with IBM WebSphere Lombardi Edition, Part 4: Building a human service using Coaches

In Part 4 of this series, you'll learn how to use WebSphere® Lombardi V7.1 Coaches to create a human service for gathering order details from user and displaying an order summary to the user, using a sample purchase order process.

Share:

Chang Hua Sun, Staff Software Engineer, IBM

Chang Hua Sun photoChang Hua Sun is a staff software engineer from Business Performance and Service Optimization team within IBM Software Group, where he develops SOA and BPM technology and solution development.



Xiao Xing Liang, Software Engineer, IBM

Xiao Xing Liang photoXiaoxing Liang is a staff software engineer on the Business Performance and Service Optimization team within IBM Software Group. He is experienced in developing SOA, BPM and Web2.0 technology and solutions.



Xi Ning Wang, Advisory Software Engineer, IBM

Xi Ning Wang photoXi Ning Wang is an advisory software engineer on the IBM China Cloud Labs team in IBM Software Group, where he focuses on cloud computing related technologies development and customer solutions. He was designated an IBM developerWorks Contributing Author in 2009.



Xin Li (lixincdl@cn.ibm.com), Staff Software Engineer, IBM

Xi Lin photoXin Li is a staff software engineer at the IBM China Development Lab, focusing on SOA-related design and development. Li Xin has rich experience in Telecom domain system integration, and also has deep insight in Telecom standards and technologies.



07 December 2011

Also available in Chinese

Overview

Part 1 of this series gave you an overview of the features and architecture of WebSphere Lombardi V7.1 (hereafter called Lombardi). In Part 2 you learned how to use the most common features of Lombardi, including business process definition (BPD), and integration, human and rule services, to model the sample process. In Part 3 you learned how to use some advanced features of Lombardi to enrich to meet more complex requirements, including nested processes, milestones, event mechanisms, exception handling and Lombardi web services exposure.

In Part 4, you'll learn about using Lombardi Coaches to build human services. We'll continue to use the typical business scenario of a purchase order process as our sample.


Overview of the Lombardi Coach designer

Lombardi Coaches provide the interface for end user interaction, and are usually used to build human services. Figure 1 shows the layout of the Lombardi Coach designer.

Figure 1. The Coach designer
The Coach designer
  1. Shows all the Coaches in the currently opened service. You can change or implement the Coach page by clicking one of the Coaches.
  2. Shows the design and implementation of the selected Coach in the Design tab. You can click the Preview tab to see how the Coach will look to end users when the service runs.
  3. Use the first three icons to: (1) show the design of the Coach; (2) show both the design and the code of the Coach; (3) show only the code of the Coach, respectively;
  4. Lists the sections, controls, and variables that you can include in the Coach. Drag a section or control from the palette to the Design tab to add it to the Coach. To create a control for a variable included in the service, drag a variable from the palette to the Design tab. The type of control created depends upon the variable. For example, an input variable that is a String creates an Input Text field.
  5. Shows the properties for the control selected in the Design tab. Figure 1 shows the properties of Order Name in the Order Head Coach.

Solution overview

In this article, we'll build a Submit Purchase Order human service in the sample Purchase Order process using Coaches. For the sample Purchase Order process, the buyer needs to submit a purchase order to start the process. The Submit Purchase Order human service we'll build needs to gather the buyer's input as the value for the complex variable order.

Figure 2 illustrates the data structure of the complex structure Order. The order variable is one instance of Order, and includes two complex variables: orderHead and orderDetail. In addition, orderDetail is a list, or array, of the complex structure OrderDetail. Therefore, an order will include one orderHead and one or more orderDetail variables.

The Submit Purchase Order human service will provide a user interface user interface to gather user information to populate the variable order.

Figure 2. The data structure of Order
The data structure of Order

Figure 3 illustrates the overall Coach design for the Submit Purchase Order human service. First, you need to initiate the complex variable tw.local.order. Since one tw.local.order has one tw.object.OrderHead and one or more tw.object.OrderDetail, we'll build separate Coaches for Order Head and Order Detail. Finally, we'll build a coach show the order summary to the user.

Figure 3. The overall coach for Submit Purchase Order
The overall Coach for Submit Purchase Order

Initiating the Output Server Script

Since Order is a complex variable, you first need to initialize it. Figure 4 illustrates the implementation of the initialization. You can use new tw.object.objectType to initialize the variable with type objectType, and use new tw.object.listof.objectType to initiate a list variable with a type objectType. Use a Server Script element to do the initialization.

Some of the properties of Order can be assigned default values; for example, the identifier of orderHead can be initialized as the process instance ID (tw.system.currentProcessInstanceID) and the order date and time can be initialized as the current system date and time, as shown in Figure 4.

Figure 4. Initiating the output server script
Initiating the output server script

Creating the Order Head Coach

As you saw in Figure 4, an order will include one orderHead and one or more orderDetail variables. To fulfill the order variable, you need to provide an interface to gather orderHead and orderDetail information. Since there is only one orderHead for an order, you first need to create a Coach for orderHead.

Figure 5. The Create Order Head Coach
The Create Order Head Coach

Figure 5 illustrates the implementation of the Create Order Head coach. Since the orderHead, orderDate, and orderTime are initiated as shown in Figure 4, and orderCloseDate, orderCloseTime will be assigned values at the close of the order, you only need to build inputs for orderHeadName, buyer, supplierName, supplierContact, and needBuyerConfirm.

For String type input, drag and drop Text or Text Area (for multiple line input) from the palette on the right, then change the Label and select Binding for the input text, as shown in Figure 6.

For Boolean type input (needBuyerConfirm), you can drag and drop Check Box from the palette, then configure the Label and Binding properties, as you did with the input text.

Figure 6. Configure Input Text properties
Configure Input Text properties

After gathering the user input, you need at least one button to submit the form values to the back-end. Figure 7 shows the properties of the Button Group. In the Presentation properties, you can configure the Label and even add some scripts under Validation Script to do some validation.

Figure 7. Configure Button Group properties
Button Group properties

Creating the Order Detail Coach

The Create Order Detail Coach is more complicated than the Create Order Head Coach, because there is uncertain number of orderDetail variables, or the orderDetail may be a list. Because the number of orderDetail instances in an order is determined by the user, you can build the Coach with one page and can loop back to the page. Figures 8 and 9 illustrate the variables and implementation of the Create Order Detail Coach.

Figure 8. The variables of Create Order Detail Coach
The variables of Create Order Detail Coach
Figure 9. The implementation of the Create Order Detail Coach
The implementation of the Create Order Detail Coach

You can define two private variables: orderDetailNum (Integer) to record the current number of OrderDetail user inputs; and orderDetailTmp (OrderDetail) to record the value of OrderDetail user inputs in the Coach page.

In the Order Detail Coach page, we'll build the following four properties for orderDetailTmp: shipDate, productNumber, quantity and unitprice. Other properties will either be automatically generated or defined at at later stage. The four properties have three text inputs, which can be configured as shown in Figure 6.

productNumber is a Single Select control. Figure 10 shows the presentation properties of a Single Select. Data for a single select control can be either manual or dynamic. Manual data has two columns: Value is the real value when submitting the form to the back-end, Display Text is the text displayed on the page. In this example, we'll build the productNumber select using manual data. You'll learn how to use dynamic data in Part 5.

Two buttons in the Create Order Detail Coach page control the logic. When either button is clicked, the value of orderDetailTmp is added to the tw.local.order.orderDetail list. If the Save & Create Another Order Detail button is clicked, the user is redirected to the Create Order Detail Coach page. If the Next button is clicked, the Create Order Detail step is finished.

Figure 10. Single Select properties
Single Select properties

Figure 11 shows the implementation of the logic. In the beginning, orderDetailNum has a default value of zero, and tw.local.orderDetailTmp is instanced as a new tw.object.OrderDetail.

Figure 11. The pre- and post assignments for Create Order Detail
The pre- and post assignments for Create Order Detail

After the user submits the Coach page, tw.local.orderDetailTmp is added to the tw.local.order.orderDetail list, as shown in Listing 1.

Listing 1. Post-execution assignments
tw.local.order.orderDetail[tw.local.orderDetailNum] = new 
tw.object.OrderDetail();

tw.local.order.orderDetail[tw.local.orderDetailNum].shipDate = 
tw.local.orderDetailTmp.shipDate;
tw.local.order.orderDetail[tw.local.orderDetailNum].productNumber = 
tw.local.orderDetailTmp.productNumber;
tw.local.order.orderDetail[tw.local.orderDetailNum].quantity = 
tw.local.orderDetailTmp.quantity;
tw.local.order.orderDetail[tw.local.orderDetailNum].unitPrice = 
tw.local.orderDetailTmp.unitPrice;

tw.local.order.orderDetail[tw.local.orderDetailNum].orderDetailCode = 
tw.system.currentProcessInstanceID + tw.local.orderDetailTmp.productNumber;
tw.local.order.orderDetail[tw.local.orderDetailNum].orderNumber = "ORDER_" + 
tw.system.currentProcessInstanceID + tw.local.orderDetailTmp.productNumber;
tw.local.order.orderDetail[tw.local.orderDetailNum].updatedQuantity = 
tw.local.orderDetailTmp.quantity;
tw.local.order.orderDetail[tw.local.orderDetailNum].updatedUnitPrice = 
tw.local.orderDetailTmp.unitPrice;
tw.local.orderDetailNum = tw.local.orderDetailNum + 1;

Creating the View Order Summary Coach

After the Create Order Head and Create Order Detail Coaches are completed, the order is fulfilled and job of the Submit Purchase Order Human Service is finished. However, it's a good idea to show a summary of the order to the user. Figure 12 illustrates the implementation of a View Order Summary Coach.

The Order Head section shows the value of tw.local.order.orderHead as output text. The Order Detail section shows the value of tw.local.order.orderDetail as a table control. The table control displays the orderDetail and is needed only to configure the Binding property, similar to the Text Input property.

Figure 12. The View Order Summary Coach implementation
The View Order Summary Coach implementation

Running the Coaches

Figures 13, 14 and 15 illustrate the completed Submit Purchase Order human service. When the user enters the values for Order Head and clicks Next, the Create Order Detail page is displayed. The user can create any number of order details by clicking the Save & Create Another Order Detail button. Finally, the user is shown a summary of the order.

Figure 13. Submit Purchase Order Coach
Submit Purchase Order Coach
Figure 14. Order details
Order details
Figure 15. Order summary
Order summary

Conclusion

In this paper, you learned how to use Lombardi Coaches to build human services. The Coach capabilities enrich the user experience in our sample purchase order process.

In Part 5, we'll cover more advanced Coach features, including dynamic data binding, the runtime rendering mechanism of the Coach, and how to customize the Coach.

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Business process management on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Business process management, WebSphere
ArticleID=779478
ArticleTitle=Modeling your business processes with IBM WebSphere Lombardi Edition, Part 4: Building a human service using Coaches
publish-date=12072011