You are on page 1of 94

Oracle® Cloud

Implementing the Business Card Scanner Mobile Application


Use Case for Oracle Sales Cloud

E53633-03

November 2014
Oracle Cloud Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud

E53633-03

Copyright © 2014, Oracle and/or its affiliates. All rights reserved.

Primary Author: Chris Kutler

Contributor: Lisa Call, Shaun Hayes, Vijay Eadala, Jonathan Lee, Michael Spencer

This software and related documentation are provided under a license agreement containing restrictions on
use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your
license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license,
transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse
engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is
prohibited.

The information contained herein is subject to change without notice and is not warranted to be error-free. If
you find any errors, please report them to us in writing.

If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it
on behalf of the U.S. Government, the following notice is applicable:

U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,
any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users
are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and
agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and
adaptation of the programs, including any operating system, integrated software, any programs installed on
the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to
the programs. No other rights are granted to the U.S. Government.

This software or hardware is developed for general use in a variety of information management
applications. It is not developed or intended for use in any inherently dangerous applications, including
applications that may create a risk of personal injury. If you use this software or hardware in dangerous
applications, then you shall be responsible to take all appropriate failsafe, backup, redundancy, and other
measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages
caused by use of this software or hardware in dangerous applications.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of
their respective owners.

Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks
are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD,
Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced
Micro Devices. UNIX is a registered trademark of The Open Group.

This software or hardware and documentation may provide access to or information on content, products,
and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly
disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle
Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your
access to or use of third-party content, products, or services.
Contents

Preface ................................................................................................................................................................. v

1 Introduction to the Use Cases


About the Sample Project Used in This Guide .................................................................................... 1-1

2 Obtaining Access to the Software Services


Accessing the Software Services ............................................................................................................. 2-1

3 Downloading and Installing the Software


About the Use Case .................................................................................................................................... 3-1
Installing the Android SDK and Tools .................................................................................................. 3-2
Installing and Configuring JDeveloper 11.1.1.7.1 and JDeveloper 11.1.2.4..................................... 3-4
Troubleshooting the Use Case ................................................................................................................. 3-8
Launch of JDeveloper Stalls While Restoring Editors ....................................................................3-8
Android 17 API Paths Not Available from Android Mobile: Platforms Preferences ................3-9
Additional Resources ................................................................................................................................ 3-9

4 Building the Service Application


About the Use Case .................................................................................................................................... 4-2
Creating the Service Application ............................................................................................................ 4-3
Creating the Organization Service Proxy .............................................................................................. 4-8
Creating the OSCOrganization Class.................................................................................................. 4-13
Deploying the Service Application to Oracle Java Cloud Service - SaaS Extension ................. 4-19
Verifying the Service Application Deployment................................................................................ 4-20
Extending the Application to Use a Different Card Scan Service ................................................. 4-21
Creating the Basic Authorization Application .................................................................................. 4-22
Troubleshooting Application Deployment ........................................................................................ 4-23
Deployment to Oracle Java Cloud Service - SaaS Extension Failed .......................................... 4-23
Additional Resources ............................................................................................................................. 4-23

5 Configuring the Virtual Device


About the Use Case .................................................................................................................................... 5-1
Configuring the Emulator......................................................................................................................... 5-1
Additional Resources ................................................................................................................................ 5-6

iii
6 Building the Mobile Application
About the Use Case .................................................................................................................................... 6-2
About the Web Service Data Controls.................................................................................................... 6-2
Building the Mobile Application............................................................................................................ 6-3
Adding the Cards Feature...................................................................................................................... 6-10
Adding the Customer Search ................................................................................................................ 6-29
Testing the Cards Feature....................................................................................................................... 6-35
Troubleshooting the Use Case .............................................................................................................. 6-38
Android Virtual Device Is Not Responding .................................................................................. 6-39
A View Page on the Device Displays an Error Message ............................................................. 6-39
The Photo Is Not Displayed on the Scan Business Card Page .................................................... 6-39
Web Service Information Is Not Retrieved or Saved ................................................................... 6-40
The Google Map Is Not Displayed on the Detail Page ................................................................ 6-41
Additional Resources ............................................................................................................................. 6-41

iv
Preface

Topics:
■ Audience
■ Documentation Accessibility
■ Related Documents
■ Conventions
Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
describes how to implement a mobile application that interacts with Oracle Sales
Cloud and other web services. Using prebuilt Oracle JDeveloper applications, you first
learn how to build a service application that coordinates calls to multiple web services
to provide a simple web service for consumption by mobile applications. Then, you
learn how to build an Oracle ADF Mobile application that uses the service.

Audience
This document is intended for information technology personnel and developers who
have a basic understanding of Java EE, web services, and authorization concepts.

Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle
Accessibility Program website at
http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc.

Access to Oracle Support


Oracle customers have access to electronic support through My Oracle Support. For
information, visit
http://www.oracle.com/pls/topic/lookup?ctx=acc&id=info or visit
http://www.oracle.com/pls/topic/lookup?ctx=acc&id=trs if you are
hearing impaired.

Related Documents
For more information, see these Oracle resources:
■ Oracle Cloud
http://cloud.oracle.com
■ Oracle ADF Mobile Tutorials

v
http://www.oracle.com/technetwork/developer-tools/adf/learnmo
re/adfmobiletutorials-1882877.html
■ Oracle Sales Cloud Integration Documentation
http://docs.oracle.com/cloud/latest/salescs_gs/salescs_
integrate.htm

Conventions
The following text conventions are used in this document:

Convention Meaning
boldface Boldface type indicates graphical user interface elements associated
with an action, or terms defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or placeholder variables for
which you supply particular values.
monospace Monospace type indicates commands within a paragraph, URLs, code
in examples, text that appears on the screen, or text that you enter.

vi
1
Introduction to the Use Cases
1

This guide uses a sample project to illustrate the key tasks for building a mobile
application that consumes local and remote resources, including Oracle Sales Cloud
resources. The sample project uses the following services and technologies:
■ Oracle Sales Cloud
■ Oracle Java Cloud Service - SaaS Extension
■ Oracle Java Cloud Service - SaaS Extension SDK
■ Oracle Database Cloud Service
■ Oracle ADF Mobile framework
■ ABBYY Cloud Optical Character Recognition service
■ Google geocoding service
■ Software as a Service (SaaS)
■ Platform as a Service (PaaS)
The following table summarizes the use cases described in this guide:

Use Case Description


Chapter 2, "Obtaining Obtain access to the software services that are consumed by the
Access to the Software sample service application, and obtain access to the platform
Services" service that you will deploy the service application on.
Chapter 3, "Downloading Install the software that you need to build the sample service
and Installing the application and the sample mobile application that consumes the
Software" service application's web services.
Chapter 4, "Building the Build the service application that interacts with Oracle Sales Cloud
Service Application" and third-party web service operations to provide a simplified
interface for use by mobile applications, and then deploy the
application to an Oracle Java Cloud Service - SaaS Extension
instance.
Chapter 5, "Configuring Configure the Android phone virtual device, which you use to test
the Virtual Device" the mobile application.
Chapter 6, "Building the Use Oracle ADF Mobile technology to build a mobile application
Mobile Application" that consumes the web services that are provided by the service
application.

About the Sample Project Used in This Guide


This guide uses the business card scanner sample project. The goal of the business card
scanner project is to create a mobile application that enables a user to take a photo of a

Introduction to the Use Cases 1-1


About the Sample Project Used in This Guide

business card, scan the photo into text, edit the text, and save the results in an Oracle
Sales Cloud contact record. While editing the text, the user can search Oracle Sales
Cloud for companies (customers) with matching or similar names, and then update
the scanned text using information from a selected search result. The ABBYY optical
character recognition (OCR) web service is used to scan the photo into text, and the
Google geocoding web service is used to locate the card's address. The interim
business card information and process status is stored in a local database on the
device.
The project architecture is based on the Oracle SaaS PaaS architecture that is shown in
the following figure. This architecture uses a service application to interact with
various web services and consolidate those interactions into a simple set of web
service operations for use by mobile applications. This architecture can be applied to
software projects that share the following characteristics:
■ The mobile application uses local and remote resources.
■ The mobile application stores data on both remote servers and local devices.
■ The mobile application must ensure that the mobile application's content is always
up to date.
■ The mobile application accesses native hardware and local device information.

SaaS

Mobile Application PaaS SOAP/REST Web Service

Oracle ADF Web Service


SQLite SOAP/REST SOAP/REST Web Service
Mobile Application

SOAP/REST Web Service

As shown in the following figure, the business card scanner project consists of the
following components.
■ Business Card Scanner Cloud Services: This application, which runs in an Oracle
Java Cloud Service - SaaS Extension instance, is the back-end code that acts as both
a proxy and an orchestrator for all external and third-party service calls. This
application:
– Hosts the business card scanner web services
– Consumes system-to-system identity mapping
■ Business Card Scanner Basic Authentication: A simple user ID-password
authentication mechanism used to protect access to the mobile application, and to
verify the logged-in user's identity.
■ Business Card Scanner Configuration: Simple scripts that allow the ABBYY and
Google licensing information to be maintained outside of the Business Card
Scanner Cloud Services project, and to configure the remote location of the Oracle
Sales Cloud instance URL.
■ Business Card Scanner Mobile Application: This application, which runs on a
smartphone or a tablet, enables users to scan business cards, edit the results, and
save the results as an Oracle Sales Cloud contact. This application consists of:
– A UI that is built using Oracle ADF Mobile packages
– Local storage used to store a photo of a business card, its status, and its
scanned results until it's fully processed into an Oracle Sales Cloud contact
– Web service interactions with the Business Card Scanner Cloud Services

1-2 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
About the Sample Project Used in This Guide

■ Oracle Sales Cloud Web Services: The services that provide and store information
about contacts, organizations, and locations.
■ ABBYY Cloud: Third-party optical character recognition (OCR) service
– RESTful calls to the ABBYY Cloud OCR service pass business card photos to
scan to text.
– After processing the photo, the service returns a temporary, one-time URL that
points to the location of the results document.
– A call to the response URL downloads an XML document with the processed
business card results.
■ Google Geocoding Service: This service locates an address.

Oracle Java Cloud Service Abbyy Cloud OCR


- SaaS Extension Web Service
Business Card
Scanner Basic Google Geocoding
Authentication Web Service

Business Card Business Card Oracle Sales Cloud


Scanner Mobile Scanner Cloud
LocationService
Application Services
Web Service

Business Card
PersonService
Scanner
Web Service
Configuration Scripts

OrganizationService
Web Service

Introduction to the Use Cases 1-3


About the Sample Project Used in This Guide

1-4 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
2
Obtaining Access to the Software Services
2

This section describes how to obtain access to the software services that are consumed
by the Business Card Scanner Cloud Services application, and how to obtain access to
the platform service that you will deploy the service application on.

Topics:
■ Accessing the Software Services

Executive Summary

Use Case The Business Card Scanner Cloud Services application that you will
build accesses the ABBYY Cloud OCR web service and the Google
geocoding web service. You must obtain accounts from ABBYY and
Google before you can use the services. You will deploy the application
to an Oracle Java Cloud Service - SaaS Extension instance, and you will
use the instance's database service. To perform these tasks, you must
have access to a service instance.
Implementation Get an ABBYY account and obtain an application ID and password. Get
Summary a Google account and obtain an API key for the geocoding web service.
Get access to an Oracle Java Cloud Service - SaaS Extension instance for
which you have Java administration and database development roles.
Components ■ ABBYY Cloud OCR web service
■ Google geocoding web service
■ Oracle Java Cloud Service - SaaS Extension

Accessing the Software Services


The application that you build in Building the Service Application accesses ABBYY
and Google web services. You must register with ABBYY and Google before you can
access these services. You must also obtain access to an Oracle Java Cloud Service -
SaaS Extension instance.

Topics:
■ Task 1, "Register for the ABBYY Cloud OCR Web Service"
■ Task 2, "Obtain an API Key for the Google Geocoding Web Service"
■ Task 3, "Get Access to Oracle Java Cloud Service - SaaS Extension"

Obtaining Access to the Software Services 2-1


Accessing the Software Services

Task 1 Register for the ABBYY Cloud OCR Web Service


If you don't have an account for the ABBYY Cloud OCR Web Service, go to
http://ocrsdk.com/ and then start a free trial. You can use the trial to develop and
test the software.

Note: If you prefer to use a different web service, see Extending the
Application to Use a Different Card Scan Service.

After you obtain an account, register the Business Card Scanner Cloud Services
application to obtain an application name and password. After you register the
application, ABBYY sends an email confirmation, which includes the application name
and password, as shown in the following example. Make a note of the application
name and password, which you need in Chapter 4, "Building the Service Application."
Dear ,

New Application BCSADFMOBILE has been created for your account. Application
password is aB1cDeFGh2Ij34k/lMnoPQrS

For security reasons it is different from account information that you use to
access private section of ABBYY Cloud OCR SDK web site.

Please remember that any time you can log in to private section of ABBYY Cloud OCR
SDK web site using this link: cloud.ocrsdk.com and the same ABBYY Online account
where you can:
- View and manage your APPLICATION information
- Reset password for your APPLICATION
- Download API documentation, sample application and test images

You may also contact cloudocrsdk@abbyy.com if you have any questions or require
assistance.

Task 2 Obtain an API Key for the Google Geocoding Web Service
If you don't have a Google account, then obtain one. When you have a Google account,
go to https://developers.google.com/maps/documentation/geocoding/
and then follow the steps for obtaining an API key.

Task 3 Get Access to Oracle Java Cloud Service - SaaS Extension


If you don't have access to an Oracle Java Cloud Service - SaaS Extension instance, go
to https://cloud.oracle.com and obtain a 30-day trial. Ensure that you have the
necessary roles to administer Java applications and to develop databases.

Note: Access to an Oracle Java Cloud Service - SaaS Extension


instance is controlled through the use of roles that are configured
using the instance's Identity Console. (Roles are named groups of
related privileges). Instances are pre-seeded with a set of roles. Later
in this book, you use the Oracle Java Cloud Service - SaaS Extension
SDK. To use the SDK, you must have the Java_Administrators role
assigned to you.

2-2 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
3
Downloading and Installing the Software
3

This section describes how to download, install, and configure the software that you
need to build the Business Card Scanner applications.

Topics:
■ About the Use Case
■ Installing the Android SDK and Tools
■ Installing and Configuring JDeveloper 11.1.1.7.1 and JDeveloper 11.1.2.4
■ Troubleshooting the Use Case
■ Additional Resources

Executive Summary

Use Case You need software to build a mobile application that interacts with
Oracle Sales Cloud through a service application that is deployed to a
platform service.
Implementation To prepare for mobile application testing and debugging, install the
Summary Android SDK and tools.
To build a service application that is deployed to an Oracle Java Cloud
Service - SaaS Extension instance, download and install Oracle
JDeveloper 11.1.1.7.1, and then download the latest Oracle Java Cloud
Service - SaaS Extension SDK and configure JDeveloper to use that
SDK.
To build an application that is based on the Oracle ADF Mobile
framework, download and install Oracle JDeveloper 11.1.1.2.4. Then
configure JDeveloper to use the downloaded Android software.
Components ■ Windows operating system with a minimum of 8 GB of memory
■ JDeveloper 11.1.1.7.1 with Oracle Java Cloud Service - SaaS
Extension SDK
■ JDeveloper 11.1.1.2.4 with Oracle ADF Mobile extension
■ Android SDK and tools including the Android 4.2.2 (API 17)
packages

About the Use Case


The Business Card Scanner mobile application is based on the Oracle ADF Mobile
framework. To build a mobile application that is based on the Oracle ADF Mobile
framework, you must use JDeveloper 11.1.2.4. This version enables you to add the
Oracle ADF Mobile extension to the development environment.

Downloading and Installing the Software 3-1


Installing the Android SDK and Tools

