Search code examples
javaif-statementconditional-statementstalend

Talend, If Statement with subconditions


I'm working on a Talend job where i need to insert informations in a column depending of informations to another column. For example, the target here is to insert "O" into "Saisie_manuelle_O_pour_Oui_sinon_rien" if "Code_direction" equals "D45" and "Fonction_libelle" not equals CHEF DE SERVICE or "Fonction_Libelle" not equals CHEF DE SERVICE ADJOINT.

For the moment i tried this :

if ("D45".equals(input_row.Code_direction) && (!("CHEF DE SERVICE".equals(input_row.Fonction_libelle) && !"CHEF DE SERVICE ADJOINT".equals(input_row.Fonction_libelle))) {
    output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "O";}

It work but not 100%. It put "O" everywhere where "Code_direction" = "D45" even if Fonction_libelle not equal CHEF DE SERVICE OR CHEF DE SERVICE ADJOINT...

I think i did something wrong but i'm not able to see what...

Any help will be very appreciated !


Solution

  • Never mind, for the moment i will do something else... I can do what i want by doing an other if statement after it, for example :

    if ("D45".equals(input_row.Code_direction)) {
        output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "O";
    }
    
    if ("CHEF DE SERVICE".equals(input_row.Fonction_libelle) || "CHEF DE SERVICE ADJOINT".equals(input_row.Fonction_libelle)) {
        output_row.Saisie_manuelle_O_pour_Oui_sinon_rien = "";
    }
    

    This is not very clean but it's working ! I'll continue like this for the moment.