Search in sources :

Example 1 with DRGElement

use of org.kie.dmn.model.v1_1.DRGElement in project drools by kiegroup.

the class XStreamMarshaller method newXStream.

private XStream newXStream() {
    XStream xStream = createTrustingXStream(staxDriver, Definitions.class.getClassLoader());
    xStream.alias("artifact", Artifact.class);
    xStream.alias("definitions", Definitions.class);
    xStream.alias("inputData", InputData.class);
    xStream.alias("decision", Decision.class);
    xStream.alias("variable", InformationItem.class);
    xStream.alias("informationRequirement", InformationRequirement.class);
    xStream.alias("requiredInput", DMNElementReference.class);
    xStream.alias("literalExpression", LiteralExpression.class);
    // TODO will need to remove dups and find missing element not captured?
    xStream.alias("DMNElement", DMNElement.class);
    xStream.alias("allowedValues", UnaryTests.class);
    xStream.alias("artifact", Artifact.class);
    xStream.alias("association", Association.class);
    xStream.alias("authorityRequirement", AuthorityRequirement.class);
    xStream.alias("authorityRequirement", AuthorityRequirement.class);
    xStream.alias("authorityRequirement", AuthorityRequirement.class);
    xStream.alias("binding", Binding.class);
    xStream.alias("businessContextElement", BusinessContextElement.class);
    xStream.alias("businessKnowledgeModel", BusinessKnowledgeModel.class);
    xStream.alias("column", InformationItem.class);
    xStream.alias("context", Context.class);
    xStream.alias("contextEntry", ContextEntry.class);
    xStream.alias("decision", Decision.class);
    xStream.alias("decisionMade", DMNElementReference.class);
    xStream.alias("decisionMaker", DMNElementReference.class);
    xStream.alias("decisionOwned", DMNElementReference.class);
    xStream.alias("decisionOwner", DMNElementReference.class);
    xStream.alias("decisionService", DecisionService.class);
    xStream.alias("decisionTable", DecisionTable.class);
    xStream.alias("defaultOutputEntry", LiteralExpression.class);
    xStream.alias("definitions", Definitions.class);
    xStream.alias("drgElement", DMNElementReference.class);
    // xStream.alias("drgElement", DRGElement.class ); ambiguity, also referring to top-level xsd element just under xsd root.
    xStream.alias("elementCollection", ElementCollection.class);
    xStream.alias("elementCollection", ElementCollection.class);
    xStream.alias("encapsulatedDecision", DMNElementReference.class);
    xStream.alias("encapsulatedLogic", FunctionDefinition.class);
    xStream.alias("expression", Expression.class);
    xStream.alias("formalParameter", InformationItem.class);
    xStream.alias("functionDefinition", FunctionDefinition.class);
    xStream.alias("impactedPerformanceIndicator", DMNElementReference.class);
    xStream.alias("impactingDecision", DMNElementReference.class);
    xStream.alias("import", Import.class);
    xStream.alias("import", Import.class);
    // TODO where?
    xStream.alias("importedElement", String.class);
    xStream.alias("importedValues", ImportedValues.class);
    xStream.alias("informationItem", InformationItem.class);
    xStream.alias("informationRequirement", InformationRequirement.class);
    xStream.alias("input", InputClause.class);
    xStream.alias("inputData", DMNElementReference.class);
    xStream.alias("inputData", InputData.class);
    xStream.alias("inputDecision", DMNElementReference.class);
    xStream.alias("inputEntry", UnaryTests.class);
    xStream.alias("inputExpression", LiteralExpression.class);
    xStream.alias("inputValues", UnaryTests.class);
    xStream.alias("invocation", Invocation.class);
    xStream.alias("itemComponent", ItemDefinition.class);
    xStream.alias("itemDefinition", ItemDefinition.class);
    xStream.alias("itemDefinition", ItemDefinition.class);
    xStream.alias("knowledgeRequirement", KnowledgeRequirement.class);
    xStream.alias("knowledgeRequirement", KnowledgeRequirement.class);
    xStream.alias("knowledgeSource", KnowledgeSource.class);
    xStream.alias("literalExpression", LiteralExpression.class);
    xStream.alias("namedElement", NamedElement.class);
    xStream.alias("organizationUnit", OrganizationUnit.class);
    xStream.alias("output", OutputClause.class);
    xStream.alias("outputDecision", DMNElementReference.class);
    xStream.alias("outputEntry", LiteralExpression.class);
    xStream.alias("outputValues", UnaryTests.class);
    xStream.alias("owner", DMNElementReference.class);
    xStream.alias("parameter", InformationItem.class);
    xStream.alias("performanceIndicator", PerformanceIndicator.class);
    xStream.alias("relation", Relation.class);
    xStream.alias("requiredAuthority", DMNElementReference.class);
    xStream.alias("requiredDecision", DMNElementReference.class);
    xStream.alias("requiredDecision", DMNElementReference.class);
    xStream.alias("requiredInput", DMNElementReference.class);
    xStream.alias("requiredInput", DMNElementReference.class);
    xStream.alias("requiredKnowledge", DMNElementReference.class);
    xStream.alias("rule", DecisionRule.class);
    xStream.alias("sourceRef", DMNElementReference.class);
    xStream.alias("supportedObjective", DMNElementReference.class);
    xStream.alias("targetRef", DMNElementReference.class);
    xStream.alias("textAnnotation", TextAnnotation.class);
    // TODO where?
    xStream.alias("type", String.class);
    xStream.alias("typeRef", QName.class);
    xStream.alias("usingProcess", DMNElementReference.class);
    xStream.alias("usingTask", DMNElementReference.class);
    xStream.alias("variable", InformationItem.class);
    xStream.alias("variable", InformationItem.class);
    xStream.alias("variable", InformationItem.class);
    xStream.alias("variable", InformationItem.class);
    // xStream.alias("allowedAnswers", xsd:string.class );
    // xStream.alias("description", xsd:string.class );
    // xStream.alias("question", xsd:string.class );
    // xStream.alias("text", xsd:string.class );
    // xStream.alias("text", xsd:string.class );
    // xStream.alias("text", xsd:string.class );
    xStream.alias("row", org.kie.dmn.model.v1_1.List.class);
    xStream.alias("list", org.kie.dmn.model.v1_1.List.class);
    xStream.alias("extensionElements", DMNElement.ExtensionElements.class);
    // Manually imported TEXT = String
    xStream.alias(LiteralExpressionConverter.TEXT, String.class);
    xStream.alias(TextAnnotationConverter.TEXT, String.class);
    xStream.alias(UnaryTestsConverter.TEXT, String.class);
    xStream.alias(DecisionConverter.QUESTION, String.class);
    xStream.alias(DecisionConverter.ALLOWED_ANSWERS, String.class);
    xStream.alias(DMNElementConverter.DESCRIPTION, String.class);
    xStream.registerConverter(new AssociationConverter(xStream));
    xStream.registerConverter(new AuthorityRequirementConverter(xStream));
    xStream.registerConverter(new BindingConverter(xStream));
    xStream.registerConverter(new BusinessKnowledgeModelConverter(xStream));
    xStream.registerConverter(new ContextConverter(xStream));
    xStream.registerConverter(new ContextEntryConverter(xStream));
    xStream.registerConverter(new DecisionConverter(xStream));
    xStream.registerConverter(new DecisionRuleConverter(xStream));
    xStream.registerConverter(new DecisionServiceConverter(xStream));
    xStream.registerConverter(new DecisionTableConverter(xStream));
    xStream.registerConverter(new DefinitionsConverter(xStream));
    xStream.registerConverter(new DMNElementReferenceConverter(xStream));
    xStream.registerConverter(new FunctionDefinitionConverter(xStream));
    xStream.registerConverter(new ImportConverter(xStream));
    xStream.registerConverter(new ImportedValuesConverter(xStream));
    xStream.registerConverter(new InformationItemConverter(xStream));
    xStream.registerConverter(new InformationRequirementConverter(xStream));
    xStream.registerConverter(new InputClauseConverter(xStream));
    xStream.registerConverter(new InputDataConverter(xStream));
    xStream.registerConverter(new InvocationConverter(xStream));
    xStream.registerConverter(new ItemDefinitionConverter(xStream));
    xStream.registerConverter(new KnowledgeRequirementConverter(xStream));
    xStream.registerConverter(new KnowledgeSourceConverter(xStream));
    xStream.registerConverter(new LiteralExpressionConverter(xStream));
    xStream.registerConverter(new OrganizationUnitConverter(xStream));
    xStream.registerConverter(new OutputClauseConverter(xStream));
    xStream.registerConverter(new PerformanceIndicatorConverter(xStream));
    xStream.registerConverter(new RelationConverter(xStream));
    xStream.registerConverter(new TextAnnotationConverter(xStream));
    xStream.registerConverter(new UnaryTestsConverter(xStream));
    xStream.registerConverter(new QNameConverter());
    xStream.registerConverter(new DMNListConverter(xStream));
    xStream.registerConverter(new ElementCollectionConverter(xStream));
    xStream.registerConverter(new ExtensionElementsConverter(xStream, extensionRegisters));
    xStream.ignoreUnknownElements();
    for (DMNExtensionRegister extensionRegister : extensionRegisters) {
        extensionRegister.registerExtensionConverters(xStream);
    }
    return xStream;
}
Also used : DMNElement(org.kie.dmn.model.v1_1.DMNElement) XStream(com.thoughtworks.xstream.XStream) XStreamUtils.createTrustingXStream(org.kie.soup.commons.xstream.XStreamUtils.createTrustingXStream) Definitions(org.kie.dmn.model.v1_1.Definitions) DMNExtensionRegister(org.kie.dmn.api.marshalling.v1_1.DMNExtensionRegister)

