use of org.kie.dmn.validation.dtanalysis.model.DDTAOutputClause in project drools by kiegroup.
the class DMNDTAnalyser method compileTableOutputClauses.
private void compileTableOutputClauses(DMNModel model, DecisionTable dt, DDTATable ddtaTable) {
for (int jColIdx = 0; jColIdx < dt.getOutput().size(); jColIdx++) {
OutputClause oe = dt.getOutput().get(jColIdx);
Interval infDomain = new Interval(RangeBoundary.CLOSED, Interval.NEG_INF, Interval.POS_INF, RangeBoundary.CLOSED, 0, jColIdx + 1);
String allowedValues = null;
if (oe.getOutputValues() != null) {
allowedValues = oe.getOutputValues().getText();
} else {
QName outputTypeRef = (oe.getTypeRef() == null && dt.getOutput().size() == 1) ? dt.getTypeRef() : oe.getTypeRef();
if (outputTypeRef != null) {
QName typeRef = DMNCompilerImpl.getNamespaceAndName(dt, ((DMNModelImpl) model).getImportAliasesForNS(), outputTypeRef, model.getNamespace());
allowedValues = findAllowedValues(model, typeRef);
}
}
if (allowedValues != null) {
ProcessedUnaryTest compileUnaryTests = (ProcessedUnaryTest) FEEL.compileUnaryTests(allowedValues, FEEL.newCompilerContext());
UnaryTestInterpretedExecutableExpression interpreted = compileUnaryTests.getInterpreted();
UnaryTestListNode utln = (UnaryTestListNode) interpreted.getASTNode();
if (utln.getElements().size() != 1) {
verifyUnaryTestsAllEQ(utln, dt);
List<Comparable<?>> discreteValues = getDiscreteValues(utln);
List<Comparable<?>> outputOrder = new ArrayList<>(discreteValues);
Collections.sort((List) discreteValues);
Interval discreteDomainMinMax = new Interval(RangeBoundary.CLOSED, discreteValues.get(0), discreteValues.get(discreteValues.size() - 1), RangeBoundary.CLOSED, 0, jColIdx + 1);
DDTAOutputClause ic = new DDTAOutputClause(discreteDomainMinMax, discreteValues, outputOrder);
ddtaTable.getOutputs().add(ic);
} else if (utln.getElements().size() == 1) {
UnaryTestNode utn0 = (UnaryTestNode) utln.getElements().get(0);
Interval interval = utnToInterval(utn0, infDomain, null, 0, jColIdx + 1);
DDTAOutputClause ic = new DDTAOutputClause(interval);
ddtaTable.getOutputs().add(ic);
} else {
throw new IllegalStateException("inputValues not null but utln: " + utln);
}
} else {
DDTAOutputClause ic = new DDTAOutputClause(infDomain);
ddtaTable.getOutputs().add(ic);
}
}
}
Aggregations