Search in sources :

Example 6 with DecisionService

use of org.kie.dmn.model.api.DecisionService 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 7 with DecisionService

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

the class DMNValidatorImpl method validateModel.

private List<DMNMessage> validateModel(DMNResource mainModel, List<DMNResource> otherModels) {
    Definitions mainDefinitions = mainModel.getDefinitions();
    StatelessKieSession kieSession = mainDefinitions instanceof org.kie.dmn.model.v1_1.KieDMNModelInstrumentedBase ? kb11.newStatelessKieSession() : kb12.newStatelessKieSession();
    MessageReporter reporter = new MessageReporter(mainModel);
    kieSession.setGlobal("reporter", reporter);
    // exclude dynamicDecisionService for validation
    List<DMNModelInstrumentedBase> dmnModelElements = allChildren(mainDefinitions).filter(d -> !(d instanceof DecisionService && Boolean.parseBoolean(d.getAdditionalAttributes().get(new QName("http://www.trisotech.com/2015/triso/modeling", "dynamicDecisionService"))))).collect(toList());
    List<Definitions> otherModelsDefinitions = otherModels.stream().map(DMNResource::getDefinitions).collect(Collectors.toList());
    BatchExecutionCommand batch = CommandFactory.newBatchExecution(Arrays.asList(CommandFactory.newInsertElements(dmnModelElements, "DEFAULT", false, "DEFAULT"), CommandFactory.newInsertElements(otherModelsDefinitions, "DMNImports", false, "DMNImports")));
    kieSession.execute(batch);
    return reporter.getMessages().getMessages();
}
Also used : Arrays(java.util.Arrays) DMNModelInstrumentedBase(org.kie.dmn.model.api.DMNModelInstrumentedBase) DMNMessage(org.kie.dmn.api.core.DMNMessage) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) DMNCompilerImpl(org.kie.dmn.core.compiler.DMNCompilerImpl) FileSystemResource(org.drools.core.io.impl.FileSystemResource) CommandFactory(org.kie.internal.command.CommandFactory) XStreamMarshaller(org.kie.dmn.backend.marshalling.v1x.XStreamMarshaller) DMNModel(org.kie.dmn.api.core.DMNModel) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) ResourceWithConfigurationImpl(org.kie.internal.io.ResourceWithConfigurationImpl) DMNAssemblerService(org.kie.dmn.core.assembler.DMNAssemblerService) DMNCompilerConfiguration(org.kie.dmn.api.core.DMNCompilerConfiguration) DMNProfile(org.kie.dmn.core.compiler.DMNProfile) EnumSet(java.util.EnumSet) DMNFactory(org.kie.dmn.core.api.DMNFactory) DMNCompilerConfigurationImpl(org.kie.dmn.core.compiler.DMNCompilerConfigurationImpl) DefaultDMNMessagesManager(org.kie.dmn.core.util.DefaultDMNMessagesManager) DMN_VERSION(org.kie.dmn.backend.marshalling.v1x.XStreamMarshaller.DMN_VERSION) Collection(java.util.Collection) Set(java.util.Set) Reader(java.io.Reader) ChainedProperties(org.kie.internal.utils.ChainedProperties) Collectors(java.util.stream.Collectors) BatchExecutionCommand(org.kie.api.command.BatchExecutionCommand) Resource(org.kie.api.io.Resource) List(java.util.List) Stream(java.util.stream.Stream) VALIDATE_SCHEMA(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_SCHEMA) SAXException(org.xml.sax.SAXException) InternalDMNDTAnalyserFactory(org.kie.dmn.validation.dtanalysis.InternalDMNDTAnalyserFactory) ANALYZE_DECISION_TABLE(org.kie.dmn.validation.DMNValidator.Validation.ANALYZE_DECISION_TABLE) DTAnalysis(org.kie.dmn.validation.dtanalysis.model.DTAnalysis) QName(javax.xml.namespace.QName) MsgUtil(org.kie.dmn.core.util.MsgUtil) BaseResource(org.drools.core.io.impl.BaseResource) DMNMessageImpl(org.kie.dmn.core.impl.DMNMessageImpl) VALIDATE_COMPILATION(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_COMPILATION) StreamSource(javax.xml.transform.stream.StreamSource) ReaderResource(org.drools.core.io.impl.ReaderResource) ClassLoaderUtil(org.kie.dmn.feel.util.ClassLoaderUtil) Source(javax.xml.transform.Source) Function(java.util.function.Function) Schema(javax.xml.validation.Schema) Definitions(org.kie.dmn.model.api.Definitions) ArrayList(java.util.ArrayList) DMNMarshallerFactory(org.kie.dmn.backend.marshalling.v1x.DMNMarshallerFactory) XMLConstants(javax.xml.XMLConstants) InternalKnowledgeBase(org.drools.kiesession.rulebase.InternalKnowledgeBase) InternalDMNDTAnalyser(org.kie.dmn.validation.dtanalysis.InternalDMNDTAnalyser) Properties(java.util.Properties) SchemaFactory(javax.xml.validation.SchemaFactory) Logger(org.slf4j.Logger) DMNMessageManager(org.kie.dmn.core.api.DMNMessageManager) IOException(java.io.IOException) Validator(javax.xml.validation.Validator) File(java.io.File) KieBaseBuilder(org.drools.modelcompiler.builder.KieBaseBuilder) Collectors.toList(java.util.stream.Collectors.toList) StringReader(java.io.StringReader) DMNResourceDependenciesSorter(org.kie.dmn.core.assembler.DMNResourceDependenciesSorter) DMNResource(org.kie.dmn.core.assembler.DMNResource) Msg(org.kie.dmn.core.util.Msg) VALIDATE_MODEL(org.kie.dmn.validation.DMNValidator.Validation.VALIDATE_MODEL) Collections(java.util.Collections) DecisionService(org.kie.dmn.model.api.DecisionService) InputStream(java.io.InputStream) QName(javax.xml.namespace.QName) Definitions(org.kie.dmn.model.api.Definitions) DMNModelInstrumentedBase(org.kie.dmn.model.api.DMNModelInstrumentedBase) DecisionService(org.kie.dmn.model.api.DecisionService) BatchExecutionCommand(org.kie.api.command.BatchExecutionCommand) StatelessKieSession(org.kie.api.runtime.StatelessKieSession)

