private void populateSearchCriteria(boolean isActive, String name, String rulesEngineEntityID, Integer categoryID) { form.chkActiveOnly().setValue(isActive); form.txtRuleName().setValue(name); if (rulesEngineEntityID != null) { List<RulesEngineEntity> entities = new Entities().getAllPublicEntities(); for (int i = 0 ; i < entities.size(); i++) { if (rulesEngineEntityID.equals(entities.get(i).getId())) { form.cmbEntity().setValue(entities.get(i)); break; } } } if (categoryID != null) { for (int i = 0; i < form.treRootEntity().getNodes().size(); i++) { if (form.treRootEntity().getNodes().get(i).getValue() instanceof BusinessRuleCategory && ((BusinessRuleCategory)form.treRootEntity().getNodes().get(i).getValue()).getID() == categoryID) { form.treRootEntity().setValue(form.treRootEntity().getNodes().get(i).getValue()); break; } } } }
/** * */ private void setBusinessRuleCategoryTree() { // Clear the tree form.treRootEntity().getNodes().clear(); // Get business rule categories BusinessRuleCategoryCollection ruleCategoryCollection = ims.admin.vo.lookups.LookupHelper.getBusinessRuleCategory(this.domain.getLookupService()); // If the rules categories are missing - interupt if (ruleCategoryCollection == null) return; // Set the category nodes for (int i = 0; i < ruleCategoryCollection.size(); i++) { BusinessRuleCategory businessRuleCategory = ruleCategoryCollection.get(i); if (businessRuleCategory != null && businessRuleCategory.getParent() == null) { // Set node value TreeNode node = form.treRootEntity().getNodes().add(businessRuleCategory, businessRuleCategory.getText()); node.setIdentifier(new Integer(0)); node.setText(((BusinessRuleCategory) node.getValue()).getText() + " (" + node.getIdentifier().toString() + ")"); // Add sub categories setTreeNodeSubCategories(node, businessRuleCategory); } } }
/** * * @param nodeByValue * @param businessRuleCategory */ private void setTreeNodeSubCategories(TreeNode node, BusinessRuleCategory businessRuleCategory) { if (businessRuleCategory == null) return; if (node == null) throw new CodingRuntimeException("Major Logical Error - Can not populate a null node in tree business rule category"); // Add business rule childs to tree if (businessRuleCategory.getChildInstances() != null) { for (int i = 0; i < businessRuleCategory.getChildInstances().size(); i++) { LookupInstVo lookupInstVo = businessRuleCategory.getChildInstances().get(i); if (lookupInstVo instanceof BusinessRuleCategory) { // Set node value TreeNode childNode = node.getNodes().add((BusinessRuleCategory) lookupInstVo, ((BusinessRuleCategory) lookupInstVo).getText()); childNode.setIdentifier(new Integer(0)); childNode.setText(((BusinessRuleCategory) childNode.getValue()).getText() + " (" + childNode.getIdentifier().toString() + ")"); // Add sub categories setTreeNodeSubCategories(childNode, (BusinessRuleCategory) lookupInstVo); } } } }
private void initialize() throws PresentationLogicException { // hide tab Overview form.lyrRules().tabOverview().setHeaderVisible(false); form.lyrRules().tabGeneral().ccBusinessRuleCategory().clear(); form.lyrRules().tabGeneral().ccBusinessRuleCategory().initialize(BusinessRuleCategory.TYPE_ID); form.getLocalContext().setIsFirstConditionDefined(false); // Clear tabs form.lyrRules().tabConditions().dyngrdConditions().clear(); form.lyrRules().tabConditions().dyngrdConditions().getRows().clear(); form.lyrRules().tabActions().dyngrdActions().clear(); form.lyrRules().tabActions().dyngrdActions().getRows().clear(); // Clear tab General form.lyrRules().tabGeneral().txtName().setValue(null); form.lyrRules().tabGeneral().txtDescription().setValue(null); form.lyrRules().tabGeneral().ccBusinessRuleCategory().setValue(null); form.lyrRules().tabGeneral().dteValidFrom().setValue(null); form.lyrRules().tabGeneral().dteValidTo().setValue(null); form.lyrRules().tabGeneral().chkDateRange().setValue(false); onChkDateRangeValueChanged(); form.lyrRules().tabGeneral().chkActive().setValue(false); // Focus tab General form.lyrRules().showtabGeneral(); // Focus on Name form.lyrRules().tabGeneral().txtName().setFocus(); form.getLocalContext().setAlreadyAddedCollection(false); }
/** * */ public void open() throws PresentationLogicException { clearInstanceControls(); try { // Set business rule category tree setBusinessRuleCategoryTree(); //Get search criteria boolean isActive = form.chkActiveOnly().getValue(); String name = form.txtRuleName().getValue(); String rulesEngineEntityID = form.cmbEntity().getValue() != null ? form.cmbEntity().getValue().getId() : null; Integer categoryID = form.treRootEntity().getValue() != null ? ((BusinessRuleCategory) form.treRootEntity().getValue()).getID() : null; //Set search criteria in Global Context if (form.getGlobalContext().Rules.RulesList.getRulesSearchCriteria() == null) { BusinessRulesSearchVo searchCriteria = new BusinessRulesSearchVo(); searchCriteria.setActiveOnly(isActive); searchCriteria.setName(name); searchCriteria.setEntityID(rulesEngineEntityID); searchCriteria.setCategoryID(categoryID); form.getGlobalContext().Rules.RulesList.setRulesSearchCriteria(searchCriteria); } else { isActive = form.getGlobalContext().Rules.RulesList.getRulesSearchCriteria().getActiveOnly(); name = form.getGlobalContext().Rules.RulesList.getRulesSearchCriteria().getName(); rulesEngineEntityID = form.getGlobalContext().Rules.RulesList.getRulesSearchCriteria().getEntityID(); categoryID = form.getGlobalContext().Rules.RulesList.getRulesSearchCriteria().getCategoryID(); populateSearchCriteria(isActive, name, rulesEngineEntityID, categoryID); } // Search the rules if (form.treRootEntity().getValue() instanceof BusinessRuleCategory) { setRulesList(domain.listRules(isActive, name, rulesEngineEntityID), categoryID); } else { setRulesList(domain.listRules(isActive,name, rulesEngineEntityID), null); } // Set focus on rule name search text box form.txtRuleName().setFocus(); } catch (DomainInterfaceException e) { engine.showMessage(e.getMessage(), "UKSH - Error Message"); } form.setMode(FormMode.VIEW); }
/** * * @param listRules */ private void setRulesList(BusinessRuleVoCollection listRules, Integer categoryID) { // Clear the rule list form.dyngrdRules().getRows().clear(); // If the collection is null - interrupt if (listRules == null || listRules.size() == 0) { engine.showMessage("No rules matching the entered search criteria were found. ");//WDEV-18211 return; } // Iterate through the collection for (int i = 0; i < listRules.size(); i++) { BusinessRuleVo rule = listRules.get(i); // Add non nulls elements to the grid if (rule != null) { // Increment number on tree business rule category node TreeNode node = form.treRootEntity().getNodeByValue(rule.getCategory()); node.setIdentifier(((Integer) node.getIdentifier()) + 1); node.setText(((BusinessRuleCategory) node.getValue()).getText() + " (" + node.getIdentifier().toString() + ")"); if (categoryID != null) { if (categoryID.equals(rule.getCategory().getID())) { setRuleListRow(form.dyngrdRules().getRows().newRow(), rule); } } else { setRuleListRow(form.dyngrdRules().getRows().newRow(), rule); } } } form.dyngrdRules().setFooterValue("Total: " + String.valueOf(form.dyngrdRules().getRows().size()));//18211 }