Visualisations
Providing a visual representation of decision logic is a core concern of Decisions4s. Below we present the available ways of generating such representation.
Markdown
Markdown representation is provided out-of-the box in the core module.
import decisions4s.*
val decisionTable: DecisionTable[Input, Output, ?] = ???
val markdown: String = MarkdownRenderer.render(decisionTable)
Decision Model and Notation (DMN)
DMN model can be generated using the following dependency:
"org.business4s" %% "decisions4s-dmn" % "0.0.1"
import decisions4s.dmn.*
val dmnXml: String = DmnRenderer.render(decisionTable).toXML
DMN As Image
DMN is an XML file that is not human-friendly without a way to render it. Decisions4s comes with an additional utility that allows converting the DMN into an image through dmn-js library.
Rendering the image involves running a web browser through Selenium and capturing screenshots from there. By default, the assumed browser is Chrome and so ChromeDriver needs to be installed.
This process is rather slow and not recommended for live server-side usage.
"org.business4s" %% "decisions4s-dmn-to-image" % "0.0.1"
import decisions4s.dmn.image.*
val converter = DmnToImageConverter()
converter.convertDiagram(dmnXml)
Alternative Visualizations
It's possible to convert DecisionTable
s into other formats, e.g., csv file or alternative markdown representations.
Users are encouraged
to write their own representations
using decisions4s.internal.RenderUtils.prepare
that converts a decision table to a structured format ready for further customizations.