/** * Promotion test persister constructor. * * @param beanFactory the bean factory */ public PromotionTestPersister(final BeanFactory beanFactory) { this.beanFactory = beanFactory; tac = beanFactory.getBean("testApplicationContext"); ruleService = beanFactory.getBean(ContextIdNames.RULE_SERVICE); ruleSetService = beanFactory.getBean(ContextIdNames.RULE_SET_SERVICE); storeService = beanFactory.getBean(ContextIdNames.STORE_SERVICE); catalogService = beanFactory.getBean(ContextIdNames.CATALOG_SERVICE); sellingContextService = beanFactory.getBean(ContextIdNames.SELLING_CONTEXT_SERVICE); tagConditionService = beanFactory.getBean(ContextIdNames.TAG_CONDITION_SERVICE); ruleEngine = beanFactory.getBean("epRuleEngine"); ruleEngine.resetRuleBaseCache(); }
/** * Update a given promotion rule with conditions cleanup. * * @param promotionRule promotion rule to update * @return updated promotion rule */ public Rule updatePromotionRuleWithConditionsCleanup(final Rule promotionRule) { if (promotionRule.getSellingContext() != null) { SellingContext sellingContext = sellingContextService.getByGuid(promotionRule.getSellingContext().getGuid()); for (ConditionalExpression conditionalExpression : sellingContext.getConditions().values()) { tagConditionService.delete(conditionalExpression); } } Rule updatedPromotionRule = ruleService.update(promotionRule); ruleEngine.recompileRuleBase(); return updatedPromotionRule; }
/** * Update a given promotion rule. * * @param promotionRule promotion rule to update * @return updated promotion rule */ public Rule updatePromotionRule(final Rule promotionRule) { Rule updatedPromotionRule = ruleService.update(promotionRule); ruleEngine.recompileRuleBase(); return updatedPromotionRule; }
/** * Save configured rule into a database. * * @param promotionRule to be saved * @return persisted rule */ public Rule persistPromotionRule(final Rule promotionRule) { Rule persistedPromotionRule = ruleService.add(promotionRule); ruleEngine.recompileRuleBase(); return persistedPromotionRule; }