Defining the survivor validation flow

Deduplication

author
Talend Documentation Team
EnrichVersion
6.5
EnrichProdName
Talend Data Services Platform
Talend ESB
Talend Open Studio for Big Data
Talend Big Data
Talend Open Studio for ESB
Talend Big Data Platform
Talend Real-Time Big Data Platform
Talend Open Studio for Data Integration
Talend Open Studio for MDM
Talend Data Management Platform
Talend Data Integration
Talend MDM Platform
Talend Data Fabric
task
Data Quality and Preparation > Third-party systems > Data Quality components > Deduplication components
Design and Development > Third-party systems > Data Quality components > Deduplication components
Data Governance > Third-party systems > Data Quality components > Deduplication components
EnrichPlatform
Talend Studio

Procedure

  1. Double-click tRuleSurvivorship to open its Component view.
  2. Select GRP_ID from the Group Identifier list and GRP_SIZE from the Group size list.
  3. In the Rule package name field, replace the by-default name org.talend.survivorship.sample with a name of your choice, if needed.
    The survivor validation flow will be generated and saved under this name in the Repository tree view of the Integration perspective.
  4. In the Rule table, click the plus button to add a row per rule.
    In this example, define one rule and complete it as the following:

    Order

    Rule name

    Reference column

    Function

    Value

    Target column

    Sequential

    "Rule1"

    File

    Expression

    .equals("1")

    Acctname

    One rule, "Rule1", will be generated and executed by tRuleSurvivorship. This rule validates the records in the File column that comply with the expression you enter in the Value column of the Rule table. The component will then select the corresponding value as the best breed from the Acctname target column.
  5. Next to Generate rules and survivorship flow, click the icon to generate the rule package according to the conditions you have defined.
    The rule package is generated and saved under Metadata > Rules Management > Survivorship Rules in the Repository tree view of the Integration perspective.
  6. In the Repository tree view, browse to the rule file under the Survivorship Rules folder and double-click "Rule1" to open it.
    But this rule will select the values that come from file 1. However, you may also want to survive records based on specific criteria; for example, if Acctname has a value in file1, you may want to use that value, or else use the value from file2 instead. To do this, you must modify the code manually in the rule file.
  7. Modify the rule with the following Drools code:
    package org.talend.survivorship.sample 
    
    rule "ExistInFile1"
        no-loop true
        dialect "mvel"
        ruleflow-group "Rule1Group"
    when
        $input : RecordIn( file.equals("1"), acctname!= null, !acctname.trim().equals("") )  
    then
        System.out.println("ExistInFile1 fired\t" + $input.record_id);
        dataset.survive( $input.TALEND_INTERNAL_ID, "Acctname" );
        dataset.survive( $input.TALEND_INTERNAL_ID, "File" );
    end
    
    rule "NotExistFile1"
        no-loop true
        dialect "mvel"
        ruleflow-group "Rule1Group"
    when
        $input : RecordIn( file.equals("2"), acctname!= null && !acctname.trim().equals("") )  
        (not (exists (RecordIn( file.equals("1") ))) 
        or exists( RecordIn( file.equals("1"), acctname== null || acctname.trim().equals("") ) ))
    then
        System.out.println("NotExistFile1 fired\t" + $input.record_id);
        dataset.survive( $input.TALEND_INTERNAL_ID, "Acctname" );
        dataset.survive( $input.TALEND_INTERNAL_ID, "File" );
    end
    Warning:

    After you modify the rule file, you must not click the icon. Otherwise, your modifications will be replaced by the new generation of the rule package.