Dynamic Decision Glossaries

OpenRules decisions use business glossaries that are usually presented in Excel tables that may look like this table “glossary”:

The column “Variable Name” refers to decision variables mentioned in all rules (decision tables) under these names (any combination of words in plain English). The column “Business Concepts” refers to business concepts, to which the variables belong. Business users do not worry about how these concepts are defined – the same decision should continue to work in the same way independently whether these concepts are associated with Java objects or with Excel Data tables (used for testing). The column “Attributes” specify technical names of the attributes that represent variable names (no spaces allowed). For example, attributes may correspond to members of Java classes associated with business concepts.

The objective of this post is to explain the use of the OpenRules Glossary API for more complex practical situations. In large, real-world projects the actual content of business concepts such as the above “Customer” can be defined in external applications using Java-based Business Object Models or they may come from XML files, a database table, etc. The list of attributes inside business objects can be very large and/or to be defined dynamically.

In such cases, you do not want to repeat all attributes in your Excel-based glossary and then worry about keeping the glossary synchronized with an IT implementation. However, it is possible to programmatically define/extend the definition of the Glossary. For example, we may leave in the Excel’s glossary only statically defined business concepts and their decision variables, e.g. in the above table we may keep only the variables of the concept “Response” and remove all rows related to the concept “Customer”. Then in the Java module that creates an object “decision” of the predefined type Decision we may add the following code:

Decision decision = new Decision(fileName);
String[] attributes = getCustomerAttributes();
String businessConcept = “Customer”;
for (int i = 0; i < attributes.length; i++) {
      String varName = attributes[i].getName();
      decision.getGlossary().put(varName,businessConcept,varName);
}

decision.put(“customer”, customer);
decision.execute();

Here we assume that the method getCustomerAttributes() returns the names of attributes defined in the class Customer. The variable name and the attribute name are the same for simplicity – of course you may defined them differently.

You may add multiple concepts to the Glossary in a similar way. In  all cases keep in mind that the table “Glossary glossary” always has to be present in your Excel repository even when it contain no rows. You also may find that the same method “put(varName, businessConcept, attributeName)” of the class Glossary is used in the Glossary Template definition in the standard file “DecisionTemplates.xls”.

Advertisement
This entry was posted in Decision Management, OpenRules Specific and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s