/** * Function used to populate the Business Rules collection from business * rules grid on ICP Stage tab * * @return */ private BusinessRuleVoCollection getICPStageRules() { // Create a new rule collection BusinessRuleVoCollection rules = new BusinessRuleVoCollection(); // Iterate rules grid rows for (int i = 0; i < form.ctnConfiguration().lyrICPTabs().Stage().grdStageRules().getRows().size(); i++) { BusinessRuleVo rule = form.ctnConfiguration().lyrICPTabs().Stage().grdStageRules().getRows().get(i).getValue(); // Skip null rules if (rule == null) continue; // Add rule to collection rules.add(rule); } // Return populated rule collection return rules; }
/** * Function used to populate the Business Rules collection from business * rules grid on ICP Phase tab * * @return */ private BusinessRuleVoCollection getICPPhaseRules() { // Create a new rule collection BusinessRuleVoCollection rules = new BusinessRuleVoCollection(); // Iterate rules grid rows for (int i = 0; i < form.ctnConfiguration().lyrICPTabs().Phase().grdPhaseRules().getRows().size(); i++) { BusinessRuleVo rule = form.ctnConfiguration().lyrICPTabs().Phase().grdPhaseRules().getRows().get(i).getValue(); // Skip null rules if (rule == null) continue; // Add rule to collection rules.add(rule); } // Return populated rule collection return rules; }
/** * */ public void open() throws PresentationLogicException { //WDEV-18211 form.dyngrdRules().getRows().clear(); // Set IsModified to false (local context) WDEV-18211 moved here form.getLocalContext().setIsModified(false); // Load the rules list BusinessRuleVoCollection ruleList = domain.list(form.cmbEntity().getValue()); if (form.cmbEntity().getValue() != null && (ruleList == null || ruleList.size() == 0)) { engine.showMessage("No rules were found for the selected Data Entity"); updateContextMenuState(); return; } setRuleList(ruleList); // Keep previous selection form.dyngrdRules().setValue(form.getLocalContext().getSelectedRule()); //WDEV-18211 form.setMode(FormMode.VIEW); }
/** * */ private BusinessRuleVoCollection getRuleList() { if (form.dyngrdRules().getRows().size() == 0) return null; BusinessRuleVoCollection ruleList = new BusinessRuleVoCollection(); for (int i = 0; i < form.dyngrdRules().getRows().size(); i++) { DynamicGridRow row = form.dyngrdRules().getRows().get(i); if (row.getValue() instanceof BusinessRuleVo) { BusinessRuleVo rule = (BusinessRuleVo) row.getValue(); ruleList.add(rule); } } return ruleList; }
/** * */ private void setRuleList(BusinessRuleVoCollection list) { // Clear the rules list form.dyngrdRules().getRows().clear(); if (list == null) return; for (int i = 0; i < list.size(); i++) { BusinessRuleVo rule = list.get(i); // Add non nulls elements to the grid if (rule != null) { setRuleListRow(form.dyngrdRules().getRows().newRow(), rule); } } }
/** * */ 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); }
/** * Function used to populate rules for an ICP Stage configuration * * @param rules * - Business Rules collection used for populating ICP Stage * rules grid */ private void setICPStageRules(BusinessRuleVoCollection rules) { // Clear rules grid form.ctnConfiguration().lyrICPTabs().Stage().grdStageRules().getRows().clear(); // Terminate function if rules collection is null if (rules == null) return; for (BusinessRuleVo rule : rules) { // Skip rule if null if (rule == null) continue; // Create a new row grdStageRulesRow newRow = form.ctnConfiguration().lyrICPTabs().Stage().grdStageRules().getRows().newRow(); // Fill new row columns cells newRow.setcolName(rule.getName()); newRow.setcolDescription(rule.getDescription()); newRow.setcolCategory(rule.getCategory()); newRow.setcolActive(rule.getActive()); // Set row value newRow.setValue(rule); } }
/** * Function used to populate rules for an ICP Phase configuration * * @param rules * - Business Rules collection used for populating ICP Phase * rules grid */ private void setICPPhaseRules(BusinessRuleVoCollection rules) { // Clear rules grid form.ctnConfiguration().lyrICPTabs().Phase().grdPhaseRules().getRows().clear(); // Terminate function if rule collection is null if (rules == null) return; // Iterate rule collection for (BusinessRuleVo rule : rules) { // Skip null rules if (rule == null) continue; // Create a new row grdPhaseRulesRow newRow = form.ctnConfiguration().lyrICPTabs().Phase().grdPhaseRules().getRows().newRow(); // Fill new row columns cells newRow.setcolName(rule.getName()); newRow.setcolDescription(rule.getDescription()); newRow.setcolCategory(rule.getCategory()); newRow.setcolActive(rule.getActive()); // Set row value newRow.setValue(rule); } }
/** * */ 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; }