コード例 #1
0
 /**
  * Updates or deletes a specified rule template option on the rule template
  *
  * @param updatedRuleTemplate the RuleTemplate being updated
  * @param key the option key
  * @param value the option value
  */
 protected void updateOrDeleteRuleTemplateOption(
     RuleTemplateBo updatedRuleTemplate, String key, Object value) {
   if (value != null) {
     // if the option exists and the incoming value is non-null (it's set), update it
     RuleTemplateOptionBo option = updatedRuleTemplate.getRuleTemplateOption(key);
     if (option != null) {
       option.setValue(value.toString());
     } else {
       updatedRuleTemplate
           .getRuleTemplateOptions()
           .add(new RuleTemplateOptionBo(key, value.toString()));
     }
   } else {
     // otherwise if the incoming value IS null (not set), then explicitly remove the entry (if it
     // exists)
     Iterator<RuleTemplateOptionBo> options =
         updatedRuleTemplate.getRuleTemplateOptions().iterator();
     while (options.hasNext()) {
       RuleTemplateOptionBo opt = options.next();
       if (key.equals(opt.getCode())) {
         options.remove();
         break;
       }
     }
   }
 }
コード例 #2
0
 private void assertRuleTemplateExport(
     RuleTemplateBo oldRuleTemplate, RuleTemplateBo newRuleTemplate) {
   assertFalse(
       "Ids should be different.", oldRuleTemplate.getId().equals(newRuleTemplate.getId()));
   assertEquals(oldRuleTemplate.getDescription(), newRuleTemplate.getDescription());
   assertEquals(oldRuleTemplate.getName(), newRuleTemplate.getName());
   if (oldRuleTemplate.getDelegationTemplate() != null) {
     assertRuleTemplateExport(
         oldRuleTemplate.getDelegationTemplate(), newRuleTemplate.getDelegationTemplate());
   } else {
     assertNull(newRuleTemplate.getDelegationTemplate());
   }
   assertAttributes(
       oldRuleTemplate.getRuleTemplateAttributes(),
       newRuleTemplate.getRuleTemplateAttributes(),
       "attribute");
   assertAttributes(
       oldRuleTemplate.getActiveRuleTemplateAttributes(),
       newRuleTemplate.getActiveRuleTemplateAttributes(),
       "active attribute");
   assertOptions(
       oldRuleTemplate.getRuleTemplateOptions(), newRuleTemplate.getRuleTemplateOptions());
 }