Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to build a job where one field is a text field which is being translated using tREST and Google Translate API. The second field is the key(id) assiciated with the text field. However, the output of the tREST component yields just the fields "Body"(with translated text in JSON format) and "ERROR_CODE". My objective is to load the output into a database. How can I do this while keeping the key associated with each translated text row?
Desired output format:
ID TEXT
1 abcdefg
2 bcdefgh
3 cdefgh
BR
Lars
I'm assuming your data (ID and TEXT) are coming from a DB or a flat file. In this case, read in your data from your source and connect it to a tFlowToIterate component. This will save each row in the globalMap using the row name and the column name as a key to each column. If your row from your source component is "row1" and your column names are "ID" and "TEXT", you can retrieve those values using ....
((String)globalMap.get("row1.TEXT"))
....for TEXT and ...
((Integer)globalMap.get("row1.ID"))
...for ID. I am assuming that ID is an Integer and TEXT is a String here.
After your tFlowToIterate you would add a tJava component as a dummy component. This is because you cannot link to a tRestClient component with an Iterate link. In your tRestClient component you can use your TEXT value in your URL by appending the following code to your URL....
"Your url...../"+((String)globalMap.get("row1.TEXT"))
Then after your tRestClient, you can add a tMap to link your returned data with its original value (if necessary) and its ID by adding output columns for the ID and original TEXT. You would use the globalMap code I have shown above for this.
I'm assuming your data (ID and TEXT) are coming from a DB or a flat file. In this case, read in your data from your source and connect it to a tFlowToIterate component. This will save each row in the globalMap using the row name and the column name as a key to each column. If your row from your source component is "row1" and your column names are "ID" and "TEXT", you can retrieve those values using ....
((String)globalMap.get("row1.TEXT"))
....for TEXT and ...
((Integer)globalMap.get("row1.ID"))
...for ID. I am assuming that ID is an Integer and TEXT is a String here.
After your tFlowToIterate you would add a tJava component as a dummy component. This is because you cannot link to a tRestClient component with an Iterate link. In your tRestClient component you can use your TEXT value in your URL by appending the following code to your URL....
"Your url...../"+((String)globalMap.get("row1.TEXT"))
Then after your tRestClient, you can add a tMap to link your returned data with its original value (if necessary) and its ID by adding output columns for the ID and original TEXT. You would use the globalMap code I have shown above for this.
Hi rhall_2_0!
Thanks for your advice - it worked just fine