use of org.kie.dmn.core.ast.DMNDecisionServiceFunctionDefinitionEvaluator.DSFormalParameter in project drools by kiegroup.
the class DecisionServiceCompiler method compileEvaluator.
@Override
public void compileEvaluator(DMNNode node, DMNCompilerImpl compiler, DMNCompilerContext ctx, DMNModelImpl model) {
DecisionServiceNodeImpl ni = (DecisionServiceNodeImpl) node;
List<DSFormalParameter> parameters = new ArrayList<>();
for (DMNElementReference er : ni.getDecisionService().getInputData()) {
String id = DMNCompilerImpl.getId(er);
InputDataNode input = model.getInputById(id);
String inputNamePrefix = inputQualifiedNamePrefix(input, model);
if (input != null) {
ni.addInputParameter(inputNamePrefix != null ? inputNamePrefix + "." + input.getName() : input.getName(), input);
parameters.add(new DSFormalParameter(inputNamePrefix, input.getName(), input.getType()));
} else {
MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, ni.getDecisionService(), model, null, null, Msg.REFERENCE_NOT_FOUND_FOR_DS, id, node.getName());
}
}
for (DMNElementReference er : ni.getDecisionService().getInputDecision()) {
String id = DMNCompilerImpl.getId(er);
DecisionNode input = model.getDecisionById(id);
String inputNamePrefix = inputQualifiedNamePrefix(input, model);
if (input != null) {
ni.addInputParameter(inputNamePrefix != null ? inputNamePrefix + "." + input.getName() : input.getName(), input);
parameters.add(new DSFormalParameter(inputNamePrefix, input.getName(), input.getResultType()));
} else {
MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, ni.getDecisionService(), model, null, null, Msg.REFERENCE_NOT_FOUND_FOR_DS, id, node.getName());
}
}
for (DMNElementReference er : ni.getDecisionService().getEncapsulatedDecision()) {
String id = DMNCompilerImpl.getId(er);
DecisionNode input = model.getDecisionById(id);
if (input != null) {
// nothing to do.
} else {
MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, ni.getDecisionService(), model, null, null, Msg.REFERENCE_NOT_FOUND_FOR_DS, id, node.getName());
}
}
List<DecisionNode> outputDecisions = new ArrayList<>();
for (DMNElementReference er : ni.getDecisionService().getOutputDecision()) {
String id = DMNCompilerImpl.getId(er);
DecisionNode outDecision = model.getDecisionById(id);
if (outDecision != null) {
outputDecisions.add(outDecision);
} else {
MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, ni.getDecisionService(), model, null, null, Msg.REFERENCE_NOT_FOUND_FOR_DS, id, node.getName());
}
}
boolean coerceSingleton = ((DMNCompilerConfigurationImpl) compiler.getDmnCompilerConfig()).getOption(CoerceDecisionServiceSingletonOutputOption.class).isCoerceSingleton();
DMNDecisionServiceFunctionDefinitionEvaluator exprEvaluator = new DMNDecisionServiceFunctionDefinitionEvaluator(ni, parameters, coerceSingleton);
ni.setEvaluator(exprEvaluator);
if (ni.getType() != null) {
checkFnConsistency(model, ni, ni.getType(), outputDecisions);
}
}
Aggregations