Importing and Exporting Clarity's Bulk Data
Batch engine APIs provide a high-performance approach to interacting with large data sets. Clarity’s developers want to test importing and exporting with batch APIs to understand how they can interact with their object data and populate dashboards with historic data sets.
In these exercises, you’ll export and import Clarity’s object entries with JSON data and batch API endpoints.
Exercise: Exporting Clarity’s Existing Tickets
Here, you’ll leverage the export-task endpoint to create a batch export of Clarity’s existing Ticket object entries.
-
Sign in as the Clarity Admin user.
- Username:
admin@clarityvisionsolutions.com
- Password:
learn
- Username:
-
Navigate to the API Explorer at http://localhost:8080/o/api.
-
In the upper right, click the REST Applications drop-down menu and select
headless-batch-engine/v1.0
. -
Under the ExportTask section, expand the
postExportTask
endpoint.
-
Enter these parameters and click Execute:
Parameter Value className com.liferay.object.rest.dto.v1_0.ObjectEntry contentType JSON batchNestedFields permissions fieldNames description,priority,resolution,subject,suggestions,ticketStatus,type
taskItemDelegateName C_Ticket NOTE
To import object entries, use the object definition as the value for the taskItemDelegateName property. The value’s format should beC_ObjectName
, whereC_
is a prefix followed by the object’s name (case-sensitive). -
Verify in the Response body that the batch process was submitted:
If theexecuteStatus
isSTARTED
, the batch engine task was submitted. -
Copy the ERC (
externalReferenceCode
) value for a future step.
In this case,70fbff63-fab4-fafe-71d0-33fc0862cfcd
. -
Within the Headless Batch Engine API, expand the
getExportTaskByExternalReferenceCode
endpoint. -
Paste in the previously copied ERC to the
externalReferenceCode
parameter and click Execute. -
Verify that the batch job now lists
Large batch jobs can include thousands of data entries and take longer to complete. You can use this endpoint to check in on a batch job’s progress while it’s being processed.COMPLETED
for theexecuteStatus
: -
Within the Headless Batch Engine API, expand the
getExportTaskByExternalReferenceCodeContent
endpoint. -
Enter the same previously copied
externalReferenceCode
and click Execute.
-
Verify that the request's status code is 200 and the Response body includes a “Download file” link.
The downloaded file contains a JSON array containing all of Clarity’s existing Ticket entries, including only the filtered fields specified within the batch export job.
Exercise: Importing Clarity’s New Ticket Object Entries
While you can create import jobs with the Headless Batch Engine API’s import-task
endpoints, Clarity would like to test leveraging the Ticket object’s dedicated batch
endpoint to import some historic data records. Here, you’ll create a batch import to populate additional ticket object entries.
-
Navigate to the API Explorer at http://localhost:8080/o/api.
-
In the upper right, click the REST Applications drop-down menu and select
c/tickets
. -
Under the Ticket section, expand the
postTicketBatch
endpoint. -
Replace the placeholder curly brackets in the Request body with two square brackets.
This prepares your payload to include a JSON array. -
In your course workspace, open the
exercises/module-3/historic_ticket_data.json
file and copy its contents. -
In API Explorer, paste the JSON contents between the square brackets and click Execute.
-
Examine the Request body to verify that the import started:
The executeStatus of STARTED indicates that the batch job has started. -
From the Response body, copy the job’s
externalReferenceCode
. -
In the upper right, click the REST Applications drop-down menu and select
headless-batch-engine/v1.0
. -
Under the ImportTask section, expand the
getImportTaskByExternalReferenceCode
endpoint. -
Paste the copied
externalReferenceCode
and click Execute.
-
Verify that the Response body lists COMPLETED with 10 total items imported:
NOTE
If theexecuteStatus
showsFAILED
, check theerrorMessage
field to understand what issue was encountered. -
Navigate to the Clarity home page.
-
Open the Site Menu (
), click Page Tree, and navigate to the Tickets page.
You should see 10 additional tickets included on Clarity’s dashboard, including historic, closed tickets.
Conclusion
Excellent! You’ve successfully leveraged dedicated batch APIs to export batch data from Liferay and import a set of object entries. You’ve explored both the dedicated batch engine endpoints and an entity-specific batch endpoint. This provides the foundation to migrate large data sets within your Liferay environment using APIs.
Next, you’ll review what you've learned before completing the course.
Capabilities
Product
Education
Contact Us