Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

deactivate/activate component from code

Hello,

is there a way to change Talend's component properties (ex activate/deactivate component) from java code - not using right click?

Let say I would like to have a job (job_main) with code in tJava like:

IF globalmap.get("var1") == 1 THEN JOB(name).COMPONENT(name).activate
IF globalmap.get("var2") == 0 THEN JOB(name2).COMPONENT(name2).deactivate;

So after that I can run other mentioned jobs with particular components activated/deactivated.

Is it possible? I know that running job generate some java code that can't be changed during execution, that why I accept situation when I have to run "job_main" first and then other (modified) jobs after that manually.

 

I am new to Talend, but familiar with VBA, so for me its like changing properties of some object from VBA code (like change color of shape in the sheet)

 

After all I am asking that question because I have a job like: input --> tMap --> multiple outputs  and I would like to execute only particular outputs according to some variable values. (there are ~10 outputs and I have 30 jobs like that - will be more that 100) I was looking into RUN IF but unfortunately I cant use run if beetwen tMap and Output.

 

Can any one help me with my issue?

Labels (2)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

There is no way to activate/deactivate a Component by Java code.

But you can control Creation of Output from tmap using Global Var/Context in ExpressionFilter

 

0683p000009M387.jpg

View solution in original post

6 Replies
akumar2301
Specialist II
Specialist II

There is no way to activate/deactivate a Component by Java code.

But you can control Creation of Output from tmap using Global Var/Context in ExpressionFilter

 

0683p000009M387.jpg

vapukov
Master II
Master II

Hi,

 

you can not activate/deactivate components

but you could use RunIf trigger for this

0683p000009M3BB.png0683p000009M329.png

Anonymous
Not applicable
Author

It sounds like you can do this without activating/deactivating code. In your example you talk about a tMap with 10 outputs. You can filter the outputs dynamically quite easily. 

 

For example.....

 

I might have a job with 3 possible flows out of a tMap; flowA, flowB and flowC. 

I can parameterise these so that the flow can be changed based upon a simple context variable that is supplied to the job at runtime.

Below is a screen shot of a basic job like this...

0683p000009M09h.png

Inside the tMap, it looks like this....

0683p000009M3Cw.png

If you look at the 3 output flows, they are each filtered by a context variable called Flow. This can be set at runtime.

 

So that is one way of achieving what you described, there are also several other ways. You will need to be a bit more specific about your requirement for us to nail down the path you need to take.

Anonymous
Not applicable
Author

I keep doing this, I pick a post to answer and then get sidetracked with something else. Come back to it. Post. Then find out that I have essentially answered in the same way as others. Sorry @uganesh, our answers are practically the same. @vapukov that was potentially going to be one of the alternatives I would have offered if what I (and @uganesh ) offered was not what was required.

Anonymous
Not applicable
Author

@uganesh , @rhall Thanks guys, that filter is exactly what I needed!

I have one problem with that solution, probably because I don't understand global variables.

I am using global variable in filter [((Integer)globalMap.get("var1")).equals(1)] and everything works when I set global variables inside job like on the screen below:

 

0683p000009M316.png

 

But like I said before there will be more than 100 jobs of that kind. So I would like to set global variables once, in the begging of main job and then check variables values in sub jobs (called by tRunJob from main job). When I set global variables in main job  (pic below) and call child job (on pic above without tJavaRow part) I get error during tMap  "java.lang.NullPointerException".

 

0683p000009M2ue.png

 

I guess its because global variable that I have in condition is not set (null) and I get nothing to output. 

Can I pass global variables values to every sub job and avoid setting their values inside every sub job?

 

 

akumar2301
Specialist II
Specialist II

you can pass parent context variable/even parent global Map to pass to child job.

https://help.talend.com/reader/Wi~~2Q0v6A43uBlbET9gQg/0UPTaLWRsIeAqa8hxWsuAw


Also you could create a routine having a ConcurrentHashMap that exposes get/put methods. set your variable in that hash.

As all your job is in same Project , all the job will share this hash.