Code to access the component matrix properties - Cloud - 8.0

Talend Studio User Guide

Version
Cloud
8.0
Language
English
Product
Talend Big Data
Talend Big Data Platform
Talend Cloud
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Real-Time Big Data Platform
Module
Talend Studio
Content
Design and Development
Last publication date
2024-02-29

The component matrix properties are created and changed by users according to various data transformation purposes. These properties are defined by tabular parameters, for example, the operation parameters or groupby parameters that users can define through the tSQLTemplateAggregate component.

To access these tabular parameters that are naturally more flexible and complicated, two approaches are available:

  • The </.../> approach:

</.../> is one of the syntax used by the SQL templates. This approach often needs hard coding for every parameter to be extracted.

For example, a new parameter is created by user and is given the name NEW_PROPERTY. If you want to access it by using </NEW_PROPERTY/>, the below code is needed.

else if (paramName.equals("NEW_PROPERTY")) {
 List<Map<String, String>> newPropertyTableValue = (List<Map<String, String>>)
  ElementParameterParser.getObjectValue(node, "__NEW_PROPERTY__");
 for (int ii = 0; ii <newPropertyTableValue.size(); ii++) {  
   Map<String, String> newPropertyMap =newPropertyTableValue.get(ii);
   realValue += ...;//append generated codes
 ......
  }
}
  • The EXTRACT(__GROUPBY__); approach:

The below code shows the second way to access the tabular parameter (GROUPBY).

<%
 String query = "insert into " + __TABLE_NAME__ + "(id, name, date_birth) select sum(id), name, date_birth from cust_teradata group by";
  EXTRACT(__GROUPBY__);
  for (int i=0; i < __GROUPBY_LENGTH__ ; i++) {
 query += (__GROUPBY_INPUT_COLUMN__[i] + " ");
 }
 %>
<%=query %>;

When coding the statements, respect the rules as follows:

  • The extract statement must use EXTRACT(__GROUPBY__);. Upcase should be used and no space char is allowed. This statement should be used between <% and %>.

  • Use __GROUPBY_LENGTH__, in which the parameter name is followed by _LENGTH, to get the line number of the tabular GROUPBY parameters you define in the Groupby area on a Component view. It can be used between <% and %> or <%= and %>.

  • Use code like __GROUPBY_INPUT_COLUMN__[i] to extract the parameter values. This can be used between <% and %> or between <%= and %>.

  • In order to access the parameter correctly, do not use the identical name prefix for several parameters. For example in the component, avoid to define two parameters with the names PARAMETER_NAME and PARAMETER_NAME_2, as the same prefix in the names causes erroneous code generation.