Execute Groovy validators in Job flow

Highlighted
One Star emo
One Star

Execute Groovy validators in Job flow

Hi,
The Excel files that I upload are like snowflakes, no two are alike! To speed up development time, I'd like to access our Groovy/Grails domain class validators prior to the upload of each row.
I've tried many suggestions both on this forum and outside. The most promising is to bind to the globalMap using tGroovyFile and then call it from a tJava component, but tGroovyFile throws a groovy.lang.MissingPropertyException: No such property: globalMap for class: Script1.
The example code in the Groovy file is:
globalMap.put("GroovyObject", new MyGroovyObject())
class MyGroovyObject {
def myMethod(row) {
// Do anything you want with the row
// update the row directly like
row.counter++
row.email = row.email + "_TEST"
}}
It errors out before even getting to the tMap. Is there something I'm missing? (I'm a Groovy noob.) Is there example code somewhere?
Thanks,
Eileen
One Star

Re: Execute Groovy validators in Job flow

Hi,
This blog post has a video that shows how to use groovy with Talend:
http://bekwam.blogspot.com/2011/02/tutorial-using-groovy-with-talend-open.html
Here's another post that describes how to get data out of groovy (say a validator result and error messages object).

http://bekwam.blogspot.com/2011/04/passing-variable-out-of-tgroovy-with.html
Employee

Re: Execute Groovy validators in Job flow

Thanks for the blog posts Carl!
Best,
Pcoffre.
One Star emo
One Star

Re: Execute Groovy validators in Job flow

Hi walkerca,
I have seen the first link, and the issue I have is that tGroovy and tGroovyFile only run once at the beginning of the job, and the code needs to run for every row. The second link looks promising and is one I haven't seen before. I'll work with it to see if it solves my problem.
Thank you for your response!
Eileen

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch