Automatically get Input variables from decision table

Hello everyone,

I’m working at a rather complex decision model. My working DMN prototype has around 140 input variables in total and consists of many interconnected DMN tables. For testing, I have my program read those variables from a CSV so the engine can process them (I’m using a SpringBoot project). And that works just fine.
However, there are many cases where only a fraction of those inputs is necessary, because e.g. the result is always negative when a certain variable is false.
In those cases, I’d like to spare the user from entering the rest of the inputs. Therefore I want to subdivide the model into subsections, each only asking the user (probably via some kind of web form) for the required input data.

This sounds like a use case for bpmn to me. But I don’t want to hard code the input variables into my BPMN model or my input forms - there will likely be many changes and maintainability is an issue. So I tried sticking to DMN. My goal is to have a generic input form that looks at a decision table and asks the user for all the input variables this table depends on.

TL;DR My question is this: Is it possible to get the required inputs for a decision table at runtime (or at all) without explicitly declaring them anywhere but in the decision table itself? So far, I could only extract the inputs for a table via rest api and querying for its decision-definition. But since I have many decision tables feeding into one another, I also need the required inputs for the tables my main decision table depends on.

It would be super helpful if somebody could point me in the right direction. Thanks in advance!

Hi @VanGorg,

you can read your DMN model with the DMN Model api: Read a Model | docs.camunda.org

Hope this helps, Ingo

1 Like

I followed the suggestion of @Ingo_Richtsmeier (thank you!) and was a little embarrassed that I overlooked that. Well, with a little tweaking that solved the issue nicely. I adapted the code from the docs into two methods. One that finds all previous decisions a given decision depends on and a second one that extracts the inputs for those decisions.
For anyone interested, I’ll post the core of my solution here:

private List<Decision> getAllPreviousDecisions(Decision currentDecision) {
        //Recursively walks backwards in the decision process and returns all decisions that currentDecision depends on.
        List<Decision> resultList = new ArrayList<>();
        // get the information requirements
        Collection<InformationRequirement> informationRequirements =
                currentDecision.getInformationRequirements();

        for (InformationRequirement informationRequirement : informationRequirements) {
            Decision requiredDecision = informationRequirement.getRequiredDecision();
            resultList.add(requiredDecision);//Add found decision to results
            resultList.addAll(getAllPreviousDecisions(requiredDecision));//Check for further decisions down the line and add those, too.
        }

        return resultList;
    }

    private List<Input> getInputsFromDecisions(Collection<Decision> decisions){
        //Extracts all Inputs from a Collection of Decision objects.
        List<Input> allInputs = new ArrayList<>();
        for (Decision d : decisions){
            DecisionTable decisionTable = (DecisionTable) d.getUniqueChildElementByType(DecisionTable.class);
            allInputs.addAll(decisionTable.getInputs());
        }
        return allInputs;
    }

Keep in mind, this doesn’t check for duplicates and is probably not the most efficient solution! But it gets the job done on a basic level and can be optimized from there.