Program: 122646
Project: 122646
Buggy source:
private static void updateColumnsOnElement(IElement element,List<ColumnNameChanged> columnsChanged,boolean synWidthWithMetadataColumn,String[] prevColumnNameList,String[] curColumnNameList,String[] curColumnValueList,List<String> refColumnListNamesTmpWithSourceName,List<String> refColumnListValuesTmp,String[] refColumnListNames,String[] refColumnListValues,boolean isSCDComponent,boolean isEdifactComponent){
  List<String> columnList;
  String[] columnNameList;
  String edifactId=null;
  if (isEdifactComponent) {
    for (    IElementParameter par : element.getElementParametersWithChildrens()) {
      if (par.getName().equals("String_Node_Str")) {
        edifactId=par.getValue().toString();
        break;
      }
    }
  }
  for (int i=0; i < element.getElementParameters().size(); i++) {
    IElementParameter param=element.getElementParameters().get(i);
    columnList=getColumnList(element,param.getContext());
    columnNameList=columnList.toArray(new String[0]);
    if (param.getFieldType() == EParameterFieldType.COLUMN_LIST && !isSCDComponent) {
      curColumnNameList=columnNameList;
      curColumnValueList=columnNameList;
    }
    if (param.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST) {
      curColumnNameList=prevColumnNameList;
      curColumnValueList=prevColumnNameList;
    }
    if (param.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
      curColumnNameList=refColumnListNames;
      curColumnValueList=refColumnListValues;
    }
    if ((param.getFieldType() == EParameterFieldType.COLUMN_LIST && !isSCDComponent) || param.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || param.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
      param.setListItemsDisplayName(curColumnNameList);
      param.setListItemsValue(curColumnValueList);
      boolean currentColumnStillExist=ArrayUtils.contains(curColumnValueList,param.getValue());
      if (!currentColumnStillExist) {
        for (int j=0; j < refColumnListNamesTmpWithSourceName.size(); j++) {
          if (param.getValue().equals(refColumnListNamesTmpWithSourceName.get(j))) {
            param.setValue(refColumnListValuesTmp.get(j));
            break;
          }
        }
        currentColumnStillExist=ArrayUtils.contains(curColumnValueList,param.getValue());
      }
      if (curColumnNameList.length > 0 && !currentColumnStillExist) {
        param.setValue(curColumnValueList[0]);
      }
 else       if (!currentColumnStillExist) {
        param.setValue("String_Node_Str");
      }
      syncNodePropertiesColumns(param,columnsChanged,curColumnNameList);
    }
    if (param.getFieldType() == EParameterFieldType.TABLE) {
      Object[] itemsValue=param.getListItemsValue();
      for (int j=0; j < itemsValue.length; j++) {
        if (itemsValue[j] instanceof IElementParameter) {
          IElementParameter tmpParam=(IElementParameter)itemsValue[j];
          columnList=getColumnList(element,tmpParam.getContext());
          String[] tableColumnNameList=columnList.toArray(new String[0]);
          if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST) {
            curColumnNameList=tableColumnNameList;
            curColumnValueList=tableColumnNameList;
          }
          if (tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST && element instanceof INode) {
            curColumnNameList=prevColumnNameList;
            curColumnValueList=prevColumnNameList;
          }
          if (tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST && element instanceof IConnection) {
            curColumnNameList=tableColumnNameList;
            curColumnValueList=tableColumnNameList;
          }
          if (tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
            curColumnNameList=refColumnListNames;
            curColumnValueList=refColumnListValues;
          }
          if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
            tmpParam.setListItemsDisplayCodeName(curColumnNameList);
            tmpParam.setListItemsDisplayName(curColumnNameList);
            tmpParam.setListItemsValue(curColumnValueList);
            if (curColumnValueList.length > 0) {
              tmpParam.setDefaultClosedListValue(curColumnValueList[0]);
            }
 else {
              tmpParam.setDefaultClosedListValue("String_Node_Str");
            }
            syncNodePropertiesTableColumns(param,columnsChanged,curColumnNameList,tmpParam);
          }
        }
      }
    }
    if (param.isBasedOnSchema()) {
      List<Map<String,Object>> paramValues=(List<Map<String,Object>>)param.getValue();
      List<Map<String,Object>> newParamValues=new ArrayList<Map<String,Object>>();
      for (int j=0; j < columnNameList.length; j++) {
        String columnName=columnNameList[j];
        String[] codes=param.getListItemsDisplayCodeName();
        Map<String,Object> newLine=null;
        boolean found=false;
        ColumnNameChanged colChanged=null;
        if (columnsChanged != null) {
          for (int k=0; k < columnsChanged.size() && !found; k++) {
            colChanged=columnsChanged.get(k);
            if (colChanged.getNewName().equals(columnName)) {
              found=true;
            }
          }
        }
        if (found) {
          found=false;
          for (int k=0; k < paramValues.size() && !found; k++) {
            Map<String,Object> currentLine=paramValues.get(k);
            if (currentLine.get(codes[0]).equals(colChanged.getOldName())) {
              currentLine.put(codes[0],colChanged.getNewName());
              found=true;
            }
          }
        }
        found=false;
        for (int k=0; k < paramValues.size() && !found; k++) {
          Map<String,Object> currentLine=paramValues.get(k);
          if (currentLine.get(codes[0]) == null) {
            currentLine.put(codes[0],columnName);
          }
          if (currentLine.get(codes[0]).equals(columnName)) {
            found=true;
            newLine=currentLine;
          }
        }
        if (!found) {
          newLine=TableController.createNewLine(param);
          newLine.put(codes[0],columnName);
          if (!StringUtils.isEmpty(edifactId)) {
            org.talend.core.model.metadata.builder.connection.Connection connection=MetadataTool.getConnectionFromRepository(edifactId);
            if (connection != null && connection instanceof EDIFACTConnection) {
              List<org.talend.core.model.metadata.builder.connection.MetadataTable> tables=ConnectionHelper.getTablesWithOrders(connection);
              for (              MetadataColumn col : tables.get(0).getColumns()) {
                if (col.getLabel().equals(columnName)) {
                  if (col instanceof EDIFACTColumn) {
                    EDIFACTColumn edicolumn=(EDIFACTColumn)col;
                    String ediXpath=edicolumn.getEDIXpath();
                    newLine.put(codes[0],columnName);
                    newLine.put(codes[1],ediXpath);
                    break;
                  }
                }
              }
            }
          }
          if (element instanceof Node) {
            Node node=(Node)element;
            String familyName=node.getComponent().getOriginalFamilyName();
            if (familyName != null && familyName.equals("String_Node_Str")) {
              for (              IElementParameter par : node.getElementParametersWithChildrens()) {
                if (par.getName().equals("String_Node_Str")) {
                  String hbaseConnectionId=par.getValue().toString();
                  String columnFamily=null;
                  org.talend.core.model.metadata.builder.connection.Connection connection=MetadataTool.getConnectionFromRepository(hbaseConnectionId);
                  if (connection != null && connection instanceof DatabaseConnection) {
                    IMetadataConnection metadataConnection=ConvertionHelper.convert((DatabaseConnection)connection);
                    List<org.talend.core.model.metadata.builder.connection.MetadataTable> tables=ConnectionHelper.getTablesWithOrders(connection);
                    boolean find=false;
                    for (                    org.talend.core.model.metadata.builder.connection.MetadataTable table : tables) {
                      for (                      MetadataColumn column : table.getColumns()) {
                        if (column.getLabel() != null && column.getLabel().equals(columnName)) {
                          for (                          TaggedValue tv : column.getTaggedValue()) {
                            String tag=tv.getTag();
                            if (tag != null && tag.equals("String_Node_Str")) {
                              String value=tv.getValue();
                              if (value != null) {
                                columnFamily=value;
                                break;
                              }
                            }
                          }
                        }
                        if (find) {
                          break;
                        }
                      }
                      if (find) {
                        break;
                      }
                    }
                  }
                  if (columnFamily != null) {
                    newLine.put(codes[1],TalendTextUtils.addQuotes(columnFamily));
                    break;
                  }
                }
              }
            }
          }
        }
        if (synWidthWithMetadataColumn) {
          setColumnSize(newLine,element,codes,param);
        }
        newParamValues.add(j,newLine);
      }
      paramValues.clear();
      paramValues.addAll(newParamValues);
    }
 else     if (param.isColumnsBasedOnSchema()) {
      List<Map<String,Object>> paramValues=(List<Map<String,Object>>)param.getValue();
      List<Map<String,Object>> newParamValues=new ArrayList<Map<String,Object>>();
      String[] listRepositoryItem=new String[columnNameList.length];
      String[] listItemsDisplayValue=new String[columnNameList.length];
      String[] listItemsDisplayCodeValue=new String[columnNameList.length];
      Object[] listItemsValue=new Object[columnNameList.length];
      String[] listItemsShowIf=new String[columnNameList.length];
      String[] listItemsNotShowIf=new String[columnNameList.length];
      ElementParameter newParam;
      for (int j=0; j < columnNameList.length; j++) {
        String columnName=columnNameList[j];
        listItemsDisplayCodeValue[j]=columnName;
        listItemsDisplayValue[j]=columnName;
        listRepositoryItem[j]="String_Node_Str";
        listItemsShowIf[j]=null;
        listItemsNotShowIf[j]=null;
        newParam=new ElementParameter(element);
        newParam.setName(columnName);
        newParam.setDisplayName("String_Node_Str");
        newParam.setFieldType(EParameterFieldType.TEXT);
        newParam.setValue("String_Node_Str");
        listItemsValue[j]=newParam;
        boolean found=false;
        ColumnNameChanged colChanged=null;
        if (columnsChanged != null) {
          for (int k=0; k < columnsChanged.size() && !found; k++) {
            colChanged=columnsChanged.get(k);
            if (colChanged.getNewName().equals(columnName)) {
              found=true;
            }
          }
        }
        for (int k=0; k < paramValues.size(); k++) {
          Map<String,Object> line=paramValues.get(k);
          Map<String,Object> newline=new HashMap<String,Object>();
          if (found) {
            Object object=line.get(colChanged.getOldName());
            if (object != null) {
              newline.put(colChanged.getNewName(),object);
              line.remove(colChanged.getOldName());
              line.putAll(newline);
            }
          }
        }
      }
      param.setListItemsDisplayName(listItemsDisplayValue);
      param.setListItemsDisplayCodeName(listItemsDisplayCodeValue);
      param.setListItemsValue(listItemsValue);
      param.setListRepositoryItems(listRepositoryItem);
      param.setListItemsShowIf(listItemsShowIf);
      param.setListItemsNotShowIf(listItemsNotShowIf);
    }
  }
}

