class ExecuteDMNCommand implements ExecutableCommand<DMNResult> {

    @Override
    public DMNResult execute(Context context) {
        RegistryContext registryContext = (RegistryContext) context;
        DMNModel activeModel = registryContext.lookup(DMNModel.class);
        DMNRuntime dmnRuntime = registryContext.lookup(DMNRuntime.class);
        DMNContext dmnContext = registryContext.lookup(DMNContext.class);
        if (activeModel == null) {
            throw new IllegalStateException("No DMN active model defined");
        }
        if (dmnRuntime == null) {
            throw new IllegalStateException("No DMNRuntime available");
        }
        if (dmnContext == null) {
            dmnContext = dmnRuntime.newContext();
        }
        DMNResult dmnResult = dmnRuntime.evaluateAll(activeModel, dmnContext);
        registryContext.register(DMNResult.class, dmnResult);

        // reset context
        registryContext.register(DMNContext.class, dmnRuntime.newContext());

        return dmnResult;
    }

}