Example 2 with DRGElement

use of org.kie.dmn.model.v1_1.DRGElement in project drools by kiegroup.

the class BusinessKnowledgeModelCompiler method compileNode.

@Override
public void compileNode(DRGElement de, DMNCompilerImpl compiler, DMNModelImpl model) {
    BusinessKnowledgeModel bkm = (BusinessKnowledgeModel) de;
    BusinessKnowledgeModelNodeImpl bkmn = new BusinessKnowledgeModelNodeImpl(bkm);
    DMNType type = null;
    if (bkm.getVariable() == null) {
        DMNCompilerHelper.reportMissingVariable(model, de, bkm, Msg.MISSING_VARIABLE_FOR_BKM);
        return;
    }
    DMNCompilerHelper.checkVariableName(model, bkm, bkm.getName());
    if (bkm.getVariable() != null && bkm.getVariable().getTypeRef() != null) {
        type = compiler.resolveTypeRef(model, bkmn, bkm, bkm.getVariable(), bkm.getVariable().getTypeRef());
    } else {
        // for now the call bellow will return type UNKNOWN
        type = compiler.resolveTypeRef(model, bkmn, bkm, bkm, null);
    }
    bkmn.setResultType(type);
    model.addBusinessKnowledgeModel(bkmn);
}
Also used : BusinessKnowledgeModel(org.kie.dmn.model.v1_1.BusinessKnowledgeModel) BusinessKnowledgeModelNodeImpl(org.kie.dmn.core.ast.BusinessKnowledgeModelNodeImpl) DMNType(org.kie.dmn.api.core.DMNType)

