Program: 77145
Project: 77145
Buggy source:
/** 
 * Updates values of <code>sourceHandle</code> with the given <code>sourceDesign</code>.
 * @param setDesign the ODA data source design
 * @param setHandle the Model handle
 * @param isSourceChanged <code>true</code> if the data source of the given design has been changed. Otherwise <code>false</code>.
 * @throws SemanticException if any of <code>sourceDesign</code> property values is not valid.
 */
public void updateDataSetHandle(DataSetDesign setDesign,OdaDataSetHandle setHandle,boolean isSourceChanged) throws SemanticException {
  if (setDesign == null || setHandle == null)   return;
  DesignUtil.validateObject(setDesign);
  CommandStack stack=setHandle.getModuleHandle().getCommandStack();
  stack.startTrans(null);
  try {
    setHandle.getElement().setProperty(OdaDataSourceHandle.EXTENSION_ID_PROP,setDesign.getOdaExtensionDataSetId());
    setHandle.setName(setDesign.getName());
    setHandle.setDisplayName(setDesign.getDisplayName());
    Properties props=setDesign.getPublicProperties();
    if (props != null) {
      EList propList=props.getProperties();
      for (int i=0; i < propList.size(); i++) {
        Property prop=(Property)propList.get(i);
        setHandle.setProperty(prop.getName(),prop.getValue());
      }
    }
    props=setDesign.getPrivateProperties();
    if (props != null) {
      EList propList=props.getProperties();
      for (int i=0; i < propList.size(); i++) {
        Property prop=(Property)propList.get(i);
        setHandle.setPrivateDriverProperty(prop.getName(),prop.getValue());
      }
    }
    DesignValues designerValues=null;
    try {
      designerValues=SerializerImpl.instance().read(setHandle.getDesignerValues());
    }
 catch (    IOException e) {
    }
    updateROMDataSetParamList(setHandle,new DataSetParameterAdapter().newROMSetParams(setDesign,setHandle,designerValues == null ? null : designerValues.getDataSetParameters()));
    ResultSets cachedResultSets=designerValues == null ? null : designerValues.getResultSets();
    ResultSetDefinition cachedResultDefn=null;
    if (cachedResultSets != null && !cachedResultSets.getResultSetDefinitions().isEmpty())     cachedResultDefn=(ResultSetDefinition)cachedResultSets.getResultSetDefinitions().get(0);
    updateROMResultSets(setHandle,new ResultSetsAdapter().newROMResultSets(setDesign,setHandle,cachedResultDefn));
    setHandle.setResultSetName(setDesign.getPrimaryResultSetName());
    setHandle.setQueryText(setDesign.getQueryText());
    String odaValues=serializeOdaValues(setDesign);
    setHandle.setDesignerValues(odaValues);
    DataSourceDesign sourceDesign=setDesign.getDataSourceDesign();
    if (sourceDesign != null) {
      OdaDataSourceHandle sourceHandle=(OdaDataSourceHandle)setHandle.getDataSource();
      if (isSourceChanged && sourceHandle != null && !sourceHandle.getModuleHandle().isReadOnly()) {
        setHandle.setDataSource(sourceDesign.getName());
        updateDataSourceHandle(sourceDesign,sourceHandle);
      }
      if (!isSourceChanged && sourceHandle != null && !sourceHandle.getModuleHandle().isReadOnly() && !(new EcoreUtil.EqualityHelper().equals(createDataSourceDesign(sourceHandle),sourceDesign))) {
        updateDataSourceHandle(sourceDesign,sourceHandle);
      }
    }
 else     setHandle.setDataSource(null);
  }
 catch (  SemanticException e) {
    stack.rollback();
    throw e;
  }
  stack.commit();
}