Fixed version (ground truth):
private static void updateColumnsOnElement(IElement element,List<ColumnNameChanged> columnsChanged,boolean synWidthWithMetadataColumn,String[] prevColumnNameList,String[] curColumnNameList,String[] curColumnValueList,List<String> refColumnListNamesTmpWithSourceName,List<String> refColumnListValuesTmp,String[] refColumnListNames,String[] refColumnListValues,boolean isSCDComponent,boolean isEdifactComponent){
  List<String> columnList;
  String[] columnNameList;
  String edifactId=null;
  if (isEdifactComponent) {
    for (    IElementParameter par : element.getElementParametersWithChildrens()) {
      if (par.getName().equals("String_Node_Str")) {
        edifactId=par.getValue().toString();
        break;
      }
    }
  }
  for (int i=0; i < element.getElementParameters().size(); i++) {
    IElementParameter param=element.getElementParameters().get(i);
    columnList=getColumnList(element,param.getContext());
    columnNameList=columnList.toArray(new String[0]);
    if (param.getFieldType() == EParameterFieldType.COLUMN_LIST && !isSCDComponent) {
      curColumnNameList=columnNameList;
      curColumnValueList=columnNameList;
    }
    if (param.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST) {
      curColumnNameList=prevColumnNameList;
      curColumnValueList=prevColumnNameList;
    }
    if (param.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
      curColumnNameList=refColumnListNames;
      curColumnValueList=refColumnListValues;
    }
    if ((param.getFieldType() == EParameterFieldType.COLUMN_LIST && !isSCDComponent) || param.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || param.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
      param.setListItemsDisplayName(curColumnNameList);
      param.setListItemsValue(curColumnValueList);
      boolean currentColumnStillExist=ArrayUtils.contains(curColumnValueList,param.getValue());
      if (!currentColumnStillExist) {
        for (int j=0; j < refColumnListNamesTmpWithSourceName.size(); j++) {
          if (param.getValue().equals(refColumnListNamesTmpWithSourceName.get(j))) {
            param.setValue(refColumnListValuesTmp.get(j));
            break;
          }
        }
        currentColumnStillExist=ArrayUtils.contains(curColumnValueList,param.getValue());
      }
      if (curColumnNameList.length > 0 && !currentColumnStillExist) {
        param.setValue(curColumnValueList[0]);
      }
 else       if (!currentColumnStillExist) {
        param.setValue("String_Node_Str");
      }
      syncNodePropertiesColumns(param,columnsChanged,curColumnNameList);
    }
    if (param.getFieldType() == EParameterFieldType.TABLE) {
      Object[] itemsValue=param.getListItemsValue();
      for (      Object element2 : itemsValue) {
        if (element2 instanceof IElementParameter) {
          IElementParameter tmpParam=(IElementParameter)element2;
          columnList=getColumnList(element,tmpParam.getContext());
          String[] tableColumnNameList=columnList.toArray(new String[0]);
          if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST) {
            curColumnNameList=tableColumnNameList;
            curColumnValueList=tableColumnNameList;
          }
          if (tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST && element instanceof INode) {
            curColumnNameList=prevColumnNameList;
            curColumnValueList=prevColumnNameList;
          }
          if (tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST && element instanceof IConnection) {
            curColumnNameList=tableColumnNameList;
            curColumnValueList=tableColumnNameList;
          }
          if (tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
            curColumnNameList=refColumnListNames;
            curColumnValueList=refColumnListValues;
          }
          if (tmpParam.getFieldType() == EParameterFieldType.COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.PREV_COLUMN_LIST || tmpParam.getFieldType() == EParameterFieldType.LOOKUP_COLUMN_LIST) {
            tmpParam.setListItemsDisplayCodeName(curColumnNameList);
            tmpParam.setListItemsDisplayName(curColumnNameList);
            tmpParam.setListItemsValue(curColumnValueList);
            if (curColumnValueList.length > 0) {
              tmpParam.setDefaultClosedListValue(curColumnValueList[0]);
            }
 else {
              tmpParam.setDefaultClosedListValue("String_Node_Str");
            }
            syncNodePropertiesTableColumns(param,columnsChanged,curColumnNameList,tmpParam);
          }
        }
      }
    }
    if (param.isBasedOnSchema()) {
      List<Map<String,Object>> paramValues=(List<Map<String,Object>>)param.getValue();
      List<Map<String,Object>> newParamValues=new ArrayList<Map<String,Object>>();
      for (int j=0; j < columnNameList.length; j++) {
        String columnName=columnNameList[j];
        String[] codes=param.getListItemsDisplayCodeName();
        Map<String,Object> newLine=null;
        boolean found=false;
        ColumnNameChanged colChanged=null;
        if (columnsChanged != null) {
          for (int k=0; k < columnsChanged.size() && !found; k++) {
            colChanged=columnsChanged.get(k);
            if (colChanged.getNewName().equals(columnName)) {
              found=true;
            }
          }
        }
        if (found) {
          found=false;
          for (int k=0; k < paramValues.size() && !found; k++) {
            Map<String,Object> currentLine=paramValues.get(k);
            if (currentLine.get(codes[0]).equals(colChanged.getOldName())) {
              currentLine.put(codes[0],colChanged.getNewName());
              found=true;
            }
          }
        }
        found=false;
        for (int k=0; k < paramValues.size() && !found; k++) {
          Map<String,Object> currentLine=paramValues.get(k);
          if (currentLine.get(codes[0]) == null) {
            currentLine.put(codes[0],columnName);
          }
          if (currentLine.get(codes[0]).equals(columnName)) {
            found=true;
            newLine=currentLine;
          }
        }
        if (!found) {
          newLine=TableController.createNewLine(param);
          newLine.put(codes[0],columnName);
          if (!StringUtils.isEmpty(edifactId)) {
            org.talend.core.model.metadata.builder.connection.Connection connection=MetadataTool.getConnectionFromRepository(edifactId);
            if (connection != null && connection instanceof EDIFACTConnection) {
              List<org.talend.core.model.metadata.builder.connection.MetadataTable> tables=ConnectionHelper.getTablesWithOrders(connection);
              for (              MetadataColumn col : tables.get(0).getColumns()) {
                if (col.getLabel().equals(columnName)) {
                  if (col instanceof EDIFACTColumn) {
                    EDIFACTColumn edicolumn=(EDIFACTColumn)col;
                    String ediXpath=edicolumn.getEDIXpath();
                    newLine.put(codes[0],columnName);
                    newLine.put(codes[1],ediXpath);
                    break;
                  }
                }
              }
            }
          }
          if (element instanceof Node) {
            Node node=(Node)element;
            String familyName=node.getComponent().getOriginalFamilyName();
            if (familyName != null && familyName.equals("String_Node_Str")) {
              for (              IElementParameter par : node.getElementParametersWithChildrens()) {
                if (par.getName().equals("String_Node_Str")) {
                  String hbaseConnectionId=par.getValue().toString();
                  String columnFamily=null;
                  org.talend.core.model.metadata.builder.connection.Connection connection=MetadataTool.getConnectionFromRepository(hbaseConnectionId);
                  if (connection != null && connection instanceof DatabaseConnection) {
                    IMetadataConnection metadataConnection=ConvertionHelper.convert(connection);
                    List<org.talend.core.model.metadata.builder.connection.MetadataTable> tables=ConnectionHelper.getTablesWithOrders(connection);
                    boolean find=false;
                    for (                    org.talend.core.model.metadata.builder.connection.MetadataTable table : tables) {
                      for (                      MetadataColumn column : table.getColumns()) {
                        if (column.getLabel() != null && column.getLabel().equals(columnName)) {
                          for (                          TaggedValue tv : column.getTaggedValue()) {
                            String tag=tv.getTag();
                            if (tag != null && tag.equals("String_Node_Str")) {
                              String value=tv.getValue();
                              if (value != null) {
                                columnFamily=value;
                                break;
                              }
                            }
                          }
                        }
                        if (find) {
                          break;
                        }
                      }
                      if (find) {
                        break;
                      }
                    }
                  }
                  if (columnFamily != null) {
                    newLine.put(codes[1],TalendTextUtils.addQuotes(columnFamily));
                    break;
                  }
                }
              }
            }
          }
        }
        if (synWidthWithMetadataColumn) {
          setColumnSize(newLine,element,codes,param);
        }
        newParamValues.add(j,newLine);
      }
      paramValues.clear();
      paramValues.addAll(newParamValues);
    }
 else     if (param.isColumnsBasedOnSchema()) {
      List<Map<String,Object>> paramValues=(List<Map<String,Object>>)param.getValue();
      List<Map<String,Object>> newParamValues=new ArrayList<Map<String,Object>>();
      String[] listRepositoryItem=new String[columnNameList.length];
      String[] listItemsDisplayValue=new String[columnNameList.length];
      String[] listItemsDisplayCodeValue=new String[columnNameList.length];
      Object[] listItemsValue=new Object[columnNameList.length];
      String[] listItemsShowIf=new String[columnNameList.length];
      String[] listItemsNotShowIf=new String[columnNameList.length];
      ElementParameter newParam;
      for (int j=0; j < columnNameList.length; j++) {
        String columnName=columnNameList[j];
        listItemsDisplayCodeValue[j]=columnName;
        listItemsDisplayValue[j]=columnName;
        listRepositoryItem[j]="String_Node_Str";
        listItemsShowIf[j]=null;
        listItemsNotShowIf[j]=null;
        newParam=new ElementParameter(element);
        newParam.setName(columnName);
        newParam.setDisplayName("String_Node_Str");
        newParam.setFieldType(EParameterFieldType.TEXT);
        newParam.setValue("String_Node_Str");
        listItemsValue[j]=newParam;
        boolean found=false;
        ColumnNameChanged colChanged=null;
        if (columnsChanged != null) {
          for (int k=0; k < columnsChanged.size() && !found; k++) {
            colChanged=columnsChanged.get(k);
            if (colChanged.getNewName().equals(columnName)) {
              found=true;
            }
          }
        }
        for (int k=0; k < paramValues.size(); k++) {
          Map<String,Object> line=paramValues.get(k);
          Map<String,Object> newline=new HashMap<String,Object>();
          if (found) {
            Object object=line.get(colChanged.getOldName());
            if (object != null) {
              newline.put(colChanged.getNewName(),object);
              line.remove(colChanged.getOldName());
              line.putAll(newline);
            }
          }
        }
      }
      param.setListItemsDisplayName(listItemsDisplayValue);
      param.setListItemsDisplayCodeName(listItemsDisplayCodeValue);
      param.setListItemsValue(listItemsValue);
      param.setListRepositoryItems(listRepositoryItem);
      param.setListItemsShowIf(listItemsShowIf);
      param.setListItemsNotShowIf(listItemsNotShowIf);
    }
  }
}