Mobile technologies provide real-time access to business process management (BPM) processes from remote locations. By extending existing processes to mobile workers, enterprises can significantly improve business responsiveness, increase worker productivity, and improve processing times.
This article — the first in a series on mobile BPM — describes how to build a simple “Hello World” task list mobile application for use by mobile workers who interact with BPM processes.
The first part of this article explores a completed BPM mobile solution to give you an understanding of how remote mobile workers could interact with a process instance via a mobile task list application running on an Android mobile device. The second part of the article provides the steps to develop the application described, including testing and deployment, to give you a foundation for building your own mobile task list app for processes you have implemented using IBM Business Process Manager 7.5.1.
The business scenario used in this example is insurance claims handling. For the purpose of this article, the insurance claim process scenario used here (Figure 1) is very simple (and is not meant to illustrate best practices of claims handling).
Figure 1. Claim processing process with Mobile swim lane
The process has two human task swim lanes:
- The Office swim lane has two users defined (Figure
2). All tasks in that swim lane will be assigned automatically to one
of these users on a round robin basis.
Figure 2. Tasks in the Office swim lane are assigned to cpOffice Group
- Similarly, the Mobile swim lane also has two users
Figure 3. Tasks in the Mobile swim lane are assigned to cpMobile Group
In Figure 1, notice the link from the More Information Needed BPMN (Business Process Modeling Notation) decision primitive to the Request Field Information human activity (marked 1 in the figure). Since the office-based Claims Examiners have no real-time access to remote locations, they can request the filed information needed to process a claim from a remote mobile Claims Examiner and get the results back instantly.
Notice the link between from the Request Field Information human task to the Manual Processing human task (marked 2 in Figure 1). When the mobile worker completes the task, the request field information flows back to the office-based Claims Examiner. Since the information is supplied via the process, it becomes a permanent part of the process instance: it is time-stamped, signed, and authenticated, and can be tracked and audited.
Finally, notice that the pattern of requesting field information by the office-based Claims Examiner from the mobile Claims Examiner can be repeated until the office-based Claims Examiner has sufficient information to make a decision.
A day in the life of Claims Examiners
Let’s see how an office-based Claims Examiner (Bernard – cpOfficeUser1) and a mobile Claims Examiner (Paul – cpMobileUser2) collaborate to complete a claim:
- Bernard logs in to the Process Portal as cpOfficeUser1 (Figure 4).
Figure 4. Office-based Claims Examiner logs into Process Portal
Since Bernard’s user ID is part of cpOffice group (Figure 2), which is associated with the Office swim lane, he finds several tasks in his task list (Figure 5). Notice the tasks are for the Manual Processing process step in the Office swim lane (Figure 1).
- Bernard decides to work on task highlighted in Figure 5. He clicks the
green arrow next to the last task in the Run column.
Figure 5. Office-based Claims Examiner claims his task
- While reviewing the task, Bernard realizes that he needs some
information from a mobile Claims Examiner. He clicks the ADD
QUESTION button (Figure 6).
Figure 6. Office-based Claims Examiner needs filed information
Bernard types his question,
What is odometer value?and clicks the GET MORE INFORMATION button. Notice that the date, time, and user fields are filled in automatically and are read only (Figure 7). The time stamp and user ID are added automatically for auditing purposes.
Figure 7. Office-based Claims Examiner forwards the request to a Mobile Claims Examiner
Figure 8 shows the diagram of this process instance. Notice that because Bernard requested more information form a mobile Claims Examiner, the next task to be executed is now in the Mobile swim lane.
Figure 8. The next task instance is Request Field Information in the Mobile swim lane
- From his mobile device (in this case, an Android tablet) Paul (mobile
user cpMobileUser2 , see Figure 3) launches his Mobile Claims
application (Figure 9).
Figure 9. Mobile Task List application
Because the security credentials are already preconfigured for Paul in the Mobile Claims application (discussed later), Paul does not need to login again and he immediately sees his task list (Figure 10).
- Paul selects task 189, which is the task that originated above in step
3 by Bernard, the office-based Claims Examiner. Recall that Bernard
needed to know the odometer reading.
Figure 10. Task in the Mobile Task List application
- Paul sees the question from Bernard (cpOfficeUser1) and clicks the
ADD REPLY button (Figure 11).
Figure 11. Request Field Data Task user interface rendered on mobile device
- Paul types the answer to Bernard’s questions and clicks the
SUBMIT button (Figure 12).
Figure 12. Completion of Mobile Task
Figure 13 shows the process diagram of this process instance. Notice that because Paul completed his task with the answer to Bernard’s question, the next task to be executed is now in the Office swim lane. Actually, the task assignment was not left to chance. The task was assigned to the previous task owner in the Office swim lane (Bernard - cpOfficeUser1) rather than to any user in the swim lane.
Figure 13. The next task instance is Manual Processing in the Office swim lane
- Bernard looks at his task list and discovers that task 189 that is now
again assigned to him (Figure 14). Bernard clicks the green arrow to
work on the task.
Figure 14. Task 189 is ready for approval
He sees Paul’s answer. Based the new information provided by Paul, he decides to approve the task, and then clicks the COMPLETE button to conclude it (Figure 15).
Figure 15. Task 189 is completed
The next task to be performed is now the Notify Customer task (Figure 16).
Figure 16. Claim processing completed
The steps above describe how the mobile task list Android application can be used in the Claims Process. The remainder of this article explains how you can build and experiment with this sample mobile application.
Creating an Android task list application
The remainder of this article describes the steps involved in creating the task list application for the Android platform introduced in the previous section. Android 2.2 (Froyo) (see Resources) is used for this example, as this version (and later) covers most active Android devices. The sample Android application will interact with the Business Process Manager runtime using IBM Business Process Manager 7.5.1 REST APIs to query and invoke tasks for a mobile business user. For simplicity, the default Android widgets and layouts are used.
The major steps to create this sample app include:
- Install the Android SDK
- Create an Android project
- Create an activity to view tasks
- Create an activity to view coaches
- Link the two activities together
- Create a virtual device and test the application
1. Install the Android SDK
Installing the Android SDK involves installing the SDK starter package, installing the Eclipse ADT plugin, and adding the desired platforms and components (Figure 17). (See Resources to download these components.)
- Download an Eclipse IDE (the “Eclipse Classic” version is recommended) if you don't already have one.
- Download and install the SDK starter package for your system.
- Download the eclipse ADT plug.
- Add the Android 2.2 platform and recommended components by launching
the Android SDK Manager from within Eclipse.
Figure 17. Recommended components
2. Create an Android project
An Android project is very similar to an Eclipse Java™ project; it's a container for your classes and other Android resources.
- In Eclipse, create an Android project by navigating to File
> New > other > Android > Android Project.
Enter a name, such as
HelloBPMWorld, and click Next.
- Select Android 2.2 under Build Target and click
Next (Figure 18).
Figure 18. Build Target
- For Application Name, enter
Mobile Claims. For Package Name, enter
hello.bpm.world, and enter
TasksActivityin the Create Activity field (Figure 19). Click Finish.
Figure 19. Application Info
3. Create an activity to view tasks
An activity provides a GUI panel with which users can interact for the purpose of doing some specific thing. You will use the REST API from Business Process Manager to get the tasks and create a ListActivity to display them. You will use the search component of the REST API (Figure 20). (See Using the REST APIs in IBM Business Manager 7.5 for details about the APIs.)
Figure 20. REST Search API
- You've already created the activity in the New Android Project wizard;
however, it extends the wrong super class. Open
TasksActivity.java and change the super class
ListActivity. ListActivity provides default content (a list) so remove the setContentView(R.layout.main) method call from the onCreate method (Figure 21).
Figure 21. ListActivity
- Use a SimpleCursorAdapter as the ListAdapter to
provide the contents of the list (Figure 22). Table A describes key
elements of this code.
Figure 22. Using ListAdapter
Table A. Key elements of Figure 22
Line Description 132 An adapter for a Cursor object. A cursor object can be used to iterate backward or forward through a data set. 133 simple_list_item_2: An Android layout for a list item that displays two lines of text, one above the other.
MatrixCursor: A simple Cursor implementation.
134-135 Map the columns in the MatrixCursor to the text fields in the simple_list_item_2 layout. 136-146 Trigger the list view to redraw itself when the dataset changes.
- Before setting the list adapter, create a text view to display when
the list is empty (Figure 23).
Figure 23. Create a View for an Empty List
- Create an AsyncTask class inside TasksActivity to
perform the REST API call. Make sure to override the
doInBackground() method (Figure 24 and Table B).
Figure 24. Create an AsyncTask
Table B. Key elements of Figure 24
Line Description 27 This AsyncTask accepts a string as input (the query string) and a string for updating the UI (not used in this example), and returns a JSONObject, the result of the API call. 29 The base path for the REST search API.
- Before implementing the doInBackground() method, add some constants to
TasksActivity for server connection information (Figure 25).
Figure 25. Connection Information
- In doInBackground(), create an HTTP client, set up the credentials,
execute an HTTP PUT, and then return the resultant JSON object (Figure
Figure 26. REST API Call
- You now have an AsyncTask that calls the Business Process Manager REST
API in a background thread. You need to update the UI before and after
you execute this method. Luckily, AsyncTask provides you with methods
to do this. First, override the onPreExecute() method (Figure 27 and
Figure 27. Reset List View
Table C. Key elements of Figure 27
Line Description 131-132 Check to see if the list view already has content. 135-136 Clear the adapter so the list’s empty view (that is, the “loading” text) will be shown. 137 Trigger the list view to update.
- Override the onPostExecute() method to update the
adapter with the results from doInBackground() (Figure 28 and Table
Figure 28. Update List View
Table D. Key elements of Figure 28
Line Description 104-105 Retrieve the cursor to add the data to. 107-110 If the result of the REST API call contains no data, then update the empty view text and return. 117-132 The first row in each list item will be the task subject concatenated with the task due date. The second row will be the task instance name. 133 Add each task to the cursor in order to display it in the list view.
- You now have a complete QueryTask. You need to call it from the
onCreate() method. You can also set the title of this activity to
something more informative (Figure 29).
Figure 29. Invoke AsyncTask
- Android requires applications to declare which services and hardware
they require in order to function. Since QueryTask opens an Internet
connection, you need to update the
AndroidManifest.xml file that was generated when
you created the project. The manifest is where you define your
application and the activities and services it provides.
Figure 30. Android permissions
Table E. Key elements of Figure 30
Line Description 3 The package is what identifies your app in the Android Market so try and make it unique. 4 The Android Market uses this version code. It needs to be incremented with each release so you can publish an update to your app. 5 This is what is displayed in the Android Market to the user, it can technically be any string. Just be sure to keep the updates consistent. 7 This is the minimum Android OS version on which the app can be installed; 8 is the code for Android 2.2. 8 Gives the app permission to use the Internet.
4. Create an activity to view coaches
Running a task on a desktop computer launches a human service in a browser. You will do something similar in Android, except that instead of launching a web browser you will create another activity that has one widget; a WebView. As the name implies, a WebView is a view that displays web pages.
- Create a new class in the hello.bpm.world package called
WebviewActivity, and have it extend android.app.Activity.
- Override the onCreate() method and create a WebView
object (Figure 31).
Figure 31. Create a WebView
settings (Figure 32).
Figure 32. WebView Settings
- Next, create and set the WebChromeClient and the
and handle authentication, respectively (Figure 33).
Figure 33. Create WebView Clients
- Finally, get the title and URL to load from the activity’s intent
(Figure 34 and Table F).
Figure 34. Set Title and Load URL
Table F. Key elements of Figure 34
Line Description 71, 75 These values will be set by TasksActivity (see next section).
- Update the AndroidManifest.xml file to add the new activity (Figure
Figure 35. Add Webview Activity
5. Link the two activities together
You have an activity to list the user’s tasks and an activity to display the coach for the task. You will use the Android Intent system to launch one from the other.
- In TasksActivity override the onListItemClick()
method to invoke the WebviewActivity when the user touches a
task in the list (Figure 36 and Table G).
Figure 36. Launching Webview Activity
Table G. Key elements of Figure 36
Line Description 188-190 Retrieve the ID of the task to launch and the string to use as the title of the WebviewActivity. 194 Create the URL to pass into the WebView. 197 Create the Intent that will tell Android what action you want to do (view), the data to pass in (uri) and, in this case, which class to invoke. 198-200 A bundle is essentially a hash map for you to pass in data to the intent that will be accessible from the receiving activity. 201 Start the activity and get notified when the user returns from it. The requestCode can be an arbitrary int, as you’re only launching one activity.
- Override onActivityResult() in TasksActivity to
refresh the tasks list when the user returns from the WebviewActivity
Figure 37. Reload Tasks List
6. Create a virtual device and test the application
You can test your Android application either on a physical device or on a device simulator. The steps below will help you do both.
- Click the toolbar button to open the Android Virtual Device Manager
Figure 38. Open AVD Manager
- In the dialog, click the New button to bring up the
new AVD button. Fill in the Name field, set the Target to
Android 2.2 - API Level 8, and set the SD Card
10MiB. Click Create AVD (Figure 39).
Figure 39. New AVD
- Select the AVD you just created and click the Start button, accepting defaults for the dialogs that pop up.
- Wait for the simulator to launch and for the Android home screen to appear. If it starts up with the lock panel, unlock it by sliding the lock icon to the right.
- Go back to Eclipse and right click on the HelloBPMWorld project and select Run As > Android Application.
And that’s it! You should see the simulator launch the HelloBPMWorld app and list all of the tasks for the cpMobileUser2 user.
To test this on an actual Android device, close the simulator and attach your phone or tablet to your computer via the USB cable (Windows® users will need to download the USB driver. You need to enable USB debugging on your device via Settings > Applications > Development > USB debugging, then simply launch your project again in Eclipse. It will install the app on your device.
This article introduced a simple “Hello World” mobile application that enables both mobile workers and office-based worker to collaborate in completing a process instance. First, the completed solution was illustrated to show the actual steps and the touch points between mobile and office-based roles in action. Next, you learned how to build the sample mobile application using IBM Business Process Manager 7.5.1 REST API and the Android SDK.
You are now ready to start your Mobile BPM journey!
|Sample application||HelloBPMWorld.zip||16 KB|
|Code sample||SampleAppFiles.zip||5 KB|
- Using the REST APIs in IBM Business Process Manager V7.5
- IBM Business Process Manager product information
- IBM Business Process Management (BPM) software and services
- IBM Business Process Manager Information Center
- IBM developerWorks IBM Business Process Management zone
- Android 2.2 Platform Highlights
Get products and technologies
- Eclipse IDE downloads
- Download the Android SDK
- Downloading the ADT Plugin
- Google USB Driver
- IBM developerWorks WebSphere