Example 3 with DRGElement

use of org.kie.dmn.model.v1_1.DRGElement in project drools by kiegroup.

the class DMNCompilerImpl method processDrgElements.

private void processDrgElements(DMNCompilerContext ctx, DMNFEELHelper feel, DMNModelImpl model, Definitions dmndefs) {
    for (DRGElement e : dmndefs.getDrgElement()) {
        boolean foundIt = false;
        for (DRGElementCompiler dc : drgCompilers) {
            if (dc.accept(e)) {
                foundIt = true;
                dc.compileNode(e, this, model);
                continue;
            }
        }
        if (!foundIt) {
            MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, e, model, null, null, Msg.UNSUPPORTED_ELEMENT, e.getClass().getSimpleName(), e.getId());
        }
    }
    for (BusinessKnowledgeModelNode bkm : model.getBusinessKnowledgeModels()) {
        BusinessKnowledgeModelNodeImpl bkmi = (BusinessKnowledgeModelNodeImpl) bkm;
        for (DRGElementCompiler dc : drgCompilers) {
            if (bkmi.getEvaluator() == null && dc.accept(bkm)) {
                dc.compileEvaluator(bkm, this, ctx, model);
            }
        }
    }
    for (DecisionNode d : model.getDecisions()) {
        DecisionNodeImpl di = (DecisionNodeImpl) d;
        for (DRGElementCompiler dc : drgCompilers) {
            if (di.getEvaluator() == null && dc.accept(d)) {
                dc.compileEvaluator(d, this, ctx, model);
            }
        }
    }
    detectCycles(model);
}
Also used : BusinessKnowledgeModelNode(org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode) BusinessKnowledgeModelNodeImpl(org.kie.dmn.core.ast.BusinessKnowledgeModelNodeImpl) DecisionNode(org.kie.dmn.api.core.ast.DecisionNode) DecisionNodeImpl(org.kie.dmn.core.ast.DecisionNodeImpl) DRGElement(org.kie.dmn.model.v1_1.DRGElement)

