tMDMRestInput
processing.
tMDMRestInput Standard properties
These properties are used to configure tMDMRestInput running in
the Standard Job framework.
The Standard
tMDMRestInput component belongs to the Talend MDM family.
This component is available in Talend MDM Platform and in Talend Data Fabric.
Basic settings
Schema and Edit |
A schema is a row description, it defines the number of fields Click Edit
|
||||
 |
Built-In: The schema will be created and |
||||
 |
Repository: The schema already exists |
||||
Use an existing connection |
Select this check box if you want to use a configured tMDMConnection component. |
||||
URL |
Enter the URL to access the MDM server through the REST API. |
||||
Username and Password |
Enter the user authentication data for the MDM server. To enter the password, click the […] button next to the |
||||
Data Container |
Enter the name of the data container that holds the data |
||||
Type |
Select Master or |
||||
Retrieve raw data |
Select this check box to retrieve all the queried data into a
|
||||
Query Text |
Enter the query text you want to include in REST API calls to Apart from the default sample query, the query text can be:
You can provide each JSON field of your query text between either single or Any single quote included in the value of a field in the query text must be For example, if you have the value This is Product's
Once you have entered the query text, make sure to set the Warning: You need to select the Retrieve Raw Data check box only if you want to
parse the queried raw data in XML or JSON format by yourself. Note: Using this component, when retrieving data from an entity
involving a repeating foreign key element, you must add a join clause between the main entity and the linked entity in your select query. For example, considering an entity named Product which contains a collection of foreign keys pointing
Instead you have to
For more information about the select query with a join |
||||
Die on error |
Select this check box to skip the row in error and complete the |
Advanced settings
Batch Size |
Number of lines in each processed batch. When the number of records for the current query is greater |
tStatCatcher Statistics |
Select this check box to gather the processing metadata at the |
Global Variables
Global Variables |
ERROR_MESSAGE: the error message generated by the
NB_LINE: the number of rows processed. This is an After A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see |
Usage
Usage rule |
tMDMRestInput can be used along with tMDMConnection, tMDMRestInput needs an output link. |
How to set the schema correctly based on the query text when using
tMDMRestInput
When using the component tMDMRestInput, you
can use the query language to narrow down the data records to be retrieved. Based on the
query, you need to set the schema correctly for the retrieved data.
You can also find more information about the MDM query language
and REST data access in Talend Help Center (https://help.talend.com).
Query cases
-
When a query only counts how many results are returned by the
query, you need to define one and only one column count in the schema. -
When a query gets a metadata field, you need to define a
column the same name as the metadata field in the schema. -
When a query gets one or more fields, you need to define one
or more columns whose names are the same as the returned fields in the
schema. -
When a query uses an alias, you need to define a column the
same name as the alias field in the schema.
For example, if a query text gets the following fields, you need to
define columns in the schema correspondingly: id, price, timestamp, taskid and productname.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
"{ 'select': { 'from': ['Product'], 'fields': [ {'field': 'Product/Id'}, {'field': 'Product/Price'}, {'metadata': 'timestamp'}, {'metadata': 'task_id'}, {'alias' : [{'name' : 'ProductName'}, {'field': 'Product/Name'}]} ] } }" |
Reading data from an MDM hub through the REST API
This scenario applies only to Talend MDM Platform and Talend Data Fabric.
This scenario describes a two-component Job that reads data from a business entity in the MDM
server through the REST API.
In this example, we assume that you have already imported the MDM demo project. For further
information about how to import a demo project, see
Talend Studio User Guide.
This Job fetches data records that pertain to the Product
entity of the Product data container in the MDM demo project.
Dropping and linking the components
-
From the Palette, drop tMDMRestInput and tLogRow onto
the design workspace. - Connect the components using a Row > Main link.
Configuring the components
-
Double-click tMDMRestInput
to view its Basic settings in the
Component tab. -
In the Schema list,
select Built-In and then click the
[…] button next to Edit schema to open a dialog box in which you
can define the structure of the retrieved data.In this example, we will extract the four elements of the
product information defined in the Product data model
into the four fields: id, name, description and price. -
Click the [+] button and
add four columns of the type String.The data records retrieved from the MDM server need to be
mapped into a correct schema. For more information, see How to set the schema correctly based on the query text when using tMDMRestInput. -
Click OK to validate
your changes.The Propagate dialog
box pops up. Click Yes to propagate your
changes. -
In the URL field, enter
the URL to access the MDM server through the REST API. In this example, leave it
as default. -
In the Username and
Password fields, enter the
credentials to access the MDM server. -
In the Data Container
field, enter the name of the container which holds the data you want to
retrieve, Product in this example.Then, select Master
from the Type list. -
Leave the check box Retrieve raw data clear since in
this example we will use a query text to retrieve four fields from the Product
data container. -
In the Query Text area,
enter the query you want to include in the REST API calls for retrieving the
data records of interest. The entire query text is enclosed with double
quotes.In this example, enter the following to retrieve the product
record(s) with a price larger than 500:123456789101112131415"{'select':{'from':['Product'],'fields':[{'field':'Product/Id'},{'field':'Product/Name'},{'field':'Product/Description'},{'field':'Product/Price'}],'where': {'gt': [{'field':'Product/Price'},{'value':'500'}]}}}" -
Double-click tLogRow and
then select Table from the Mode list.
Saving and executing the Job
- Press Ctrl+S to save your Job.
-
Execute the Job by pressing F6 or clicking
Run on the Run tab.All data records that pertain to the Product entity in the
Product data container with a price larger than 500 are
retrieved and displayed on the console.