/**
  * This method retrieves a rule from the repository given the rule id.
  *
  * @see org.kuali.rice.krms.impl.repository.RuleBoService#getRuleByRuleId(java.lang.String)
  */
 @Override
 public RuleDefinition getRuleByRuleId(String ruleId) {
   if (StringUtils.isBlank(ruleId)) {
     throw new IllegalArgumentException("rule id is null");
   }
   RuleBo bo = businessObjectService.findBySinglePrimaryKey(RuleBo.class, ruleId);
   return RuleBo.to(bo);
 }
 /**
  * Converts a List<RuleBo> to an Unmodifiable List<Rule>
  *
  * @param RuleBos a mutable List<RuleBo> to made completely immutable.
  * @return An unmodifiable List<Rule>
  */
 public List<RuleDefinition> convertListOfBosToImmutables(final Collection<RuleBo> ruleBos) {
   ArrayList<RuleDefinition> rules = new ArrayList<RuleDefinition>();
   for (RuleBo bo : ruleBos) {
     RuleDefinition rule = RuleBo.to(bo);
     rules.add(rule);
   }
   return Collections.unmodifiableList(rules);
 }
 /**
  * This overridden creates a KRMS Rule in the repository
  *
  * @see
  *     org.kuali.rice.krms.impl.repository.RuleBoService#createRule(org.kuali.rice.krms.api.repository.rule.RuleDefinition)
  */
 @Override
 public RuleDefinition createRule(RuleDefinition rule) {
   if (rule == null) {
     throw new IllegalArgumentException("rule is null");
   }
   final String nameKey = rule.getName();
   final String namespaceKey = rule.getNamespace();
   final RuleDefinition existing = getRuleByNameAndNamespace(nameKey, namespaceKey);
   if (existing != null) {
     throw new IllegalStateException("the rule to create already exists: " + rule);
   }
   RuleBo ruleBo = RuleBo.from(rule);
   businessObjectService.save(ruleBo);
   return RuleBo.to(ruleBo);
 }
  /**
   * This method retrieves a rule from the repository given the name of the rule and namespace.
   *
   * @see org.kuali.rice.krms.impl.repository.RuleBoService#getRuleByRuleId(java.lang.String)
   */
  @Override
  public RuleDefinition getRuleByNameAndNamespace(String name, String namespace) {
    if (StringUtils.isBlank(name)) {
      throw new IllegalArgumentException("name is blank");
    }
    if (StringUtils.isBlank(namespace)) {
      throw new IllegalArgumentException("namespace is blank");
    }

    final Map<String, Object> map = new HashMap<String, Object>();
    map.put("name", name);
    map.put("namespace", namespace);

    RuleBo myRule =
        businessObjectService.findByPrimaryKey(RuleBo.class, Collections.unmodifiableMap(map));
    return RuleBo.to(myRule);
  }