Search in sources :

Example 26 with DMNElementReference

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

the class DecisionConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    Decision dec = (Decision) parent;
    if (dec.getQuestion() != null)
        writeChildrenNodeAsValue(writer, context, dec.getQuestion(), QUESTION);
    if (dec.getAllowedAnswers() != null)
        writeChildrenNodeAsValue(writer, context, dec.getAllowedAnswers(), ALLOWED_ANSWERS);
    if (dec.getVariable() != null)
        writeChildrenNode(writer, context, dec.getVariable(), VARIABLE);
    for (InformationRequirement ir : dec.getInformationRequirement()) {
        writeChildrenNode(writer, context, ir, INFORMATION_REQUIREMENT);
    }
    for (KnowledgeRequirement kr : dec.getKnowledgeRequirement()) {
        writeChildrenNode(writer, context, kr, KNOWLEDGE_REQUIREMENT);
    }
    for (AuthorityRequirement ar : dec.getAuthorityRequirement()) {
        writeChildrenNode(writer, context, ar, AUTHORITY_REQUIREMENT);
    }
    for (DMNElementReference so : dec.getSupportedObjective()) {
        writeChildrenNode(writer, context, so, SUPPORTED_OBJECTIVE);
    }
    for (DMNElementReference ipi : dec.getImpactedPerformanceIndicator()) {
        writeChildrenNode(writer, context, ipi, IMPACTED_PERFORMANCE_INDICATOR);
    }
    for (DMNElementReference dm : dec.getDecisionMaker()) {
        writeChildrenNode(writer, context, dm, DECISION_MAKER);
    }
    for (DMNElementReference downer : dec.getDecisionOwner()) {
        writeChildrenNode(writer, context, downer, DECISION_OWNER);
    }
    for (DMNElementReference up : dec.getUsingProcess()) {
        writeChildrenNode(writer, context, up, USING_PROCESS);
    }
    for (DMNElementReference ut : dec.getUsingTask()) {
        writeChildrenNode(writer, context, ut, USING_TASK);
    }
    if (dec.getExpression() != null) {
        Expression e = dec.getExpression();
        String nodeName = MarshallingUtils.defineExpressionNodeName(xstream, e);
        writeChildrenNode(writer, context, e, nodeName);
    }
}
Also used : KnowledgeRequirement(org.kie.dmn.model.api.KnowledgeRequirement) DMNElementReference(org.kie.dmn.model.api.DMNElementReference) InformationRequirement(org.kie.dmn.model.api.InformationRequirement) Expression(org.kie.dmn.model.api.Expression) AuthorityRequirement(org.kie.dmn.model.api.AuthorityRequirement) Decision(org.kie.dmn.model.api.Decision) TDecision(org.kie.dmn.model.v1_4.TDecision)

Example 27 with DMNElementReference

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

the class DecisionServiceConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    DecisionService decisionService = (DecisionService) parent;
    for (DMNElementReference ref : decisionService.getOutputDecision()) {
        writeChildrenNode(writer, context, ref, OUTPUT_DECISION);
    }
    for (DMNElementReference ref : decisionService.getEncapsulatedDecision()) {
        writeChildrenNode(writer, context, ref, ENCAPSULATED_DECISION);
    }
    for (DMNElementReference ref : decisionService.getInputDecision()) {
        writeChildrenNode(writer, context, ref, INPUT_DECISION);
    }
    for (DMNElementReference ref : decisionService.getInputData()) {
        writeChildrenNode(writer, context, ref, INPUT_DATA);
    }
}
Also used : DMNElementReference(org.kie.dmn.model.api.DMNElementReference) TDMNElementReference(org.kie.dmn.model.v1_4.TDMNElementReference) TDecisionService(org.kie.dmn.model.v1_4.TDecisionService) DecisionService(org.kie.dmn.model.api.DecisionService)

Example 28 with DMNElementReference

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

the class DMNElementReferenceConverter method writeAttributes.

@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
    super.writeAttributes(writer, parent);
    DMNElementReference er = (DMNElementReference) parent;
    if (er.getHref() != null)
        writer.addAttribute(HREF, er.getHref());
}
Also used : DMNElementReference(org.kie.dmn.model.api.DMNElementReference) TDMNElementReference(org.kie.dmn.model.v1_4.TDMNElementReference)

Example 29 with DMNElementReference

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

the class ValidatorImportTest method testWrongImportBaseModelFromReaderInput.

