use of org.kie.dmn.model.v1_1.TDecisionTable in project drools by kiegroup.
the class XLS2DMNParser method appendDecisionDT.
private void appendDecisionDT(Definitions definitions, Map<String, DTHeaderInfo> headerInfos) {
for (DTHeaderInfo hi : headerInfos.values()) {
Decision decision = new TDecision();
decision.setName(hi.getSheetName());
decision.setId("d_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
InformationItem variable = new TInformationItem();
variable.setName(hi.getSheetName());
variable.setId("dvar_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
variable.setTypeRef(new QName("Any"));
decision.setVariable(variable);
for (String ri : hi.getRequiredInput()) {
InformationRequirement ir = new TInformationRequirement();
DMNElementReference er = new TDMNElementReference();
er.setHref("#id_" + CodegenStringUtil.escapeIdentifier(ri));
ir.setRequiredInput(er);
decision.getInformationRequirement().add(ir);
}
for (String ri : hi.getRequiredDecision()) {
InformationRequirement ir = new TInformationRequirement();
DMNElementReference er = new TDMNElementReference();
er.setHref("#d_" + CodegenStringUtil.escapeIdentifier(ri));
ir.setRequiredDecision(er);
decision.getInformationRequirement().add(ir);
}
DecisionTable dt = new TDecisionTable();
dt.setOutputLabel(hi.getSheetName());
dt.setId("ddt_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
dt.setHitPolicy(HitPolicy.ANY);
for (String ri : hi.getRequiredInput()) {
InputClause ic = new TInputClause();
ic.setLabel(ri);
LiteralExpression le = new TLiteralExpression();
le.setText(ri);
ic.setInputExpression(le);
dt.getInput().add(ic);
}
for (String rd : hi.getRequiredDecision()) {
InputClause ic = new TInputClause();
ic.setLabel(rd);
LiteralExpression le = new TLiteralExpression();
le.setText(rd);
ic.setInputExpression(le);
dt.getInput().add(ic);
}
OutputClause oc = new TOutputClause();
dt.getOutput().add(oc);
decision.setExpression(dt);
definitions.getDrgElement().add(decision);
}
}
use of org.kie.dmn.model.v1_1.TDecisionTable in project drools by kiegroup.
the class DMNDTAnalysisExceptionTest method smokeTest.
@Test
public void smokeTest() {
DecisionTable dtRef = new TDecisionTable();
DMNDTAnalysisException ut = new DMNDTAnalysisException("smoke test", dtRef);
Assertions.assertThat(ut.getDt()).isEqualTo(dtRef);
}
use of org.kie.dmn.model.v1_1.TDecisionTable in project kie-wb-common by kiegroup.
the class DecisionTablePropertyConverterTest method testWBFromDMNSingleOutputClauseTypeRef.
@Test
public void testWBFromDMNSingleOutputClauseTypeRef() {
final org.kie.dmn.model.api.DecisionTable dmn = new TDecisionTable();
final org.kie.dmn.model.api.OutputClause dmnOutputClause1 = new TOutputClause();
dmn.setId(UUID);
dmn.setDescription(DESCRIPTION);
dmn.setTypeRef(new QName(QNAME_LOCALPART));
dmnOutputClause1.setName(NAME);
dmnOutputClause1.setTypeRef(new QName(QNAME_LOCALPART + "-oc1"));
dmn.getOutput().add(dmnOutputClause1);
final DecisionTable wb = DecisionTablePropertyConverter.wbFromDMN(dmn);
assertThat(wb).isNotNull();
assertThat(wb.getId()).isNotNull();
assertThat(wb.getId().getValue()).isEqualTo(UUID);
assertThat(wb.getDescription()).isNotNull();
assertThat(wb.getDescription().getValue()).isEqualTo(DESCRIPTION);
assertThat(wb.getTypeRef()).isNotNull();
assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART);
assertThat(wb.getOutput()).hasSize(1);
final OutputClause wbOutputClause1 = wb.getOutput().get(0);
assertThat(wbOutputClause1.getName()).isNull();
assertThat(wbOutputClause1.getTypeRef()).isNull();
}
use of org.kie.dmn.model.v1_1.TDecisionTable in project kie-wb-common by kiegroup.
the class DecisionTablePropertyConverterTest method testWBFromDMNMultipleOutputClauseTypeRef.
@Test
public void testWBFromDMNMultipleOutputClauseTypeRef() {
final org.kie.dmn.model.api.DecisionTable dmn = new TDecisionTable();
final org.kie.dmn.model.api.OutputClause dmnOutputClause1 = new TOutputClause();
final org.kie.dmn.model.api.OutputClause dmnOutputClause2 = new TOutputClause();
dmn.setId(UUID);
dmn.setDescription(DESCRIPTION);
dmn.setTypeRef(new QName(QNAME_LOCALPART));
dmnOutputClause1.setName(NAME + "-oc1");
dmnOutputClause2.setName(NAME + "-oc2");
dmnOutputClause1.setTypeRef(new QName(QNAME_LOCALPART + "-oc1"));
dmnOutputClause2.setTypeRef(new QName(QNAME_LOCALPART + "-oc2"));
dmn.getOutput().add(dmnOutputClause1);
dmn.getOutput().add(dmnOutputClause2);
final DecisionTable wb = DecisionTablePropertyConverter.wbFromDMN(dmn);
assertThat(wb).isNotNull();
assertThat(wb.getId()).isNotNull();
assertThat(wb.getId().getValue()).isEqualTo(UUID);
assertThat(wb.getDescription()).isNotNull();
assertThat(wb.getDescription().getValue()).isEqualTo(DESCRIPTION);
assertThat(wb.getTypeRef()).isNotNull();
assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART);
assertThat(wb.getOutput()).hasSize(2);
final OutputClause wbOutputClause1 = wb.getOutput().get(0);
final OutputClause wbOutputClause2 = wb.getOutput().get(1);
assertThat(wbOutputClause1.getName()).isEqualTo(NAME + "-oc1");
assertThat(wbOutputClause2.getName()).isEqualTo(NAME + "-oc2");
assertThat(wbOutputClause1.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART + "-oc1");
assertThat(wbOutputClause2.getTypeRef().getLocalPart()).isEqualTo(QNAME_LOCALPART + "-oc2");
}
Aggregations