/** * If the RuleSet contains any RuleSetRule object with an invalid RuleRef OID (OID that is not in * DB or in the Valid Rule Lists) , Then add an error to the ruleSetBeanWrapper, which in terms * will make the RuleSet inValid. * * @param importContainer * @param ruleSetBeanWrapper */ private void isRuleSetRuleValid( RulesPostImportContainer importContainer, AuditableBeanWrapper<RuleSetBean> ruleSetBeanWrapper) { for (RuleSetRuleBean ruleSetRuleBean : ruleSetBeanWrapper.getAuditableBean().getRuleSetRules()) { String ruleDefOid = ruleSetRuleBean.getOid(); if (ruleSetRuleBean.getId() == null) { if (getExpressionService() .getEventDefinitionCRF(ruleSetBeanWrapper.getAuditableBean().getTarget().getValue()) .getStatus() .isDeleted()) { ruleSetBeanWrapper.error( "This is an invalid Rule Set because the target is pointing to an item in the event definition CRF that has a status of removed"); } if (importContainer.getInValidRules().get(ruleDefOid) != null || importContainer.getValidRules().get(ruleDefOid) == null && getRuleDao().findByOid(ruleDefOid) == null) { ruleSetBeanWrapper.error( "The Rule you are trying to reference does not exist or is Invalid"); } if (importContainer.getValidRules().get(ruleDefOid) != null) { AuditableBeanWrapper<RuleBean> r = importContainer.getValidRules().get(ruleDefOid); if (!isRuleExpressionValid(r, ruleSetBeanWrapper.getAuditableBean())) ruleSetBeanWrapper.error( "The Contextual expression in one of the Rules does not validate against the Target expression in the Current RuleSet"); } } } }
private void putRuleInCorrectContainer( AuditableBeanWrapper<RuleBean> ruleBeanWrapper, RulesPostImportContainer importContainer) { if (!ruleBeanWrapper.isSavable()) { importContainer.getInValidRuleDefs().add(ruleBeanWrapper); importContainer .getInValidRules() .put(ruleBeanWrapper.getAuditableBean().getOid(), ruleBeanWrapper); } else if (ruleBeanWrapper.getAuditableBean().getId() == null) { importContainer.getValidRuleDefs().add(ruleBeanWrapper); importContainer .getValidRules() .put(ruleBeanWrapper.getAuditableBean().getOid(), ruleBeanWrapper); } else if (ruleBeanWrapper.getAuditableBean().getId() != null) { importContainer.getDuplicateRuleDefs().add(ruleBeanWrapper); importContainer .getValidRules() .put(ruleBeanWrapper.getAuditableBean().getOid(), ruleBeanWrapper); } }