Program: 115320
Project: 115320
Buggy source:
public void hideNew(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);
      }
      for (      ItemDataBean oidBasedItemData : itemDataBeans) {
        ItemFormMetadataBean itemFormMetadataBean=getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemOrItemGroup.getItemBean().getId(),eventCrfBeanA.getCRFVersionId());
        DynamicsItemFormMetadataBean dynamicsMetadataBean=getDynamicsItemFormMetadataBean(itemFormMetadataBean,eventCrfBeanA,oidBasedItemData);
        if (dynamicsMetadataBean == null && oidBasedItemData.getValue().equals("String_Node_Str")) {
          hideItem(itemFormMetadataBean,eventCrfBeanA,oidBasedItemData);
        }
 else         if (dynamicsMetadataBean != null && dynamicsMetadataBean.isShowItem() && oidBasedItemData.getValue().equals("String_Node_Str") && !itemsAlreadyShown.contains(new Integer(oidBasedItemData.getItemId()))) {
          dynamicsMetadataBean.setShowItem(false);
          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) {
              hideGroup(itemGroupMetadataBean,eventCrfBeanA);
            }
 else             if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
              dynamicsGroupBean.setShowGroup(false);
              getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
            }
 else             if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
              dynamicsGroupBean.setPassedDde(1);
              getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
            }
          }
        }
      }
    }
  }
  resetItemCounter();
}

Fixed version (ground truth):
public void hideNew(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);
      }
      for (      ItemDataBean oidBasedItemData : itemDataBeans) {
        ItemFormMetadataBean itemFormMetadataBean=getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemOrItemGroup.getItemBean().getId(),eventCrfBeanA.getCRFVersionId());
        DynamicsItemFormMetadataBean dynamicsMetadataBean=getDynamicsItemFormMetadataBean(itemFormMetadataBean,eventCrfBeanA,oidBasedItemData);
        if (dynamicsMetadataBean == null && oidBasedItemData.getValue().equals("String_Node_Str")) {
          hideItem(itemFormMetadataBean,eventCrfBeanA,oidBasedItemData);
        }
 else         if (dynamicsMetadataBean != null && dynamicsMetadataBean.isShowItem() && oidBasedItemData.getValue().equals("String_Node_Str")) {
          dynamicsMetadataBean.setShowItem(false);
          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) {
              hideGroup(itemGroupMetadataBean,eventCrfBeanA);
            }
 else             if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
              dynamicsGroupBean.setShowGroup(false);
              getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
            }
 else             if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
              dynamicsGroupBean.setPassedDde(1);
              getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
            }
          }
        }
      }
    }
  }
}