Defining a Custom Data Schema

The ticketing application requires custom data fields and selections. You use Liferay objects and picklists to define a custom data schema.

Creating Custom Picklists

A picklist is a predetermined list of values users can select. Picklists are needed for custom fields such as ticket status, ticket type, and ticket priority.

Deploy the Custom Picklists

Deploy the liferay-ticket-batch-list-type-definition client extension with the following command:

./gradlew :client-extensions:liferay-ticket-batch-list-type-definition:deploy

Navigate to Control PanelPicklists. See that five new picklists have been created.

Five new picklists have been created.

Examining the Custom Picklists Code

Each client extension project is defined by the client-extension.yaml file. The first section defines the assemble block that specifies the files included in the deployable .zip file. The assemble block for this client extension looks like this:

assemble:
    - from: batch
      into: batch

See Assembling Client Extensions to learn more.

This list-type-batch client extension is a batch type client extension. It is defined as follows:

liferay-ticket-batch-list-type-definition:
    name: Liferay Ticket Batch List Type Definition
    oAuthApplicationHeadlessServer: liferay-ticket-batch-list-type-definition-oauth-application-headless-server
    type: batch

See Batch YAML Configuration Reference for an explanation of each property.

The client extension makes use of the batch engine headless API and the picklists headless API. To make secure API requests, the client extension is configured to use OAuth2 authorization. It is defined as follows:

liferay-ticket-batch-list-type-definition-oauth-application-headless-server:
    .serviceAddress: localhost:8080
    .serviceScheme: http
    name: Liferay Ticket Batch List Type Definition OAuth Application Headless Server
    scopes:
        - Liferay.Headless.Admin.List.Type.everything
        - Liferay.Headless.Batch.Engine.everything
    type: oAuthApplicationHeadlessServer

Note that the Liferay.Headless.Admin.List.Type resource and Liferay.Headless.Batch.Engine resource are given full CRUD access.

See client-extension.yaml for the full definition.

The five picklists and their selection items are defined in the JSON file located in the /batch/ folder of the client extension. See the list-type-definition.batch-engine-data.json file for the full definitions.

Creating Custom Objects

Once the picklists are defined, the application’s custom object can be created.

Deploy the Custom Object

Deploy the liferay-ticket-batch-object-definition client extension with the following command:

./gradlew :client-extensions:liferay-ticket-batch-object-definition:deploy

In Liferay, navigate to Control PanelObjects. See that a new ticket object has been created.

A new ticket object has been created.

Examining the Custom Object Code

This liferay-ticket-batch-object-definition client extension is also a batch type client extension. The client extension’s YAML file is defined in the same way as the liferay-ticket-batch-list-type-definition client extension. See batch YAML Configuration Reference for an explanation of each property.

See client-extension.yaml for the full definition.

The custom ticket object is defined in the JSON file located in the /batch/ folder of the client extension. See the object-definition.batch-engine-data.json file for the full definition.

Generating Ticket Data through APIs

With the custom ticket object finished, new ticket entries can be created within Liferay. They can also be imported through the use of the object’s REST APIs.

Run the command below to generate a ticket entry:

./gradlew :client-extensions:liferay-ticket-batch-object-entry:deploy

In Liferay, navigate to Control PanelTickets. See that a new ticket entry has been created.

A new ticket entry has been created.

Next: Apply a Custom Theme to the ticketing system.

Relevant Concepts

Capabilities

Product

Contact Us

Connect

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