public RulesPostImportContainer validateRuleDefs(RulesPostImportContainer importContainer) {
    for (RuleBean ruleBean : importContainer.getRuleDefs()) {
      AuditableBeanWrapper<RuleBean> ruleBeanWrapper = new AuditableBeanWrapper<RuleBean>(ruleBean);

      if (isRuleOidValid(ruleBeanWrapper) && isRuleExpressionValid(ruleBeanWrapper, null)) {
        RuleBean persistentRuleBean = getRuleDao().findByOid(ruleBeanWrapper.getAuditableBean());
        if (persistentRuleBean != null) {
          String name = ruleBeanWrapper.getAuditableBean().getName();
          String expressionValue = ruleBeanWrapper.getAuditableBean().getExpression().getValue();
          String expressionContextName =
              ruleBeanWrapper.getAuditableBean().getExpression().getContextName();
          Context context =
              expressionContextName != null
                  ? Context.getByName(expressionContextName)
                  : Context.OC_RULES_V1;
          ruleBeanWrapper.setAuditableBean(persistentRuleBean);
          ruleBeanWrapper.getAuditableBean().setName(name);
          ruleBeanWrapper.getAuditableBean().getExpression().setValue(expressionValue);
          ruleBeanWrapper.getAuditableBean().getExpression().setContext(context);
          // ruleBeanWrapper.getAuditableBean().setId(persistentRuleBean.getId());
          // ruleBeanWrapper.getAuditableBean().getExpression().setId(persistentRuleBean.getExpression().getId());
        }
      }
      putRuleInCorrectContainer(ruleBeanWrapper, importContainer);
    }
    logger.info(
        "# of Valid RuleDefs : {} , # of InValid RuleDefs : {} , # of Overwritable RuleDefs : {}",
        new Object[] {
          importContainer.getValidRuleDefs().size(),
          importContainer.getInValidRuleDefs().size(),
          importContainer.getDuplicateRuleDefs().size()
        });
    return importContainer;
  }
  public RulesPostImportContainer validateRuleSetDefs(RulesPostImportContainer importContainer) {
    for (RuleSetBean ruleSetBean : importContainer.getRuleSets()) {
      AuditableBeanWrapper<RuleSetBean> ruleSetBeanWrapper =
          new AuditableBeanWrapper<RuleSetBean>(ruleSetBean);
      ruleSetBeanWrapper.getAuditableBean().setStudy(currentStudy);
      if (isRuleSetExpressionValid(ruleSetBeanWrapper)) {
        RuleSetBean persistentRuleSetBean = getRuleSetDao().findByExpression(ruleSetBean);

        if (persistentRuleSetBean != null) {
          List<RuleSetRuleBean> importedRuleSetRules =
              ruleSetBeanWrapper.getAuditableBean().getRuleSetRules();
          ruleSetBeanWrapper.setAuditableBean(persistentRuleSetBean);
          ruleSetBeanWrapper.getAuditableBean().addRuleSetRules(importedRuleSetRules);
          // ruleSetBeanWrapper.getAuditableBean().setId(persistentRuleSetBean.getId());
        } else {
          if (importContainer
              .getValidRuleSetExpressionValues()
              .contains(ruleSetBeanWrapper.getAuditableBean().getTarget().getValue())) {
            ruleSetBeanWrapper.error(
                "You have two rule assignments with exact same Target, Combine and try again");
          }
          ruleSetBeanWrapper
              .getAuditableBean()
              .setStudyEventDefinition(
                  getExpressionService()
                      .getStudyEventDefinitionFromExpression(ruleSetBean.getTarget().getValue()));
          ruleSetBeanWrapper
              .getAuditableBean()
              .setCrf(
                  getExpressionService().getCRFFromExpression(ruleSetBean.getTarget().getValue()));
          ruleSetBeanWrapper
              .getAuditableBean()
              .setCrfVersion(
                  getExpressionService()
                      .getCRFVersionFromExpression(ruleSetBean.getTarget().getValue()));
        }
        isRuleSetRuleValid(importContainer, ruleSetBeanWrapper);
      }
      putRuleSetInCorrectContainer(ruleSetBeanWrapper, importContainer);
    }
    logger.info("# of Valid RuleSetDefs : " + importContainer.getValidRuleSetDefs().size());
    logger.info("# of InValid RuleSetDefs : " + importContainer.getInValidRuleSetDefs().size());
    logger.info(
        "# of Overwritable RuleSetDefs : " + importContainer.getDuplicateRuleSetDefs().size());
    return importContainer;
  }