Search in sources :

Example 11 with InputData

use of org.kie.dmn.model.api.InputData in project drools by kiegroup.

the class InputDataCompiler method compileNode.

@Override
public void compileNode(DRGElement de, DMNCompilerImpl compiler, DMNModelImpl model) {
    InputData input = (InputData) de;
    InputDataNodeImpl idn = new InputDataNodeImpl(input);
    if (input.getVariable() != null) {
        DMNCompilerHelper.checkVariableName(model, input, input.getName());
        DMNType type = compiler.resolveTypeRef(model, de, input.getVariable(), input.getVariable().getTypeRef());
        idn.setType(type);
    } else {
        idn.setType(model.getTypeRegistry().unknown());
        DMNCompilerHelper.reportMissingVariable(model, de, input, Msg.MISSING_VARIABLE_FOR_INPUT);
    }
    model.addInput(idn);
}
Also used : InputData(org.kie.dmn.model.api.InputData) InputDataNodeImpl(org.kie.dmn.core.ast.InputDataNodeImpl) DMNType(org.kie.dmn.api.core.DMNType)

Example 12 with InputData

use of org.kie.dmn.model.api.InputData in project drools by kiegroup.

the class DefinitionsConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Definitions def = (Definitions) parent;
    for (Import i : def.getImport()) {
        writeChildrenNode(writer, context, i, IMPORT);
    }
    for (ItemDefinition id : def.getItemDefinition()) {
        writeChildrenNode(writer, context, id, ITEM_DEFINITION);
    }
    for (DRGElement e : def.getDrgElement()) {
        String nodeName = DRG_ELEMENT;
        if (e instanceof BusinessKnowledgeModel) {
            nodeName = "businessKnowledgeModel";
        } else if (e instanceof Decision) {
            nodeName = "decision";
        } else if (e instanceof InputData) {
            nodeName = "inputData";
        } else if (e instanceof KnowledgeSource) {
            nodeName = "knowledgeSource";
        } else if (e instanceof DecisionService) {
            nodeName = "decisionService";
        }
        writeChildrenNode(writer, context, e, nodeName);
    }
    for (Artifact a : def.getArtifact()) {
        String nodeName = ARTIFACT;
        if (a instanceof Association) {
            nodeName = "association";
        } else if (a instanceof TextAnnotation) {
            nodeName = "textAnnotation";
        }
        writeChildrenNode(writer, context, a, nodeName);
    }
    for (ElementCollection ec : def.getElementCollection()) {
        writeChildrenNode(writer, context, ec, ELEMENT_COLLECTION);
    }
    for (BusinessContextElement bce : def.getBusinessContextElement()) {
        String nodeName = BUSINESS_CONTEXT_ELEMENT;
        if (bce instanceof OrganizationUnit) {
            nodeName = "organizationUnit";
        } else if (bce instanceof PerformanceIndicator) {
            nodeName = "performanceIndicator";
        }
        writeChildrenNode(writer, context, bce, nodeName);
    }
    if (def.getDMNDI() != null) {
        writeChildrenNode(writer, context, def.getDMNDI(), "DMNDI");
    }
}
Also used : Import(org.kie.dmn.model.api.Import) PerformanceIndicator(org.kie.dmn.model.api.PerformanceIndicator) TDefinitions(org.kie.dmn.model.v1_2.TDefinitions) Definitions(org.kie.dmn.model.api.Definitions) ItemDefinition(org.kie.dmn.model.api.ItemDefinition) BusinessContextElement(org.kie.dmn.model.api.BusinessContextElement) Decision(org.kie.dmn.model.api.Decision) Artifact(org.kie.dmn.model.api.Artifact) DecisionService(org.kie.dmn.model.api.DecisionService) Association(org.kie.dmn.model.api.Association) KnowledgeSource(org.kie.dmn.model.api.KnowledgeSource) OrganizationUnit(org.kie.dmn.model.api.OrganizationUnit) BusinessKnowledgeModel(org.kie.dmn.model.api.BusinessKnowledgeModel) ElementCollection(org.kie.dmn.model.api.ElementCollection) InputData(org.kie.dmn.model.api.InputData) TextAnnotation(org.kie.dmn.model.api.TextAnnotation) DRGElement(org.kie.dmn.model.api.DRGElement)

Example 13 with InputData

use of org.kie.dmn.model.api.InputData in project drools by kiegroup.

the class DMNExtensionRegisterTest method testUsingSystemProperty.

@Test
public void testUsingSystemProperty() {
    try {
        System.setProperty("org.kie.dmn.profiles.FirstNameLastNameProfile", FirstNameLastNameProfile.class.getCanonicalName());
        assertEquals(FirstNameLastNameProfile.class.getCanonicalName(), System.getProperty("org.kie.dmn.profiles.FirstNameLastNameProfile"));
        final DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string-with-extensions.dmn", this.getClass());
        final DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0001-input-data-string");
        assertThat(dmnModel, notNullValue());
        assertThat(formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
        assertEquals(3, dmnModel.getDefinitions().getDrgElement().size());
        final InputData inputData1 = (InputData) dmnModel.getDefinitions().getDrgElement().get(1);
        assertEquals("First Name", inputData1.getName());
        final DMNElement.ExtensionElements id1elements = inputData1.getExtensionElements();
        assertNotNull(id1elements);
        assertEquals(1, id1elements.getAny().size());
        final FirstNameDescription firstNameDescription = (FirstNameDescription) id1elements.getAny().get(0);
        assertEquals("First name in latin characters", firstNameDescription.getContent());
        final InputData inputData2 = (InputData) dmnModel.getDefinitions().getDrgElement().get(2);
        assertEquals("Last Name", inputData2.getName());
        final DMNElement.ExtensionElements id2elements = inputData2.getExtensionElements();
        assertNotNull(id2elements);
        assertEquals(1, id2elements.getAny().size());
        final LastNameDescription lastNameDescription = (LastNameDescription) id2elements.getAny().get(0);
        assertEquals("Last name in latin characters", lastNameDescription.getContent());
    } catch (final Exception e) {
        LOG.error("{}", e.getLocalizedMessage(), e);
        throw e;
    } finally {
        System.clearProperty("org.kie.dmn.profiles.FirstNameLastNameProfile");
        assertNull(System.getProperty("org.kie.dmn.profiles.FirstNameLastNameProfile"));
    }
}
Also used : DMNElement(org.kie.dmn.model.api.DMNElement) InputData(org.kie.dmn.model.api.InputData) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) Test(org.junit.Test)

