Program: 121232
Project: 121232
Buggy source:
/** 
 * Set the values to default if needed.
 * @param currentParam Current parameter that has been modified in the interface
 * @param testedParam Tested parameter, to know if there is a link for the default values between this parameter andthe current.
 */
private void setDefaultValues(IElementParameter currentParam,IElementParameter testedParam){
  boolean contains=false;
  for (  IElementParameterDefaultValue value : testedParam.getDefaultValues()) {
    if (value.getIfCondition() != null) {
      if (value.getIfCondition().contains(currentParam.getName())) {
        contains=true;
        break;
      }
    }
    if (value.getNotIfCondition() != null) {
      if (value.getNotIfCondition().contains(currentParam.getName())) {
        contains=true;
        break;
      }
    }
  }
  if (!contains && testedParam.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) {
    boolean isCurrentComboValid=true;
    if (testedParam.getListItemsShowIf() != null || testedParam.getListItemsNotShowIf() != null) {
      String value=(String)testedParam.getValue();
      int index=ArrayUtils.indexOf(testedParam.getListItemsValue(),value);
      if (testedParam.getListItemsShowIf() != null) {
        String conditionShowIf=testedParam.getListItemsShowIf()[index];
        if (conditionShowIf != null) {
          isCurrentComboValid=Expression.evaluate(conditionShowIf,elem.getElementParameters());
        }
      }
      if (testedParam.getListItemsNotShowIf() != null) {
        String conditionNotShowIf=testedParam.getListItemsNotShowIf()[index];
        if (conditionNotShowIf != null) {
          isCurrentComboValid=!Expression.evaluate(conditionNotShowIf,elem.getElementParameters());
        }
      }
    }
    if (!isCurrentComboValid && testedParam.getListItemsShowIf() != null) {
      for (      String condition : testedParam.getListItemsShowIf()) {
        if (condition != null && condition.contains(currentParam.getName())) {
          boolean isValid=Expression.evaluate(condition,elem.getElementParameters());
          if (isValid) {
            int index=ArrayUtils.indexOf(testedParam.getListItemsShowIf(),condition);
            testedParam.setValue(testedParam.getListItemsValue()[index]);
            break;
          }
        }
      }
    }
    if (!isCurrentComboValid && !contains && testedParam.getListItemsNotShowIf() != null) {
      for (      String condition : testedParam.getListItemsNotShowIf()) {
        if (condition != null && condition.contains(currentParam.getName())) {
          boolean isValid=!Expression.evaluate(condition,elem.getElementParameters());
          if (isValid) {
            int index=ArrayUtils.indexOf(testedParam.getListItemsNotShowIf(),condition);
            testedParam.setValue(testedParam.getListItemsValue()[index]);
            break;
          }
        }
      }
    }
  }
 else   if (testedParam.getDefaultValues().size() > 0 && contains) {
    oldElementValues.put(testedParam,testedParam.getValue());
    if (!testedParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
      String oldMapping="String_Node_Str";
      if (!testedParam.getFieldType().equals(EParameterFieldType.CHECK) && !testedParam.getFieldType().equals(EParameterFieldType.RADIO)) {
        oldMapping=(String)testedParam.getValue();
      }
      testedParam.setValueToDefault(elem.getElementParameters());
      if (testedParam.getFieldType().equals(EParameterFieldType.MAPPING_TYPE)) {
        String newMapping=(String)testedParam.getValue();
        if (!oldMapping.equals(newMapping)) {
          Node node=(Node)elem;
          if (node.getMetadataList().size() > 0) {
            IMetadataTable metadataTable=node.getMetadataList().get(0);
            metadataTable.setDbms(newMapping);
          }
        }
      }
    }
 else {
      Node node=(Node)elem;
      if (node.getMetadataList().size() > 0) {
        IMetadataTable metadataTable=null;
        IMetadataTable newMetadataTable=null;
        if (node.getComponent() != null && "String_Node_Str".equals(node.getComponent().getName())) {
          boolean isBuiltIn=false;
          final IElementParameter elementParameter=node.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
          if (elementParameter != null) {
            Object value=elementParameter.getValue();
            if ("String_Node_Str".equals(value.toString())) {
              isBuiltIn=true;
            }
          }
          if (isBuiltIn) {
            metadataTable=node.getMetadataFromConnector(testedParam.getContext());
            testedParam.setValueToDefault(node.getElementParameters());
            IMetadataTable defaultMetadataTable=(IMetadataTable)testedParam.getValue();
            if (testedParam.getName().equals("String_Node_Str")) {
              newMetadataTable=defaultMetadataTable;
            }
          }
 else {
            metadataTable=node.getMetadataFromConnector(testedParam.getContext());
            if (testedParam.getName().equals("String_Node_Str")) {
              newMetadataTable=metadataTable;
            }
          }
          IMetadataTable defaultMetadataTable=(IMetadataTable)testedParam.getValue();
          if (testedParam.getName().equals("String_Node_Str")) {
            IElementParameter param=node.getElementParameter(EParameterName.SCHEMA.getName());
            IMetadataTable meta=node.getMetadataFromConnector(param.getContext());
            newMetadataTable=meta.clone(true);
            List<IMetadataColumn> toAdd=new ArrayList<IMetadataColumn>();
            for (            IMetadataColumn column : defaultMetadataTable.clone(true).getListColumns()) {
              boolean found=false;
              for (              IMetadataColumn existingColumn : newMetadataTable.getListColumns()) {
                if (existingColumn.getLabel().equals(column.getLabel())) {
                  found=true;
                  break;
                }
              }
              if (!found) {
                toAdd.add(column);
              }
              newMetadataTable.getListColumns().addAll(toAdd);
            }
          }
        }
 else {
          metadataTable=node.getMetadataFromConnector(testedParam.getContext());
          testedParam.setValueToDefault(node.getElementParameters());
          newMetadataTable=(IMetadataTable)testedParam.getValue();
        }
        if (metadataTable != null && newMetadataTable != null) {
          newMetadataTable.setTableName(metadataTable.getTableName());
          newMetadataTable.setAttachedConnector(metadataTable.getAttachedConnector());
          List<IMetadataColumn> columnsToRemove=new ArrayList<IMetadataColumn>();
          for (          IMetadataColumn column : metadataTable.getListColumns()) {
            if (column.isCustom()) {
              columnsToRemove.add(column);
            }
          }
          metadataTable.getListColumns().removeAll(columnsToRemove);
          boolean onlyHaveCustomInDefault=true;
          List<IMetadataColumn> customColumnsFromDefault=new ArrayList<IMetadataColumn>();
          for (          IMetadataColumn column : newMetadataTable.getListColumns()) {
            if (!column.isCustom()) {
              onlyHaveCustomInDefault=false;
            }
 else {
              customColumnsFromDefault.add(column);
            }
          }
          metadataTable.getListColumns().addAll(customColumnsFromDefault);
          if (onlyHaveCustomInDefault) {
            newMetadataTable=metadataTable;
          }
          changeMetadataCommand=new ChangeMetadataCommand(node,null,null,newMetadataTable);
          changeMetadataCommand.execute(true);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Set the values to default if needed.
 * @param currentParam Current parameter that has been modified in the interface
 * @param testedParam Tested parameter, to know if there is a link for the default values between this parameter andthe current.
 */
private void setDefaultValues(IElementParameter currentParam,IElementParameter testedParam){
  boolean contains=false;
  for (  IElementParameterDefaultValue value : testedParam.getDefaultValues()) {
    if (value.getIfCondition() != null) {
      if (value.getIfCondition().contains(currentParam.getName())) {
        contains=true;
        break;
      }
    }
    if (value.getNotIfCondition() != null) {
      if (value.getNotIfCondition().contains(currentParam.getName())) {
        contains=true;
        break;
      }
    }
  }
  if (!contains && testedParam.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) {
    boolean isCurrentComboValid=true;
    if (testedParam.getListItemsShowIf() != null || testedParam.getListItemsNotShowIf() != null) {
      String value=(String)testedParam.getValue();
      int index=ArrayUtils.indexOf(testedParam.getListItemsValue(),value);
      if (index != -1) {
        if (testedParam.getListItemsShowIf() != null) {
          String conditionShowIf=testedParam.getListItemsShowIf()[index];
          if (conditionShowIf != null) {
            isCurrentComboValid=Expression.evaluate(conditionShowIf,elem.getElementParameters());
          }
        }
        if (testedParam.getListItemsNotShowIf() != null) {
          String conditionNotShowIf=testedParam.getListItemsNotShowIf()[index];
          if (conditionNotShowIf != null) {
            isCurrentComboValid=!Expression.evaluate(conditionNotShowIf,elem.getElementParameters());
          }
        }
      }
    }
    if (!isCurrentComboValid && testedParam.getListItemsShowIf() != null) {
      for (      String condition : testedParam.getListItemsShowIf()) {
        if (condition != null && condition.contains(currentParam.getName())) {
          boolean isValid=Expression.evaluate(condition,elem.getElementParameters());
          if (isValid) {
            int index=ArrayUtils.indexOf(testedParam.getListItemsShowIf(),condition);
            testedParam.setValue(testedParam.getListItemsValue()[index]);
            break;
          }
        }
      }
    }
    if (!isCurrentComboValid && !contains && testedParam.getListItemsNotShowIf() != null) {
      for (      String condition : testedParam.getListItemsNotShowIf()) {
        if (condition != null && condition.contains(currentParam.getName())) {
          boolean isValid=!Expression.evaluate(condition,elem.getElementParameters());
          if (isValid) {
            int index=ArrayUtils.indexOf(testedParam.getListItemsNotShowIf(),condition);
            testedParam.setValue(testedParam.getListItemsValue()[index]);
            break;
          }
        }
      }
    }
  }
 else   if (testedParam.getDefaultValues().size() > 0 && contains) {
    oldElementValues.put(testedParam,testedParam.getValue());
    if (!testedParam.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
      String oldMapping="String_Node_Str";
      if (!testedParam.getFieldType().equals(EParameterFieldType.CHECK) && !testedParam.getFieldType().equals(EParameterFieldType.RADIO)) {
        oldMapping=(String)testedParam.getValue();
      }
      testedParam.setValueToDefault(elem.getElementParameters());
      if (testedParam.getFieldType().equals(EParameterFieldType.MAPPING_TYPE)) {
        String newMapping=(String)testedParam.getValue();
        if (!oldMapping.equals(newMapping)) {
          Node node=(Node)elem;
          if (node.getMetadataList().size() > 0) {
            IMetadataTable metadataTable=node.getMetadataList().get(0);
            metadataTable.setDbms(newMapping);
          }
        }
      }
    }
 else {
      Node node=(Node)elem;
      if (node.getMetadataList().size() > 0) {
        IMetadataTable metadataTable=null;
        IMetadataTable newMetadataTable=null;
        if (node.getComponent() != null && "String_Node_Str".equals(node.getComponent().getName())) {
          boolean isBuiltIn=false;
          final IElementParameter elementParameter=node.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
          if (elementParameter != null) {
            Object value=elementParameter.getValue();
            if ("String_Node_Str".equals(value.toString())) {
              isBuiltIn=true;
            }
          }
          if (isBuiltIn) {
            metadataTable=node.getMetadataFromConnector(testedParam.getContext());
            testedParam.setValueToDefault(node.getElementParameters());
            IMetadataTable defaultMetadataTable=(IMetadataTable)testedParam.getValue();
            if (testedParam.getName().equals("String_Node_Str")) {
              newMetadataTable=defaultMetadataTable;
            }
          }
 else {
            metadataTable=node.getMetadataFromConnector(testedParam.getContext());
            if (testedParam.getName().equals("String_Node_Str")) {
              newMetadataTable=metadataTable;
            }
          }
          IMetadataTable defaultMetadataTable=(IMetadataTable)testedParam.getValue();
          if (testedParam.getName().equals("String_Node_Str")) {
            IElementParameter param=node.getElementParameter(EParameterName.SCHEMA.getName());
            IMetadataTable meta=node.getMetadataFromConnector(param.getContext());
            newMetadataTable=meta.clone(true);
            List<IMetadataColumn> toAdd=new ArrayList<IMetadataColumn>();
            for (            IMetadataColumn column : defaultMetadataTable.clone(true).getListColumns()) {
              boolean found=false;
              for (              IMetadataColumn existingColumn : newMetadataTable.getListColumns()) {
                if (existingColumn.getLabel().equals(column.getLabel())) {
                  found=true;
                  break;
                }
              }
              if (!found) {
                toAdd.add(column);
              }
              newMetadataTable.getListColumns().addAll(toAdd);
            }
          }
        }
 else {
          metadataTable=node.getMetadataFromConnector(testedParam.getContext());
          testedParam.setValueToDefault(node.getElementParameters());
          newMetadataTable=(IMetadataTable)testedParam.getValue();
        }
        if (metadataTable != null && newMetadataTable != null) {
          newMetadataTable.setTableName(metadataTable.getTableName());
          newMetadataTable.setAttachedConnector(metadataTable.getAttachedConnector());
          List<IMetadataColumn> columnsToRemove=new ArrayList<IMetadataColumn>();
          for (          IMetadataColumn column : metadataTable.getListColumns()) {
            if (column.isCustom()) {
              columnsToRemove.add(column);
            }
          }
          metadataTable.getListColumns().removeAll(columnsToRemove);
          boolean onlyHaveCustomInDefault=true;
          List<IMetadataColumn> customColumnsFromDefault=new ArrayList<IMetadataColumn>();
          for (          IMetadataColumn column : newMetadataTable.getListColumns()) {
            if (!column.isCustom()) {
              onlyHaveCustomInDefault=false;
            }
 else {
              customColumnsFromDefault.add(column);
            }
          }
          metadataTable.getListColumns().addAll(customColumnsFromDefault);
          if (onlyHaveCustomInDefault) {
            newMetadataTable=metadataTable;
          }
          changeMetadataCommand=new ChangeMetadataCommand(node,null,null,newMetadataTable);
          changeMetadataCommand.execute(true);
        }
      }
    }
  }
}