DMN Interchange Software

The DMN 1.1 standard includes a new interchange format that soon will become public. The objective of this software is to help vendors to create their own readers (parsers) of the standard DMN XML files and generators of their own decision models based on the parsed files.

Below  is a brief description of the Java package “org.dmn.xml” that was initially created by OpenRules to address a simple DMCommunity Apr-2016 Challenge.  It includes the following Java classes that you may download with a simple click and use without any restrictions:

  • DecisionTable.java – a placeholder for all elements of DMN-based decision tables. Currently it includes:
    • table’s name
    • hit policy
    • array of input variables (their names)
    • array of output variables (their names)
    • array of rules

These arrays are dynamic (implemented  as ArrayList) and you may add elements to these arrays.

  • Rule.java – a placeholder for all rules inside DMN-based decision tables. Currently a rule includes:
    • array of input entries (strings)
    • array of output entries (string)

These entries correspond to columns described as arrays of input and output variables in the above decision table.

  • DmnXmlReader.java – an abstract class that can read a DMN file and extract key decision model elements from this file. The current implementation extracts all decision tables only and represents them in an array of the instances of the class DecisionTable. It includes the following  implemented methods:
    • readDecisionTables(name-of-of input-file): it read the input file formatted using DMN XML and produces ArrayList<DecisionTable>.
    • Currently this method looks for tags “decisionTable” inside parent-tags recognized by keywords “decision” and “businessKnowledgeModel” /   “encapsulatedLogic”. We need to know the parent tags to only use their names as teh default values for empty output columns inside decision tables. However, if we assume that output columns always include non-empty variable names (that could be easily done by the DMN XML generators), we would not need parent tags and may search for all decision tables across the entire xml-file.
    • The vendor specific abstract methods are the following:
      • String processInputFormula(String entry)
      • String processOutputFormula(String entry)
      • String processNotApplicableEntry(String entry)
      • They allow a specific vendor to provide their own treatment of teh read input entries. For example, you may replace the default N/A character ‘-‘ with a space.

Each vendor may create a concrete subclass (e.g. DmnXmlReaderOpenRules) that overrides the above abstract methods. We expect to ad more methods as we expand this base vendor-neutral class to handle other DMN constructs beyond decision tables.

  • DecisionTableGenerator – an interface that currently defines only one method “generate” with two parameters: an array of decision tables generated by DmnXmlReader and the name of the file in which all these tables should be written. In particular, the implementation called DecisionTableGeneratorOpenRules generates all decision tables into an Excel file in the OpenRules format. It should be easy for other vendors to create their own generators.

Here is an example of a simple test that uses these classes:

public static void main(String argv[]) {
      DmnXmlReader reader = new DmnXmlReaderOpenRules();
      ArrayList<DecisionTable> decisionTables =                  reader.readDecisionTables(“./xml/VacationDaysChallenge.xml”);
      DecisionTableGenerator generator = new DecisionTableGeneratorOpenRules();
      generator.generate(decisionTables,”./xls/VacationDaysChallenge.xls”);
}

We expect that DMCommunity will enrich these classes to cover the entire DMN XML format. These free common pieces of software would be helpful to promote the DMN interchange among different BR&DM vendors.

Leave a Reply

Please log in using one of these methods to post your comment:

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 )

Google+ photo

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

Connecting to %s