Example 14 with InputData

use of org.kie.dmn.model.api.InputData in project drools by kiegroup.

the class DefinitionsConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Definitions def = (Definitions) parent;
    for (Import i : def.getImport()) {
        writeChildrenNode(writer, context, i, IMPORT);
    }
    for (ItemDefinition id : def.getItemDefinition()) {
        writeChildrenNode(writer, context, id, ITEM_DEFINITION);
    }
    for (DRGElement e : def.getDrgElement()) {
        String nodeName = DRG_ELEMENT;
        if (e instanceof BusinessKnowledgeModel) {
            nodeName = "businessKnowledgeModel";
        } else if (e instanceof Decision) {
            nodeName = "decision";
        } else if (e instanceof InputData) {
            nodeName = "inputData";
        } else if (e instanceof KnowledgeSource) {
            nodeName = "knowledgeSource";
        }
        writeChildrenNode(writer, context, e, nodeName);
    }
    for (Artifact a : def.getArtifact()) {
        String nodeName = ARTIFACT;
        if (a instanceof Association) {
            nodeName = "association";
        } else if (a instanceof TextAnnotation) {
            nodeName = "textAnnotation";
        }
        writeChildrenNode(writer, context, a, nodeName);
    }
    for (ElementCollection ec : def.getElementCollection()) {
        writeChildrenNode(writer, context, ec, ELEMENT_COLLECTION);
    }
    for (BusinessContextElement bce : def.getBusinessContextElement()) {
        String nodeName = BUSINESS_CONTEXT_ELEMENT;
        if (bce instanceof OrganizationUnit) {
            nodeName = "organizationUnit";
        } else if (bce instanceof PerformanceIndicator) {
            nodeName = "performanceIndicator";
        }
        writeChildrenNode(writer, context, bce, nodeName);
    }
}
Also used : Import(org.kie.dmn.model.api.Import) PerformanceIndicator(org.kie.dmn.model.api.PerformanceIndicator) TDefinitions(org.kie.dmn.model.v1_1.TDefinitions) Definitions(org.kie.dmn.model.api.Definitions) ItemDefinition(org.kie.dmn.model.api.ItemDefinition) BusinessContextElement(org.kie.dmn.model.api.BusinessContextElement) Decision(org.kie.dmn.model.api.Decision) Artifact(org.kie.dmn.model.api.Artifact) Association(org.kie.dmn.model.api.Association) KnowledgeSource(org.kie.dmn.model.api.KnowledgeSource) OrganizationUnit(org.kie.dmn.model.api.OrganizationUnit) BusinessKnowledgeModel(org.kie.dmn.model.api.BusinessKnowledgeModel) ElementCollection(org.kie.dmn.model.api.ElementCollection) InputData(org.kie.dmn.model.api.InputData) TextAnnotation(org.kie.dmn.model.api.TextAnnotation) DRGElement(org.kie.dmn.model.api.DRGElement)

Example 15 with InputData

use of org.kie.dmn.model.api.InputData in project drools by kiegroup.

the class InputDataConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    InputData id = (InputData) parent;
    if (id.getVariable() != null) {
        writeChildrenNode(writer, context, id.getVariable(), VARIABLE);
    }
}
Also used : TInputData(org.kie.dmn.model.v1_1.TInputData) InputData(org.kie.dmn.model.api.InputData)

Aggregations

InputData (org.kie.dmn.model.api.InputData)19 Decision (org.kie.dmn.model.api.Decision)6 DRGElement (org.kie.dmn.model.api.DRGElement)5 Definitions (org.kie.dmn.model.api.Definitions)5 Test (org.junit.Test)4 Artifact (org.kie.dmn.model.api.Artifact)4 Association (org.kie.dmn.model.api.Association)4 BusinessContextElement (org.kie.dmn.model.api.BusinessContextElement)4 BusinessKnowledgeModel (org.kie.dmn.model.api.BusinessKnowledgeModel)4 ElementCollection (org.kie.dmn.model.api.ElementCollection)4 Import (org.kie.dmn.model.api.Import)4 ItemDefinition (org.kie.dmn.model.api.ItemDefinition)4 KnowledgeSource (org.kie.dmn.model.api.KnowledgeSource)4 OrganizationUnit (org.kie.dmn.model.api.OrganizationUnit)4 PerformanceIndicator (org.kie.dmn.model.api.PerformanceIndicator)4 TextAnnotation (org.kie.dmn.model.api.TextAnnotation)4 DMNModel (org.kie.dmn.api.core.DMNModel)3 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)3 DMNElement (org.kie.dmn.model.api.DMNElement)3 DecisionService (org.kie.dmn.model.api.DecisionService)3