Program: 137268
Project: 137268
Buggy source:
private SurvivorShipAlgorithmParams createSurvivorShipAlgorithmParams(AnalysisMatchRecordGrouping analysisMatchRecordGrouping,RecordMatchingIndicator recordMatchingIndicator,Map<MetadataColumn,String> columnMap){
  SurvivorShipAlgorithmParams survivorShipAlgorithmParams=new SurvivorShipAlgorithmParams();
  List<SurvivorshipKeyDefinition> survivorshipKeyDefs=recordMatchingIndicator.getBuiltInMatchRuleDefinition().getSurvivorshipKeys();
  List<SurvivorshipFunction> survFunctions=new ArrayList<SurvivorshipFunction>();
  for (  SurvivorshipKeyDefinition survDef : survivorshipKeyDefs) {
    SurvivorshipFunction func=survivorShipAlgorithmParams.new SurvivorshipFunction();
    func.setSurvivorShipKey(survDef.getName());
    func.setParameter(survDef.getFunction().getAlgorithmParameters());
    func.setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.getTypeBySavedValue(survDef.getFunction().getAlgorithmType()));
    survFunctions.add(func);
  }
  survivorShipAlgorithmParams.setSurviorShipAlgos(survFunctions.toArray(new SurvivorshipFunction[survivorshipKeyDefs.size()]));
  List<DefaultSurvivorshipDefinition> defSurvDefs=recordMatchingIndicator.getBuiltInMatchRuleDefinition().getDefaultSurvivorshipDefinitions();
  Map<Integer,SurvivorshipFunction> defaultSurvRules=new HashMap<Integer,SurvivorshipFunction>();
  for (  MetadataColumn metaColumn : columnMap.keySet()) {
    String dataTypeName=TalendTypeConvert.convertToJavaType(metaColumn.getTalendType());
    for (    DefaultSurvivorshipDefinition defSurvDef : defSurvDefs) {
      if (dataTypeName.equals(defSurvDef.getDataType())) {
        putNewSurvFunc(columnMap,survivorShipAlgorithmParams,defaultSurvRules,metaColumn,defSurvDef);
        break;
      }
 else       if (defSurvDef.getDataType().equals("String_Node_Str") || isNumber(dataTypeName)) {
        putNewSurvFunc(columnMap,survivorShipAlgorithmParams,defaultSurvRules,metaColumn,defSurvDef);
        break;
      }
    }
  }
  survivorShipAlgorithmParams.setDefaultSurviorshipRules(defaultSurvRules);
  CombinedRecordMatcher combinedRecordMatcher=analysisMatchRecordGrouping.getCombinedRecordMatcher();
  survivorShipAlgorithmParams.setRecordMatcher(combinedRecordMatcher);
  Map<IRecordMatcher,SurvivorshipFunction[]> survAlgos=new HashMap<IRecordMatcher,SurvivorshipFunction[]>();
  SurvivorshipFunction[] survFuncs=survivorShipAlgorithmParams.getSurviorShipAlgos();
  Map<Integer,SurvivorshipFunction> colIdx2DefaultSurvFunc=survivorShipAlgorithmParams.getDefaultSurviorshipRules();
  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().equals(matcherType)) {
        surFuncsInMatcher[idx]=colIdx2DefaultSurvFunc.get(Integer.valueOf(mkDef.get(IRecordGrouping.COLUMN_IDX)));
        if (surFuncsInMatcher[idx] == null) {
          surFuncsInMatcher[idx]=survivorShipAlgorithmParams.new SurvivorshipFunction();
          surFuncsInMatcher[idx].setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.CONCATENATE);
          surFuncsInMatcher[idx].setParameter(StringUtils.EMPTY);
        }
      }
 else {
        for (        SurvivorshipFunction survFunc : survFuncs) {
          String keyName=mkDef.get(IRecordGrouping.MATCH_KEY_NAME);
          if (keyName.equals(survFunc.getSurvivorShipKey())) {
            surFuncsInMatcher[idx]=survFunc;
            break;
          }
        }
      }
      idx++;
    }
    survAlgos.put(combinedRecordMatcher.getMatchers().get(matchRuleIdx),surFuncsInMatcher);
  }
  survivorShipAlgorithmParams.setSurvivorshipAlgosMap(survAlgos);
  return survivorShipAlgorithmParams;
}

