Beruflich Dokumente
Kultur Dokumente
OFFLINE
Time Entry
Oracle HCM Time and Labor Cloud Services
Introduction .................................................................................................. 5
PouchDB ....................................................................................................................................23
Login.js .............................................................................................................................................................................................. 26
Time Tampering......................................................................................... 48
The objective of this document is to outline the tasks involved in developing a mobile time entry
application. This application works when the mobile device is connected to the internet (online) and
when it isn't (offline). This document answers the question, “What does it take to develop and
enhance mobile offline time entry leveraging Oracle HCM Time and Labor Cloud Services?”
Currently, people can use Time and Labor to report time online in multiple ways, such as with time
cards and Web Clock, in browsers and on mobile devices. To let people, report time offline, you
need to create an application that can run on most mobile platforms, such as Android, iOS, and
Windows.
You can use this document as a how-to guide or a reference guide while developing your mobile
application. The document has references to the Oracle JET framework and Offline Persistence
Toolkit and some open source tools and technologies required to develop the mobile offline time
reporting application. These references include example code snippets that you can use and
enhance, as needed.
The mobile offline application described in this document uses Oracle HCM REST APIs for Web
Clock. These APIs integrate metadata, configuration, and Web Clock events functionality to deliver
an end-to-end mobile Web Clock application that includes offline capabilities.
• Time Layout Sets provide the Web Clock Layout metadata and configurations for the person
reporting time.
• Web Clock Events are created when the person reports time. They provide historical data in daily
time events for up to 7 days.
We have identified the following four critical use cases with respect to developing this mobile offline
application. These use cases include code snippets that you can leverage, as needed.
• Authentication
This document and the processes outlined within were produced by eVerge Group, LLC in conjunction and at
the direction of Oracle Corporation. eVerge Group, LLC is an Oracle Platinum and certified Oracle HCM Cloud
implementation partner. For more information regarding eVerge Group, please contact us at 1-972-608-1803 or
information@evergegroup.com.
The mobile application described here extends the existing Web Clock functionality to support both online and offline time reporting.
The underlying servers are updated in real time when the person reports their time while online. The time data reported when the
person is offline are stored on the local device. When connectivity is re-established, the time data are synchronized with the server. The
synchronized time data can then be processed and transferred to the appropriate consumers, such as payroll and project costing.
Authentication: The application opens after the person signs in with valid credentials. When signing in for the first time, the person
must be online. After a successful first sign in, the person can use the application both online and offline.
Rendering Web Clock Layouts: After they sign in, the person sees the Web Clock home page where they report time and view daily
events for up to 7 days in the past.
Storing Time Reported While Offline: If the device is online, time reported with Web Clock is synchronized to the server. But, if the
device is offline, the clock events and associated data are stored on the device until the next time the application is online.
Synchronizing Time Reported While Offline: The device regularly checks the network connectivity and as soon as the device is
online, the application fetches the reported time data from the offline storage and posts it to the server.
Time Tampering: The application provides a guard against time tampering attempts by the person. It does this by saving a copy of
the location time stamp and increasing the count by +1 every minute the device is offline. When the device is back online, the
application compares the device time stamp with the location time stamp, and, if it detects any discrepancies, it marks the specific
time event as tampered.
Cordova and XCode: Integrates with Android and iOS platforms, respectively
Oracle Offline Persistence Toolkit: Stores the person info and API response to render Web Clock pages when offline. It also stores
the time reported while offline and synchronizes the time data with the server when the device is back online.
The View consists of the UI components such as the buttons and icons. The Model represents the application data and includes Offline
Persistence Toolkit, which is responsible for storing the time data reported while offline. The View/Model in this architecture mediates
communication between the UI elements and the application data. It describes the state of the data in the model.
There is a two-way data binding between the View and the Model, where data changes in the View/Model are sent to the UI
components, and input from the UI components is written back to the View/Model.
The Model synchronizes with the Oracle HCM Cloud Server, which describes all of the Time and Labor configuration details, such as
the time layout sets and worker time entry profiles. It gives the options to get and update the clock events and accepts the data by
enabling API services.
The REST APIs are the middleware services between the application and HCM cloud. This is the layer responsible for the transfer of
information between the HCM server and the mobile application.
This mobile application design enables people to clock in and out on their mobile devices, regardless of whether they're online or
offline. This boosts the ease and accuracy of their time reporting and results in fewer defaults and deviations.
This table describes the items that make up the high-level architecture.
ITEM DESCRIPTION
View The View is a collection of UI components implemented as HTML5 custom elements, ranging from basic buttons to
advanced data visualization components. To design the view components in Web Clock, use HTML5, CSS. Also use it
to render static images, such as the clock in, clock out, meal in, and meal out icons on web clock buttons.
ViewModel The ViewModel exposes data from the Model to the View and maintains the application's state. In the view model, the
binder mediates communication between the view and the data binder. The view model has been described as a state
of the data in the model. In this layer, you use JavaScript files to define event handlers that you then use to populate
the data provider and bind the data provider to observables that the view component can use.
Model The Model represents the application data. In this layer, you use implemented REST API calls to get the data from
Oracle HCM Time and Labor Cloud Service to store in Offline Persistent Toolkit to use when the mobile device is
offline. Offline Persistent Toolkit uses PouchDB internally for storage.
HCM Cloud Server Oracle HCM Time and Labor Cloud Server, gives you the options to get and update the web clock events. It contains
the time entry object configurations, such as time layout sets and worker time entry profiles. It accepts external time
data provided by REST API services. It also has Web Clock; which people use to clock in and out. Web Clock can be
extended to a mobile platform in both online and offline modes.
You configure multiple time entry objects so that people can use Web Clock to report time. These objects include web
clock buttons and time card fields that you add to the web clock layout. Then, you use groups and time entry profiles
to associate the web clock layout with the people you want reporting time with Web Clock.
Here's a high-level architecture diagram that shows how the time entry objects you configure work together.
Web clock button configurations include clock events and time attributes, such as Payroll Time Type. Each button in
the group has a single display name and can store the values for multiple time attributes associated with a single clock
event. A time attribute reflects how much time is paid or recorded as an information entry and qualifies the associated
time event or time entry.
Here's an example of a web clock buttons configuration that was created using the Time Entry Layout Components
task in the Setup and Maintenance work area. The task is part of the Workforce Deployment offering, Time and Labor
functional area.
REST APIs REST APIs are middleware services between this mobile application and the HCM cloud server. This layer gets
information from the HCM cloud server in the form of an HTTP request and transfers it to the mobile application. The
various services involved in this process provide time layout sets and web clock events. It works according to
authentication.
Oracle HCM REST APIs interact with the HCM cloud server and the mobile applications.
The REST APIs in this table support an offline web clock configuration. JSON responses from GET methods are
stored in this mobile application to use when rendering the mobile pages. Offline data stored in the mobile application
is synchronized with the HCM cloud server using POST calls.
Time Layout Sets GET Retrieves the web clock layout configuration and stores
it in this mobile application.
Web Clock Events GET Retrieves the web clock events that match the criteria,
such as person id, and stores the last 7 days' worth as
history details.
Web Clock Events POST Updates the HCM cloud server with the time data stored
in this mobile application, so server-side processes can
validate time cards and run the approval workflows.
PouchDB is an open-source JavaScript database designed to run in a browser. It enables applications to store data locally while offline,
then synchronize it with PouchDB and compatible servers when the application is back online. It keeps the person's data synchronized
no matter where they next use the application.
The mobile offline solution described here uses Offline Persistent Toolkit to synchronize and store web clock configuration data and
web clock events.
The GET webClockEvents API gets web clock events for the last 7 days from the HCM cloud server for the toolkit to store in
persistent storage. This mobile application uses them to render details for each of the last 7 days in the Daily Time Events section of
the Web Clock page, shown here.
The toolkit uses PouchDB to store web clock events and related time attributes when the mobile device is offline.
The POST webClockEvents API synchronizes with the HCM cloud server, the web clock events and related attributes that were
stored while the mobile device was offline, when the mobile device is online again.
Hardware Requirements
REQUIREMENT VERSION OR CAPACITY
RAM 1 GB recommended
Software Requirements
REQUIREMENT VERSION
Plugins and tools Cordova, Xcode, Android, iOS & Windows tools
2 Install Oracle JET (7.2.0). In the command prompt, run this command:
npm –g install @oracle/ojet-cli
If you get an error after running this command, clear the cache by changing the network with the
command npm clear cache –force, then run the first command again.
3 Install the Cordova plugin In the command prompt, run this command:
(9.0.0). npm install –g cordova
cordova --version
4 Install the Xcode development Install the Xcode development environment from the App Store, which is only available on
environment. macOS.
After installing Xcode, install the Xcode command-line tools by running this command in a
terminal window:
xcode-select -- install
5 Create the mobile offline time 1. Create the project folder that will store the source files.
entry application project. 2. In the command prompt, go to the project folder.
3. Create the project using this command: ojet create MobileOfflineApp --hybrid
--appname "MobileOfflineApp" --platform=android,ios,windows --
template=navdrawer
4. Make sure that the project was created successfully by reviewing the project source in
Internet Explorer.
For details about creating a hybrid mobile application, see Create a Hybrid Mobile Application
Using the Oracle JET Command-Line Interface in the Developing Applications with Oracle JET
guide on docs.oracle.com, in the middleware documentation.
6 Build the project. In Oracle JET Command-Line Interface, run this command:
ojet build android
7 Serve the project. In Oracle JET Command-Line Interface, run this command:
ojet serve [ios|android|windows]
For Android: >ojet serve android –destination=emulator
For Windows: >ojet serve windows –browser=chrome
8 Install the Android tools. Use the Install Android Development Tools procedure in the Developing Applications with Oracle
JET guide on docs.oracle.com, in the middleware documentation. The procedure guides you
through these tasks:
Installing an emulator accelerator
Creating an Android virtual device
Setting up your Android device to install an application from your development machine
Installing Gradle and configuring Gradle proxy settings
Configuring environment variables to reference JDK and Android SDK installations
9 Install the iOS tools. Use the Install iOS Development Tools procedure in the Developing Applications with Oracle
JET guide on docs.oracle.com, in the middleware documentation.
10 Install the Windows tools. Use the Install Windows Development Tools procedure in the Developing Applications with
Oracle JET guide on docs.oracle.com, in the middleware documentation.
11 Install NetBeans. Use NetBeans as an IDE to develop this mobile application. Download the latest NetBeans
version from netbeans.org.
12 Install Oracle Offline 1. Read the Offline Persistent Toolkit README file.
Persistent Toolkit. 2. Add the toolkit to the application. In the command prompt, run this command:
npm install offline-persistence-toolkit
3. Add pouchDB and pouchDB-find. In the command prompt, run this command:
npm install pouchdb pouchdb-find
copyCustomLibsToStaging: {
fileList: [
{cwd: 'node_modules/@oracle/offline-persistence-toolkit/',
src: ['*'],
dest: 'web/js/libs/persist'},
{cwd: 'node_modules/pouchdb/',
src: ['*'],
dest: 'web/js/libs/pouchdb'}
]
},
6. Add the libs configuration in the js/path_mapping.json file using the Installing the
Offline Persistence Toolkit procedure in the Developing Applications with Oracle JET guide
on docs.oracle.com, in the middleware documentation.
13 Store images and icons in the You need to store the web clock icons in the application source code. Create the folder src >
mobile offline time entry css > images and add the icons or images you want to use in the application.
application.
2. Make sure the project is imported successfully. It should look like this:
To add destination details, see the Serve a Hybrid Mobile Application section of the Create a Hybrid Mobile Application Using Oracle
JET Command Line-Interface topic. This topic is in the Developing Applications with Oracle JET guide on docs.oracle.com, in the
middleware documentation.
The Web Clock home page shows buttons, such as Start Shift and End Shift, that the person uses to report their time. This mobile
application records the corresponding clock events and any additional time attributes. This information appears in the Daily Events
section, so the person can confirm they reported their time accurately. Web Clock also shows person details and signout options.
When the person is ready, they submit their reported time and the mobile application checks the network status.
If the device is online, the application connects to the HCM APIs and updates the time entries to the server.
If the device is offline, the application stores the time data in the offline toolkit. Offline web clock events are stored in an indexed
database in the form of key and value pairs. The data can be handled according to the key.
To synchronize or update the time data on the HCM Cloud Server, the mobile application calls the API. The API returns an appropriate
status code and message after the update.
After the user submits their credentials, the mobile application checks the network status. If the device is online, the application
connects to the HCM cloud server using the HCM authenticate REST API and validates the domain and credentials. The API responds
in JSON format with a status code.
If the API responds that the credentials are valid and includes the status code, effective start date, person id, and profile details, the
Web Clock home page appears. The page includes the appropriate web clock buttons and time card fields as well as daily event
details for up to the last 7 days. The application also caches these details in the offline data toolkit.
If the API responds that the credentials are invalid and doesn't include the status code or other necessary details, an error message
appears.
During the first sign in, the device needs to be in online mode so that the mobile application and signin credentials can be authenticated
by HCM cloud server. After the initial signin, if the application is offline, it gets the data from the offline toolkit.
Here's a high-level design flow show how this mobile application authenticates signin credentials.
URL: eiwb-dev1.fa.us6.oraclecloud.com/hcmRestApi/resources/latest/emps?q=UserName=<username>
Type: GET
Offline Persistent Toolkit uses PouchDB to store the offline data. Data sets are stored in the form of key and value pairs in persistent
storage. From persistent storage, the device fetches username, person id, and the effective date to validate the user and to render the
web clock home page.
1. Add offline persistent toolkit libraries in js/viewModels/login.js file as shown in the adjacent screenshot.
2. Add user information into persistent storage which can later be retrieved when the device is offline.
Integration Touchpoints
Make sure the Oracle JET application created the src folder with the css, and js subfolders. Then create the login.html and login.js files.
Here's an example of the mobile application signin page that you're creating.
5. We have provided code snippet along with this document. Please refer login.html for the sample code for login. (login.html is present
in src\js\views directory and contains full source code of authentication workflow).
3. Add the code to get the domain, username, and password values.
5. We have provided code snippet along with this document. Please refer login.js for the sample code (login.js is present in
src\js\viewModel directory and contains full source code of user authentication along with JavaScript library).
The JWT token text contains a set of claims, which are a combination of standard and user-defined unique name: value pair fields. In
JWT tokens for Oracle Fusion REST APIs, we include three required fields along with a single optional field (prn) where we put the
username. These fields are:
FIELD DESCRIPTION
Thus, a JWT token includes the username and the expiration period for the token, which can be passed by the mobile application to
Oracle Fusion REST APIs. This is a Base64url encoded value. The token can be verified and trusted because it's digitally signed. JWTs
can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA or ECDSA.
After the person is successfully authenticated when they first sign in to the application, the JWT token can be generated and stored in
Offline Persistence Toolkit. This token can then be used to transfer the information between the mobile application and HCM cloud
server without the need for repeated authorization.
The JWT Token for Authorization topic in the REST API for Oracle HCM Cloud guide on docs.oracle.com, in the Human Resources
cloud application documentation.
The Using JWT To Secure Your Cloud Application Integrations blog in Oracle Fusion Applications Developer Relations on
blogs.oracle.com.
The Web Clock home page shows buttons, such as Start Shift and End Shift, that the person uses to report their time. This mobile
application records the corresponding clock events and any additional time attributes. This information appears in the Daily Events
section, so the person can confirm they reported their time accurately. Web Clock also shows person details and sign-out options.
Here's a high-level design flow showing how this mobile application renders Web Clock when online.
})
HCM CONFIGURATIONS
People need the Employee abstract role to use Web Clock to report time. They also need the privileges to call GET and POST
operations for their own web clock events. You need to assign the role and privileges to the custom roles that people will need to use
offline Web Clock.
REST
PRIVILEGE CODE PRIVILEGE NAME ACTIONS DESCRIPTIONS
CREATE WEBCLOCK.HTML
3. Add the code to show the web clock page after successful sign-in authentication.
4. Refer webclock.html(src\js\views) for the source code of web clock rendering. A file webclock.html contains user interface details of
rendering web clock use case.
4. Refer webclock.js(src\js\viewModel) for the source code of web clock rendering. A file webclock.js contains business and API
processing logic.
1. Add offline persistent toolkit libraries in the js/viewModels/webclock.js file, as shown in step 2.
2. Add person information to persistent storage for use when the device is offline. See the earlier authentication code snippets for the
full source code, for login module.
4. Add event listener information to detect the network status, as shown here.
In this use case, PouchDB is storing the timeLayoutSets and webClockEvents API responses so the application can render Web Clock
when offline. One can check the persistent storage for offline data in browser via Inspect Element.
Design Flow
When the person reports time when offline, the mobile application connects to Offline Persistent Toolkit to store the time data. PouchDB
stores the data in an indexed database. It creates separate objects to store individual data. The persistent toolkit connects to PouchDB
using the persistent store factory in the application. It operates in a directional way, meaning it uses online mode to set the data and
offline mode to retrieve it, as shown here.
webclock.html
webclock.js
3. Add the code to identify the network status and save data to persistent toolkit if the device is offline.
4. Add offline persistent toolkit library details in webclock.js to enable offline feature.
6. Add the event listener information to detect whether the network is online or offline, as shown here.
8. Add a custom handler patch function to store reported time data in persistent storage if the device is offline. Also add a block to
update the data on the server if the device is online. Here's the code snippet. Refer only to the IF block.
Design Flow
When the device finds and connects to the network, the mobile application starts to synchronize the data in persistent storage to the
server. The application fetches the data from persistent storage, prepares the payload for the POST API call, and submits the request
to the server.
webclock.js
If the device is online, the mobile application gets the offline time data from persistent storage to synchronize to the server.
Submit the offline data to the HCM APIs to synchronize the data to the server, as shown here. After submitting the request to the
server, check the API status to determine the synchronization status. If the API returns the status code 201, it indicates a successful
synchronization to the server. Otherwise, the application again stores the data in persistent storage.
To check the synchronization status, find the API status on the Network tab. If the API returns the status code 200, it indicates a
successful synchronization to the server. Otherwise, check the error messages.
1. Write a function to get the location time stamp, using the navigator.geolocation method, like the function shown here.
2. Write a function to store the location time stamp in local storage and increase it by 1 every minute while offline, like the function
shown here.
If the device doesn't find the geolocation, it returns an error message, like this message.
1. Add the cacheStrategies.js file to the project source and import it in the webclock.js, as shown here.
2. Generate the keystore.jks file using the steps in the Generate and upload key and keystone section of the Sign your app topic.
4. Add the .jks file details of keystore, store password, alias, password, and keystore type, as shown here.
6. In the command prompt of the project folder, run this command to build the .apk file:
1. Import the .xcodeproj file to Xcode. The file is located here: /{project_name}/hybrid/platforms/ios/{project_name}.xcodeproj
2. Add the APPLE ID in Xcode by navigating to the Accounts section, as shown here.
2. Here's what you need to do after importing the project into Xcode:
b. On the Signing and Capabilities tab, enable the Automatically manage signing check box.
d. Make sure that the provisioning profile was created, as shown here.
Select the Show in Finder option to show the content of the packageon the right side of the panel
1 1.0.0 eVerge Dec 6, Released version with executive summary, overview, authentication, design flow,
Software & 2019 use cases with development steps and packaging.
Technology
Services
Private
Limited
2 1.0.1 eVerge Dec 18, Updated the document based on Oracle team review comments
Software & 2019
Technology
Services
Private
Limited
Corporate Headquarters:
4965 Preston Park Blvd., Suite 700
Plano, TX 75093
www.evergegroup.com
Contact Information:
1-972-608-1803
information@evergegroup.com
Bangalore Office:
91-080-25639848
ORACLE CORPORATION
Worldwide Headquarters
500 Oracle Parkway, Redwood Shores, CA 94065 USA
Worldwide Inquiries
TELE + 1.650.506.7000 + 1.800.ORACLE1
FAX + 1.650.506.7200
oracle.com
CONNECT W ITH US
Call +1.800.ORACLE1 or visit oracle.com. Outside North America, find your local office at oracle.com/contact.
Copyright © 2020, Oracle and/or its affiliates. All rights reserved. This document is provided for information purposes only, and the contents hereof are
subject to change without notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed
orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any
liability with respect to this document, and no contractual obligations are formed either directly or indirectly by this document. This document may not be
reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written permission.
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. 0120
White Paper MOBILE OFFLINE Time Entry
January 2020January 2020