tjavarow run if

One Star

tjavarow run if

hi all
i want to do connection between tjavarow to tjavarow only if something is happend how can i do it?
i try to use run if but i can't to connect him to the second tjavarow.. 
in the talend we have something that can help?

Five Stars

Re: tjavarow run if

You need to better explain what you are trying to do.
"if something happend"?
It is unlikely that you're going to be connecting two tJavarow components with an "if".
One Star

Re: tjavarow run if

ok i try to explain better.

i want to use tjavarow, in the first javarow do same java code, after that to chack if the variable a1 for example is equals to "1" go to the second javarow, else if a1 is equals to "2" go to the other javarow 
Five Stars

Re: tjavarow run if

It sounds like you're trying to filter your output?
If you're simply looking at input data to determine which way it should go, you could use a tMap with multiple outputs.
tMap has an expression filter on the output.
tMap_1 set expression filter for output1 to "1".equals(row1.a1)
          set expression filter for output2 to "2".equals(row1.a1)

If you're new to Talend, tJavaRow is not the first component of choice. There are usually better components.
One Star

Re: tjavarow run if

i am using map with filtter and it works,  i need to do the section (you can see in the picture attachted) where it says: "Will happen in any case". 
1- first, i need to know how to implement from "JAVA ROW" to execute 2 "IF" statements. (see attached file).
2- after that step, i need to take action in any case, meaning, no matter which "IF" statement happened, the next step should ALWAYS run.
Thanks in advence.
Five Stars

Re: tjavarow run if

What happens in "action"?
Maybe a tFlowToIterate followed by tJava gives you what you need?
One Star

Re: tjavarow run if

in the action i just comput variables.
and i don't think that tjava will help me i need to use tjavaRow 
Five Stars

Re: tjavarow run if

Sorry, I don't think I can help.
I think the answer to your original question was to split the data using tMap which you are doing anyway.
I do not know what "comput variable" means and then what you want to do after.
the two evaluations coming from your tJavaRow_1 are exactly what you'd do in tMap to split outputs.
One Star

Re: tjavarow run if

ok Thanks  on your help. 
Four Stars

Re: tjavarow run if

Why not do all the code in the first tJavaRow?
One Star

Re: tjavarow run if

because i want to see the whole flow, i may be able do write everything in "tJavaRow" but then again, what's the
point in using TALEND?
so i can write sql statement in the tJavaRow and do everything in java, what what would be the logic in that?
i'm now exploring the Talend and want to unify\combine\unite 2 Flows into 1, as depicted in the pictures i've attached in previous message.

the goal is as follows, from the beginning:
 i have a row that needed to be processed, and that row is split into 2 flows:
1- first flow      --> will happen only if some condition happens.
2- second flow  --> the same as the 1st flow--> will happen only if another condition happens.

Eventually, for every row (with no regarding to which flow i've entered, for instance, i can enter flow 1 or flow 2 )
i need to perform some more actions, like : log \update DB   etc....
and i don't want to write these actions twice. 
meaning, from 2 flows, i need only 1 output, 1 outcome.

i'd appreciate any help. 
Ten Stars

Re: tjavarow run if

First of all, Talend is just a tool that generates Java. There is no shame in using Java to circumvent a situation where you litter the job with components. However, you can do what you want to do. But you will be sacrificing performance to show the whole flow, you will be bending Talend rules on data flow (you are not supposed to split a flow and rejoin it in a subjob) and you will be loading your job with far too many components. But since Talend is arguably the most flexible DI tool, you can do this. Below is a screenshot of an example I have put together...
 


You have to make use of tFlowToIterates to create global variables from your flow data, you then use dummy tJava components to "terminate" a path before switching to RunIf links to test your global variables. This has to be iterated rather than flowed. You can then "do something" with the data before switching to a tFlowToIterate again, terminating with a tJava and using RunIfs to merge back to a single flow of data. This is done using a tFixedFlowInput. You then can carry on. Rather than explain the full complexity of this in text, I have included the job here RunningTotal.zip

Alternatively, you can be much more efficient with code, development time and performance and use this in your tJavaRow....

String value = input_row.SomeValue;

if(value.equals("hello")){
    output_row.SomeText = "olleh";
}else if(value.equals("world")){
    output_row.SomeText = "dlrow";
}


By the way, the example was written using Talend v562. You can use with any version the same or greater
One Star

Re: tjavarow run if

ok I try this solution and it work thanks... :-)

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

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

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download