All my (rule) methods are in java util class (refer to Util class below)
From the decision table – DefinePromotionStatus, DefineTopLevelRecommendation – I need to pass an attribute of customer object – customer.getJobAttrs() and DefineResult – I need to pass customer and response object
How do I specify this in my decision table.
Also, please glance thro my entire test case and let me know if you see
any obvious mistakes.
Class Customer {
String name;
String id;
String dept;
Map<String, String> jobAttrs;
}
Class Response {
Boolean isEligible;
String result;
}
Class Controller{
Customer c = new Customer();
c.setName(“RJ Drobick”);
c.setId(86182618);
c.setDept(“Executive”);
Map<String, String> attrs = new HashMap<String, String>();
attrs.put(“Business_awards”, “B102,B6772”);
attrs.put(“Papers_submitted”, “P898,P6151”);
attrs.put(“Recommendations”, “3”);
c.setJobsAttrs(attrs);
Response resp = new Response();
String filename = “file:rules/main/CustomerRules.xls”;
Decision decision = new Decision(“DetermineCustomerPromotionEligibility”, filename);
decision.put(“Customer”, c);
decision.put(“Response”, resp);
decision.execute();
System.out.println(decision.getOutput());
}
Class Utils {
static boolean isEligibleForPromotion(Map<String, String> attrs){
if (...)
return true;
}
return false;
}
static Map<String, String> addJobAttribute(Map<String, String> attrMap, String attrName, String attrValue){
attrMap.put(attrName, attrValue);
return attrMap;
}
static String getCongratulatoryMessage(Response resp, Cutomer customer){
if (resp.isEligible()) {
return “Congratulations ” + customer.getName() + “!! You are promoted.”;
} else {
return “Sorry ” + customer.getName() + “ Better luck next year”;
}
}
}
DecisionObject decisionObjects |
|
Business Concept |
Business Object |
Customer |
:= decision.get(“c”); |
Response |
:= decision.get(“resp”); |
Decision DetermineCustomerPromotionEligibility |
|
Decisions |
Execute Decision Tables |
Define Promotion Eligibility |
DefinePromotionStatus |
Define Special Recommendation |
DefineTopLevelRecommendation |
Define Result |
DefineResult |
Define Decision Output |
:= decision.setOutput(${Congratulatory Message}); |
Decision Tables
DecisionTable DefinePromotionStatus |
|
Conclusion |
|
Eligible for Promotion |
|
Is |
::=Utils.isEligibleForPromotion(customer.getJobAttrs()) |
DecisionTable DefineTopLevelRecommendation |
||
Condition |
Conclusion |
|
Name |
Job Attributes |
|
‘==’ |
“RJ Drobick” |
::=Utils.addJobAttribute(customer.getJobAttrs(), “isSpecialRecommendation”, “true”) |
DecisionTable DefineResult |
|
Conclusion |
|
Congratulatory Message |
|
Is |
::=Utils. getCongratulatoryMessage(response, customer) |
Glossary |
||
Variable |
Business Concept |
Attribute |
Name |
Customer
|
Name |
Id |
Id |
|
Department |
Dept |
|
Job Attributes |
jobAttrs |
|
Eligible for Promotion |
Response |
isEligible |
Congratulatory Message |
Result |
...<w:LsdException Locked="false" Priority="65" SemiHidden="false"