Determining all DMN input variables

Is it possible to determine all required input variables to a DMN / DRD model?

If I invoke the “evaluateDecision” method via the Java API without passing a required variable I can catch a “PropertyNotFoundException” one by one and display that, but I’d like to be able to retrieve all required variables before the execution occurs.

The DMN simulation page here https://camunda.com/dmn/simulator/ manages it, but I can’t find the right API calls to make to get the same info.

One other thing, the DMN is already deployed so is in the repository, and comes back as a DecisionDefinition object.

Thanks Steve

Hi @steve,

you have to parse the decision table with the model API: https://docs.camunda.org/manual/7.12/user-guide/model-api/dmn-model-api/read-a-model/

Hope this helps, Ingo

1 Like

@Ingo_Richtsmeier When will you create a REST API for the DMN engine? It seems to me that the REST API for BPMN is more complete than the DMN (where Java API is richer).

Hi @Finnur_Olafsson,

What do you mean by

When will you create a REST API for the DMN engine?

I think that your question is not much related to the original topic and deserves a new thread.

There is space to clarify your question.

Cheers, Ingo

Hi @Ingo_Richtsmeier!

Your answer to the original topic was to use the Model API to get the relevant information. However, that is a Java API. We only use REST API (as Bernd has said; you can totally use Camunda without Java by just using the REST APIs). That is why I asked if a Model REST API would be created since this is missing. Or do you have another suggestion on how to solve the original topic using current REST APIs?

Kind regards,
Finnur

Hi @Finnur_Olafsson,

if you don’t want (or cannot) use the Java API, try out the dmn-moddle API from BPMN.io: https://github.com/bpmn-io/dmn-moddle

But it is an unknown country for me…

Hope this helps, Ingo

Thanks for everyone’s help - just to feedback we ended up getting it working via the Java API - it was pretty easy in the end…

public Map<String, InputImpl> getDecisionDefinitionInputs(DmnModelInstance modelInstance, String tableIdFilter)
{
    Map<String, InputImpl> dmnInputs = new HashMap<>();

    Collection<DecisionTable> tables = modelInstance.getModelElementsByType(DecisionTable.class);
    for (DecisionTable table : tables)
    {
        if (tableIdFilter != null && !tableIdFilter
                .startsWith(table.getParentElement().getAttributeValue("id") + ":"))
            continue;

        Collection<Input> inputs = table.getInputs();
        for (Input input : inputs)
        {
            InputImpl inputImpl = ((InputImpl) input);

            log.debug("Input : {}, {}, {}, {}", inputImpl.getId(), inputImpl.getLabel(),
                      inputImpl.getInputExpression().getTextContent(), inputImpl.getInputExpression().getTypeRef());

            if (!dmnInputs.containsKey(inputImpl.getId()))
                dmnInputs.put(inputImpl.getId(), inputImpl);
        }
    }

    return dmnInputs;
}