Mastering Data Modeling with Liferay Objects

Course Overview

Exporting and Importing Object Data Models

When promoting Liferay object applications between environments, the first step is to migrate the data model and its dependencies. This includes both the object definition, as well as its associated picklists, notification templates, and any other resource used by the object. Here, you’ll explore the three primary methods for exporting and importing these resources:

  • Using the Liferay UI

  • Leveraging Headless APIs and Batch Engine

Using the Liferay UI to Export and Import

The simplest method for exporting and importing object definitions and picklists is the Liferay UI. Within their respective applications, you can export each definition or picklist as a JSON file.

Currently, you cannot export and import notification templates via the Liferay UI.

When you export object definitions, the JSON includes the object’s complete schema, including configurations, fields, actions, relationships, and more. However, it's important to note the JSON only includes one-to-many relationships if the object is on the parent side. You can also export object folders to include multiple, related object definitions in the same JSON file.

You can export object folders to include multiple, related object definitions in the same JSON file.

When you export picklists, the JSON includes all of its list items, capturing each item’s localized name, key, and ERC. This ensures your exported picklists ready for import into other environments.

When you export picklists, the JSON includes all of its list items.

Importing object definitions and picklists is similarly straightforward. When initiating an import, you provide a name for the entity and select the desired JSON file. Liferay automatically sets the entity's ERC based on the file's content, ensuring consistency and preventing duplicates. The import process uses this ERC to identify the object or picklist. If a definition or picklist with the same ERC already exists, Liferay replaces the existing entity with the imported one.

Importing object definitions and picklists is similarly straightforward.

When exporting and importing object definitions and picklists, keep these considerations in mind:

  • Relationships and External References: If an imported definition references picklists or objects that don't exist, Liferay automatically generates placeholders for them using the external reference codes provided by the JSON file.

  • Folder Organization: Organizing related objects into folders can streamline the export and import process, since you can promote entire folders between environments.

  • Overriding Definitions and Picklists: Overriding an existing object definition or picklist is permanent and can result in data loss if the JSON file is missing information.

Using Batch APIs and Client Extensions

Liferay's object-admin APIs empower developers to manage object definitions programmatically, including their relationships, actions, and other elements. These APIs include batch processing methods that enable you to export or import multiple objects within the same API call through the Batch Engine. For large-scale migrations or integration with external systems, this batch processing capability provides an efficient, automated way to manage multiple object definitions in a single API request.

Liferay's object-admin APIs empower developers to manage object definitions programmatically, including their relationships, actions, and other elements.
 

Liferay also provides the headless-admin-list-types REST APIs for creating and managing picklist definitions (ListTypeDefinition) and their entries (ListTypeEntry). These APIs enable programmatic creation, modification, and deletion of picklists. Additionally, with these batch endpoints, you can export or import multiple picklists with a single API call, streamlining the migration process.

Liferay also provides the headless-admin-list-types REST APIs for creating and managing picklist definitions and their entries.

For notification templates, Liferay provides the notification REST APIs. These APIs offer programmatic access to notification templates, so you can efficiently promote them to new environments when migrating data models. This is particularly important since you cannot export and import notification templates through the Liferay UI.

For notification templates, Liferay provides the notification REST APIs.

You can streamline data model migration using Batch Client Extensions. These extensions leverage Liferay's Batch Engine to automate the import and export of object definitions, picklists, notification templates, workflow definitions, and other entities as JSON files. This automation is particularly valuable for large-scale migrations or situations requiring frequent data transfers between environments.

Conclusion

Liferay offers flexible methods for migrating data models, ensuring consistency when promoting object-based applications between environments. Whether you prefer the UI or the programmatic control of headless APIs and batch processing, understanding these options empowers you to effectively manage and migrate your data models and their dependencies. Next, you’ll learn about exporting and importing object entries.

  • Using the Liferay UI to Export and Import

  • Using Batch APIs and Client Extensions

  • Conclusion

Loading Knowledge

Capabilities

Product

Education

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy