Program: 115097
Project: 115097
Buggy source:
protected DisplayItemWithGroupBean buildMatrixForRepeatingGroups(DisplayItemWithGroupBean diwgb,DisplayItemGroupBean itemGroup,EventCRFBean ecb,SectionBean sb,List<ItemBean> itBeans,Map<String,ItemDataBean> dataMap,List<String> nullValuesList){
  int tempOrdinal=1;
  ItemDataDAO iddao=new ItemDataDAO(getDataSource(),locale);
  int maxOrdinal=iddao.getMaxOrdinalForGroup(ecb,sb,itemGroup.getItemGroupBean());
  if (maxOrdinal == 0)   maxOrdinal=1;
  ItemFormMetadataDAO ifmdao=new ItemFormMetadataDAO<String,ArrayList>(getDataSource());
  List<DisplayItemGroupBean> itemGroups=new ArrayList<DisplayItemGroupBean>();
  boolean groupHasData=false;
  for (int i=1; i <= maxOrdinal; i++) {
    List<DisplayItemBean> displayItemBeans=new ArrayList<DisplayItemBean>();
    DisplayItemGroupBean dig=new DisplayItemGroupBean();
    for (    ItemBean itBean : itBeans) {
      DisplayItemBean displayItemBean=new DisplayItemBean();
      ItemFormMetadataBean ifm=ifmdao.findByItemIdAndCRFVersionId(itBean.getId(),ecb.getCRFVersionId());
      displayItemBean.setMetadata(ifm);
      displayItemBean.setItem(itBean);
      ItemDataBean itemData=dataMap.get(itBean.getId() + "String_Node_Str" + i);
      if (itemData != null) {
        groupHasData=true;
        displayItemBean.setIsNewItem(false);
      }
      if (itemData == null) {
        itemData=displayItemBean.getData();
        itemData.setValue("String_Node_Str");
        itemData.setOrdinal(i);
      }
      addNullValues(displayItemBean,nullValuesList);
      displayItemBean.setData(itemData);
      displayItemBean.loadDBValue();
      displayItemBeans.add(displayItemBean);
    }
    dig.setItems(displayItemBeans);
    dig.setHasData(groupHasData);
    itemGroups.add(dig);
  }
  diwgb.setItemGroups(itemGroups);
  diwgb.setDbItemGroups(itemGroups);
  return diwgb;
}

Fixed version (ground truth):
protected DisplayItemWithGroupBean buildMatrixForRepeatingGroups(DisplayItemWithGroupBean diwgb,DisplayItemGroupBean itemGroup,EventCRFBean ecb,SectionBean sb,List<ItemBean> itBeans,Map<String,ItemDataBean> dataMap,List<String> nullValuesList,boolean isSubmitted){
  int tempOrdinal=1;
  ItemDataDAO iddao=new ItemDataDAO(getDataSource(),locale);
  int maxOrdinal=iddao.getMaxOrdinalForGroup(ecb,sb,itemGroup.getItemGroupBean());
  if (maxOrdinal == 0)   maxOrdinal=1;
  ItemFormMetadataDAO ifmdao=new ItemFormMetadataDAO<String,ArrayList>(getDataSource());
  List<DisplayItemGroupBean> itemGroups=new ArrayList<DisplayItemGroupBean>();
  boolean groupHasData=false;
  for (int i=1; i <= maxOrdinal; i++) {
    List<DisplayItemBean> displayItemBeans=new ArrayList<DisplayItemBean>();
    DisplayItemGroupBean dig=new DisplayItemGroupBean();
    for (    ItemBean itBean : itBeans) {
      DisplayItemBean displayItemBean=new DisplayItemBean();
      ItemFormMetadataBean ifm=ifmdao.findByItemIdAndCRFVersionId(itBean.getId(),ecb.getCRFVersionId());
      displayItemBean.setMetadata(ifm);
      displayItemBean.setItem(itBean);
      ItemDataBean itemData=dataMap.get(itBean.getId() + "String_Node_Str" + i);
      if (itemData != null) {
        groupHasData=true;
        displayItemBean.setIsNewItem(false);
      }
      if (itemData == null) {
        itemData=displayItemBean.getData();
        itemData.setValue("String_Node_Str");
        itemData.setOrdinal(i);
      }
      addNullValues(displayItemBean,nullValuesList);
      displayItemBean.setData(itemData);
      if (ecb.getStage() == DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE || ecb.getStage() == DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) {
        if (shouldLoadDBValues(displayItemBean) && !isSubmitted) {
          displayItemBean.loadDBValue();
        }
      }
 else {
        if (shouldLoadDBValues(displayItemBean)) {
          LOGGER.trace("String_Node_Str");
          displayItemBean.loadDBValue();
          LOGGER.trace("String_Node_Str" + displayItemBean.getData().getValue());
        }
      }
      displayItemBeans.add(displayItemBean);
    }
    dig.setItems(displayItemBeans);
    dig.setHasData(groupHasData);
    itemGroups.add(dig);
  }
  diwgb.setItemGroups(itemGroups);
  diwgb.setDbItemGroups(itemGroups);
  return diwgb;
}