The Business Card Scanner mobile application interacts with Oracle Sales Cloud and
third-party web services through the Business Card Scanner Cloud Services
application. To build the services application, which will be deployed to an Oracle Java
Cloud Service - SaaS Extension instance, you must use JDeveloper 11.1.1.7.1.
To test the Business Card Scanner mobile application on Windows, you must have the
Android SDK, supporting tools that include a device emulator, and a device monitor
that enables you to analyze and debug device interactions.
Note that this guide describes how to build the mobile application on a Windows
platform, which requires the Android SDK. You can also build the application on a
Mac platform using iOS or the Android SDK, and on Linux using the Android SDK.

Tip: To have adequate performance while you work with the


Android emulator from JDeveloper, you must have a minimum of 8
GB of memory.

Installing the Android SDK and Tools


Topics:
■ Task 1, "Download and Install the Android Software"
■ Task 2, "Install Additional Android Packages"

Task 1 Download and Install the Android Software


You must have the Android SDK and developer tools to test and debug mobile
applications for Android.
1. Go to the Android SDK download page at
http://developer.android.com/sdk/index.html.
2. Scroll to the bottom of the page and expand GET THE SDK FOR AN EXISTING
IDE.
3. Click Download the stand-alone Android SDK Tools for Windows.
4. Agree to the terms and conditions.
5. Click Download the SDK Tools for Windows, and then click Save File.
6. Save and then run installer_rversion-windows.exe to start the Android SDK
Tools Setup wizard.
7. On the Welcome page, click Next.
8. After the wizard detects where the Java SE Development Kit is installed, click
Next.
9. On the Choose Users page, select whether to install for anyone using the computer
or just yourself, and then click Next
10. On the Choose Install Location page, enter the destination folder, such as
C:\Android\android-sdk, and then click Next.
Make a note of where you installed the files. You will need this information when
you configure JDeveloper 11.1.2.4 in Task 3, "Configure Oracle ADF Mobile for the
Android Platform".
11. On the Choose a Start Menu folder page, select the Start Menu folder or select Do
not create shortcuts, and then click Install.
12. After the installation completes, click Next.

3-2 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Installing the Android SDK and Tools

13. Ensure that Start SDK Manager is selected, and then click Finish.
You use the manager in the next task to install additional packages.

Task 2 Install Additional Android Packages


Because the emulator in later versions requires more memory and is slower, use
Android 4.2.2 (API 17) to develop and test the Business Card Scanner mobile
application. In addition to the Android 4.2.2 SDK platform and ARM EABI v7a system
image, you must also install the Android Support Library, Google Cloud Messaging
for Android Library, and Google USB Driver. Use the Android SDK Manager to select
and install the packages.
1. If the Android SDK manager isn't open, complete one of the following steps:
■ From the Start menu, find and select SDK Manager.
■ Go to the folder that you installed the Android SDK in, such as
C:\Android\android-sdk, and then double-click SDK Manager.exe.
You might need to run this executable file as an administrator. To do so, right
click SDK Manager.exe and select Run as Administrator.
The Android SDK Manager might take several seconds to start.
2. In the Packages section shown in the following figure, expand Tools.

3. In the Tools section, select the most current revision of the following, if they aren't
already installed:
■ Android SDK Tools
■ Android SDK Platform-tools
■ Android SDK Build-tools

Downloading and Installing the Software 3-3


Installing and Configuring JDeveloper 11.1.1.7.1 and JDeveloper 11.1.2.4

4. Select Android SDK Build-tools for revision 17 (in addition to the Android SDK
Build-tools for the most current version).
5. Expand Android 4.2.2 (API 17), and then select the following packages:
■ SDK Platform
■ ARM EABI v7a System Image
6. Select Obsolete to include obsolete packages in the list as shown in the following
figure:

7. Expand Extras, and then select the following packages:


■ Android Support Library
■ Google Cloud Messaging for Android Library (Obsolete)
■ Google USB Driver
8. Click Install Packages.
9. Accept the license, and then click Install.
10. Close the manager.

Installing and Configuring JDeveloper 11.1.1.7.1 and JDeveloper 11.1.2.4


Topics:
■ Task 1, "Download and Install JDeveloper 11.1.1.7.1"
■ Task 2, "Download and Install JDeveloper 11.1.2.4.0"
■ Task 3, "Configure Oracle ADF Mobile for the Android Platform"

Task 1 Download and Install JDeveloper 11.1.1.7.1


Oracle JDeveloper 11g (11.1.1.7.1) enables you to deploy Oracle ADF applications to
Oracle Java Cloud Service - SaaS Extension. This version supports the Oracle Java

3-4 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Installing and Configuring JDeveloper 11.1.1.7.1 and JDeveloper 11.1.2.4

Cloud Service - SaaS Extension SDK, which includes utilities that help manage Oracle
Java Cloud Service - SaaS Extension instances.
Because you are installing more than one instance of Oracle JDeveloper on your
system, you must install the software into a separate Oracle home directory.
1. Because the version that you need to download is an older version, go to the
JDeveloper archives page at
http://www.oracle.com/technetwork/developer-tools/jdev/downlo
ads/archives-090457.html
2. Click Oracle JDeveloper 11g 11.1.1.7.1.
3. Select Accept License Agreement.
4. In the Studio Edition section, select Windows Install, and then click Download
File.
5. Click Save File.
6. Select the folder to save the jdevstudio11117install.exe file in, and then click
Save.
7. To start the installer, open the folder that you saved the
jdevstudio11117install.exe file in, and then double-click the file.
8. On the Welcome page, click Next to start the installation process.
9. On the Choose Middleware Home Directory page, create a new Oracle home
directory, such as C:\Oracle\111171\Middleware\.
You must create a directory because you are installing two versions of JDeveloper.
Each installation must have a separate Oracle home directory.

Caution: The directory path can't contain spaces. For example, don't
create the Oracle home directory under C:\Program Files.

10. Click Next.

11. On the Choose Install Type page, select Complete, and then click Next.

12. Confirm the installation directories, and then click Next.

13. Select the shortcut location, click Next, and then click Next again.
14. To get the current Oracle Java Cloud Service - SaaS Extension SDK release, go to
http://www.oracle.com/technetwork/middleware/weblogic/downloa
ds/java-cloud-sdk-1848874.html, and then download the version of the
SDK that is appropriate for the version of your Oracle Java Cloud Service - SaaS
Extension instance.
15. Extract the contents into a folder, such as the C:\Users\your-user-folder\dev
folder.
16. Start JDeveloper 11.1.1.7.1

17. To change the SDK path to point to the version that you downloaded, select Tools
from the main menu, and then select Preferences.
18. In the Preferences dialog box, select Oracle Cloud.

19. In the Java Cloud Service SDK field, enter the path to the SDK folder, such as the
C:\Users\your-user-folder\dev\oracle-javacloud-sdk folder.

Downloading and Installing the Software 3-5


Installing and Configuring JDeveloper 11.1.1.7.1 and JDeveloper 11.1.2.4

20. Click OK.


21. Close JDeveloper.

Task 2 Download and Install JDeveloper 11.1.2.4.0


Oracle JDeveloper 11.1.2.4.0 (11g R2) supports the Oracle ADF Mobile extensions,
which enable you to develop on-device Oracle ADF Mobile applications.
Note that this version does not support Oracle Cloud development features.
Because you will have more than one instance of JDeveloper on your system, you must
install the software into a separate Oracle home directory.
1. Because the version that you need to download is an older version, go to the
JDeveloper archives page at
http://www.oracle.com/technetwork/developer-tools/jdev/downlo
ads/archives-090457.html
2. Click Oracle JDeveloper 11g 11.1.2.4.0.
3. Select Accept License Agreement.
4. In the Studio Edition section, select Windows Install, and then click Download
File.
5. Click Save File.
6. Select the folder to save the file in, and then click Save.
7. To start the installer, open the folder that you saved the
jdevstudio11124install.exe file in, and then double-click the file.
8. On the Welcome page, click Next to start the installation process.
9. On the Choose Middleware Home Directory page, create a new Oracle home
directory, such as C:\Oracle\11124\Middleware\.
You must create a directory because you are installing two versions of JDeveloper.
Each installation must have a separate Oracle home directory.

Caution: The directory path can't contain spaces. For example, don't
create the Oracle home directory under C:\Program Files.

10. Click Next.


11. On the Choose Install Type page, select Typical, and then click Next.

12. Confirm the installation directories, and then click Next.

13. Select the shortcut location, click Next, and then click Next again.

14. When the QuickStart page appears, start JDeveloper, select the Studio Developer
(All Features) role, and then click OK.
If you are asked whether to import preferences, click No.
15. To install the Oracle ADF Mobile extensions, complete the following steps.
a. From the main menu select Help, and then select Check for Updates.
b. On the Welcome page, click Next.
c. Select Search Update Centers, and then click Next to accept the defaults.

3-6 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Installing and Configuring JDeveloper 11.1.1.7.1 and JDeveloper 11.1.2.4

d. On the Updates page, after the list of available updates displays, enter mobile
in the Available Updates field, as shown in the following figure.

e. Select the ADF Mobile check box, and then click Next. Ignore the information
about the update. That is the same version as the one you are installing.
f. Accept the licensing agreements.
g. To start the download, click Next.
h. When the download completes, click Finish.
i. Restart JDeveloper.
j. When the Select Role dialog box appears, select the Studio Developer (All
Features) role to be able to use the Oracle ADF Mobile extensions, and then
click OK.

Task 3 Configure Oracle ADF Mobile for the Android Platform


To use the Android SDK and tools from JDeveloper, you must specify the location of
the Android files.
1. From the main menu, select Tools, and then select Preferences.
2. In the Preferences dialog box, select ADF Mobile.
3. If the Preferences dialog box does not display the available form factors, click Load
Extension.
4. Expand ADF Mobile, and then select Platforms, as shown in the following figure.

Downloading and Installing the Software 3-7


Troubleshooting the Use Case

5. In the Supported Platforms list, select Android.


6. Enter the information shown in the following table:

Field Value to Enter


Android SDK The path to the SDK folder, for example,
Location C:\Android\android-sdk
Android Platform The path to the Android API 17 platform folder, for example,
Location C:\Android\android-sdk\platforms\android-17
Android Build Tools The path to the Android API 17 build tools folder, for example,
Location C:\Android\android-sdk\build-tools\17.0.0

7. Accept all other the default values.


8. Click OK.
9. Close JDeveloper.

Troubleshooting the Use Case


Topics:
■ Launch of JDeveloper Stalls While Restoring Editors
■ Android 17 API Paths Not Available from Android Mobile: Platforms Preferences

Launch of JDeveloper Stalls While Restoring Editors


The startup of JDeveloper stalls during the restoring-editors phase.

Cause
The problem might be due to multiple installations of JDeveloper, or it might be due to
permission issues.

3-8 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Additional Resources

Solutions
Possible solutions include:
■ To cause JDeveloper to re-create the configuration data the next time that you start
it, delete the system directory that JDeveloper stores the configuration information
in. This system directory might be found in
C:\Users\your-name\AppData\Roaming\JDeveloper.
■ Ensure that you installed the 11.1.1.7 and 11.1.2.4.1 JDeveloper instances in
separate directories. Otherwise, one instance will try to load the other instance's
directory structure. If you already had JDeveloper installed, ensure that all
instances are installed in separate directory structures.
■ You might need to install JDeveloper as an administrator. To do so, right-click the
.exe file, and then select Run as Administrator.

Android 17 API Paths Not Available from Android Mobile: Platforms Preferences
You can see only Android 19 SDK paths from the Android Mobile: Platforms page.

Cause
Your system requires that you install the packages as an administrator.

Solution
Install the Android packages as an administrator.
1. Go to the folder that you installed the Android SDK in, such as
C:\Android\android-sdk.
2. Right-click SDK Manager.exe, and then select Run as Administrator.
3. Install the packages as described in Task 2, "Install Additional Android Packages".

Additional Resources
See the following resources for more information about the use cases discussed in this
section:
■ Information about installing the Oracle ADF Mobile extensions and setting up the
Android emulator
Setting Up ADF Mobile at http://docs.oracle.com/cd/E18941_
01/tutorials/toc.htm. Select JDeveloper 11g Release 2, and then scroll to the
ADF Mobile section.
■ Information about installing the Android SDK
Setting Up an Existing IDE at
https://developer.android.com/sdk/installing/index.html

Downloading and Installing the Software 3-9


Additional Resources

3-10 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
4
4Building the Service Application

This section describes building a service application that coordinates interactions with
several web services and consolidates those interactions into a simple set of web
service operations for use by mobile applications. It also discusses how to modify the
code to use a different card scan service.

Topics:
■ About the Use Case
■ Creating the Service Application
■ Creating the Organization Service Proxy
■ Creating the OSCOrganization Class
■ Deploying the Service Application to Oracle Java Cloud Service - SaaS Extension
■ Verifying the Service Application Deployment
■ Extending the Application to Use a Different Card Scan Service
■ Creating the Basic Authorization Application
■ Troubleshooting Application Deployment
■ Additional Resources

Executive Summary

Use Case The Business Card Scanner mobile application must interact with
multiple Oracle Sales Cloud services, an optical character reader (OCR)
service, and a geocoding service. You need a service application that
simplifies the mobile application's interactions with these web services,
and that offloads processing in order to minimize the mobile
application's footprint. This service will be deployed to an Oracle Java
Cloud Service - SaaS Extension instance.
Implementation Use Oracle JDeveloper 11.1.1.7.1 to build the Business Card Scanner
Summary Cloud Services application. This application contains JDeveloper
projects that coordinate and simplify interactions with the various web
services.

Building the Service Application 4-1


About the Use Case

Components ■ JDeveloper 11.1.1.7.1


■ Oracle Java Cloud Service - SaaS Extension SDK
■ E53633-03-apps.zip
■ Business Card Scanner Cloud Services (BizCardCloudServices)
application
■ Business Card Scanner Basic Authentication (BizCardBasicAuth)
application
■ Oracle Sales Cloud account
■ Oracle Java Cloud Service - SaaS Extension account
■ ABBYY OCR account
■ Google account
■ Web service proxy technologies

About the Use Case


To implement the business card scanner project specifications, the mobile application
must interact with several web services:
■ An optical card reader service to scan a photo of a business card and return the
text that is in the photo.
■ A geocoding service that locates the address from the business card.
■ The web services for interacting with Oracle Sales Cloud objects.
One method for minimizing a mobile application's footprint and bandwidth is to
provide a service application that offers a simple set of web service operations for
consumption by the mobile application, as illustrated by the Business Card Scanner
Cloud Services application described in this chapter. These web service operations
orchestrate the multiple calls to the different services. The following figure shows the
overall architecture of the Business Card Scanner Cloud Services application.

Business Card Scanner Abbyy Cloud OCR


Cloud Services Web Services
Application
Scan BizCardScanOCR Google Geocoding
Image ImageService Web Service
to Text Web Service
Business Oracle Sales Cloud
Card
Scanner LocationService
Mobile Web Service
Application
Create / Update BizCardScanOSC
PersonService
Contact, Find Matching ContactService
Web Service
Companies, Web Service
Locate Address
OrganizationService
Web Service

In this section, you build the application using JDeveloper 11.1.1.7.1 and Oracle Java
Cloud Service - SaaS Extension SDK, and you deploy it to an Oracle Java Cloud
Service - SaaS Extension instance.You also deploy an application that the mobile
application uses for authorization.

4-2 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the Service Application

Creating the Service Application


Topics:
■ Task 1, "Prerequisites"
■ Task 2, "Enable SSL Connections with ocrsdk.com"
■ Task 3, "Configure Access to the Services"
■ Task 4, "Open the BizCardScanCloudServices Application in JDeveloper 11.1.1.7.1"

Task 1 Prerequisites
Complete the following steps before creating the application.
■ The foundation of the service application is pre-built. This application is included
in a ZIP file that contains all the files that you need to build both the service
application and the mobile application.
To download the business card scanner files:
1. Download
http://docs.oracle.com/cloud/latest/supportdocs/E53633-03-
apps.zip.
2. Extract the files into a folder, such as C:\Users\your-user-folder\dev.
The ZIP file contains the following JDeveloper applications.
– BizCardScanCloudServices: This contains the projects for the Business
Card Scanner Cloud Services application.
– BizCardBasicAuth: This contains the projects for the Business Card
Scanner Basic Authentication application.
– BizCardScanCloudUI: This contains the projects for the Business Card
Scanner mobile application.
You work with the BizCardScanCloudServices and BizCardBasicAuth
JDeveloper applications in this section. Later you work with the
BizCardScanCloudUI JDeveloper application.
The ZIP file also contains the BizCardAdminConfig folder, which contains SQL
statements.
■ To complete the application, you must have the following information:

Items Description
ABBYY OCR service The application name and password are emailed to you when you
application name, register a new ABBYY Cloud application, as shown in Register for the
application ABBYY Cloud OCR Web Service. Note that the application password
password, and isn't the same as the account password.
service address
The password is a hash value that looks similar to
aB1cDeFGh2Ij34k/lMnoPQrS.
The service address is as follows:
http://cloud.ocrsdk.com
Google API key and You must have a Google API key to access the Google Geocoding
service address service.
The service address is as follows:
https://maps.googleapis.com/maps/api/geocode

Building the Service Application 4-3


Creating the Service Application

Items Description
Oracle Sales Cloud The service address is in the form of
service address, user https://zzzz.crm.usn.oraclecloud.com.
name, password
Note that the service address is typically the same as the server portion
of the URL of the simplified UI page that is displayed when you sign in
to Oracle Sales Cloud. This is the page that displays the logo and the
springboard.
Oracle Java Cloud The Oracle Java Cloud Service - SaaS Extension URL is
Service - SaaS https://cloud.oracle.com.
Extension URL, data
The data center name is similar to US Commercial 1.
center, identity
domain, user name, The identity domain is similar to usoracletrial99999.
and password
When you sign in to Oracle Java Cloud Service - SaaS Extension, the
Java service name, service names appear in the Active Platform Services section in the
and database service dashboard. The service names are similar to javatrial9999 and
name javatrial9999db.
Oracle Java Cloud The service instance URL is displayed in the Additional Information
Service - SaaS section on the page for the Java platform service. This URL is similar to
Extension service https://javatrial9999-usoracletrial99999/java.us1.oraclecloud
instance URL apps.com.

■ (Optional) Later in this document, you must provide the service paths for several
Oracle Sales Cloud services. This information is in this document. However, you
might want to learn how to determine the service paths for Oracle Sales Cloud
objects. The following steps show you how to get the service path for the
Organization object.
To get the service path for the Organization object:
1. Go to the Oracle Enterprise Repository at
http://fusionappsoer.oracle.com, and sign in as a guest.
2. In the Search area, enter Organization for the search string.
3. From the Type list, select ADF Service
4. From the Version list, select 11.1.8.0.0.
5. From the Product Family, select Sales.
6. Click Search.
7. In the Results list, select Trading Community Organization.
8. Click the Detail tab, and then scroll to the bottom of the page.
The page displays the following service path:
http://<crm_server:PortNumber>/foundationParties/OrganizationService?WSDL

Task 2 Enable SSL Connections with ocrsdk.com


In order to establish an SSL connection between the Oracle Java Cloud Service - SaaS
Extension instance and the ABBYY web service at ocrsdk.com, the instance must trust
the Certificate Authority (CA) issued SSL certificate for ocrsdk.com. If the trust
relationship is not established, the extension displays the following error when the
application calls the ABBYY web service:
BizCardScanException thrown: Unable to access Business Card Scanner URL
https://cloud.ocrsdk.com/processBusinessCard?language=English&exportFormat=xml

4-4 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the Service Application

To ensure that a trust relationship exists, obtain and then use the Oracle Java Cloud
Service - SaaS Extension SDK to upload the CA certificate for ocrsdk.com.

Note: Access to an Oracle Java Cloud Service - SaaS Extension


instance is controlled through the use of roles that are configured
using the instance's Identity Console. (Roles are named groups of
related privileges). Instances are pre-seeded with a set of roles. To use
the SDK, you must have the Java_Administrator role assigned to you.

1. To get the CA certificate for ocrsdk.com, complete the following steps. Because
each browser type has a different UI, the steps might differ for your browser.
a. From your browser, go to:
https://cloud.ocrsdk.com/processBusinessCard
A 404 error code displays, but you can ignore the error for these steps.
b. To open a dialog box about the website's certificate, click the lock icon in the
browser's address bar.
c. From the dialog box, go to the page from which you can view the certificate,
and then view the certificate's details.
d. The detail page displays a certificate hierarchy or path. The website is the
lowest item in the hierarchy. Select the parent of the website.
e. Export or copy the certificate.
f. When prompted to select a type or format, select X.509 Certificate (DER).
Some browser types save this file with a .cer extension and some save the file
with a .der extension. Regardless of the extension, when you invoke the
javacloud command in the next step, use the value CER for the -certfiletype
argument.
2. To add the certificate to the Oracle Java Cloud Service - SaaS Extension instance,
enter the following javacloud command:
javacloud add-ssl-certificates -user username -p password -id identity-domain
-si service-instance-name -datacenter data-centercode -path
path-to-downloaded-certificate -certfiletype CER

Tip: To minimize the javacloud command parameters that you must


provide, put common command-line arguments, such as user name
and service instance name, in a javacloud.parameters file. For more
information, see CI-Javacloud.properties in the SDK documentation.

Task 3 Configure Access to the Services


Create a database table in the database platform service to store the configuration
information for Oracle Java Cloud Service - SaaS Extension, Oracle Sales Cloud, the
Google Geocoding service, and the ABBYY OCR service. Then, install an Application
Express application and use that application to configure access to the services.

Building the Service Application 4-5


Creating the Service Application

Note: The JavaServiceFacade class in the BizCardConfigProperties


project provides a simplified interface to the Oracle Java Cloud Service
- SaaS Extension database instance. Note that when this class is
instantiated, it queries the Java Naming and Directory Interface (JNDI)
directory service to determine the name of the default database and
overrides the jta-data-source entry in the persistence.xml file with
that name. This method assumes that just one database resource exists
for the service.

1. Go to https://cloud.oracle.com, and then sign in.


2. In the My Services section shown in the following figure, select the data center,
and then click Sign In to My Services.

3. Enter your user name and password, enter the identity domain, and then click
Sign In.
4. Click the database platform service, such as javatrial9999db (Database).
5. Click Open Service Console.
6. Click SQL Workshop, and then click SQL Scripts.
7. Click Upload, click Browse, go to the folder that you unzipped the
E53633-03-apps.zip file into, open the BizCardAdminConfig directory, select BIZ_
CARD_SCAN_CONFIG1.sql, and then click Open.
8. Click Upload.
9. In the row for the BIZ_CARD_SCAN_CONFIG1.sql file that you just uploaded, click
Run, and then click Run Now.
If a warning that the script contains statements that will be ignored is displayed,
ignore the warning.
10. Verify that the script ran without errors.

11. Click View Results for the BizCardScanConfig script, and then verify that the
following occurred.
■ The BIZ_CARD_SCAN_CONFIG1 table was created
■ A sequence was created
■ A trigger was created
■ Three new rows were inserted
12. To go to the Application Express home page, click the Home tab.

4-6 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the Service Application

13. Click Application Builder.


14. From Application Builder, click Import.

15. From the Specify File page, click Browse, go to the folder that you unzipped the
E53633-03-apps.zip file into, open the BizCardAdminConfig directory, select the
BIZ_CARD_SCAN_CONFIG_APEXAPP.sql file, and then click Open.
16. Select Database Application, Page or Component Export, and then click Next.

17. On the File Import Confirmation page, verify that the file was imported
successfully, and then click Next.
18. On the Install page, select the one value from the Parsing Schema list. Accept the
default values for Build Status and Install as Application.
19. Click Install Application.

20. On the installation confirmation dialog box, click Run Application.

21. In the Navigation region, click Biz Card Scan Config1.


22. To configure access to the web services, click the Edit button (pencil) for each row,
and then edit the following fields.
■ Config Type: ABBYY
– External ID: Enter the name of the application that you registered with
ABBYY, as described in Prerequisites.
– License Key: Enter the ABBYY application password, as described in
Prerequisites.
■ Config Type: GOOGLEGEO
– License Key: Enter the Google API key.
■ Config Type: OSC
– URI: Enter the Oracle Sales Cloud service address.
23. Sign out.

Task 4 Open the BizCardScanCloudServices Application in JDeveloper 11.1.1.7.1


Because you will deploy this application to Oracle Java Cloud Service - SaaS
Extension, you must build the application using JDeveloper 11.1.1.7.1.
1. Start JDeveloper 11.1.1.7.1.

Tip: If you didn't close JDeveloper 11.1.2.4 after installing it, you
should close it now to free resources.

2. From the main menu, select File, and then select Open.
3. Go to the folder that you extracted the files to, open BizCardScanCloudServices,
and then open BizCardScanCloudServices.jws.
Note that the tasks in this section form a small, simple addition to the application's
existing functionality. The projects and code that already exist are available for you
to browse through. A fully running infrastructure is in place and is ready to be
extended.

Building the Service Application 4-7


Creating the Organization Service Proxy

Creating the Organization Service Proxy


The Business Card Scanner Cloud Services application must be modified to interact
with the Oracle Sales Cloud OrganizationService web service. JAX-WS web service
proxy projects enable you to easily interact with remote SOAP web services using Java
objects and methods. When you create a web service proxy project from JDeveloper,
the IDE generates the necessary objects and methods that are based on the information
in the web service's XML schema. The web service's schema uses the web services
description language (WSDL) to describe the web service's operations. This schema is
typically referred to as the WSDL. The following example shows an excerpt from the
WSDL for the OrganizationService web service. The XML element in the example
describes the getOrganization operation.
<oer:operation name="getOrganization">
<description>
Get operation for Trading Community Organization Details
</description>
<oer:parameters>
<oer:parameter name="partyId" description="Party identifier"/>
<oer:return description=
"Trading Community Organization Details that matches the inbound key
attributes."/>
</oer:parameters>
</oer:operation>

Because web services can change their WSDLs, creating a separate JDeveloper proxy
project for each web service is a good practice. By creating a separate project for each
web service, you can regenerate a web service's classes and methods automatically
whenever a WSDL changes, either during the development process, or over the
lifespan of the consumed service, such as in new releases. There is also the possibility
that when you consume more than one web service from the same source (such as
Oracle Sales Cloud) there might be name space conflicts or overlaps for the Java and
XML artifacts that are created from different WSDLs. A separate proxy project for each
web service helps to keep a well-defined boundary for each individual service that
you use, and prevents accidental overlaps or similar side effects. Another benefit of
separate projects is that each proxy can be implemented and maintained by a different
team.
In this application, proxy projects exist for the following Oracle Sales Cloud business
object web services:
■ LocationService
■ PersonService
In this section you create a proxy project for the OrganizationService web service.

Tip: To learn about Oracle Sales Cloud web services, and their
operations and payload structures, go to the Oracle Enterprise
Repository at https://fusionappsoer.oracle.com, and then
search for external ADF services for the Sales product family.

Topics:
■ Task 1, "Create the Organization Service Proxy Project"
■ Task 2, "Configure the Dependencies"
■ Task 3, "Explore the Generated Files"

4-8 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the Organization Service Proxy

Task 1 Create the Organization Service Proxy Project


1. To create a generic project, from the main menu, select File, and then select New.

2. In the New Gallery, select General, select Generic Project, and then click OK.
3. In the Application Name field, enter: OSCOrganizationServiceProxy
4. From the Available list in the Project Technologies tab, select Java, Oracle Cloud,
and Web Services, as shown in the following figure.

5. Click Next.
6. On the Project Java Settings page, ensure that the default package is
oracle.apps.cloud.bizCard.service.
7. Click Finish.
8. To access the Create Web Service Proxy wizard, right-click the
OSCOrganizationServiceProxy project, and then select New.
9. In the Categories list in the All Technologies tab, expand Business Tier, and then
select Web Services.
10. Select the Web Service Proxy item, as shown in the following figure, and then
click OK.

Building the Service Application 4-9


Creating the Organization Service Proxy

11. In the Create Web Service Proxy wizard, click Next.

12. On the Select Client Style page, select JAX-WS Style, and then click Next.

13. On the Select Web Service Description page, enter the following URL in the WSDL
Document URL field. Replace sales-cloud-service-address with the service
address for your Oracle Sales Cloud instance.
https://sales-cloud-service-address/foundationParties/OrganizationService?wsdl

For example, if the service address is zzzz.crm.usn.oraclecloud.com, you would


enter the following URL.
https://zzzz.crm.us1.oraclecloud.com/foundationParties/OrganizationService?wsdl

14. Click Next.


It might take several seconds before the wizard starts fetching the
OrganizationService WSDL document. The wizard gets the information from the
WSDL document and then builds the model for the service. It might take several
minutes for the wizard to build the service.
15. On the Specify Default Mapping Options page that is shown in the following
figure, enter the values shown in the following table.

4-10 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the Organization Service Proxy

Field Value Notes


Package oracle.apps.cloud.bizCard.service.osc.organization The package for the generated
Name artifacts.
Root oracle.apps.cloud.bizCard.service.osc.organization.type JDeveloper resolves into Java
Package classes the web services types
for that are defined in the WSDL,
Generated and then stores them in this
Types package.
Generate Clear the option. If you don't clear the check box,
As Async then additional methods are
added to the proxy client. These
methods allow you to call the
web service asynchronously.
Asynchronous support isn't
required for this application.
Note that typically, web services
are programmed synchronously
if the application requires the
web service to return a response
for further processing.

16. Accept all the other default values.

17. Click Next.


It might take several seconds for the next page to appear.
18. On the Port Endpoints page, accept the default values, and then click Next.

19. On the Asynchronous Methods page, select Don't generate any asynchronous
methods.

Building the Service Application 4-11


Creating the Organization Service Proxy

20. Click Finish.


21. Complete the following steps to modify the automatically generated
OrganizationService_Service class.
a. Use the search field in the top-right corner to find and open the
OrganizationService_Service.java file, as shown in the following figure.

Tip: To find where the file exists in the Application Navigator,


right-click in the source, and then select Select in Navigator.

b. The automatically-generated static block in this class throws an access