Example 4 with DRGElement

use of org.kie.dmn.model.v1_1.DRGElement in project drools by kiegroup.

the class DecisionCompiler method compileNode.

@Override
public void compileNode(DRGElement de, DMNCompilerImpl compiler, DMNModelImpl model) {
    Decision decision = (Decision) de;
    DecisionNodeImpl dn = new DecisionNodeImpl(decision);
    DMNType type = null;
    if (decision.getVariable() == null) {
        DMNCompilerHelper.reportMissingVariable(model, de, decision, Msg.MISSING_VARIABLE_FOR_DECISION);
        return;
    }
    DMNCompilerHelper.checkVariableName(model, decision, decision.getName());
    if (decision.getVariable() != null && decision.getVariable().getTypeRef() != null) {
        type = compiler.resolveTypeRef(model, dn, decision, decision.getVariable(), decision.getVariable().getTypeRef());
    } else {
        type = compiler.resolveTypeRef(model, dn, decision, decision, null);
    }
    dn.setResultType(type);
    model.addDecision(dn);
}
Also used : DecisionNodeImpl(org.kie.dmn.core.ast.DecisionNodeImpl) Decision(org.kie.dmn.model.v1_1.Decision) DMNType(org.kie.dmn.api.core.DMNType)

Example 5 with DRGElement

use of org.kie.dmn.model.v1_1.DRGElement 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, idn, de, input.getVariable(), input.getVariable().getTypeRef());
        idn.setType(type);
    } else {
        idn.setType(DMNTypeRegistry.UNKNOWN);
        DMNCompilerHelper.reportMissingVariable(model, de, input, Msg.MISSING_VARIABLE_FOR_INPUT);
    }
    model.addInput(idn);
}
Also used : InputData(org.kie.dmn.model.v1_1.InputData) InputDataNodeImpl(org.kie.dmn.core.ast.InputDataNodeImpl) DMNType(org.kie.dmn.api.core.DMNType)

Aggregations

DMNType (org.kie.dmn.api.core.DMNType)3 BusinessKnowledgeModelNodeImpl (org.kie.dmn.core.ast.BusinessKnowledgeModelNodeImpl)2 DecisionNodeImpl (org.kie.dmn.core.ast.DecisionNodeImpl)2 XStream (com.thoughtworks.xstream.XStream)1 BusinessKnowledgeModelNode (org.kie.dmn.api.core.ast.BusinessKnowledgeModelNode)1 DecisionNode (org.kie.dmn.api.core.ast.DecisionNode)1 DMNExtensionRegister (org.kie.dmn.api.marshalling.v1_1.DMNExtensionRegister)1 InputDataNodeImpl (org.kie.dmn.core.ast.InputDataNodeImpl)1 BusinessKnowledgeModel (org.kie.dmn.model.v1_1.BusinessKnowledgeModel)1 DMNElement (org.kie.dmn.model.v1_1.DMNElement)1 DRGElement (org.kie.dmn.model.v1_1.DRGElement)1 Decision (org.kie.dmn.model.v1_1.Decision)1 Definitions (org.kie.dmn.model.v1_1.Definitions)1 InputData (org.kie.dmn.model.v1_1.InputData)1 XStreamUtils.createTrustingXStream (org.kie.soup.commons.xstream.XStreamUtils.createTrustingXStream)1