Example 8 with DecisionService

use of org.kie.dmn.model.api.DecisionService 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_1.TDMNElementReference) TDecisionService(org.kie.dmn.model.v1_1.TDecisionService) DecisionService(org.kie.dmn.model.api.DecisionService)

Example 9 with DecisionService

use of org.kie.dmn.model.api.DecisionService 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 10 with DecisionService

use of org.kie.dmn.model.api.DecisionService 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";
        } else if (a instanceof Group) {
            nodeName = "group";
        }
        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 : Group(org.kie.dmn.model.api.Group) Import(org.kie.dmn.model.api.Import) PerformanceIndicator(org.kie.dmn.model.api.PerformanceIndicator) TDefinitions(org.kie.dmn.model.v1_4.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)

Aggregations

DecisionService (org.kie.dmn.model.api.DecisionService)12 Definitions (org.kie.dmn.model.api.Definitions)5 DMNElementReference (org.kie.dmn.model.api.DMNElementReference)4 DRGElement (org.kie.dmn.model.api.DRGElement)4 Artifact (org.kie.dmn.model.api.Artifact)3 Association (org.kie.dmn.model.api.Association)3 BusinessContextElement (org.kie.dmn.model.api.BusinessContextElement)3 BusinessKnowledgeModel (org.kie.dmn.model.api.BusinessKnowledgeModel)3 Decision (org.kie.dmn.model.api.Decision)3 ElementCollection (org.kie.dmn.model.api.ElementCollection)3 Import (org.kie.dmn.model.api.Import)3 InputData (org.kie.dmn.model.api.InputData)3 ItemDefinition (org.kie.dmn.model.api.ItemDefinition)3 KnowledgeSource (org.kie.dmn.model.api.KnowledgeSource)3 OrganizationUnit (org.kie.dmn.model.api.OrganizationUnit)3 PerformanceIndicator (org.kie.dmn.model.api.PerformanceIndicator)3 TextAnnotation (org.kie.dmn.model.api.TextAnnotation)3 InputStream (java.io.InputStream)2 DecisionServices (org.kie.dmn.model.v1_1.extensions.DecisionServices)2 File (java.io.File)1