Professional Documents
Culture Documents
E53633-03
November 2014
Oracle Cloud Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
E53633-03
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
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.
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:
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
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.
Business Card
PersonService
Scanner
Web Service
Configuration Scripts
OrganizationService
Web Service
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
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"
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.
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
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.
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.
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
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:
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.
11. On the Choose Install Type page, select Complete, 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.
Caution: The directory path can't contain spaces. For example, don't
create the Oracle home directory under C:\Program Files.
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.
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
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.
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
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
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
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.
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
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
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.
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.
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
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.
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
4-10 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Creating the Organization Service Proxy
19. On the Asynchronous Methods page, select Don't generate any asynchronous
methods.
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.
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"
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.
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();
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;
}
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" });
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;
}
typeItem.getValue().add(partyType);
typeItem.setConjunction(Conjunction.AND);
return typeItem;
}
return filters;
}
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);
}
}
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.
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/
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.
List<BizCardScanConfig1> list
=jsfclient.getBizCardScanConfig1ConfigType("YOURCONFIGNAME");
this.applicationId =list.get(0).getExternalId();
this.applicationPassword =list.get(0).getLicenseKey();
this.applicationUrl = list.get(0).getUri();
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"
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.
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.
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
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
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.
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.
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.
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.
6-2 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Building the Mobile Application
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.
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.
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/"/>
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.
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.
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.
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
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.
6-10 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature
4. Enter the following package in the Feature ID field, and then click OK.
feature.Cards
6. In the Navigation Bar Icon field, click the Search button (magnifying glass), and
then select the following image file.
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.
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.
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.
Field Value
Name oscContactDetailBean
Class oracle.apps.cloud.bizCard.mobile.bean.OSCContactDetailBean
Scope pageFlow
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.
e. Click OK.
f. In the Edit List View dialog box, shown in the following figure, select the
following value bindings.
6-16 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Adding the Cards Feature
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
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
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.
<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}"/>
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}
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.
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}
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
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.
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.
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.
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 != ''}
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%;
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.
6-28 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
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
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;
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;
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.
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
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
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"/>
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.
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.
12. If the correct one is found, select it to set that as the contact's company.
13. Return to the detail view.
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.
6-38 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Troubleshooting the Use Case
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.
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.
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.
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:
6-40 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud
Additional Resources
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.
6-42 Implementing the Business Card Scanner Mobile Application Use Case for Oracle Sales Cloud