- Discuss DSL programming paradigm.
- Why SQL is classified as DSL and not Imperative?
- Write SQL to select records from the entity
MoquiTraining
, User should be able to filter records bytrainingName
ortrainingId
. - Parameterize the above SQL query. Execute parameterised SQL from MySQL Workbench.
-
Fetch MoquiTraining Records:
- Create a new service to fetch records from the
MoquiTraining
entity. - Allow filtering by
trainingName
ortrainingId
. - Return a list of records containing only
trainingId
,trainingName
, andtrainingDate
.
- Create a new service to fetch records from the
-
Create/Update MoquiTraining Records:
- Implement a service to create or update records in the
MoquiTraining
entity. - Check for existing records using
trainingName
ortrainingId
. - Update if a record exists; create a new one otherwise.
- Validate input:
trainingName
is mandatory.trainingDate
format is "MM/dd".
- Return the
trainingId
.
- Implement a service to create or update records in the
-
Run Service and Verify:
- Test the new services to ensure they create, update, and retrieve records correctly.
Push your new service implementations to the "moqui-training" repository on GitHub.
This guide focuses on writing services in Moqui's Minilang, a domain-specific language designed for implementing business logic.
- Service Wrappers: Moqui provides convenient service wrappers to interact with various entities and operations.
- Examples:
entity-find
: Find entity records based on criteria.entity-auto
: Automate common entity actions (create, update, delete).service-call
: Invoke other services within your logic.
- Return Errors: Handle and report errors gracefully within your services.
- Log Statements: Use logging to record useful information during service execution.
- Passing Parameters:
- Context: The service context provides access to variables and objects.
- Additional Parameters: You can pass extra parameters alongside the context.
- Custom Map: Organize parameters using a map for clarity.
- List Parameters: Services can accept list-type input parameters.