/** * */ public BusinessRuleVoCollection list(RulesEngineEntity entity) { if (entity == null) return null; DomainFactory factory = getDomainFactory(); IMSCriteria criteria = new IMSCriteria(BusinessRule.class, factory); criteria.equal("this.rootEntity", entity.getId()); criteria.equal("this.active", true); List rules = criteria.find(); Collections.sort(rules, new BusinessRuleComparator(SortOrder.DESCENDING)); return BusinessRuleVoAssembler.createBusinessRuleVoCollectionFromBusinessRule(rules); }
public BusinessRuleVoCollection listRules(Boolean activeOnly, String name, String entityID) throws DomainInterfaceException { DomainFactory factory = getDomainFactory(); IMSCriteria criteria = new IMSCriteria(BusinessRule.class, factory); if (activeOnly) { criteria.equal("this.active", true); } if (name != null && name.length() > 0) { criteria.like("this.name", "%" + name + "%"); } if (entityID != null) { criteria.equal("this.rootEntity", entityID); } List list = criteria.find(); Collections.sort(list, new BusinessRuleComparator(SortOrder.DESCENDING)); return BusinessRuleVoAssembler.createBusinessRuleVoCollectionFromBusinessRule(list); }
public BusinessRuleVo save(BusinessRuleVo rule) throws ims.domain.exceptions.StaleObjectException, UnqViolationUncheckedException { if(rule == null) throw new CodingRuntimeException("BusinessRuleVo is null"); DomainFactory factory = getDomainFactory(); BusinessRule dom = BusinessRuleVoAssembler.extractBusinessRule(factory,rule); factory.save(dom); return BusinessRuleVoAssembler.create(dom); }
/** * */ public BusinessRuleVoCollection save(BusinessRuleVoCollection rules) throws DomainInterfaceException, StaleObjectException, ForeignKeyViolationException, UniqueKeyViolationException { if (rules == null) throw new CodingRuntimeException("Major Logical Error - Rules collection must not be null"); DomainFactory factory = getDomainFactory(); for (int i = 0; i < rules.size(); i++) { BusinessRuleVo rule = rules.get(i); BusinessRule domRule = BusinessRuleVoAssembler.extractBusinessRule(factory, rule); if (rule.getXmlContent() == null) throw new CodingRuntimeException("Major Logical Error - XML Content cannot be null"); String xml; try { IRule iRule = RuleXmlSerialization.deserializeFromXml(rule.getXmlContent(), Entities.getInstance()); iRule.setPriority(rule.getPriority()); xml = RuleXmlSerialization.serialize(iRule); domRule.setXmlContent(xml); factory.save(domRule); } catch (Exception e) { throw new DomainInterfaceException(e.getMessage()); } } // Return null return null; }