Create Steps Using Gradle - QS Format
Overview
A flow must have at least one step.
- For Ingestion, Mapping, Matching, Merging, and Mastering steps: Create a flow using Gradle with the
-PwithInlineSteps=true
option. The resulting flow configuration file includes an example step for each predefined type of step. Simply customize these example steps. - For Custom steps: You can create the flow separately, run the Gradle task hubCreateStepDefinition, and manually copy and insert the step definition into the flow configuration file.
The options for custom step types are different between QuickStart and Gradle:
QuickStart Custom Step Type field selections |
Gradle hubCreateStepDefinition -PstepDefType options |
---|---|
Ingestion | ingestion |
|
custom |
Before you begin
You need:
- Java JRE (OpenJDK) 8
- MarkLogic Server (See Version Compatibility.)
- Gradle 6.4 up to the latest 6.x release
About this task
- Creating a Loading / Mapping / Matching / Merging / Mastering step
- Creating a Custom-Ingestion / Custom-Other step
Before creating a step using Gradle, you need:
- A local project in the QS format. To create a new project: Create a Project Using Gradle
- A flow in the QS format. To create a flow: Create a Flow Using Gradle
-
Ingestion / Mapping / Matching / Merging / Mastering
When you created the flow using the Gradle task hubCreateFlow, examples for each default step type are already embedded in the flow configuration file. Simply edit those examples or use them as templates to add more steps.
-
Custom-Ingestion / Custom-Other
To create Custom steps in Gradle:
- Using Gradle, create the step definition.
./gradlew hubCreateStepDefinition -PstepDefName=yourstepname -PstepDefType=[ingestion|custom] -Pformat=[sjs|xqy] -i gradlew.bat hubCreateStepDefinition -PstepDefName=yourstepname -PstepDefType=[ingestion|custom] -Pformat=[sjs|xqy] -i - stepDefName
- (Required) The name of the custom step definition to create.
- stepDefType
- The type of the custom step definition to create:
ingestion
(To create a Custom-Ingestion step.)custom
(To create a Custom-Mapping, Custom-Mastering, or Custom-Other step.)
The default is
custom
. - format
- The format of the module to associate with the new step definition:
xqy
for XQuery orsjs
for JavaScript. The default issjs
.
A module is created under your-project-root/src/main/ml-modules and is associated with the step definition to perform the processes required for the step; for example, you can create a module to wrap each document in your own custom envelope.
- If
-Pformat=sjs
or if the option is not specified, only one file is created:- main.sjs, which is the JavaScript module that you must customize.
- If
-Pformat=xqy
, two files are created:- lib.xqy, which is the XQuery module that you must customize.
- main.sjs, which acts as a wrapper around lib.xqy.
In the resulting step definition, the modulePath setting points to the custom module file.
- Manually add the step to the flow.
- In a text editor, open the step definition file.
- Likewise, open the flow configuration file.
You can find your flow configuration file in
your-project-root/flows
. - In the
steps
node, add the step as a key-value pair.- For the key, enter a string containing a number which represents the order of the step in the sequence.
Note: The steps can be listed in any order, as long as the keys are unique within the
steps
node of the flow. Duplicate keys can produce unexpected results. The key number must be greater than 0. - For the value, copy and paste the entire content of the step definition file.
- For the key, enter a string containing a number which represents the order of the step in the sequence.
- Edit the step in the flow configuration file.
- Rename the name setting to stepDefinitionName.
- Rename the type setting to stepDefinitionType.
- Create a new name setting and assign it a name for the step.
- (Optional) Delete the following settings:
- language
- version
- modulePath
The values for these settings are retrieved from the step definition.
- Modify your custom module.
Learn more: Custom Step Settings
- Using Gradle, create the step definition.
What to do next
- (Optional) To perform other tasks outside the Data Hub space, you can add interceptors and custom hooks to the step.
- Run the flow.
- For a local environment, run the flow:
- For a DHS environment without Hub Central, for other cloud environments, or for on-premises environments, run the flow using the client JAR.