Program: 77377
Project: 77377
Buggy source:
/** 
 * Adapts base data set properties
 */
public static void adaptBaseDataSet(DataSetHandle modelDataSet,BaseDataSetDesign dteDataSet) throws BirtException {
  if ((!(modelDataSet instanceof JointDataSetHandle)) && modelDataSet.getDataSource() == null) {
    throw new AdapterException(ResourceConstants.DATASOURCE_NULL_ERROR);
  }
  if (!(modelDataSet instanceof JointDataSetHandle)) {
    dteDataSet.setDataSource(modelDataSet.getDataSource().getQualifiedName());
    dteDataSet.setBeforeOpenScript(modelDataSet.getBeforeOpen());
    dteDataSet.setAfterOpenScript(modelDataSet.getAfterOpen());
    dteDataSet.setOnFetchScript(modelDataSet.getOnFetch());
    dteDataSet.setBeforeCloseScript(modelDataSet.getBeforeClose());
    dteDataSet.setAfterCloseScript(modelDataSet.getAfterClose());
    HashMap paramBindingCandidates=new HashMap();
    Iterator elmtIter=modelDataSet.parametersIterator();
    if (elmtIter != null) {
      while (elmtIter.hasNext()) {
        DataSetParameterHandle modelParam=(DataSetParameterHandle)elmtIter.next();
        dteDataSet.addParameter(new ParameterAdapter(modelParam));
        if (modelParam.isInput()) {
          String defaultValueExpr=null;
          if (modelParam instanceof OdaDataSetParameterHandle && ((OdaDataSetParameterHandle)modelParam).getParamName() != null) {
            defaultValueExpr=PARAMS_PREFIX + "String_Node_Str" + ((OdaDataSetParameterHandle)modelParam).getParamName()+ "String_Node_Str";
          }
 else           defaultValueExpr=modelParam.getDefaultValue();
          if (defaultValueExpr != null)           paramBindingCandidates.put(modelParam.getName(),defaultValueExpr);
        }
      }
    }
    elmtIter=modelDataSet.paramBindingsIterator();
    if (elmtIter != null) {
      while (elmtIter.hasNext()) {
        ParamBindingHandle modelParamBinding=(ParamBindingHandle)elmtIter.next();
        paramBindingCandidates.put(modelParamBinding.getParamName(),modelParamBinding.getExpression());
      }
    }
    if (paramBindingCandidates.size() > 0) {
      elmtIter=paramBindingCandidates.keySet().iterator();
      while (elmtIter.hasNext()) {
        Object paramName=elmtIter.next();
        assert(paramName != null && paramName instanceof String);
        String expression=(String)paramBindingCandidates.get(paramName);
        dteDataSet.addInputParamBinding(new InputParamBindingAdapter((String)paramName,expression));
      }
    }
    dteDataSet.setCacheRowCount(modelDataSet.getCachedRowCount());
  }
  Iterator elmtIter=modelDataSet.computedColumnsIterator();
  if (elmtIter != null) {
    while (elmtIter.hasNext()) {
      ComputedColumnHandle modelCmptdColumn=(ComputedColumnHandle)elmtIter.next();
      dteDataSet.addComputedColumn(new ComputedColumnAdapter(modelCmptdColumn));
    }
  }
  elmtIter=modelDataSet.filtersIterator();
  if (elmtIter != null) {
    while (elmtIter.hasNext()) {
      FilterConditionHandle modelFilter=(FilterConditionHandle)elmtIter.next();
      dteDataSet.addFilter(new FilterAdapter(modelFilter));
    }
  }
  if (modelDataSet instanceof OdaDataSetHandle) {
    elmtIter=modelDataSet.resultSetIterator();
    if (elmtIter != null) {
      while (elmtIter.hasNext()) {
        OdaResultSetColumnHandle modelColumn=(OdaResultSetColumnHandle)elmtIter.next();
        if (!modelColumn.getColumnName().equals(modelColumn.getNativeName()))         dteDataSet.addResultSetHint(new ColumnAdapter((ResultSetColumnHandle)modelColumn));
      }
    }
  }
 else {
    elmtIter=modelDataSet.resultSetHintsIterator();
    if (elmtIter != null) {
      while (elmtIter.hasNext()) {
        ResultSetColumnHandle modelColumn=(ResultSetColumnHandle)elmtIter.next();
        dteDataSet.addResultSetHint(new ColumnAdapter(modelColumn));
      }
    }
  }
  elmtIter=modelDataSet.columnHintsIterator();
  if (elmtIter != null) {
    List columnDefns=dteDataSet.getResultSetHints();
    while (elmtIter.hasNext()) {
      ColumnHintHandle modelColumnHint=(ColumnHintHandle)elmtIter.next();
      ColumnDefinition existDefn=findColumnDefn(columnDefns,modelColumnHint.getColumnName());
      if (existDefn != null)       updateColumnDefn(existDefn,modelColumnHint);
 else       dteDataSet.addResultSetHint(new ColumnAdapter(modelColumnHint));
    }
  }
}

Fixed version (ground truth):
/** 
 * Adapts base data set properties
 */
public static void adaptBaseDataSet(DataSetHandle modelDataSet,BaseDataSetDesign dteDataSet) throws BirtException {
  if ((!(modelDataSet instanceof JointDataSetHandle)) && modelDataSet.getDataSource() == null) {
    throw new AdapterException(ResourceConstants.DATASOURCE_NULL_ERROR);
  }
  if (!(modelDataSet instanceof JointDataSetHandle)) {
    dteDataSet.setDataSource(modelDataSet.getDataSource().getQualifiedName());
    dteDataSet.setBeforeOpenScript(modelDataSet.getBeforeOpen());
    dteDataSet.setAfterOpenScript(modelDataSet.getAfterOpen());
    dteDataSet.setOnFetchScript(modelDataSet.getOnFetch());
    dteDataSet.setBeforeCloseScript(modelDataSet.getBeforeClose());
    dteDataSet.setAfterCloseScript(modelDataSet.getAfterClose());
    dteDataSet.setCacheRowCount(modelDataSet.getCachedRowCount());
  }
  populateParameter(modelDataSet,dteDataSet);
  populateComputedColumn(modelDataSet,dteDataSet);
  populateFilter(modelDataSet,dteDataSet);
  mergeHints(modelDataSet,dteDataSet);
}