violation if it's invoked by an application that is running in an Oracle Java
Cloud Service - SaaS Extension instance. This is because applications that are
running in an Oracle Java Cloud Service - SaaS Extension instance cannot
create file or directory references in the application's current directory.
The information from the automatically generated static block isn't necessary
because its purpose is to provide a hint of where the local WSDL might be, so
that the application can validate the connection against the WSDL. Without
the hint, the connection tries to create the connection as written, which is more
appropriate in this application because the end point is dynamically
generated.
To remove the unnecessary code that causes the access violation, replace the
static block with the following code, and then save your changes.
static
{
System.setProperty("javax.xml.transform.TransformerFactory",
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
}

Task 2 Configure the Dependencies


Add the new project as a dependency of the BizCardScanOSCServiceBase project.
1. In the Application Navigator, right-click the BizCardScanOSCServiceBase
project, and then select Project Properties.
2. In the Project Properties dialog box, select Dependencies, and then click the Edit
button (pencil).
3. Expand OSCOrganizationServiceProxy.jpr, and then select the
OrganizationService-Client check box.
4. Click OK, and then click OK again.
5. To make the classes available for import statements, right-click
BizCardScanOSCServiceBase, and then select Rebuild
BizCardScanOSCServiceBase.jpr.

4-12 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the OSCOrganization Class

Note that the build will complete, but it will display errors about not finding the
OSCOrganization class because of work in progress. Ignore the warnings. You will
fix those errors in the following tasks.

Task 3 Explore the Generated Files


The BizCardScanCloudServices JDeveloper application uses the Organization web
service to retrieve a list of organization parties for a specified name. Follow these steps
to examine the code that is used by the service.
1. In the OSCOrganizationServiceProxy project, go to the
oracle.apps.cloud.bizCard.service.osc.organization.type package.
2. Open and examine the FindOrganization.java class, which describes the content
that is required for the findOrganization web service call.
3. (Optional) Open and examine FindCriteria.java and FindControl.java, which
are required for the call, and OrganizationPartyResult.java, which describes the
returned content.
4. Go to the oracle.apps.cloud.bizCard.service.osc.organization package and
open the OrganizationService.java class.
5. Examine the findOrganization method. This method is called by the application
to retrieve a list of organization parties.

Creating the OSCOrganization Class


The application includes the abstract OSCServiceBase class to manage injecting the
authorization and authentication interactions with the Oracle Sales Cloud business
object web services.
To simplify interactions with the OrganizationService web service call, create a Java
class that implements the OSCServiceBase class and that exposes only the methods
and parameters that are necessary for this use case. This class will have one public
method that returns a list of customers that have matching names.

Topics:
■ Task 1, "Create a Class to Orchestrate OrganizationService Web Service Calls"
■ Task 2, "Override the initializeConnection Method"
■ Task 3, "Add Code to Retrieve the Service Port URL from the Database"
■ Task 4, "Implement Code to Retrieve a List of Matching Customer Names"

Task 1 Create a Class to Orchestrate OrganizationService Web Service Calls


1. To create the class, from the BizCardScanOSCServiceBase project in the
Application Navigator, right-click the
oracle.apps.cloud.bizCard.service.osc.impl package, and then select New, as
shown in the following figure.

Building the Service Application 4-13


Creating the OSCOrganization Class

2. In the New Gallery, expand General, select Java, select Java Class, and then click
OK.
3. In the Create Java Class dialog box, in the Name field, enter: OSCOrganization
4. Don't change the Package value.
5. In the Extends field, enter:
oracle.apps.cloud.bizCard.service.osc.OSCServiceBase
6. Click OK.
7. In the source editor, add the following import statements. Note that orange
warning tags appear for the statements because they are not yet used in the class.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.net.URL;
import java.net.MalformedURLException;
import javax.xml.namespace.QName;
import com.sun.xml.ws.developer.WSBindingProvider;
import oracle.apps.cloud.bizCard.service.osc.exception.OSCServiceException;
import oracle.apps.cloud.bizCard.service.*;
import oracle.apps.cloud.bizCard.service.osc.*;
import oracle.apps.cloud.bizCard.service.osc.model.*;
import oracle.apps.cloud.bizCard.service.osc.exception.*;
import oracle.apps.cloud.bizCard.service.osc.organization.*;
import oracle.apps.cloud.bizCard.service.osc.organization.type.*;

8. In the source editor, add the following declarations to the top of the
OSCOrganization class. These declarations are necessary to get the logger class, to
specify the security policy, and to hold information about the service.
private static Logger logger =
Logger.getLogger(OSCOrganization.class.getName());
private static final String OSC_CONFIG_TYPE = "OSC";
private static final String ORG_SERVICE =
"/foundationParties/OrganizationService?WSDL";
private SecurityPolicyFeature[] securityFeature =
new SecurityPolicyFeature[] {
new SecurityPolicyFeature(

4-14 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the OSCOrganization Class

"oracle/wss_username_token_over_ssl_client_policy")
};
private OrganizationService orgService;

9. From the main menu, select File, and then select Save All.

Task 2 Override the initializeConnection Method


Change the initializeConnection method to look up the service end point of the
Oracle ADF Business Components web service from the ADF connection support. The
OrgService instance is the proxy class that invokes methods to query the remote web
service.
Replace the initializeConnection method with the following code.
If you are copying text from PDF, you might need to fix line-break errors and remove
header and footer text.
@Override
protected void initializeConnection() {
logger.entering(this.getClass().getName(), "initializeConnection");

if (!isInitialized()) {
logger.log(Level.FINE,
"Initializing connection for OrganizationService");
this.defineConnection();
try {
orgService =
(new OrganizationService_Service(getServicePortUrl(),
new QName(
"http://xmlns.oracle.com/apps/cdm/foundation/parties/"
+ "organizationService/applicationModule/",
"OrganizationService"
))).getOrganizationServiceSoapHttpPort(securityFeature);
} catch (Throwable e) {
logger.log(Level.SEVERE,
"organizationService_service.getOrganizationServiceSoapHttpPort failed",
e);
}
this.injectAuthentication((WSBindingProvider)orgService);
this.setInitialized(true);
}
logger.log(Level.INFO, "initializeConnection End");
}

Task 3 Add Code to Retrieve the Service Port URL from the Database
In Creating the Service Application, you created a table in the Oracle Java Cloud
Service - SaaS Extension database to store information about the various services,
including service port URLs. You must modify the getServicePortUrl method to use
the JavaServiceFacade class to access that database, and to get the
OrganizationService service port URL that is stored in the database table.
Replace the getServicePortURL method with the following code.
If you are copying text from PDF, you might need to fix line-break errors and remove
header and footer text.
protected URL getServicePortUrl() {
URL wsdlLocationURL = null;
JavaServiceFacade jsfclient = new JavaServiceFacade();

Building the Service Application 4-15


Creating the OSCOrganization Class

List<BizCardScanConfig1> list =
jsfclient.getBizCardScanConfig1ConfigType(OSC_CONFIG_TYPE);
String uri = list.get(0).getUri();
logger.log(Level.INFO,
"Connection properties ORGANIZATION_CONFIG_TYPE: URI: " + uri);
try {
wsdlLocationURL = new URL(uri + ORG_SERVICE);
logger.log(Level.INFO,
"Connection properties wsdlLocationURL: " +
wsdlLocationURL.toString());
} catch (MalformedURLException e) {
logger.log(Level.ALL, "Failed to create wsdlLocationURL using:" + uri,
e);
}
return wsdlLocationURL;
}

Task 4 Implement Code to Retrieve a List of Matching Customer Names


Add the findOSCCustomersForName public method and supporting code. This method
returns a list of customer (organization) names that match, start with, or contain a
given name.
1. Add the ConstructMultipartViewCriteriaItem support method to find matching
names and add the STOP_WORDS list that the method uses.
If you are copying text from PDF, you might need to fix line-break errors and
remove header and footer text.

Note: If JDeveloper prompts you to select an import statement for a


class, press Alt+Enter, and then, choose the class that is in the
oracle.apps.cloud.bizCard.service.osc.organization.type
package.

private List<ViewCriteriaItem>
constructMultipartViewCriteriaItem(String[] stringParts,
String partsOperator) {
List<ViewCriteriaItem> crItems = new ArrayList<ViewCriteriaItem>();
for (String namePart : stringParts) {
if (namePart.trim().length() > 0 &&
!STOP_WORDS.contains(namePart.trim().toUpperCase())) {
ViewCriteriaItem vci = new ViewCriteriaItem();
vci.setAttribute("PartyName");
vci.setConjunction(Conjunction.OR);
vci.setOperator(partsOperator);
vci.setUpperCaseCompare(true);
vci.getValue().add(namePart);
crItems.add(vci);
}
}
return crItems;
}
private static final List<String> STOP_WORDS =
Arrays.asList(new String[] { "AND", "THE", "A", "AN" });

2. Add the createExactMatchItem and createStartsWithItem support methods.

4-16 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the OSCOrganization Class

If you are copying text from PDF, you might need to fix line-break errors and
remove header and footer text.
private ViewCriteriaItem createExactMatchItem(String name) {
ViewCriteriaItem nameItem = new ViewCriteriaItem();
nameItem.setAttribute("PartyName");
nameItem.setOperator("=");
nameItem.getValue().add(name);
nameItem.setUpperCaseCompare(true);
nameItem.setConjunction(Conjunction.OR);
return nameItem;
}

private List<ViewCriteriaItem> createStartsWithItem(String[] stringParts) {


return constructMultipartViewCriteriaItem(stringParts, "STARTSWITH");
}

3. Add the createPartyFilterItem support method to find matching names.


private ViewCriteriaItem createPartyFilterItem(String partyType) {
ViewCriteriaItem typeItem = new ViewCriteriaItem();
typeItem.setAttribute("PartyType");
typeItem.setOperator("=");

typeItem.getValue().add(partyType);
typeItem.setConjunction(Conjunction.AND);
return typeItem;
}

4. Add the getFilterForPartyNameMatch method, which defines a set of view


criteria items for the search condition in the comma-separated name argument. It
removes double occurrences of blanks (the delimiter), and then splits the search
string (name) into an array.
If you are copying text from PDF, you might need to fix line-break errors and
remove header and footer text.

Note: If JDeveloper prompts you to select an import statement for a


class, press Alt+Enter, and then, choose the class that is in the
oracle.apps.cloud.bizCard.service.osc.organization.type
package.

private ViewCriteria getFilterForPartyNameMatch(String partyType,


String name) {
// slice the string into pieces.
// 1. try to match on the whole phrase
// 2. try to match on STARTSWITH the first two or three phrases
// 3. try to match on CONTAINS every individual substring
// (which will likely always return null)
String[] stringParts = name.replaceAll(" ", " ").split(" ");

ViewCriteriaItem partyTypeItem = createPartyFilterItem(partyType);


ViewCriteriaItem exactMatchItem = createExactMatchItem(name);
List<ViewCriteriaItem> startsWithMatchItems =
createStartsWithItem(stringParts);

ViewCriteriaRow typeFilters = new ViewCriteriaRow();


typeFilters.getItem().add(partyTypeItem);

Building the Service Application 4-17


Creating the OSCOrganization Class

ViewCriteriaRow nameFilters = new ViewCriteriaRow();


nameFilters.getItem().add(exactMatchItem);
nameFilters.getItem().addAll(startsWithMatchItems);
//nameFilters.getItem().addAll(containsMatchItems);
nameFilters.setConjunction(Conjunction.AND);

ViewCriteria filters = new ViewCriteria();


filters.getGroup().add(typeFilters);
filters.getGroup().add(nameFilters);

return filters;
}

5. Add the findOSCCustomersForName method to retrieve matching names. This


method uses an Oracle ADF Business Components view criteria finder method to
filter the result set of the query to contain customers that match the name
argument. The range start and size allows pagination and limits the number of
customers retrieved in a single call. The list of customers is then transformed into
an array and returned to the calling method.
If you are copying from PDF, you might need to correct line-break errors and
remove header and footer text.

Note: If JDeveloper prompts you to select an import statement for a


class, press Alt+Enter, and then choose the appropriate class. For the
ServiceException class, choose
oracle.apps.cloud.bizCard.service.osc.organization.ServiceEx
ception. For all other classes, choose the class that is in the
oracle.apps.cloud.bizCard.service.osc.organization.type
package.

public CustomerResult[] findOSCCustomersForName(


String name, int fetchSize, int fetchStart)
throws OSCServiceException {
initializeConnection();

FindCriteria criteria = new FindCriteria();


criteria.setFetchSize(fetchSize);
criteria.setFetchStart(fetchStart);
criteria.setFilter(
getFilterForPartyNameMatch("ORGANIZATION", name));

FindControl control = new FindControl();


control.setRetrieveAllTranslations(false);

OrganizationPartyResult result;
try {
result = orgService.findOrganization(criteria, control);
List<CustomerResult> resultList =
new ArrayList<CustomerResult>();
for (OrganizationParty org : result.getValue()) {
CustomerResult customer = new CustomerResult();
customer.setCustomerId(org.getPartyId());
customer.setFullName(org.getPartyName());
if (org.getPartySite() != null &&
org.getPartySite().size() > 0) {
customer.setAddress(
org.getPartySite().get(0).getFormattedAddress().getValue());

4-18 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Deploying the Service Application to Oracle Java Cloud Service - SaaS Extension

}
if (org.getPreferredContactPersonId().getValue() != null) {
Long preferredContactId =
org.getPreferredContactPersonId().getValue();
for (Relationship rel : org.getRelationship()) {
if (rel.getObjectId().equals(preferredContactId)) {
customer.setPreferredContact(rel.getPartyName());
break;
}
}
}
if (org.getURL().getValue() != null) {
customer.setCompanyUrl(org.getURL().getValue());
}
resultList.add(customer);
}
return resultList.toArray(new CustomerResult[resultList.size()]);

} catch (ServiceException e) {
logger.log(Level.SEVERE, "Failed to query Organization", e);
throw new OSCServiceException(e);
}
}

6. To replace the package import statements with class-specific import statements,


right-click in the source editor, and then select Organize Imports.
7. Save and close the file.

Deploying the Service Application to Oracle Java Cloud Service - SaaS


Extension
Use JDeveloper to deploy the application to Oracle Java Cloud Service - SaaS
Extension. You will need the Oracle Java Cloud Service - SaaS Extension data center,
domain identity, service name, user name, and password that you got in Prerequisites.

Task: Deploy the Application to Oracle Java Cloud Service - SaaS Extension
1. In the Application Navigator, right-click the BizCardScanCloudServices
application, select Deploy, and then select BizCardScanner.
2. On the Deployment Action page in the Deploy wizard, select Deploy to
Application Server, and then click Next.
3. To add an application server, complete the following steps.
a. On the Select Server page in the Create Application Server Connection wizard,
click the Add button (green plus sign).
b. On the Name and Type page, enter a connection name, such as
MyJavaCloudService.
c. From the Connection Type list, select Oracle Cloud, and then click Next.
d. On the Authentication page, enter your Oracle Java Cloud Service - SaaS
Extension user name and password, and then click Next.
e. On the Configuration page, select the data center, as shown in the following
figure.

Building the Service Application 4-19


Verifying the Service Application Deployment

f. Enter the identity domain and service name, and then click Next.
g. Click Test Connection.
h. Click Finish.
4. On the Select Server page of the Deploy wizard, select the application server that
you just created, and then click Finish.
5. Watch the progress in the Messages and Deployment tabs.
6. The deployment messages include the application URL, which contains the Oracle
Java Cloud Service - SaaS Extension instance URL, as shown in the following
example. Make a note of this address. You can use this address to verify the
deployment.
https://jcs-service-instance-URL/BizCardScanCloudServices/

If the application does not deploy successfully, see Troubleshooting Application


Deployment.

Verifying the Service Application Deployment


To verify the deployment, complete one of the following tasks:

Task: Verify the WSDL Descriptions Were Published


1. Go to
https://jcs-service-instance-URL/BizCardScanCloudServices/BizCardScanOC
RImagePort?wsdl to see the WSDL for the image scan service.
2. Go to
https://jcs-service-instance-URL/BizCardScanCloudServices/BizCardOSCCon
tactPort?wsdl to see the WSDL for the contact services.
3. (Optional) To view the operations' input parameters and responses, go to the URL
that is defined for the schemaLocation in the WSDL's xsd:import element.

4-20 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Extending the Application to Use a Different Card Scan Service

Task: Verify the Application Appears in Oracle Java Cloud Service - SaaS
Extension Control
1. From JDeveloper, select View, and then select Application Server Navigator.

2. From the Application Server Navigator, right-click the name of the connection to
the Oracle Java Cloud Service - SaaS Extension instance, and then choose Launch
Admin Console.
3. Sign in.
4. In the Service Instances table, click the Manage button for the service instance to
which you deployed the application.
5. On the Control page for the instance, verify that BizCardScan appears in the
Applications table.

Extending the Application to Use a Different Card Scan Service


The application was designed to make it easy to switch to a different card scan service.
If you choose to use a different card scan service, complete the following task.

Task: Use a Different Card Scan Service


1. Create a class that implements the
oracle.apps.cloud.bizCard.service.ocr.IBusinessCardScanner interface, and
that contains the following method. This method must call the card scan service to
scan the image, and then populate the BusinessCardResult return value with the
results.
BusinessCardResult scanBusinessCard(byte[] image)
throws BizCardScanException;

2. Modify the getBusinessCardScanner method in


oracle.apps.cloud.bizCard.service.ocr.BusinessCardScannerFactory.java
to return your class instead of AbbyBusinessCardScanner, as shown in the
following example:
public IBusinessCardScanner getBusinessCardScanner() {

// Return custom OCR Scanner object instead


// of the original ABBYY object

// Was: return new AbbyyBusinessCardScanner();


return new MyOCRCloudCardScanner();
}

3. If necessary, complete security set up tasks, such as adding a CA certificate as


described in Enable SSL Connections with ocrsdk.com.
4. (Optional) Use the BIZ_CARD_SCAN_CONFIG1 table described in Configure
Access to the Services to store information about the service, such as a password,
license key, or URL. The following example shows how to query the database table
for your configuration information:
JavaServiceFacade jsfclient = new JavaServiceFacade();

List<BizCardScanConfig1> list
=jsfclient.getBizCardScanConfig1ConfigType("YOURCONFIGNAME");

this.applicationId =list.get(0).getExternalId();

Building the Service Application 4-21


Creating the Basic Authorization Application

this.applicationPassword =list.get(0).getLicenseKey();

this.applicationUrl = list.get(0).getUri();

Creating the Basic Authorization Application


The Basic Authorization application is the server code that implements the Oracle Java
Cloud Service - SaaS Extension credential management for consumers of the Business
Card Scanner Cloud Services web services. It is implemented as a separate application
so that it can be swapped out, as appropriate, if different credential management
requirements arise.
Oracle Java Cloud Service - SaaS Extension access is controlled through the use of roles
that are configured using the Identity Console. (Roles are named groups of related
privileges). Service instances are pre-seeded with a set of roles, one of which is
service-name.JAVA_USERS. Users who are granted this role have access to the Java
applications that are deployed to the service. Use this default role to authenticate
users.
The Basic Authorization application includes a landing page that is configured as a
secure resource in the Oracle Java Cloud Service - SaaS Extension instance. To access
the contents of the landing page, a user must have the correct authentication
credentials for the service-name.JAVA_USERS role.
When a user signs in to the Business Card Scanner mobile application, the application
silently passes the user name and password to the Basic Authorization application's
landing page. If the page returns the HTTP code for "forbidden," then the mobile
application knows that the user isn't a valid Java application user.

Topics:
■ Task 1, "Open the Basic Authorization Application"
■ Task 2, "Configure the Java Service Name"
■ Task 3, "Deploy the Application to Oracle Java Cloud Service - SaaS Extension"

Task 1 Open the Basic Authorization Application


1. In the Application Navigator, click Open Application.
2. Go to the folder that you extracted the files in, open BizCardBasicAuth, and then
open BizCardScanBasicAuth.jws.

Task 2 Configure the Java Service Name


Identify the role name for valid Java application users.
1. In the Application Navigator, expand ViewController, expand Web Content, and
then expand WEB-INF.
2. Double-click weblogic.xml to open it in the editor.
3. Click the Source tab.
4. Change the principal-name value to the role that your instance uses to identify
valid Java application users, as shown in the following example.
<principal-name>javatrial9999.Java_Users</principal-name>

5. Save your changes.

4-22 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Additional Resources

Task 3 Deploy the Application to Oracle Java Cloud Service - SaaS Extension
Deploy the application in the same manner described in Task: Deploy the Application
to Oracle Java Cloud Service - SaaS Extension.

Troubleshooting Application Deployment


Topics:
■ Deployment to Oracle Java Cloud Service - SaaS Extension Failed

Deployment to Oracle Java Cloud Service - SaaS Extension Failed


When you deployed the application from JDeveloper, the following message was
displayed in the Deployment tab.
Oracle Cloud job failed. Message from the Oracle Cloud server was:
Oracle Cloud job failed. Check job log file.

Cause
Typically, this message occurs when you deploy an application that was already
deployed. To determine the error that prevented deployment, click the link for the
Oracle Cloud Deploy Job Log.

Solution
When you redeploy an application, the service first deletes the deployed application
and then deploys it. Sometimes, the service attempts to deploy the application before
the deletion process completes. Try deploying the application again. Alternatively,
complete the following steps to delete the deployed application, and then deploy it
again. If you are sharing the service instance with others, before completing the steps,
ensure that no one else is trying to deploy the same application to your service.
1. From JDeveloper, select View, and then select Application Server Navigator.
2. From the Application Server Navigator, right-click the name of the connection to
the Oracle Java Cloud Service - SaaS Extension instance, and then choose Launch
Admin Console.
3. Sign in.
4. In the Service Instances table, click the Manage button for the service instance to
which you deployed the application.
5. In the Applications section on the Oracle Java Cloud Service - SaaS Extension
Control page, select the application, and then click Delete Application.
6. Scroll to the bottom of the page to monitor the deletion process. You might need to
click the Refresh button to get the current status. When the status is Complete, try
deploying again.
7. If you still cannot redeploy, try stopping and restarting the service.

Additional Resources
To learn how to access Google's Google Maps API Geocoding service, see Geocoding
Service available at
https://developers.google.com/maps/documentation/javascript/geoc
oding.

Building the Service Application 4-23


Additional Resources

4-24 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
5
Configuring the Virtual Device
5

This section describes how to create and configure an Android virtual device
(emulator), which you use to test the Business Card Scanner mobile application.

Topics:
■ About the Use Case
■ Configuring the Emulator
■ Additional Resources

Executive Summary

Use Case During the development stage, you must test the Business Card
Scanner mobile application from your computer.
Implementation The Android virtual device (AVD), which emulates a mobile device,
Summary enables you to test the mobile application during the development
phase. Use the AVD Manager to create an Android virtual device and
then upload photos of business cards into the virtual device's
sdcard/Pictures folder. Then, scan the virtual device's SD card to add
the photos to the virtual device's gallery.
Components ■ AVD Manager
■ Digital photos of business cards
■ Android virtual device
■ Virtual device's SD card
■ Virtual device's Media Provider and Gallery applications

About the Use Case


This document discusses how to configure an Android virtual device to run the mobile
application. Note that you can use the iOS SDK and the iPhone simulator also, but this
document provides steps for Android development only.

Configuring the Emulator


Topics:
■ Task 1, "Start the Android Virtual Device Manager"
■ Task 2, "Create an Android Virtual Device"
■ Task 3, "Start the Virtual Device"

Configuring the Virtual Device 5-1


Configuring the Emulator

■ Task 4, "Load Business Card Photos"


■ Task 5, "(Optional) Configure the Proxy and Port"

Task 1 Start the Android Virtual Device Manager


Use the Android Virtual Device Manager to create a virtual device.
1. To start the Android Virtual Device Manager, go to the folder that you installed the
Android SDK in, such as C:\Android\android-sdk, and then double-click AVD
Manager.exe.
If your version of the SDK does not contain the AVD Manager.exe file, then
complete the following steps.
a. Double-click SDK Manager.exe.
b. To open the Android Virtual Device manager, from the main menu, select
Tools, and then select Manage AVDs.

Task 2 Create an Android Virtual Device


When you create a virtual device, you should configure a device that uses fewer
resources, such as the configurations described in this section.
1. From the Android Virtual Device Manager dialog box, click Create.
2. In the Edit Android Virtual Device dialog box, enter the following values.

Field Value
AVD Name ADFmf
Device Nexus One (3.7", 480 x 800: hdpi)
Target Android 4.2.2 - API Level 17
CPU/ABI ARM (armeabi-v7a)
Hardware keyboard present Selected
Skin Skin with dynamic hardware controls
Front Camera None
Back Camera Emulated
RAM 768
VM Heap 32
Internal Storage 500
SD Card: Size 500 MiB
Emulation Options None selected

3. Click OK, and then click OK again.

Task 3 Start the Virtual Device


To start the device from the Android Virtual Device Manager, select the ADFmf
device, click Start, and then click Launch.

Task 4 Load Business Card Photos


Create digital photos of business cards, copy them to your computer, and then use the
Android Device Monitor to load the photos into the virtual device.

5-2 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Configuring the Emulator

1. Take three or four digital photos of business cards, and then copy the photos to
your computer. If possible, include business cards from companies that are in your
Oracle Sales Cloud database.

Note: The technology framework that is used in the mobile


application to stream a photo can't process photos taken with some
phones and digital cameras. One way to ensure that the application
can scan a photo is to open the photo in Paint.net and then save it as a
JPEG with the quality factor set to 100 percent.
The Business Card Scanner Cloud Services application processes English
text only.

2. If the virtual device isn't running, start it by following the steps in Start the Virtual
Device.
3. To start the Android Device Monitor, open a command window, go to the tools
folder in the Android SDK directory, such as C:\Android\android-sdk\tools, and
then run monitor.bat.
The monitor takes a few seconds to appear.
4. In the File Explorer tab, which lists the directories on the virtual device, expand
the mnt folder and verify that the sdcard folder is writable. If the permissions for
the sdcard folder aren't d---rwxr-x, as shown in the following figure, complete
the following steps.

a. Open a command window, and then go to the SDK's platform-tools folder,


such as C:\Android\android-sdk\platform-tools.
b. Enter adb shell, and then press Enter.
c. At the hash (#) prompt, enter the following commands.
su

Configuring the Virtual Device 5-3


Configuring the Emulator

mount -o rw,remount rootfs /


chmod 777 /mnt/sdcard
exit
exit

Note: The File Explorer list also shows sdcard at the top level. This is
a symbolic link to /mnt/sdcard, and you can't perform the following
steps using that entry.

5. Expand sdcard. If sdcard doesn't contain Pictures, then select sdcard, click New
Folder (green plus sign), and then create the Pictures folder.
6. To open the Put File on Device file selector, select Pictures, and then click the Push
a file onto the device button (button with the arrow pointing at a phone), as
shown in the following figure.

7. Go to the folder that you put your business card photos in.
8. Select one of the photos, and then click Open. Repeat this step for the remaining
business cards.
9. Close the monitor.
10. To enable the virtual device to recognize the photos as part of the gallery, complete
the following steps.
1. From the home screen on the virtual device, display the Apps, and then click
the Dev Tools widget, as shown in the following figure.

5-4 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Configuring the Emulator

2. To scroll through the displayed options, press the left mouse button and drag
upward.
3. Find and click Media Provider.
4. Click Scan SD Card.
5. Return to the APPS page, click the Gallery widget, and verify that the
uploaded photos appear in the All Pictures folder and the Pictures folder.
6. Stop the device to free resources.

Task 5 (Optional) Configure the Proxy and Port


If you must configure your browser's proxy and port to access the Internet from your
computer, then you must also configure the virtual device's proxy and port.
1. If the virtual device isn't running, start it by following the steps in Start the Virtual
Device.
2. From the Basic Controls section that is displayed on the right side of the virtual
device, click Menu.
3. Click System settings, and then click More.
4. Click Mobile networks, and then click Access Point Names.
5. Click an APN, such as T-Mobile US.
6. Click Proxy and enter the proxy information that enables your computer to access
the Internet.
7. Click Port and enter the port information that enables your computer to access the
Internet.

Configuring the Virtual Device 5-5


Additional Resources

Additional Resources
For information about how to set up the Android virtual device, see Managing Virtual
Devices at http://developer.android.com/tools/devices/index.html.

5-6 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
6
6Building the Mobile Application

This section describes building a mobile application that enables users to create Oracle
Sales Cloud contacts based on photos of business cards. It focuses on the tasks for
using the Oracle ADF Mobile framework to create a taskflow of pages and their
interactions.

Topics:
■ About the Use Case
■ About the Web Service Data Controls
■ Building the Mobile Application
■ Adding the Cards Feature
■ Adding the Customer Search
■ Testing the Cards Feature
■ Troubleshooting the Use Case
■ Additional Resources

Executive Summary

Use Case The business card scan mobile application uses the web services that
are provided by the Business Card Scanner Cloud Services application,
which is deployed to an Oracle Java Cloud Service - SaaS Extension
instance.
Implementation The mobile application is built using features that are mapped to Oracle
Summary ADF Mobile framework taskflows. The application uses a
connections.xml file to configure the URL of the Oracle Java Cloud
Service - SaaS Extension instance. The users must sign in to the
application with their Oracle Java Cloud Service - SaaS Extension user
names. The credential store in the service instance stores the Oracle
Sales Cloud user names and passwords that are associated with the
Oracle Java Cloud Service - SaaS Extension users. The application is
deployed to an Android virtual device to test the flow.

Building the Mobile Application 6-1


About the Use Case

Components ■ JDeveloper 11.1.2.4.0 (11g R2)


■ Oracle Java Cloud Service - SaaS Extension account
■ Oracle Sales Cloud account
■ E53633-03-apps.zip, which contains the Business Card Scanner
mobile application
■ Business Card Scanner Cloud Services application deployed to
Oracle Java Cloud Service - SaaS Extension. This application
provides the following web services:
– BizCardScanOCRImageService
– BizCardOSCContactService
■ Oracle Java Cloud Service - SaaS Extension Credential Store
■ Oracle ADF Mobile application framework features, taskflows,
view activities, control flows, and components
■ Android virtual device

About the Use Case


The Business Card Scanner mobile application is built using the Oracle ADF Mobile
application framework. It consumes the web services that are provided by the
BizCardScanCloudServices application. This application uses local storage to store a
photo of a business card until the information from the photo is fully processed into an
Oracle Sales Cloud contact.

About the Web Service Data Controls


A data control provides an access layer that enables you to use the same steps,
regardless of the data source, to access data for the user interfaces that you build in an
Oracle ADF application.
Oracle ADF Mobile supports three types of data controls:
■ SOAP
■ REST service
■ JavaBean (POJO)
Oracle JDeveloper enables you to directly generate a data control from a WSDL
automatically. This feature is most useful when you use the web service without
additional processing. Otherwise, you use a combination of Java classes and beans to
implement the data control. The following list describes the application's web service
data controls and the method used to create each data control.
■ SecureBizCardOSCContact: This data control for the BizCardOSCContactService
web service was generated by the Web Service Data Control wizard using the
service's WSDL.
■ OscContactDC: This data control, which accesses OSCContactService web service
operations by invoking SecureBizCardOSCContact methods, enables the mobile
application to perform additional processing, such as error handling. To create this
data control, the OscContact.java class was built based on the web service
response payload. An additional method was added to handle null key values.
Then the OscContactDetailBean.java class was built. This class includes the
desired error handling. Last, the OSCContactDC.java class was created.

6-2 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Building the Mobile Application

■ SecureBizCardScanOCRImage: This data control for the


BizCardScanOCRImageService web service was generated by the Web Service
Data Control wizard using the service's WSDL. Because it might take several
seconds for the web service to synchronously parse an image into text, the
UploadScanManager.java class was created to oversee all invocations of the data
control's uploadImage operation as background threads. This class enables the user
to continue to use the application without having to wait for the result.
This application uses SOAP data controls. Note that REST services that use JSON as a
payload are developed using a POJO exposed as a data control and the REST adapter,
which is a programmatic way of resolving REST URIs.

Building the Mobile Application


Topics:
■ Task 1, "Prerequisites"
■ Task 2, "Open the Application in JDeveloper 11.1.2.4"
■ Task 3, "Configure Access to Oracle Java Cloud Service - SaaS Extension"
■ Task 4, "Store Your Credentials in the Oracle Java Cloud Service - SaaS Extension
Instance"
■ Task 5, "Create a Deployment Profile"
■ Task 6, "Deploy and Run the Application in the Virtual Device"

Task 1 Prerequisites
Before you can run this application, you must build and deploy the Business Card
Scanner Cloud Services application and the Business Card Scanner Basic
Authentication application as described in Building the Service Application. During
that process, you downloaded and extracted the contents of E53633-03-apps.zip. This
ZIP file includes the Business Card Scanner mobile application that you use in this
section.
To run the Business Card Scanner mobile application, you must have the service name
and service instance URL of an Oracle Java Cloud Service - SaaS Extension instance.
You got the service name in the prerequisites task for Creating the Service Application.
This name would be similar to javatrial9999.
To obtain the service instance URL, complete the following steps.
1. Go to https://cloud.oracle.com.
2. In the My Services section, select the data center, and then click Sign In to My
Services.
3. Enter your user name and password, enter the identity domain, and then click
Sign In.
4. Click the Java platform service, such as javatrial9999 (Java).
5. The Service Instance URL is shown in the Additional Information section. For
example, the service instance URL might be as follows.
https://javatrial9999-usoracletrial99999.java.us1.oraclecloudapps.com

Notice that the URL is derived from the service name, identity domain, and data
center.

Building the Mobile Application 6-3


Building the Mobile Application

Task 2 Open the Application in JDeveloper 11.1.2.4


Because you use the Oracle ADF Mobile framework, you must build the application
using JDeveloper 11.1.2.4.
1. If JDeveloper 11.1.1.1.7 is open, then close it. Although you can have both
instances open at the same time, the Android virtual device uses a large amount of
resources, and you should close as many applications as possible to free those
resources.
2. Start JDeveloper 11.1.2.4.
3. In the Application Navigator, click Open Application.
4. Go to the folder that you extracted the E53633-03-apps.zip files to, open
BizCardScanCloudUI, and then open BizCardScanCloudUI.jws.

Task 3 Configure Access to Oracle Java Cloud Service - SaaS Extension


Provide the service address for your Oracle Java Cloud Service - SaaS Extension
instance.
1. Use the search field in the top-right corner to find and open the connections.xml
file.
2. Find and replace all occurrences of jcs-service-instance-URL with the service
instance URL that you obtained in Prerequisites. For example, replace
jcs-service-instance-URL with
https://javatrial9999-usoracletrial99999.java.us1.oraclecloudapps.com.
Ensure that you include https://.
Six elements must be changed. Two of these elements contain the text
jcs-service-instance-URL:port. Replace :port with :443.

Caution: Be extremely careful to replace only the


jcs-service-instance-URL portion of the addresses. If you
accidentally paste over the other text in the URL, then the application
will not work. For example, the call to the OCR scanning service will
not be made, and no scanned photos will appear in the business card
list.

Tip: To use the Replace Text dialog box to complete this step, from
the main menu, select Search, and then select Replace. Don't forget to
also replace :port with :443.

The following example shows some of the elements after


jcs-service-instance-URL was replaced with the instance's URL.
<login
url="https://javatrial9999-usoracletrial99999.java.us2.oraclecloudapps.com/BizC
ardBasicAuth-ViewController-context-root/faces/LandingPage.jspx"/>
<logout
url="https://javatrial9999-usoracletrial99999.java.us2.oraclecloudapps.com/BizC
ardBasicAuth-ViewController-context-root/faces/LandingPage.jspx"/>
...
<wsconnection
description="https://javatrial9999-usoracletrial99999.java.us2.oraclecloudapps.
com/BizCardScanCloudServices/BizCardScanOCRImagePort?wsdl"
service="{http://ocr.service.bizCard.cloud.apps.oracle/}BizCardScanOCRImageServ
ice">

6-4 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Building the Mobile Application

...
<soap
addressUrl="https://javatrial9999-usoracletrial99999.java.us2.oraclecloudapps.c
om:443/BizCardScanCloudServices/BizCardScanOCRImagePort"
xmlns="http://schemas.xmlsoap.org/wsdl/soap/"/>

3. Save your changes.

Task 4 Store Your Credentials in the Oracle Java Cloud Service - SaaS Extension
Instance
This application uses a credential to store the Oracle Sales Cloud user name and
password. Complete the following steps to associate your Oracle Java Cloud Service -
SaaS Extension user name with an Oracle Sales Cloud user name and password.
Ensure that the user can create locations in the Oracle Sales Cloud instance.
1. Open a command window, and then go to the Oracle Java Cloud Service - SaaS
Extension SDK lib folder. For example,
C:\Users\your-user-folder\dev\oracle-javacloud-sdk\lib.
2. Enter the following command.
java -jar javacloud.jar -set-credential ^
-user java-cloud-service-user-name ^
-serviceinstance java-cloud-service-name ^
-identitydomain java-cloud-service-identity-domain ^
-datacenter java-cloud-service-data-center ^
-key java-cloud-service-user-name.saascloud ^
-keyuser sales-cloud-user-name -keypassword sales-cloud-password

Replace the following with the values for your sales cloud instance, user names,
and password.
■ java-cloud-service-user-name such as first.last@mycompany.com
■ java-cloud-service-name such as javatrial9999
■ java-cloud-service-identity-domain such as usoracletrial9999
■ java-cloud-service-data-center such as us1
■ sales-cloud-user-name such as fred
■ sales-cloud-password
Notice that saascloud is appended to your user name for the -key. This is to
prevent you from overwriting your entries in the credential store for other
applications deployed to that instance.
3. When prompted, enter your Oracle Java Cloud Service - SaaS Extension password.
The command displays OK after the credential is created.

Task 5 Create a Deployment Profile


Create a profile to deploy the application to the Android virtual device.
1. If the Android virtual device isn't running, start it. To start the virtual device, from
the Android Virtual Device Manager, select the ADFmf device, click Start, and
then click Launch.
2. In the Application Navigator in JDeveloper, right-click the application, select
Deploy, and then select New Deployment Profile.

Building the Mobile Application 6-5


Building the Mobile Application

3. From the Profile Type list in the Create Deployment Profile dialog box, select ADF
Mobile for Android.
Be careful to not select ADF Mobile Application Archive.
4. In the Deployment Profile Name field, enter Android_mobile_native_archive1,
and then click OK.
5. In the ADF Mobile for Android Deployment Profile Properties dialog box, select
Android Options.
6. Click OK to accept the default values.
7. From the main menu, click Save All.

Task 6 Deploy and Run the Application in the Virtual Device


Do an initial test run of the application in the Android virtual device. At this point, the
application enables you to take photos, select business cards from your photo gallery,
and scan a selected card.
1. Ensure that the Android virtual device is running.
2. From JDeveloper, right-click the application, select Deploy, and then select
Android_mobile_native_archive1.
3. From the Deployment Action page in the Deploy wizard, select Deploy
application to emulator.
4. Click Finish.
5. Watch the deployment process in the Deployment tab.
6. After the deployment finishes successfully, click the home button in the virtual
device.
Note that through the testing process, if the virtual device takes too long, your
session might time out, and you might see an error message that the connection
was unsuccessful. Click OK, and then sign in again.
7. To go to the applications page, click the Applications button, which is shown in
the following figure.

8. To start the application, click Business Card Scanner, which is shown in the
following figure.

6-6 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Building the Mobile Application

9. On the Login page, enter your Oracle Java Cloud Service - SaaS Extension user
name and password. It might take a few minutes for the application to start in the
virtual device. If you are prompted to cancel the process or continue to wait,
choose continue to wait.
Notice the warning icon in the top left corner of the pages. The Android virtual
device displays this icon to indicate that the application was compiled in debug
mode.
10. If the Photos page does not display, click Photos.

11. On the Photos page, which is shown in the following figure, click Select Image.
Note that the complete page view might not fit in the virtual device.

Building the Mobile Application 6-7


Building the Mobile Application

12. From the gallery, which is shown in the following figure, select a business card
photo.

6-8 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Building the Mobile Application

The business card is displayed in the Scan Business Card page.


13. In the Scan Business Card page, click Scan Card, as shown in the following figure.
When the dialog box is displayed, click Ok.

Building the Mobile Application 6-9


Adding the Cards Feature

In the following section, you build the flow that displays the scanned business
cards, and that enables editing and saving the scanned text as contacts.
14. When the Scan in Progress dialog box appears, click OK.

15. Close the virtual device to free resources.

Adding the Cards Feature


Topics:
■ Task 1, "Add the Business Cards Feature"
■ Task 2, "Create a Taskflow for the Business Card List"
■ Task 3, "Add a Managed Bean to Hold Selected Card Information"
■ Task 4, "Create the Business Card List"
■ Task 5, "Add Data Fields to the Business Cards List"
■ Task 6, "Define the Select, Scroll, and Refresh Actions"
■ Task 7, "Create the Business Card Detail View"
■ Task 8, "(Optional) Test Your Changes"
■ Task 9, "Add Fields to the Detail View"
■ Task 10, "Define the Back and Create Actions"
■ Task 11, "(Optional) Test Your Changes"

6-10 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

Task 1 Add the Business Cards Feature


When you deploy an Oracle ADF Mobile application, the application is a single
application that consists of parts. This application will consist of two parts: Photos and
Cards. Each of these parts is an application feature. This application already contains
the Photos feature. You will build the Cards feature. Before you build the feature, you
define it in the adfmf-feature.xml features file.
A feature in Oracle ADF Mobile is a reusable functional unit. Its content can be local
HTML, remote server-side HTML, an AMX page, or a taskflow. The declarative
development of mobile applications done using AMX, where taskflow is the content of
choice for tasks that involve navigation among mobile views. AMX is a subframework
within Oracle ADF Mobile that provides a set of UI components.
1. In JDeveloper, use the search field in the top-right corner to find and open
adfmf-feature.xml.
2. To create a new feature, click the Add button (green plus sign) on the Features
table in the Features editor.
3. In the Create ADF Mobile Feature dialog box, name the new feature Cards, as
shown in the following figure.

4. Enter the following package in the Feature ID field, and then click OK.
feature.Cards

Ensure that you capitalize the C.


5. In the General tab, shown in the following figure, enter the following description
for the Cards feature.
Review the scan status and edit scan results for Business Cards

6. In the Navigation Bar Icon field, click the Search button (magnifying glass), and
then select the following image file.

Building the Mobile Application 6-11


Adding the Cards Feature

images/card_72.png

7. Click the Security tab, and then select Enable Feature Security.
8. Ensure that Credential Authentication is set to remote.
9. Use the search field in the top-right corner to find and open
adfmf-application.xml.
10. Click the Security tab.

11. In the Authentication and Access Control section, find the feature.Cards row.

12. From the Login Server Connection list for the feature.Cards row, select
BasicAuth.
13. Save all your changes.

14. To add the taskflow for the feature, continue to the next task.

Task 2 Create a Taskflow for the Business Card List


An ADF taskflow contains pages that interact with each other. Build a taskflow that
contains a business card list and a business card details page, as shown in the
following figure. Then, define the flow that enables the user to go from the list to the
details page. Also, define a rule for a refresh button that you add to the business card
list view.

1. From the adfmf-feature.xml page, click the Content tab.


2. In the Content table, ensure that ADF Mobile AMX is selected from the Type list
for the feature.Cards.1 item.
3. Click the Add button (green plus sign) next to the File field, and then select Task
Flow, as shown in the following figure. This will create a taskflow and associate it
with the Cards feature.

6-12 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

4. In the Create dialog box, in the File Name field, enter the following value:
BizCardList-task-flow.xml

5. To store the resulting AMX file with the other web content AMX files, ensure that
the path in the Directory field is the path to the public_html directory. You might
need to delete \feature.Cards from the path, as shown in the following figure.

6. Click OK. The new taskflow displays in the editor.


7. To add the business card list to the taskflow, from the Activities section in the
Component Palette, drag the View component onto the taskflow. A view activity
represents a page in the taskflow. Note that creating a view activity does not create
the page, it just creates a pointer.
8. On the taskflow, change the name of the view activity to BizCardList.
9. Add another View component to the page, and name it BizCardDetailView.
10. To define the flow between the two pages, in the Control Flow section in the
Component Palette, select Control Flow Case. Then, in the taskflow select
BizCardList, and then select BizCardDetailView.
11. Name the control flow cardDetail.

12. To create a rule for a refresh button, from the Control Flow section in the
Component Palette, drag and drop a Wildcard Control Flow Rule onto the
taskflow.
13. To define the flow between the refresh button and the business card list, in the
Control Flow section in the Component Palette, select Control Flow Case. Then, in
the taskflow, select the wild card control flow rule, which has the default name *,
and then select BizCardList.
14. Name the control flow refresh.

Task 3 Add a Managed Bean to Hold Selected Card Information


The application contains the OSCContactDetailBean managed bean to share the
information about the selected card between the detail page and the customer search
pages. Add this managed bean to the taskflow's pageFlow scope.
A managed bean is instantiated and dismissed by the framework per its scope
definition (view, application, pageFlow). Managed beans are expression language
accessible and hold the application's client logic.
1. In the editor, click the Overview tab, and then select Managed Beans.
2. In the Managed Beans table, click the Add button (green plus sign), and then add
the following values.

Building the Mobile Application 6-13


Adding the Cards Feature

Field Value
Name oscContactDetailBean
Class oracle.apps.cloud.bizCard.mobile.bean.OSCContactDetailBean
Scope pageFlow

3. Save your changes.

Task 4 Create the Business Card List


The business card list shows the scanned business cards for which contact information
hasn't been saved to Oracle Sales Cloud.
1. To create the page for the business card list, from the taskflow, click the Diagram
tab, and then double-click BizCardList.
2. In the Create ADF Mobile AMX Page dialog box, to add a header facet for the title,
in the Page Facets section, ensure that Header is selected.
3. The page does not need a button in the left corner of the header bar, so clear the
Primary Action check box.
4. To create a button that appears in the right corner of the header bar, ensure that
Secondary Action is selected. Users click this button to refresh the list.
5. The page does not have a footer, so ensure that the Footer check box is clear, as
shown in the following figure.

6. Click OK to accept the other default values.


7. The BizCardList.amx file is opened in the source editor. Continue to the next task
to build the list.

Task 5 Add Data Fields to the Business Cards List


The prebuilt application contains a business card data control. Use this data control to
add fields to the list and to bind the fields to data.
1. To switch the BizCardList.amx file to the visual depiction of the view, click the
Preview tab.

6-14 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

Tip: To display both the Source tab and Preview tab at the same
time, in the editor, drag the small vertical bar that is to the right of the
bottom scroll bar to the left. The editor displays two copies of the
current tab. Click one of the tabs to display both types of views.
To return to displaying only one copy of the file, select Unsplit
Document from the Window menu.

2. Complete the following steps to add the business card data fields to the list.
a. In the Application Navigator, expand the Data Controls section.
b. Expand BusinessCardsDC.
c. As shown in the following figure, drag the businessCards iterator onto the
Panel Page node in the Structure window, and then select ADF Mobile List
View, which presents a collection of items.

d. In the ListView Gallery, in the List Formats section, select Main-Sub Text,
select the third variation, and then select the first style, as shown in the
following figure.

Building the Mobile Application 6-15


Adding the Cards Feature

e. Click OK.
f. In the Edit List View dialog box, shown in the following figure, select the
following value bindings.

Element Value Binding


Main Text displayName
Subordinate Text company
Image imagePath

g. Click OK to accept the remaining default values.


3. When you created the list view, you could configure only three attributes to
provide data values. You must make additional attributes expression language
accessible so that they can be passed to the detail view. To make the values
available, complete the following steps to add additional iterator attributes to the
tree binding.

6-16 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

a. Click the Bindings tab.


b. In the Bindings section, select businessCards, and then click the Edit button
(pencil) to open the Edit Tree Binding dialog box shown in the following
figure.

c. In the Edit Tree Binding dialog box, move the following attributes from the
Available Attributes list to the Display Attributes list.
address
cardId
familyName
firstName
imageStyle
job
middleName
oscContactId
oscCustomerId
status
uploadDate

4. Click OK, and then click the Preview tab to return to the visual depiction of the
view.
5. To set the title text, in the Structure window, expand Panel Page, expand Facet -
header, and select Output Text - Header. Then, in the Common section in the
Property Inspector, set Value to Business Cards.
6. To set the button label, in the Structure window, expand Panel Page, expand Facet
- secondary, and select button. Then, in the Common section in the Property
Inspector, set Text to Refresh.
7. To enlarge the business card image area, complete the following steps.
a. From the Structure window, expand List View, expand List Item, expand
Table Layout, expand the first Row Layout, and then expand the first Cell

Building the Mobile Application 6-17


Adding the Cards Feature

Format component to ensure it's the cell that contains the Image component,
as shown in the following figure.

b. Select the Cell Format component, and then in the Appearance section in the
Property Inspector, set the values for both the Height and Width fields to
80px.
Note that AMX pages are rendered as HTML at runtime. Therefore using CSS
is the option to define size and color.
c. Select the Image component, and then in the Inline Style field enter the
following expression:
#{row.imageStyle}76px; margin:2px 0px;

8. At this point, the visual depiction in the Preview tab should look like the following
figure.

9. Complete the following steps to bind the action for querying data. You invoke this
method from action listeners when you need to refresh the list of business cards.
a. In the Bindings section on the Bindings tab for BizCardList.amx, click the
Add button (green plus sign).
b. Select action, and then click OK.
c. In the Create Action Binding dialog box, expand BusinessCardsDC, and then
select businessCards.
d. From the Select an Iterator list, select businessCardsIterator (not
businessCardsDCIterator).

6-18 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

e. Select the Execute operation, and then click OK.


10. The data control contains a prebuilt method for refreshing the cache. Bind this
method to the taskflow. This action will be called by the Refresh button.
a. In the Bindings section, click the Add button (green plus sign).
b. Select methodAction, and then click OK.
c. In the Create Action Binding dialog box, select BusinessCardsDC.
d. From the Select an Iterator list, select businessCardsDCIterator (not
businessCardsIterator).
e. Select the resetCache() operation, and then click OK.

Task 6 Define the Select, Scroll, and Refresh Actions


When the user selects an item in the list, the application switches to the detail view for
the selected business card. Create the action and then add property listeners to pass
the data for the selected business card data to the detail view. Then, configure the
scroll and refresh actions.
1. To go to the visual depiction of the view, click the Preview tab.
2. Earlier, you defined a flow from the BizCardList to the BizCardDetail view, that
you named cardDetail. To associate the user's select action with the cardDetail
flow, complete the following steps.
a. In the BizCardList.amx Structure window, expand the List View component.
b. Select List Item
c. In the Property Inspector, in the Action list, select cardDetail.
3. Use property listeners to pass the business card's data to the detail view. To create
a property listener to pass the row key, complete the following steps.
a. In the Component Palette, expand Operations, drag a Set Property Listener
onto the List Item component in the Structure window, and then select it.
b. In the Property Inspector for the Set Property Listener component, enter the
following values.

Property Value
From #{row.rowKey}
To #{pageFlowScope.rowKey}
Type action

The rowKey identifies the row to set as current on the detail page. The detail
page is also built based on the businessCardsIterator, but it will only show a
single row (in a form for editing).
When you build the detail page, you use this rowKey in an invokeAction
method reference.
4. To save time, you'll code the remaining elements instead of using drag-and-drop
steps. Switch to source view, and then paste the following elements inside the
listItem element to add the remaining Set Property Listener components.
If a quick fix icon appears in the left column, then the element has a duplicate ID.
Click the quick fix icon, and then select Generate a unique ID.

Building the Mobile Application 6-19


Adding the Cards Feature

<amx:setPropertyListener id="spl8"
from="#{row.oscContactId.inputValue}"
to="#{pageFlowScope.oscContactDetailBean.selectedOscContactId}"
type="action"/>
<amx:setPropertyListener id="spl2"
from="#{row.firstName.inputValue}"
to="#{pageFlowScope.oscContactDetailBean.selectedOscContactFirstName}"
type="action"/>
<amx:setPropertyListener id="spl3"
from="#{row.middleName.inputValue}"
to="#{pageFlowScope.oscContactDetailBean.selectedOscContactMiddleName}"
type="action"/>
<amx:setPropertyListener id="spl4"
from="#{row.familyName.inputValue}"
to="#{pageFlowScope.oscContactDetailBean.selectedOscContactFamilyName}"
type="action"/>
<amx:setPropertyListener id="spl5"
from="#{row.displayName.inputValue}"
to="#{pageFlowScope.oscContactDetailBean.selectedOscContactName}"
type="action"/>
<amx:setPropertyListener id="spl6"
from="#{row.address.inputValue}"
to="#{pageFlowScope.oscContactDetailBean.selectedOscContactAddress}"
type="action"/>
<amx:setPropertyListener id="spl9"
from="#{row.oscCustomerId.inputValue}"
to="#{pageFlowScope.oscContactDetailBean.selectedOscCustomerId}"
type="action"/>
<amx:setPropertyListener id="spl7"
from="#{row.company.inputValue}"
to="#{pageFlowScope.oscContactDetailBean.selectedOscCustomerName}"
type="action"/>
<amx:setPropertyListener id="spl10"
from="#{false}"
to="#{pageFlowScope.oscContactDetailBean.returningFromSelection}"/>

5. Switch to preview mode.


6. To enable the users to scroll through the list, complete the following steps.
a. Drag the Action Listener from the Component Palette, drop it onto the List
Item component in the Structure window, and then select it.
b. In the Property Inspector for the Action Listener component, enter the
following values.

Property Value
Binding #{bindings.resetCache.execute}
Type swipeDown

7. To make the view refresh when the user clicks the Refresh button, complete the
following steps.
a. In the Structure window, expand Facet - secondary, and then select Button -
Refresh.
b. In the Property Inspector, enter the following values.

6-20 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

Property Value
Action refresh
Action Listener #{bindings.resetCache.execute}
Disabled #{!bindings.resetCache.enabled}

c. Save your changes.

Task 7 Create the Business Card Detail View


When the user selects a card in the business card list, the view changes to the detail
view, which contains fields with values from the scanned card. The user can edit the
fields and create an Oracle Sales Cloud contact record. In this task, you create the
detail view.
Note that in this task, you put all the fields in one table. An alternative is to use
multiple panelFormLayout components to break up the fields into a more readable
page.
1. To create the page for the business card list, from the diagram view for
BizCardList-task-flow.xml, double-click BizCardDetailView.
2. In the Page Facets section, select Header, Primary Action, and then Secondary
Action.
3. The page does not have a footer, so ensure that the Footer check box is clear.
4. Click OK to accept the other default values.
5. The BizCardDetailView.amx file is opened in the source editor. Continue to the
next task to test your changes.

Task 8 (Optional) Test Your Changes


To test the business card list, launch the virtual device, and then deploy and test the
application as described in Testing the Cards Feature. Complete the steps up to, but
not including, displaying the detail view, which you build in the remaining tasks in
this section.

Task 9 Add Fields to the Detail View


Use the business card data control to add fields to the view and to bind the data fields
to their values. Then, bind to additional attributes and methods for back-end support.
1. To see the visual depiction of the view, click the Preview tab.
2. To set the title text, in the Structure window, expand Panel Page, expand Facet -
header, and select Output Text - Header. Then, in the Common section in the
Property Inspector, set Value to Business Card.
3. To set the back button label, in the Structure window, expand Facet - primary, and
select button. Then, in the Common section in the Property Inspector, set Text to
Back.
4. To set the create button label, in the Structure window, expand Facet - secondary,
and then select button. Then, in the Common section in the Property Inspector, set
Text to Create.
5. From the Data Controls section, expand BusinessCardsDC, and then drag
businessCards onto the Panel Page component.
6. Select Form, and then select ADF Mobile Form.

Building the Mobile Application 6-21


Adding the Cards Feature

7. In the Edit Form Fields dialog box, select each of the following fields, and then
click the Delete button (red x).
■ cardId
■ uploadDate
■ status
■ errorMessage
■ imagePath
■ imageStyle
■ displayName
■ oscCustomerId
■ oscContactId
8. Rearrange the components such that the following components are listed at the in
the order shown. Keep the default display labels and components.

Value Binding
firstName
middleName
familyName
job
address
company
email
phone
mobile
fax
url

The following figure shows the remaining fields in the desired order.

6-22 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

9. Click OK.
10. Complete the following steps to bind additional values and actions that you need
to use in the view.
a. Click the Bindings tab.
b. In the Bindings section, click the Add button (green plus sign).
c. In the Insert Item dialog box, select attributeValues, and then click OK.
d. From the Data Source list, select BusinessCardsDC.root.businessCards.
e. Select the errorMessage attribute, and then click OK.
f. Use the same process to add the imagePath attribute.
g. Use the same process to add the imageStyle attribute.
h. To bind the resetCache method, click the Add button, select methodAction,
click OK, select BusinessCardsDC, select the BusinessCardDCIterator
iterator, and select the resetCache() operation. Then, click OK.
i. To bind the saveOSCContact(Object) method, click the Add button, select
methodAction, and click OK. Then, select BusinessCardsDC, select the
BusinessCardDCIterator iterator, and then select the
saveOSCContact(Object) operation, as shown in the following figure.

Building the Mobile Application 6-23


Adding the Cards Feature

11. This method has an Object input parameter. To specify the value to pass in to the
method, in the Parameters section, enter the following in the Value field, and then
click OK.
#{bindings.businessCardsIterator.currentRow.dataProvider}

This parameter is an expression that points to the selected business card.


12. Later, you add a company search view that returns values from a selected
company. Complete the following steps to save the returned values to the current
business card.
a. To bind the updateCardDataWithContactSelection(Object) method, in the
Binding section, click the Add button, select methodAction, and click OK.
Then select BusinessCardsDC, select the BusinessCardDCIterator iterator,
and then select updateCardDataWithContactSelection(Object).
b. In the Parameters section, enter the following in the Value field, and then click
OK.
#{bindings.businessCardsIterator.currentRow.dataProvider}

c. In the Executables section, click the Add button (green plus sign).
d. Select invokeAction, and then click OK.
e. In the Insert invokeAction dialog box, enter the following in the id field.
doSetOscContactBeanValues

f. Select updateCardDataWithContactSelection from the Binds list, and then


click OK.
13. By default, the detail view displays the detail information for the first business
card entry in the BusinessCardDCIterator. To cause the page to display the
details for the card that was selected in the BizCardsList view, complete the
following steps.
a. In the Bindings section, click the Add button (green plus sign).
b. Select action, and then click OK.

6-24 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

c. In the Create Action Binding dialog box, expand BusinessCardsDC, and then
select businessCards.
d. From the Select an Iterator list, select businessCardsIterator (not
businessCardsDCIterator).
e. Select the setCurrentRowWithKeyValue operation (not the
setCurrentRowWithKey operation).
f. In the Parameters section, in the Value field, enter the following, and then
click OK.
#{pageFlowScope.rowKey}

g. In the Executable section, click the Add button (green plus sign).
h. Select invokeAction, and then click OK.
i. In the Insert invokeAction dialog box, set the ID to doSetRowKey.
j. From the Binds list, select setCurrentRowWithKeyValue, and then click OK.
k. Save your changes.
l. Verify that the Bindings and Executables sections looks similar to the
following figure.

m. Switch to preview mode for the next task.

14. The contact bean's address has the latitude and longitude for the Google map. To
associate the address field with the contact bean's address, in the Structure
Window, select the Input Text component for the address, and then, in the
Property Inspector, change the Value to:
#{pageFlowScope.oscContactDetailBean.selectedOscContactAddress}

15. To display error messages in red text, complete the following steps.

a. From the Text and Selection section in the Component Palette, drag the
Output Text component onto the Panel Page component in the Structure view,
and then select it.
b. In the Property Inspector for the output text, set the values shown in the
following table.

Building the Mobile Application 6-25


Adding the Cards Feature

Property Value
Value #{bindings.errorMessage.inputValue}
Rendered #{bindings.errorMessage.inputValue != ""}
Inline Style color:Red; font-weight:bold;

c. Move the Output Text component to after the Facet - secondary component.
16. (Optional) In the Structure window, expand Panel Form Layout, select each field's
Input Text component, and then, in the Property Inspector, add the hint text
shown in the following table.

Input Text Binding Hint Text


firstName First Name from Business Card
middleName Middle Name from Business Card
familyName Family (Last) Name from Business Card
job Job Title from Business Card
address Address from Business Card
company Company Name from Business Card
email Email from Business Card
phone Phone Number from Business Card
mobile Mobile Number from Business Card
fax Fax Number from Business Card
url URL from Business Card

17. Complete the following steps to add the Google map.

a. From the Layout section of the Component Palette, drag a Panel Group
Layout component onto the Panel Page component in the Structure window,
and then select it.
b. In the Property Inspector, enter the following value for the Inline Style
property:
width:100%; height:200px;

c. In the Component Palette, select DVT Mobile AMX from the list.
d. From the Map section, drag a Geographic Map component onto the Panel
Group Layout component, and then select it.
e. In the Property Inspector for the Geographic Map component, enter the
values shown in the following table.

Property Value
Inline Style width:90%; height:190px;
rendered #{bindings.address.inputValue != ''}

f. Expand Geographic Map.

6-26 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature

g. From the Other Type-Specific Child Tags section, drag a Point Location
component onto the Point Data Layer component, and then select it.
h. In the Property Inspector for the Point Location component, enter the values
shown in the following table.

Property Value
Type PointXY
Point X #{pageFlowScope.oscContactDetailBean.longitude}
Point Y #{pageFlowScope.oscContactDetailBean.latitude}

i. From the Other Type-Specific Child Tags section, drag a Marker component
onto the Point Location component, and then select it.
j. In the Short Desc field in the Property Inspector for the Marker component,
enter Contact Address.
18. Complete the following steps to add the business card image.

a. In the Component Palette, select ADF Mobile AMX from the list.
b. From the Layout section of the Component Palette, drag and drop a Panel
Label And Message component onto the Panel Page component in the
Structure window, and then select it.
c. In the Property Inspector for the Panel Label and Message component, clear
the value in the Label field.
d. From the General Controls section in the Component Palette, drag and drop
an Image component onto the Panel Label and Message component, and then
select it.
e. In the Property Inspector for the Image component, enter the values shown in
the following table. The view will display the business card image such that
it's as wide as the view, and the height is adjusted accordingly.

Property Value
Source #{bindings.imagePath.inputValue}
Inline Style height:auto; width:100%;

Task 10 Define the Back and Create Actions


The user can create the contact (save it to Oracle Sales Cloud) or go back to the
business cards list. In this task, you associate the buttons with the actions and
methods.
1. To display the business card list when the user clicks the Back button, complete the
following steps.

Note: An alternative to providing back navigation is to define a


control flow case from the detail page back to the business card list
page. The _back action that you use in these steps is an implicit
navigation provided for developer convenience. The advantage of
explicitly defining navigation cases is better readability of the diagram
and the ability to define animations for the navigation (for example,
screen flip).

Building the Mobile Application 6-27


Adding the Cards Feature

a. In the Structure window, expand Facet - primary, and then select Button -
Back. By default, the __back action was created when you added the control
flow from the list to the detail view.
b. In the Property Inspector, set the values shown in the following table.

Property Value
Action __back
Action Listener #{bindings.resetCache.execute}

2. To save the contact data when the user clicks the create button, complete the
following steps.
a. In the Structure window, expand Facet - secondary, and then select the Button
- Create component.
b. In the Property Inspector, set the values shown in the following table.

Property Value
Action #{pageFlowScope.oscContactDetailBean.confirmAndReturn}
Action #{bindings.saveOSCContact.execute}
Listener
Disabled #{!bindings.saveOSCContact.enabled}

3. The visual depiction of the view should be similar to the following figure.

4. Save your changes.

Task 11 (Optional) Test Your Changes


To test your changes, launch the virtual device, and then deploy and test the
application as described in Testing the Cards Feature. Complete the steps up to, but
not including, the organization search, which you build in the next section.

6-28 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Customer Search

Adding the Customer Search


Topics:
■ Task 1, "Add the Customer Search View to the Taskflow"
■ Task 2, "Add Data Fields to the Search Results List"
■ Task 3, "Add the Search Link to the Detail View"

Task 1 Add the Customer Search View to the Taskflow


The Customer Search view shows Oracle Sales Cloud customers that match the
company name on the business card. The user can select a customer to update
customer values for the selected business card. You create this view in this task.
1. In the Diagram tab in BizCardList-task-flow.xml, drag a View component from
the Components section in the Component Palette onto the taskflow, and then
name it FindOSCCustomer.
2. In the Component Palette, select Control Flow Case. Then, in the taskflow, select
BizCardDetailView, select FindOSCCustomer, and then name the control flow
findCustomer, as shown in the following figure.

3. To create the search page, double-click FindOSCCustomer.


4. In the Create ADF Mobile AMX Page dialog box, select Header, and then select
Primary Action.
5. Ensure that Secondary Action and Footer aren't selected.
6. Click OK to accept the other default values.
7. The FindOSCCustomer.amx file is opened in the source editor. Continue to the next
task to build the list.

Task 2 Add Data Fields to the Search Results List


The prebuilt application contains a SecureBizCardOSCContact data control. Use this
data control to add fields to the list and to bind the fields to data.
1. To switch the FindOSCCustomer.amx file to the visual depiction of the view, click
the Preview tab.
2. Complete the following steps to add the business card data fields to the list.
a. In the Application Navigator, expand the Data Controls section.
b. Expand SecureBizCardOSCContact, expand findCustomersByName(String),
and then expand Return.
c. As shown in the following figure, drag the Return iterator onto the Panel
Page node in the Structure window, and then select ADF Mobile List View.

Building the Mobile Application 6-29


Adding the Customer Search

d. In the ListView Gallery, in the List Formats section, select Main-Sub Text,
select the first variation, and then select the fourth style.
e. Click OK.
f. In the Parameters section in the Edit Action Binding dialog box, in the Value
field, enter the following value, as shown in the following figure.
#{pageFlowScope.oscContactDetailBean.oscCustomerName}

6-30 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Customer Search

g. Click OK to accept the remaining default values.


h. In the Edit List View dialog box, select the following value bindings.

Element Value Binding


Main Text fullName
Subordinate Text address

i. Click OK to accept the remaining default values.


3. When you created the list view, you could configure only two fields to display on
the page. To display additional fields, complete the following steps.
a. Click the Bindings tab.
b. In the Bindings section, select Return, and then click the Edit button (pencil)
to open the Edit Tree Binding dialog box.
c. Move all the available attributes to the Display Attributes list.
4. Click OK, and then switch to preview mode.
5. To set the title text, in the Structure window, expand Panel Page, expand Facet -
header, and select Output Text - Header. Then, in the Common section in the
Property Inspector, set Value to Select Sales Cloud Customer.
6. To set the button label, in the Structure window, expand Panel Page, expand Facet
- primary, and then select Button. Then, in the Common section in the Property
Inspector, set Text to Back, and select __back from the Action list.
7. To adjust the layout to prevent the output from being scrunched up, complete the
following steps.
a. From the Structure window, expand List View, expand List Item, and then
expand Table Layout.
b. Expand the first Row Layout component, and then select the first Cell Format
component. In the Style section in the Property Inspector, change the Row
Span value from 2 to 4.
c. Expand the second Cell Format component, and then select the Output Text
component for the full name. In the Style section in the Property Inspector, set
the following values.

Property Value
Style Class adfmf-listItem-highlightText
Inline Style text-wrap:unrestricted;white-space:pre-wrap;

d. Expand the second Row Layout component, expand the Cell Format, and
select the Output Text component for the address. In the Style section in the
Property Inspector, set the following values. Ensure that the inline style value
does not have a line break.

Property Value
Style Class adfmf-listItem-captionText
Inline Style margin-top:5px;
font-weight:normal;text-wrap:unrestricted;white-space:pre-wrap;

Building the Mobile Application 6-31


Adding the Customer Search

8. To add the additional fields, complete the following steps.


a. From the Layout section in the Component Palette, drag a Row Layout
component onto the Table Layout component in the Structure window.
b. Drag a Cell Format component onto the Row Layout component, and then
select it.
c. In the Property Inspector, set the Width value to 100%.
d. From the Text and Selection section in the Component Palette, drag an Output
Text component onto the Cell Format component, and then select it.
e. In the Property Inspector for the Output Text component, set the following
values. Ensure that the inline style value does not have a line break.
Note that the Rendered property's expression prevents the field from taking
up space if the field doesn't have a value.

Property Value
Value #{row.companyUrl}
Rendered #{row.companyUrl != null && row.companyUrl != ""}
Style Class adfmf-listItem-captionText
Inline Style margin-top:5px;
font-weight:normal;text-wrap:unrestricted;white-space:pre-wrap;

f. Repeat these steps for the preferredContact field.


Remember to change all occurrences of companyURL in the Rendered and
Source properties to preferredContact.
9. Use property listeners to pass back the company name and customer ID.
a. In the Component Palette, expand Operations, drag a Set Property Listener
onto the List Item component in the Structure window, and then select it.
b. In the Property Inspector for the Set Property Listener, enter the following
values. The action type causes the value to be stored in the
oscContactDetailBean managed bean when the user selects the item in the
list.

Property Value
From #{row.customerId.inputValue}
To #{pageFlowScope.oscContactDetailBean.selectedOscCustomerId}
Type action

c. Drag another Set Property Listener onto the List Item, and in the Property
Inspector for the Set Property Listener, enter the following values.

Property Value
From #{row.fullName.inputValue}
To #{pageFlowScope.oscContactDetailBean.selectedOscCustomerName}
Type action

6-32 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Customer Search

d. Drag a third Set Property Listener onto the List Item, and in the Property
Inspector for the Set Property Listener, enter the following values to help
detect that a selection change was made.

Property Value
From #{true}
To #{pageFlowScope.oscContactDetailBean.returningFromSelection}
Type action

10. Complete the following steps to bind to the method that forces each new search to
re-execute with the updated customer name information.
a. Click the Bindings tab.
b. From the Executables section, click the Add button (green plus sign).
c. Select invokeAction, and then click OK.
d. In the Insert invoke Action dialog box, set the ID to doFindCustomersByName,
and then, from the Binds list, select findCustomersByName.
e. Click OK.
11. The visual depiction of the page in preview mode should be similar to the
following figure.

12. Save your changes.

Task 3 Add the Search Link to the Detail View


You now need to return to the detail view to add a command link to the company field
to take the user to the search list.
1. Use the search field in the top-right corner to find and open
BizCardDetailView.amx.
2. Switch to preview mode.
3. In the Structure window, expand Panel Page, and then expand Panel Form
Layout.
4. From the Layout section in the Component Palette, drag a Panel Label and
Message component to the position above the Input Text -
#{bindings.company.hints.label} component, and then select it.
5. In the Property Inspector, enter the following value in the Label field.
#{bindings.company.hints.label}

Building the Mobile Application 6-33


Adding the Customer Search

6. Drag a Table Layout onto the Panel Label and Message, select it, and then, in the
Property Inspector, set the width to 100%.
7. Drag a Row Layout onto the Table Layout.
8. Drag a Cell Format onto the Row Layout, select it, and then, in the Property
Inspector, set the width to 100%.
9. Drag the Input Text - #{bindings.company.hints.label} component into the Cell
Format component. Then, in the Property Inspector, clear the Label field, set the
Simple value to true, and enter margin-left:-12px; in the Inline Style field.
10. Drag another Cell Format onto the Row Layout. Then, in the Property Inspector,
set the width to 24px.
11. From the General Controls section, drag a Link component (also known as a
command link component) onto the cell, and then select it.
12. In the Properties Inspector, clear the Text field.
13. From the Action list, select findCustomer

14. In the Disabled field, enter the following value.


#{!bindings.findCustomersByName.enabled}

15. From the Operations section, drag a Set Property Listener component onto the
Link component, and then select it.
16. In the Property Inspector, set the following values.

Property Value
From #{bindings.company.inputValue}
To #{pageFlowScope.oscContactDetailBean.oscCustomerName}
Type action

17. From the General Controls section, drag an Image component into the Link
component. Select the Image component, and then, in the Properties Inspector, in
the Source field, enter the following value:
/images/fuse-icon-search.png

18. From the Data Controls section, expand SecureBizCardOSCContact, drag


findCustomersByName (String) (the enclosing method, and not the Return) into
the same cell, select Method, and then select ADF Mobile Button.
This puts a command button into the cell and binds the method correctly to the
page. The orange warning box around the Disabled field in the Property Inspector
for the Link component should disappear.
19. In the Edit Action Binding dialog box, click OK to accept the default bindings.

20. In the editor, click the Source tab. You must complete the next step in the source
view. If you do it in the Structure window, you will delete the data control
binding.
21. In the source editor, delete the amx:commandButton element that you just created. It
will look similar to the following element.
<amx:commandButton actionListener="#{bindings.findCustomersByName.execute}"
text="findCustomersByName"

6-34 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Testing the Cards Feature

disabled="#{!bindings.findCustomersByName.enabled}" id="cb3"/>

22. Save your changes.

Testing the Cards Feature


Topics:
■ Task 1, "Deploy the Application"
■ Task 2, "Test the Cards Feature"

Task 1 Deploy the Application


Deploy the updated application.
1. To start the virtual device, from the Android Virtual Device Manager, select the
ADFmf device, click Start, and then click Launch.
2. Right-click the application, select Deploy, and then select Android_mobile_
native_archive1.
3. From the Deployment Action page in the Deploy wizard, select Deploy
application to emulator.
4. Click Finish.
5. Watch the deployment process in the Deployment tab.
6. After the deployment finishes successfully, go to the next task.

Task 2 Test the Cards Feature


Test the taskflow that you built.

Note: The virtual device is slower than actual devices, and it often
takes up to a minute to respond. If the application becomes
non-responsive, restart the virtual device.

After some of time, you might need to sign in to the application again.
If the log in page appears, sign in again to continue using the
application.

1. Click the home button in the virtual device.


2. Go to the APPS page.
3. To start the application, click Business Card Scanner.
4. Using the same steps as in Task 6, "Deploy and Run the Application in the Virtual
Device", select some photos of business cards, and then scan them.
5. From the menu that is on the bottom of the page, click Cards.
6. On the Business Cards page, which is shown in the following figure, if no cards
appear, click Refresh. You might need to wait a minute or more for the scanned
data to be returned from the OCR service and for the results to display on the
page. Continue clicking Refresh until the card appears.

Building the Mobile Application 6-35


Testing the Cards Feature

7. To display the detail view, select the card.


After you select the card, the virtual device displays a wait icon. The wait icon
disappears and then reappears after several seconds. After a minute or more, the
virtual device displays the detail view, as shown in the following figure.

Tip: To view the page in landscape mode, press Left-CTRL+F11.


Note that the control button on the right side of the keyboard does not
affect the layout, only the control button on the left side does. To
return to portrait mode, press Left-CTRL-+F11 again.

6-36 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Testing the Cards Feature

8. To view the map, which is at the bottom of the card, click a field label in the detail
view and drag upward. The virtual device might take several seconds to respond
to the drag motion. Wait until the scrolling stops before repeating the drag motion.
9. Review the values from the scanned card, and correct the values that were not
scanned correctly. Be careful to correct any invalid characters, such as a } character
in an address, that might cause errors when validating a contact, location, or
company.

Tip: After you edit a field, tab out of the field or click another field to
cause the application to process the change. The wait icon displays.
Don't perform another action until the wait icon disappears.
Otherwise, the other action isn't performed.

10. If the company name isn't a name that is stored as a customer in your Oracle Sales
Cloud instance, edit the company name to a value that matches a stored customer.
11. To search for matching companies, click the search button that is next to the
company field. The Select Sales Cloud Customer page is displayed, as shown in
the following figure.

Building the Mobile Application 6-37


Troubleshooting the Use Case

12. If the correct one is found, select it to set that as the contact's company.
13. Return to the detail view.

14. To save the contact to Oracle Sales Cloud, click Create.

Tip: If you changed any values after returning to the detail view,
ensure that you tabbed or clicked out of the field, and the wait icon
was displayed and disappeared before clicking Create. Otherwise,
although you see the button appear as if it was clicked, the save action
will not be executed.

If the contact is saved successfully, the scanned card is removed from the cards list.

Troubleshooting the Use Case


Topics:
■ Android Virtual Device Is Not Responding
■ A View Page on the Device Displays an Error Message
■ The Photo Is Not Displayed on the Scan Business Card Page
■ Web Service Information Is Not Retrieved or Saved
■ The Google Map Is Not Displayed on the Detail Page

6-38 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Troubleshooting the Use Case

Android Virtual Device Is Not Responding


The virtual device takes more than 10 minutes to start or isn't responding to mouse
clicks or keyboard actions.

Cause
There are insufficient resources.

Solution
Stop the virtual device and try the following steps to free resources.
1. Close all unnecessary applications.
2. Start Task Manager, go to the Processes tab, and stop adb.exe.
3. If it's still not responding, restart the computer.
4. If it's still not responding, try reinstalling the Android SDK.

Tip: You can view the virtual device's log messages from the LogCat
tab in the Android Debug Monitor. Start the monitor by running
monitor.bat in the android-sdk/tools folder.

A View Page on the Device Displays an Error Message


While testing the application, an error message is displayed.

Cause
To access the log file to help determine the cause, complete the following steps.
1. While the application is running, open a command window in the Android SDK
tools folder.
2. To start the Android Debug Monitor, run monitor.bat. It might take several
seconds for the monitor to appear.
3. In the Devices tab, select the emulator.
4. In the Android Debug Monitor, from the File Explorer tab, expand mnt, and then
expand sdcard. (If you have deployed to an actual device, the path is
mnt/shell/emulated/0.)
5. Select Business Card Scanner.txt.
6. Click the Pull a file from the device button (left arrow button pointing to a disk)
in the top-right corner, as shown in the following figure, and then save the file in a
directory of your choice.

7. Use a text editor to open the file.


8. Scan to the bottom of the file, and then search upward for the error message.

The Photo Is Not Displayed on the Scan Business Card Page


After you select a photo in the gallery, the Scan Business Card page is shown but the
place where the image should be is empty and the two buttons are disabled, or the
page is completely blank.

Building the Mobile Application 6-39


Troubleshooting the Use Case

Cause
Some known causes are that the photo was taken with a phone or a digital camera that
created an incompatible photo, or you are testing on an actual device and you selected
a picture from a remote service.

Solution
If the problem occurs with a photo that is stored on the device, then it might not be a
compatible photo. To make the photo compatible with the software, open the photo in
the Paint.net editing application, save the photo in JPEG format with the quality factor
set to 100%, and then replace the original photo on the device with the new one. Note
that Paint.net is the only software that is known to resolve this issue.
If you are testing on a phone, and the photo is stored in a remote service, download
the photo to your phone.

Web Service Information Is Not Retrieved or Saved


The results from a scanned photo are blank, a contact isn't saved to Oracle Sales Cloud,
or the company search does not return the expected results.

Cause
The causes vary with the service. For example, the service might be down, the
messages that are sent to the service aren't valid, or the business card is in a language
other than English and thus the address returned by the OCR service resulted in an
invalid location code.

Solution
View the Oracle Java Cloud Service - SaaS Extension log messages to see if the
messages indicate the problem.
1. Go to https://cloud.oracle.com, and then sign in.
2. In the My Services section, select the data center, and then click Sign In to My
Services.
3. Enter your user name and password, enter the identity domain, and then click
Sign In.
4. Click the Java platform service, such as javatrial9999.
5. Click Java Console.
6. In the Servlets and JSPs section, click View Log Messages.
7. On the Log Messages page, select the message types that you want to see.
8. Click Search.
9. Use the log messages to determine when the error occurred. The following table
shows some errors and their causes:

Error Message Cause


BizCardScanException thrown: Unable to access Business The Certificate Authority (CA)
Card Scanner URL certificate might have expired. To
https://cloud.ocrsdk.com/processBusinessCard?language resolve the issue, see Enable SSL
=English&exportFormat=xml Connections with ocrsdk.com.

6-40 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Additional Resources

Error Message Cause


Access denied The Oracle Sales Cloud user does
(oracle.wsm.security.WSFunctionPermission not have permission to create
http://xmlns.oracle.com/apps/cdm/foundation/parties/ locations.
locationService/applicationModule/LocationService#creat
eLocation invoke)

The Google Map Is Not Displayed on the Detail Page


When you scroll to the bottom of the detail page, you see an image of the business
card, but you don't see the Google map.

Cause
If you must configure a proxy and a port to enable your browser to access the Internet,
then you must also configure the virtual device.

Solution
Follow the steps at (Optional) Configure the Proxy and Port.

Additional Resources
See the following resources for more information about the use cases discussed in this
section:
■ Information about using the Oracle ADF Mobile framework
Building Mobile Applications with Oracle ADF Mobile at
http://docs.oracle.com/cd/E18941_01/tutorials/toc.htm. Select
JDeveloper 11g Release 2, and then scroll to the ADF Mobile section.

Building the Mobile Application 6-41


Additional Resources

6-42 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud

You might also like