use of org.talend.dataquality.record.linkage.grouping.swoosh.SurvivorShipAlgorithmParams.SurvivorshipFunction in project tdq-studio-se by Talend.
the class AnalysisMatchParameterAdapter method getSurvivorshipAlgosMap.
/*
* (non-Javadoc)
*
* @see org.talend.dataquality.record.linkage.grouping.adapter.MatchParameterAdapter#getSurvivorshipAlgosMap(java.util.Map)
*/
@Override
public Map<IRecordMatcher, SurvivorshipFunction[]> getSurvivorshipAlgosMap(Map<Integer, SurvivorshipFunction> colIdx2DefaultSurvFunc, List<SurvivorshipFunction> survFunctions) {
Map<IRecordMatcher, SurvivorshipFunction[]> survAlgos = new HashMap<IRecordMatcher, SurvivorshipFunction[]>();
int matchRuleIdx = -1;
List<List<Map<String, String>>> multiRules = analysisMatchRecordGrouping.getMultiMatchRules();
for (List<Map<String, String>> matchrule : multiRules) {
matchRuleIdx++;
if (matchrule == null) {
continue;
}
SurvivorshipFunction[] surFuncsInMatcher = new SurvivorshipFunction[matchrule.size()];
int idx = 0;
for (Map<String, String> mkDef : matchrule) {
String matcherType = mkDef.get(IRecordGrouping.MATCHING_TYPE);
if (AttributeMatcherType.DUMMY.name().equalsIgnoreCase(matcherType)) {
// Find the func from default survivorship rule.
surFuncsInMatcher[idx] = colIdx2DefaultSurvFunc.get(Integer.valueOf(mkDef.get(IRecordGrouping.COLUMN_IDX)));
if (surFuncsInMatcher[idx] == null) {
// Use CONCATENATE by default if not specified .
surFuncsInMatcher[idx] = new SurvivorShipAlgorithmParams().new SurvivorshipFunction();
surFuncsInMatcher[idx].setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.MOST_COMMON);
// MOD TDQ-11774 set a default parameter
surFuncsInMatcher[idx].setParameter(SurvivorshipUtils.DEFAULT_CONCATENATE_PARAMETER);
}
} else {
// Find the func from existing survivorship rule list.
for (SurvivorshipFunction survFunc : survFunctions) {
String keyName = mkDef.get(IRecordGrouping.MATCH_KEY_NAME);
if (keyName.equals(survFunc.getSurvivorShipKey())) {
surFuncsInMatcher[idx] = survFunc;
break;
}
}
}
idx++;
}
// Add the funcs to a specific record matcher. NOTE that the index of matcher must be coincidence to the
// index of match rule.
survAlgos.put(this.getCombinedRecordMatcher().getMatchers().get(matchRuleIdx), surFuncsInMatcher);
}
return survAlgos;
}
Aggregations