Search in sources :

Example 1 with TOutputClause

use of org.kie.dmn.model.v1_3.TOutputClause 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);
    }
}
Also used : TInformationRequirement(org.kie.dmn.model.v1_2.TInformationRequirement) QName(javax.xml.namespace.QName) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) LiteralExpression(org.kie.dmn.model.api.LiteralExpression) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) InformationItem(org.kie.dmn.model.api.InformationItem) TLiteralExpression(org.kie.dmn.model.v1_2.TLiteralExpression) Decision(org.kie.dmn.model.api.Decision) TDecision(org.kie.dmn.model.v1_2.TDecision) OutputClause(org.kie.dmn.model.api.OutputClause) TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) DecisionTable(org.kie.dmn.model.api.DecisionTable) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) DMNElementReference(org.kie.dmn.model.api.DMNElementReference) TDMNElementReference(org.kie.dmn.model.v1_2.TDMNElementReference) TInputClause(org.kie.dmn.model.v1_2.TInputClause) TInformationRequirement(org.kie.dmn.model.v1_2.TInformationRequirement) InformationRequirement(org.kie.dmn.model.api.InformationRequirement) TDecision(org.kie.dmn.model.v1_2.TDecision) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) TDMNElementReference(org.kie.dmn.model.v1_2.TDMNElementReference) TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) TInputClause(org.kie.dmn.model.v1_2.TInputClause) InputClause(org.kie.dmn.model.api.InputClause)

Example 2 with TOutputClause

use of org.kie.dmn.model.v1_3.TOutputClause 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();
}
Also used : TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) QName(javax.xml.namespace.QName) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) Test(org.junit.Test)

Example 3 with TOutputClause

use of org.kie.dmn.model.v1_3.TOutputClause 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");
}
Also used : TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) QName(javax.xml.namespace.QName) TDecisionTable(org.kie.dmn.model.v1_2.TDecisionTable) TOutputClause(org.kie.dmn.model.v1_2.TOutputClause) Test(org.junit.Test)

Aggregations

QName (javax.xml.namespace.QName)3 TDecisionTable (org.kie.dmn.model.v1_2.TDecisionTable)3 TOutputClause (org.kie.dmn.model.v1_2.TOutputClause)3 Test (org.junit.Test)2 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)2 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)2 DMNElementReference (org.kie.dmn.model.api.DMNElementReference)1 Decision (org.kie.dmn.model.api.Decision)1 DecisionTable (org.kie.dmn.model.api.DecisionTable)1 InformationItem (org.kie.dmn.model.api.InformationItem)1 InformationRequirement (org.kie.dmn.model.api.InformationRequirement)1 InputClause (org.kie.dmn.model.api.InputClause)1 LiteralExpression (org.kie.dmn.model.api.LiteralExpression)1 OutputClause (org.kie.dmn.model.api.OutputClause)1 TDMNElementReference (org.kie.dmn.model.v1_2.TDMNElementReference)1 TDecision (org.kie.dmn.model.v1_2.TDecision)1 TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)1 TInformationRequirement (org.kie.dmn.model.v1_2.TInformationRequirement)1 TInputClause (org.kie.dmn.model.v1_2.TInputClause)1 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)1