Fixed version (ground truth):
private SurvivorShipAlgorithmParams createSurvivorShipAlgorithmParams(AnalysisMatchRecordGrouping analysisMatchRecordGrouping,RecordMatchingIndicator recordMatchingIndicator,Map<MetadataColumn,String> columnMap){
  SurvivorShipAlgorithmParams survivorShipAlgorithmParams=new SurvivorShipAlgorithmParams();
  List<SurvivorshipKeyDefinition> survivorshipKeyDefs=recordMatchingIndicator.getBuiltInMatchRuleDefinition().getSurvivorshipKeys();
  List<SurvivorshipFunction> survFunctions=new ArrayList<SurvivorshipFunction>();
  for (  SurvivorshipKeyDefinition survDef : survivorshipKeyDefs) {
    SurvivorshipFunction func=survivorShipAlgorithmParams.new SurvivorshipFunction();
    func.setSurvivorShipKey(survDef.getName());
    func.setParameter(survDef.getFunction().getAlgorithmParameters());
    func.setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.getTypeBySavedValue(survDef.getFunction().getAlgorithmType()));
    survFunctions.add(func);
  }
  survivorShipAlgorithmParams.setSurviorShipAlgos(survFunctions.toArray(new SurvivorshipFunction[survivorshipKeyDefs.size()]));
  List<DefaultSurvivorshipDefinition> defSurvDefs=recordMatchingIndicator.getBuiltInMatchRuleDefinition().getDefaultSurvivorshipDefinitions();
  Map<Integer,SurvivorshipFunction> defaultSurvRules=new HashMap<Integer,SurvivorshipFunction>();
  for (  MetadataColumn metaColumn : columnMap.keySet()) {
    String dataTypeName=TalendTypeConvert.convertToJavaType(metaColumn.getTalendType());
    for (    DefaultSurvivorshipDefinition defSurvDef : defSurvDefs) {
      if (dataTypeName.equals(defSurvDef.getDataType())) {
        putNewSurvFunc(columnMap,survivorShipAlgorithmParams,defaultSurvRules,metaColumn,defSurvDef);
        break;
      }
 else       if (defSurvDef.getDataType().equals("String_Node_Str") && isNumber(dataTypeName)) {
        putNewSurvFunc(columnMap,survivorShipAlgorithmParams,defaultSurvRules,metaColumn,defSurvDef);
        break;
      }
    }
  }
  survivorShipAlgorithmParams.setDefaultSurviorshipRules(defaultSurvRules);
  CombinedRecordMatcher combinedRecordMatcher=analysisMatchRecordGrouping.getCombinedRecordMatcher();
  survivorShipAlgorithmParams.setRecordMatcher(combinedRecordMatcher);
  Map<IRecordMatcher,SurvivorshipFunction[]> survAlgos=new HashMap<IRecordMatcher,SurvivorshipFunction[]>();
  SurvivorshipFunction[] survFuncs=survivorShipAlgorithmParams.getSurviorShipAlgos();
  Map<Integer,SurvivorshipFunction> colIdx2DefaultSurvFunc=survivorShipAlgorithmParams.getDefaultSurviorshipRules();
  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().equals(matcherType)) {
        surFuncsInMatcher[idx]=colIdx2DefaultSurvFunc.get(Integer.valueOf(mkDef.get(IRecordGrouping.COLUMN_IDX)));
        if (surFuncsInMatcher[idx] == null) {
          surFuncsInMatcher[idx]=survivorShipAlgorithmParams.new SurvivorshipFunction();
          surFuncsInMatcher[idx].setSurvivorShipAlgoEnum(SurvivorShipAlgorithmEnum.CONCATENATE);
          surFuncsInMatcher[idx].setParameter(StringUtils.EMPTY);
        }
      }
 else {
        for (        SurvivorshipFunction survFunc : survFuncs) {
          String keyName=mkDef.get(IRecordGrouping.MATCH_KEY_NAME);
          if (keyName.equals(survFunc.getSurvivorShipKey())) {
            surFuncsInMatcher[idx]=survFunc;
            break;
          }
        }
      }
      idx++;
    }
    survAlgos.put(combinedRecordMatcher.getMatchers().get(matchRuleIdx),surFuncsInMatcher);
  }
  survivorShipAlgorithmParams.setSurvivorshipAlgosMap(survAlgos);
  return survivorShipAlgorithmParams;
}