Fixed version (ground truth):
/** 
 * Updates values of <code>sourceHandle</code> with the given <code>sourceDesign</code>.
 * @param setDesign the ODA data source design
 * @param setHandle the Model handle
 * @param isSourceChanged <code>true</code> if the data source of the given design has been changed. Otherwise <code>false</code>.
 * @param newRule <code>true</code> new rule is that if parameter only defined in DataSetHandle , hold it. <code>false</code> old rule that override all parameters in DataSetHandle.
 * @throws SemanticException if any of <code>sourceDesign</code> property values is not valid.
 */
public void updateDataSetHandle(DataSetDesign setDesign,OdaDataSetHandle setHandle,boolean isSourceChanged,boolean newRule) throws SemanticException {
  if (setDesign == null || setHandle == null)   return;
  DesignUtil.validateObject(setDesign);
  CommandStack stack=setHandle.getModuleHandle().getCommandStack();
  stack.startTrans(null);
  try {
    setHandle.getElement().setProperty(OdaDataSourceHandle.EXTENSION_ID_PROP,setDesign.getOdaExtensionDataSetId());
    setHandle.setName(setDesign.getName());
    setHandle.setDisplayName(setDesign.getDisplayName());
    Properties props=setDesign.getPublicProperties();
    if (props != null) {
      EList propList=props.getProperties();
      for (int i=0; i < propList.size(); i++) {
        Property prop=(Property)propList.get(i);
        setHandle.setProperty(prop.getName(),prop.getValue());
      }
    }
    props=setDesign.getPrivateProperties();
    if (props != null) {
      EList propList=props.getProperties();
      for (int i=0; i < propList.size(); i++) {
        Property prop=(Property)propList.get(i);
        setHandle.setPrivateDriverProperty(prop.getName(),prop.getValue());
      }
    }
    DesignValues designerValues=null;
    try {
      designerValues=SerializerImpl.instance().read(setHandle.getDesignerValues());
    }
 catch (    IOException e) {
    }
    if (newRule) {
      List retList=new DataSetParameterAdapter().mergeParamDefnOfDataSetAndDataSetDesign(setHandle,setDesign);
      updateROMDataSetParamList(setHandle,retList);
    }
 else {
      updateROMDataSetParamList(setHandle,new DataSetParameterAdapter().newROMSetParams(setDesign,setHandle,designerValues == null ? null : designerValues.getDataSetParameters()));
    }
    ResultSets cachedResultSets=designerValues == null ? null : designerValues.getResultSets();
    ResultSetDefinition cachedResultDefn=null;
    if (cachedResultSets != null && !cachedResultSets.getResultSetDefinitions().isEmpty())     cachedResultDefn=(ResultSetDefinition)cachedResultSets.getResultSetDefinitions().get(0);
    updateROMResultSets(setHandle,new ResultSetsAdapter().newROMResultSets(setDesign,setHandle,cachedResultDefn));
    setHandle.setResultSetName(setDesign.getPrimaryResultSetName());
    setHandle.setQueryText(setDesign.getQueryText());
    String odaValues=serializeOdaValues(setDesign);
    setHandle.setDesignerValues(odaValues);
    DataSourceDesign sourceDesign=setDesign.getDataSourceDesign();
    if (sourceDesign != null) {
      OdaDataSourceHandle sourceHandle=(OdaDataSourceHandle)setHandle.getDataSource();
      if (isSourceChanged && sourceHandle != null && !sourceHandle.getModuleHandle().isReadOnly()) {
        setHandle.setDataSource(sourceDesign.getName());
        updateDataSourceHandle(sourceDesign,sourceHandle);
      }
      if (!isSourceChanged && sourceHandle != null && !sourceHandle.getModuleHandle().isReadOnly() && !(new EcoreUtil.EqualityHelper().equals(createDataSourceDesign(sourceHandle),sourceDesign))) {
        updateDataSourceHandle(sourceDesign,sourceHandle);
      }
    }
 else     setHandle.setDataSource(null);
  }
 catch (  SemanticException e) {
    stack.rollback();
    throw e;
  }
  stack.commit();
}