Question

Using tScriptRule component in Talend DI 4.2.1. Using the jexl expression to evaluate the date pattern results to false for all the conditions. The snippet derived from job for testing is as :

public class Script {

static class Row {

    public String EFFECTIVEDATE;

    public String getEFFECTIVEDATE() {
        return this.EFFECTIVEDATE;
    }
}

public static void main(String[] args) {
    Row row1 = new Row();
    row1.EFFECTIVEDATE = "10-01-2012"; 
    com.bekwam.tscriptrules.JexlRowEvaluator e_tScriptRules_2 = new com.bekwam.tscriptrules.JexlRowEvaluator();
    boolean ruleTest_tScriptRules_2_1 = e_tScriptRules_2
    .evalTrue("'${TalendDate.isDate(row1.EFFECTIVEDATE, \"dd-mm-yyyy\")}' == true", "row1", row1);
    System.out.println(ruleTest_tScriptRules_2_1);
}
}

The libraries/component are from tScriptRules

Was it helpful?

Solution

Talend functions are not evaluated by the jexl expression processor. You can only use field (in your input row) in a jexl expression. As you can see in the generated java code, the only parameter passed to the method is the row and all its fields

com.bekwam.talend.component.scriptrules.Result result_tScriptRules_1 = rulesBean_tScriptRules_1.process(row1, row2, row3, counter_tScriptRules_1);

  • row1 : the input rows
  • row2 : the filtered rows
  • row3 : the rejected rows

You can modify the tscriptrules-2.0.1.jar library if you want to add Talend method evaluation in the jexl expression processor.

Instead, I would suggest to use a tmap to do this kind of data quality check

tMap Design : http://imageshack.us/a/img842/879/talendtmap.jpg tMap Result : http://imageshack.us/a/img541/5950/talendtmapresult.jpg

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top