Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
SJeshwani1618330394
Contributor
Contributor

How to pass TalendDate in tJava component?

I have a scenario in which I need to pass TalendDate.getDate into the URL in tHttpRequest component. I am able to get the result by using the below-mentioned URL but I want to get the URL using a variable. However, as we cannot pass TalendDate in the context parameter, what is the workaround to do this?

This is the URL that I am using in tHttpRequest component:

https://services5.arcgis.com/sjP4Ugu5s0dZWLjd/arcgis/rest/services/Bands_Public/FeatureServer/0/query?where=STARTDATE%20%3E='"+ TalendDate.addDate( TalendDate.getDate("YYYYMMDD"), "yyyyMMdd", -3, "MM" )+"'AND%20STARTDATE%20%3C='"+ TalendDate.addDate( TalendDate.getDate("YYYYMMDD"), "yyyyMMdd", -1, "dd" )+"'&returnGeometry=true&resultType=standard&outFields=*&outSR=4326&f=json

I want to pass a value for STARTDATE in this URL. As I cannot pass TalendDate.getDate in the context parameter, what is the other way to do this?

At the end I want to pass the whole URL as a variable so that I can change the value when I am running this job from Commandline.

Regards,

Sheetal

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi

Set URL as a context variable and initialize the value on a tJava before it is used on tHttpRequet, for debugging, print the value on the console to check if the value is set correctly, eg:

tJava

|onsubjobok

tHttpRequest--->tLogRow

 

on tJava:

context.URL="https://services5.arcgis.com/sjP4Ugu5s0dZWLjd/arcgis/rest/services/Bands_Public/FeatureServer/0/quer...'"+ TalendDate.addDate( TalendDate.getDate("YYYYMMDD"), "yyyyMMdd", -3, "MM" )+"'AND%20STARTDATE%20%3C='"+ TalendDate.addDate( TalendDate.getDate("YYYYMMDD"), "yyyyMMdd", -1, "dd" )+"'&returnGeometry=true&resultType=standard&outFields=*&outSR=4326&f=json";

 

System.out.println(context.URL);

 

 

Regards

Shong

 

 

 

View solution in original post

3 Replies
Anonymous
Not applicable

Hi

Set URL as a context variable and initialize the value on a tJava before it is used on tHttpRequet, for debugging, print the value on the console to check if the value is set correctly, eg:

tJava

|onsubjobok

tHttpRequest--->tLogRow

 

on tJava:

context.URL="https://services5.arcgis.com/sjP4Ugu5s0dZWLjd/arcgis/rest/services/Bands_Public/FeatureServer/0/quer...'"+ TalendDate.addDate( TalendDate.getDate("YYYYMMDD"), "yyyyMMdd", -3, "MM" )+"'AND%20STARTDATE%20%3C='"+ TalendDate.addDate( TalendDate.getDate("YYYYMMDD"), "yyyyMMdd", -1, "dd" )+"'&returnGeometry=true&resultType=standard&outFields=*&outSR=4326&f=json";

 

System.out.println(context.URL);

 

 

Regards

Shong

 

 

 

SJeshwani1618330394
Contributor
Contributor
Author

Hi Shong,

 

Thank you so much.

 

It's working as expected.

 

Regards,

Sheetal

SJeshwani1618330394
Contributor
Contributor
Author

Hi Shong,

 

It is working inside the Talend studio, but when I am trying to run this job from commandline I am unable to override the value of the URL variable.

 

Do I need to do anything else? All the other context variables' values I am able to change from the command line, only the variables which I am passing through tJava component are unable to override.

 

Do you know any possible solution for this?

Thank you.

 

Regards,

Sheetal