How to get Context Group name in Talend

Highlighted
Four Stars

How to get Context Group name in Talend

As per my requirement i have added 2 context groups in my job. Attached is the screenshot of my job.

Context group names are DBConnection and SourceConnection.

My requirement is to get those group names and display on console. Is there any way to get Only context group names in Talend?

Please help me.

Highlighted
Sixteen Stars
Sixteen Stars

Re: How to get Context Group name in Talend

I'm afraid this is not possible.

As far as I know, context groups are here just to let you organize context variables into the Studio.


TRF
Highlighted
Nine Stars

Re: How to get Context Group name in Talend

As a workaround you could make another context group called "ContextGroups", with a variable called "ContextGroupsList".  You could put your context group names in the list and then display the list on the console.

Highlighted
Four Stars

Re: How to get Context Group name in Talend

Thank you bilimmer. I will try to implement your approach.

Highlighted
Four Stars

Re: How to get Context Group name in Talend

Hi All,

 

Is there any other approach to get context group name.

 

Please help me.

 

Thanks,

Divya

Highlighted
Nine Stars

Re: How to get Context Group name in Talend

As TRF said, no but maybe you could prefix your context variable names with the name of the context group?  Like:

 

Context group DBConnection

DBConnection_dbName

DBConnection_dbUser

DBConnection_...

 

Context group SourceConnection

SourceConnection_ip

SourceConnection_url

SourceConnection_...

 

This would work as you can use java reflection to read your variable names, and strip everything after the first underscore...

Highlighted
Four Stars

Re: How to get Context Group name in Talend

Thanks bilimmer. Instead of updating context variable names Is it possible to dynamically get the group name?

 

 

Highlighted
Nine Stars

Re: How to get Context Group name in Talend

No.  But you really have me curious about the use case here.  What are you trying to do?  What purpose does printing the context group names in the console serve?  With more information we could suggest another approach?  

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

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog