Program: 115321
Project: 115321
Buggy source:
public void showNew(Integer itemDataId,List<PropertyBean> properties,UserAccountBean ub,RuleSetBean ruleSet){
  ItemDataBean itemDataBeanA=(ItemDataBean)getItemDataDAO().findByPK(itemDataId);
  EventCRFBean eventCrfBeanA=(EventCRFBean)getEventCRFDAO().findByPK(itemDataBeanA.getEventCRFId());
  ItemGroupMetadataBean itemGroupMetadataBeanA=(ItemGroupMetadataBean)getItemGroupMetadataDAO().findByItemAndCrfVersion(itemDataBeanA.getItemId(),eventCrfBeanA.getCRFVersionId());
  Boolean isGroupARepeating=isGroupRepeating(itemGroupMetadataBeanA);
  String itemGroupAOrdinal=getExpressionService().getGroupOrdninalCurated(ruleSet.getTarget().getValue());
  for (  PropertyBean propertyBean : properties) {
    String oid=propertyBean.getOid();
    ItemOrItemGroupHolder itemOrItemGroup=getItemOrItemGroup(oid);
    if (itemOrItemGroup.getItemBean() != null) {
      String expression=getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(),ruleSet.getTarget().getValue());
      ItemBean itemBeanB=getExpressionService().getItemBeanFromExpression(expression);
      ItemGroupBean itemGroupBeanB=getExpressionService().getItemGroupExpression(expression);
      EventCRFBean eventCrfBeanB=eventCrfBeanA;
      ItemGroupMetadataBean itemGroupMetadataBeanB=(ItemGroupMetadataBean)getItemGroupMetadataDAO().findByItemAndCrfVersion(itemBeanB.getId(),eventCrfBeanB.getCRFVersionId());
      Boolean isGroupBRepeating=isGroupRepeating(itemGroupMetadataBeanB);
      String itemGroupBOrdinal=getExpressionService().getGroupOrdninalCurated(expression);
      List<ItemDataBean> itemDataBeans=new ArrayList<ItemDataBean>();
      if (!isGroupARepeating && !isGroupBRepeating) {
        ItemDataBean oidBasedItemData=oneToOne(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub,1);
        itemDataBeans.add(oidBasedItemData);
      }
      if (!isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("String_Node_Str")) {
        List<ItemDataBean> oidBasedItemDatas=oneToMany(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub);
        itemDataBeans.addAll(oidBasedItemDatas);
      }
      if (!isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("String_Node_Str")) {
        ItemDataBean oidBasedItemData=oneToIndexedMany(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub,Integer.valueOf(itemGroupBOrdinal));
        itemDataBeans.add(oidBasedItemData);
      }
      if (isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("String_Node_Str")) {
        ItemDataBean oidBasedItemData=oneToIndexedMany(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub,Integer.valueOf(itemGroupBOrdinal));
        itemDataBeans.add(oidBasedItemData);
      }
      if (isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("String_Node_Str")) {
        ItemDataBean oidBasedItemData=oneToIndexedMany(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub,Integer.valueOf(itemGroupAOrdinal));
        itemDataBeans.add(oidBasedItemData);
      }
      logger.debug("String_Node_Str" + itemDataBeans.toString());
      for (      ItemDataBean oidBasedItemData : itemDataBeans) {
        ItemFormMetadataBean itemFormMetadataBean=getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBeanB.getId(),eventCrfBeanB.getCRFVersionId());
        DynamicsItemFormMetadataBean dynamicsMetadataBean=getDynamicsItemFormMetadataBean(itemFormMetadataBean,eventCrfBeanA,oidBasedItemData);
        if (dynamicsMetadataBean == null) {
          showItem(itemFormMetadataBean,eventCrfBeanA,oidBasedItemData);
          itemsAlreadyShown.add(new Integer(oidBasedItemData.getItemId()));
        }
 else         if (dynamicsMetadataBean != null && !dynamicsMetadataBean.isShowItem()) {
          dynamicsMetadataBean.setShowItem(true);
          getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
          itemsAlreadyShown.add(new Integer(oidBasedItemData.getItemId()));
        }
 else         if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
          logger.debug("String_Node_Str" + oidBasedItemData.getId());
          dynamicsMetadataBean.setPassedDde(1);
          getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
        }
      }
    }
 else {
      logger.debug("String_Node_Str" + oid);
      ItemGroupBean itemGroupBean=itemOrItemGroup.getItemGroupBean();
      ArrayList sectionBeans=getSectionDAO().findAllByCRFVersionId(eventCrfBeanA.getCRFVersionId());
      for (int i=0; i < sectionBeans.size(); i++) {
        SectionBean sectionBean=(SectionBean)sectionBeans.get(i);
        List<ItemGroupMetadataBean> itemGroupMetadataBeans=getItemGroupMetadataDAO().findMetaByGroupAndSection(itemGroupBean.getId(),eventCrfBeanA.getCRFVersionId(),sectionBean.getId());
        for (        ItemGroupMetadataBean itemGroupMetadataBean : itemGroupMetadataBeans) {
          if (itemGroupMetadataBean.getItemGroupId() == itemGroupBean.getId()) {
            DynamicsItemGroupMetadataBean dynamicsGroupBean=getDynamicsItemGroupMetadataBean(itemGroupMetadataBean,eventCrfBeanA);
            if (dynamicsGroupBean == null) {
              showGroup(itemGroupMetadataBean,eventCrfBeanA);
            }
 else             if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
              dynamicsGroupBean.setShowGroup(true);
              getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
            }
 else             if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
              dynamicsGroupBean.setPassedDde(1);
              getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
public void showNew(Integer itemDataId,List<PropertyBean> properties,UserAccountBean ub,RuleSetBean ruleSet){
  ItemDataBean itemDataBeanA=(ItemDataBean)getItemDataDAO().findByPK(itemDataId);
  EventCRFBean eventCrfBeanA=(EventCRFBean)getEventCRFDAO().findByPK(itemDataBeanA.getEventCRFId());
  ItemGroupMetadataBean itemGroupMetadataBeanA=(ItemGroupMetadataBean)getItemGroupMetadataDAO().findByItemAndCrfVersion(itemDataBeanA.getItemId(),eventCrfBeanA.getCRFVersionId());
  Boolean isGroupARepeating=isGroupRepeating(itemGroupMetadataBeanA);
  String itemGroupAOrdinal=getExpressionService().getGroupOrdninalCurated(ruleSet.getTarget().getValue());
  for (  PropertyBean propertyBean : properties) {
    String oid=propertyBean.getOid();
    ItemOrItemGroupHolder itemOrItemGroup=getItemOrItemGroup(oid);
    if (itemOrItemGroup.getItemBean() != null) {
      String expression=getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(),ruleSet.getTarget().getValue());
      ItemBean itemBeanB=getExpressionService().getItemBeanFromExpression(expression);
      ItemGroupBean itemGroupBeanB=getExpressionService().getItemGroupExpression(expression);
      EventCRFBean eventCrfBeanB=eventCrfBeanA;
      ItemGroupMetadataBean itemGroupMetadataBeanB=(ItemGroupMetadataBean)getItemGroupMetadataDAO().findByItemAndCrfVersion(itemBeanB.getId(),eventCrfBeanB.getCRFVersionId());
      Boolean isGroupBRepeating=isGroupRepeating(itemGroupMetadataBeanB);
      String itemGroupBOrdinal=getExpressionService().getGroupOrdninalCurated(expression);
      List<ItemDataBean> itemDataBeans=new ArrayList<ItemDataBean>();
      if (!isGroupARepeating && !isGroupBRepeating) {
        ItemDataBean oidBasedItemData=oneToOne(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub,1);
        itemDataBeans.add(oidBasedItemData);
      }
      if (!isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("String_Node_Str")) {
        List<ItemDataBean> oidBasedItemDatas=oneToMany(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub);
        itemDataBeans.addAll(oidBasedItemDatas);
      }
      if (!isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("String_Node_Str")) {
        ItemDataBean oidBasedItemData=oneToIndexedMany(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub,Integer.valueOf(itemGroupBOrdinal));
        itemDataBeans.add(oidBasedItemData);
      }
      if (isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("String_Node_Str")) {
        ItemDataBean oidBasedItemData=oneToIndexedMany(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub,Integer.valueOf(itemGroupBOrdinal));
        itemDataBeans.add(oidBasedItemData);
      }
      if (isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("String_Node_Str")) {
        ItemDataBean oidBasedItemData=oneToIndexedMany(itemDataBeanA,eventCrfBeanA,itemGroupMetadataBeanA,itemBeanB,itemGroupBeanB,itemGroupMetadataBeanB,eventCrfBeanB,ub,Integer.valueOf(itemGroupAOrdinal));
        itemDataBeans.add(oidBasedItemData);
      }
      logger.debug("String_Node_Str" + itemDataBeans.toString());
      for (      ItemDataBean oidBasedItemData : itemDataBeans) {
        ItemFormMetadataBean itemFormMetadataBean=getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBeanB.getId(),eventCrfBeanB.getCRFVersionId());
        DynamicsItemFormMetadataBean dynamicsMetadataBean=getDynamicsItemFormMetadataBean(itemFormMetadataBean,eventCrfBeanA,oidBasedItemData);
        if (dynamicsMetadataBean == null) {
          showItem(itemFormMetadataBean,eventCrfBeanA,oidBasedItemData);
        }
 else         if (dynamicsMetadataBean != null && !dynamicsMetadataBean.isShowItem()) {
          dynamicsMetadataBean.setShowItem(true);
          getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
        }
 else         if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
          logger.debug("String_Node_Str" + oidBasedItemData.getId());
          dynamicsMetadataBean.setPassedDde(1);
          getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
        }
      }
    }
 else {
      logger.debug("String_Node_Str" + oid);
      ItemGroupBean itemGroupBean=itemOrItemGroup.getItemGroupBean();
      ArrayList sectionBeans=getSectionDAO().findAllByCRFVersionId(eventCrfBeanA.getCRFVersionId());
      for (int i=0; i < sectionBeans.size(); i++) {
        SectionBean sectionBean=(SectionBean)sectionBeans.get(i);
        List<ItemGroupMetadataBean> itemGroupMetadataBeans=getItemGroupMetadataDAO().findMetaByGroupAndSection(itemGroupBean.getId(),eventCrfBeanA.getCRFVersionId(),sectionBean.getId());
        for (        ItemGroupMetadataBean itemGroupMetadataBean : itemGroupMetadataBeans) {
          if (itemGroupMetadataBean.getItemGroupId() == itemGroupBean.getId()) {
            DynamicsItemGroupMetadataBean dynamicsGroupBean=getDynamicsItemGroupMetadataBean(itemGroupMetadataBean,eventCrfBeanA);
            if (dynamicsGroupBean == null) {
              showGroup(itemGroupMetadataBean,eventCrfBeanA);
            }
 else             if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
              dynamicsGroupBean.setShowGroup(true);
              getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
            }
 else             if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
              dynamicsGroupBean.setPassedDde(1);
              getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
            }
          }
        }
      }
    }
  }
}