From Thursday, July, 9, 3:00 PM Pacific,
our Community site will be in
read-only mode
through Sunday, July 12th.
Thank you for your patience.

Using Context and globalMap from component in a custom Routine

Highlighted
Six Stars

Using Context and globalMap from component in a custom Routine

Hi,

I want to reduce all my code from my tJava so I'm trying to use Routine in a Job ToS for ESB 7.1.1.

 

For example :

I'm doing a request from a table :

"SELECT COLUMN_NAME
FROM TABLE 
WHERE TABLE_NAME = '"+context.Table+"'
AND DATA_TYPE = 'DATE'"

and I save the result in an Arraylist in a tJavaFlex:

tJavaFlex.PNG

But when I have to use it in a different tJava I have to do this :

int NbColumnDate = (Integer)globalMap.get("NbColumnDate");
for (int i = 0; i < NbColumnDate; i++)
{
        ColumnDate.add(((ArrayList)globalMap.get("ColumnNameDate")).get(i).toString());
}

So I want to put this in a Routine and just call it when I need to use this code.

I would like to know if it's possible to use context and globalMap var in custom Routine. If yes, can someone show me the way ?

When I try to use globalMap.get("myVar") or context.myVar an error is raised : context cannot be resolved to a variable and globalMap cannot be resolved to a variable.

Thank you for any help,

 

Regards.

 


Accepted Solutions
Highlighted
Six Stars

Re: Using Context and globalMap from component in a custom Routine

So after many try here is my answer :

My routine :

public static ArrayList<String> arrayListGlobalMap(ArrayList<String> myArray) { 
		ArrayList<String> MyArray = myArray; 
		return MyArray;
	}

The call in my tJava :

ArrayList<String> MyArray = new ArrayList<>();
MyArray = Java_Insert_Routine.arrayListGlobalMap((ArrayList)globalMap.get("myGlobalArray"));

View solution in original post


All Replies
Highlighted
Six Stars

Re: Using Context and globalMap from component in a custom Routine

So after many try here is my answer :

My routine :

public static ArrayList<String> arrayListGlobalMap(ArrayList<String> myArray) { 
		ArrayList<String> MyArray = myArray; 
		return MyArray;
	}

The call in my tJava :

ArrayList<String> MyArray = new ArrayList<>();
MyArray = Java_Insert_Routine.arrayListGlobalMap((ArrayList)globalMap.get("myGlobalArray"));

View solution in original post

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read