@Test
public void testWrongImportBaseModelFromReaderInput() throws IOException {
    try (final Reader reader0 = getReader("import/Base-model.dmn");
        final Reader reader1 = getReader("import/Wrong-Import-base-model.dmn")) {
        final List<DMNMessage> messages = validator.validateUsing(Validation.VALIDATE_MODEL).theseModels(reader0, reader1);
        assertThat(ValidatorUtil.formatMessages(messages), messages.size(), is(1));
        assertTrue(messages.stream().anyMatch(p -> p.getMessageType().equals(DMNMessageType.REQ_NOT_FOUND) && p.getSourceReference() instanceof DMNElementReference && ((DMNElementReference) p.getSourceReference()).getHref().equals("http://www.trisotech.com/definitions/_70df1ad5-2a33-4ede-b8b2-869988ac1d30#_1d52934e-aa4e-47c9-a011-fc989d795664")));
    }
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Arrays(java.util.Arrays) DMNElementReference(org.kie.dmn.model.api.DMNElementReference) DMNMessage(org.kie.dmn.api.core.DMNMessage) DMNResult(org.kie.dmn.api.core.DMNResult) DMNMessageType(org.kie.dmn.api.core.DMNMessageType) LoggerFactory(org.slf4j.LoggerFactory) DynamicTypeUtils.entry(org.kie.dmn.core.util.DynamicTypeUtils.entry) ValidatorImportReaderResolver(org.kie.dmn.validation.DMNValidator.ValidatorBuilder.ValidatorImportReaderResolver) Definitions(org.kie.dmn.model.api.Definitions) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) BigDecimal(java.math.BigDecimal) DMNModel(org.kie.dmn.api.core.DMNModel) Validation(org.kie.dmn.validation.DMNValidator.Validation) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DMNFactory(org.kie.dmn.core.api.DMNFactory) Logger(org.slf4j.Logger) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) Reader(java.io.Reader) DMNRuntimeUtil(org.kie.dmn.core.util.DMNRuntimeUtil) DMNDecisionServicesTest(org.kie.dmn.core.decisionservices.DMNDecisionServicesTest) DynamicTypeUtils.mapOf(org.kie.dmn.core.util.DynamicTypeUtils.mapOf) List(java.util.List) Ignore(org.junit.Ignore) DMNContext(org.kie.dmn.api.core.DMNContext) DMNMessage(org.kie.dmn.api.core.DMNMessage) DMNElementReference(org.kie.dmn.model.api.DMNElementReference) Reader(java.io.Reader) Test(org.junit.Test) DMNDecisionServicesTest(org.kie.dmn.core.decisionservices.DMNDecisionServicesTest)

Example 30 with DMNElementReference

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

the class PerformanceIndicatorConverter method writeChildren.

@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
    super.writeChildren(writer, context, parent);
    PerformanceIndicator pi = (PerformanceIndicator) parent;
    for (DMNElementReference id : pi.getImpactingDecision()) {
        writeChildrenNode(writer, context, id, IMPACTING_DECISION);
    }
}
Also used : PerformanceIndicator(org.kie.dmn.model.api.PerformanceIndicator) TPerformanceIndicator(org.kie.dmn.model.v1_3.TPerformanceIndicator) DMNElementReference(org.kie.dmn.model.api.DMNElementReference)

Aggregations

DMNElementReference (org.kie.dmn.model.api.DMNElementReference)36 Decision (org.kie.dmn.model.api.Decision)5 InformationRequirement (org.kie.dmn.model.api.InformationRequirement)5 TDMNElementReference (org.kie.dmn.model.v1_2.TDMNElementReference)5 AuthorityRequirement (org.kie.dmn.model.api.AuthorityRequirement)4 DMNModelInstrumentedBase (org.kie.dmn.model.api.DMNModelInstrumentedBase)4 DecisionService (org.kie.dmn.model.api.DecisionService)4 ElementCollection (org.kie.dmn.model.api.ElementCollection)4 Expression (org.kie.dmn.model.api.Expression)4 KnowledgeRequirement (org.kie.dmn.model.api.KnowledgeRequirement)4 OrganizationUnit (org.kie.dmn.model.api.OrganizationUnit)4 PerformanceIndicator (org.kie.dmn.model.api.PerformanceIndicator)4 TDMNElementReference (org.kie.dmn.model.v1_1.TDMNElementReference)4 TDMNElementReference (org.kie.dmn.model.v1_3.TDMNElementReference)4 TDMNElementReference (org.kie.dmn.model.v1_4.TDMNElementReference)4 IOException (java.io.IOException)2 Reader (java.io.Reader)2 Arrays (java.util.Arrays)2 List (java.util.List)2 CoreMatchers.is (org.hamcrest.CoreMatchers.is)2